back to blogs

Pre-Images in Lightning Network

Share on

In the Lightning Network (LN), a preimage refers to a unique piece of information or data that corresponds to a specific hash value.

It is used in LN’s hash time-locked contracts (HTLCs) to ensure secure and verifiable transactions. To unlock a payment channel and claim funds, the sender of a payment provides the recipient with the preimage that matches the hash provided in the HTLC. This preimage is a cryptographic proof that the conditions of the contract have been met, allowing the recipient to claim the funds. The concept of preimages adds a layer of security and trustlessness to LN transactions.

In the Lightning Network (LN), transactions are conducted using a mechanism called hash time-locked contracts (HTLCs). These contracts involve the use of cryptographic hashes and time locks to ensure secure and trustless transactions off the main Bitcoin blockchain.

A preimage is a crucial component of this process. Imagine you want to send funds through a payment channel in the Lightning Network. To initiate this transaction, you create an HTLC. This involves generating a cryptographic hash of a secret piece of information, which remains unknown to the recipient. This hash is included in the HTLC as a condition that must be fulfilled to claim the funds.

Once the HTLC is set up, you share the hash of the secret (the hash value) with the recipient. The recipient can’t derive the original secret from the hash – this is an important property of cryptographic hashing functions. To receive the funds, the recipient needs the original secret that matches the hash in the HTLC.

When the recipient wishes to claim the funds, they provide the sender with the preimage – the original secret that corresponds to the hash value. This preimage serves as cryptographic proof that the recipient has fulfilled the condition of the HTLC. The sender can use the preimage to verify that it indeed matches the hash they previously shared. If the preimage matches the hash, the sender knows the recipient has fulfilled their part of the contract and is entitled to the funds.

If the sender doesn’t receive the correct preimage within a specified timeframe, the HTLC times out, and the sender can reclaim the locked funds. This time-bound nature ensures that transactions are processed promptly in the Lightning Network.

In summary, preimages are essential for the secure functioning of hash time-locked contracts in the Lightning Network. They enable parties to prove the fulfillment of contract conditions without revealing the actual secret, adding a layer of privacy, security, and trustlessness to off-chain Bitcoin transactions.

Join the waitlist
BRINGIN NEWSLETTER
Subscribe to the Bringin newsletter
Submit
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Share on

Save in Bitcoin.  Spend in Euros.

Join thousands of Bitcoiners across Europe who use Bringin to spend Bitcoin anywhere - without custody risk, without delays, without compromise. 
One simple account.

Get started nowGet started now