---
title: "Hash Lock — definition | Nuri Glossary"
description: "A condition requiring the recipient to reveal a secret that hashes to a given value before claiming the funds."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/hash-time-lock"
---

# Hash Lock

A condition requiring the recipient to reveal a secret that hashes to a given value before claiming the funds.

## Basically

A hash lock keeps funds locked until you reveal the right secret. The lock checks that the secret produces a fixed digital fingerprint.

## Key Takeaways

- A hash lock is a spending condition that requires you to reveal a secret value, called the preimage, whose hash matches a specific digest in the locking script.
- A hash lock is one half of an HTLC (Hashed Time-Locked Contract). The hash lock enforces correctness because only someone who knows the secret can claim the funds, while the time lock enforces liveness because the sender recovers the funds if the secret is never revealed.
- Every hop in a Lightning payment uses the same hash, creating a privacy weakness. PTLCs (Point Time-Locked Contracts) are designed to solve this by replacing hashes with elliptic-curve point locks.

## What Is a Hash Lock?

A hash lock is a cryptographic spending condition on funds that you can satisfy only by providing a value called the preimage. A hash function must turn that value into a specific expected output. You can think of it as a lock that opens only with a secret key, except the key is data whose fingerprint, or hash, matches the one stamped on the lock.
Hash locks are foundational to trustless, multi-party payment protocols. They were originally described for cross-chain atomic swaps, where two parties on different blockchains need either both sides of a trade to complete or neither to complete. Hashed Time-Locked Contracts (HTLCs) later generalised the technique by pairing a hash lock with a time lock, and became the backbone of the Lightning Network's multi-hop payment routing.

## How It Works

Cryptographic hash functions are easy to compute in one direction but practically impossible to reverse. Anyone can compute H(x) instantly from a preimage x, but no one can recover x from H(x) alone without already knowing it.

## In Bitcoin Script

Bitcoin Script expresses hash locks on the Bitcoin base layer through opcodes. The simplest form uses OP_SHA256 for a single SHA-256 hash or OP_HASH256 for double SHA-256.
The unlocking script hashes the provided preimage and compares the result with the expected hash when the stack processor executes it. A match satisfies the condition. In practice, hash locks are always combined with a signature check using OP_CHECKSIG, so only the intended recipient can claim the funds rather than anyone who observes the preimage on the blockchain.

## In Multi-Hop Lightning Payments

Multi-hop payments across the Lightning Network rely on hash locks. The same payment hash links every hop when Alice pays Carol through an intermediary called Bob.
The hash lock guarantees atomicity because Carol can claim her payment only by revealing the preimage. Revealing it automatically lets Bob claim his incoming HTLC, so either the entire chain settles or none of it does.

## Hash Locks vs. Point Locks

Hash locks have a significant privacy limitation because the same hash value H(x) appears at every hop in a multi-hop payment. Any two colluding intermediaries, or a single entity operating multiple routing nodes, can observe the same hash and conclude that they are part of the same payment. This undermines the privacy benefits of onion routing, which hides the sender and receiver from intermediaries.
Point Time-Locked Contracts (PTLCs) solve this by replacing hash-and-preimage pairs with elliptic-curve points and scalars. Each hop in a PTLC uses a different locking point, so no two hops share a correlatable value. Schnorr signatures and adaptor signatures enable this because each intermediary adds a random "tweak" to the point, decorrelating the payment across hops while preserving atomicity.
You can find a deeper analysis in PTLCs: the next evolution of Lightning. The analysis covers how PTLCs change Lightning.

## Multi-Hop Payment Routing

Lightning Network HTLCs are the most widespread use of hash locks. Every routed Lightning payment relies on a hash lock to ensure that intermediaries can collect their routing fees only if the final recipient actually receives the payment. You can route payments through untrusted nodes without any risk of theft because of this mechanism.

## Cross-Chain Atomic Swaps

Hash locks were originally developed for atomic swaps between different blockchains. Both chains use the same hash to lock funds, and the party who reveals the preimage on one chain simultaneously enables the counterparty to claim funds on the other chain. Either both legs of the swap complete or neither does, without requiring any trusted intermediary.

## Submarine Swaps

Submarine swaps bridge on-chain Bitcoin and Lightning using hash locks. A service creates an on-chain HTLC locked to the same hash as a Lightning payment. The settled Lightning payment reveals the preimage, which can claim the on-chain funds, and this is how services like Loop enable channel liquidity management.

## Conditional Escrow

Hodl invoices use hash locks to create conditional payment flows. The receiver withholds the preimage until business conditions are met, such as goods delivered, service confirmed or oracle verified, then reveals it to settle the payment. You can use trustless escrow patterns without third-party custodians through this mechanism.

## Why It Matters

Hash locks are the cryptographic primitive that makes trustless, multi-party payment networks possible. Without them, every intermediary in a payment route would need to be trusted not to steal funds. Intermediaries can profit only by honestly forwarding payments because they learn the preimage only when the next hop settles and can claim their incoming payment only by using that same preimage.
Hash locks underpin the security model of payment channels and routed payments in protocols built on Bitcoin's Layer 2 ecosystem, including Spark. PTLCs may replace hash locks as the ecosystem evolves, but the core principle remains the same: cryptographic proof of knowledge replaces trust in counterparties.

## Payment Correlation

The shared hash in a multi-hop payment creates the most significant privacy drawback of hash locks. Any two colluding routing nodes can determine that they are forwarding the same payment, which is a material concern for privacy-sensitive users. The Lightning Network privacy analysis covers this issue in detail.

## Preimage Exposure

A revealed preimage becomes known to every intermediary along the route after it is used to claim a hash-locked payment. Standard Lightning payments work this way by design, with the preimage propagating backwards to settle each hop. More complex protocols that reuse the same hash across multiple contracts could unintentionally unlock funds in another context after exposure in one, so each hash lock must use a unique, purpose-specific hash.

## On-Chain Footprint

An HTLC settled on-chain, such as during a force close, adds data to the transaction through its hash lock. The preimage reveal, the hash and the conditional branching script all consume block space. Taproot mitigates this in the cooperative case, where the hash lock resolves off-chain, but the uncooperative path still carries the full script weight.

## Wormhole Attack

Two non-adjacent colluding intermediaries can exploit the shared hash in a multi-hop payment to short-circuit the route. If node A and node C collude and both see the same hash, node C can forward the preimage directly to node A, allowing them to settle their incoming HTLCs while skipping the honest nodes between them. The skipped nodes forwarded liquidity but never receive their routing fees.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. You should always do your own research before using any protocol or technology.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
