Mechanism
Last updated
Last updated
Introduction to HTLCs
Flashnet employs HTLCs (Hash Time-Locked Contracts) on the Lightning Network to facilitate atomic swaps. These cryptographic schemas enable atomic transactions between nodes that do not share a direct channel, acting as secure "lockboxes" that navigate through network channels until reaching their intended recipient. A distinctive feature of HTLCs is the necessity for the receiver to demonstrate knowledge of a pre-image (a cryptographic proof) to unlock the transferred funds, ensuring a high level of security and trustlessness in peer-to-peer exchanges.
Flashnet's mechanism operates through two interconnected HTLC payments between a Maker and a Taker, utilizing a transaction loop for execution, as outlined below:
Taker Invoice: The Taker initiates the swap by creating an invoice that includes a specific hash for which they hold the pre-image, and sends this invoice to the Maker.
Invoice Mirroring and Collateral: The Maker generates a matching invoice using the same hash and an additional collateral invoice, secured by a hash from a trusted third party (Note: the trusted third party does not have access to the funds but to the preimage for the Maker's invoice), and forwards these to the Taker.
Payment and Collateral Fulfillment: The Taker completes the Maker's side of the trade by paying the invoice and secures the transaction by fulfilling the collateral invoice as an insurance mechanism.
Closing the Loop: The Maker, upon receiving payment, must pay the Taker's invoice. The Maker does not hold the key to their invoice; they must obtain the key by sending the Taker their side of the invoice, thereby completing the transaction loop.
Trade Finalization: Once the Taker receives their payment, they release the preimage to their invoice, which atomically releases the Maker's funds as well. In the absence of foul play (if the Taker correctly settles their invoice in a timely manner), the Maker must cancel the collateral invoice, which atomically returns funds to the Taker. Failure to do so within a specified timeframe results in reputational damage for the Maker.
The mechanism includes volatility-derived collateral to address the inherent "free-option problem" in P2P atomic swaps. This collateral, secured by a trusted third party (Polarity), is based on the implied volatility of the traded pair within the invoice expiry time, providing a safety net against malicious actions. See example in Features. The secret to the collateral is only released in the taker acts maliciously, i.e. if they attempt to exercise a free option. In general, the key will be released if the trade is not settled in 5 seconds -- this is an arbitrary time frame that accounts for network latency, it can be altered to fit the traders risk tolerance.
By leveraging the Lightning Network's onion routing, Flashnet ensures transaction privacy and protection against unfair trading practices, such as front-running. Additionally, Flashnet's support for partial fills and incentivized network behavior establishes a comprehensive framework for efficient, secure, and fair trading across the cryptocurrency landscape.