CROSS-CHAIN PROTOCOLS

Cross-Chain Atomic Swap
Walkthrough

Exchange assets across different blockchains — Bitcoin ↔ Ethereum — without any trusted third party. From the classic HTLC design (Nolan 2013, Herlihy 2018) to modern PTLC-based adaptor-signature swaps. Covers griefing attacks, griefing defenses, and the submarine swap special case.

2013
Nolan's original proposal
0
Trusted parties required
48h
Max timeout (Alice side)
PTLC
Privacy-preserving variant
The Classic Problem

Alice has 1 BTC and wants 15 ETH. Bob has 15 ETH and wants 1 BTC. They don't trust each other. How do they swap without a trusted third party?

The "atomic" guarantee: both transfers happen, or neither does — no partial execution, no need for escrow.

Atomic Guarantee — Toggle to See
Bitcoin Chain
Alice
1 BTC
Bob
receives BTC
ATOMIC
Ξ
Ethereum Chain
Bob
15 ETH
Alice
receives ETH
Click a button above to see the atomic guarantee in action.
Historical Context

2013 — Tier Nolan proposes HTLC-based cross-chain swaps on Bitcoin Talk forum

2017 — First on-chain LTC/BTC atomic swap demonstrated

2018 — Maurice Herlihy formalizes multi-party atomic swaps (PODC 2018)

2022–25 — Griefing analysis, PTLC swaps, Rapidash, 4-Swap

Key Primitives

HTLC — Hash Time-Locked Contract: pay-to-hash with timeout fallback

PTLC — Point Time-Locked Contract: pay-to-EC-point (privacy preserving)

Adaptor Sig — Schnorr-based commitment that reveals a scalar on broadcast

Griefing — Timing attack where initiator holds counterparty's funds locked

Section 2

Hash-Locked Atomic Swap — Step by Step

A full BTC ↔ ETH swap using Hash Time-Locked Contracts. Alice has 1 BTC and wants 15 ETH. Bob has 15 ETH and wants 1 BTC.

Step 0 / 7
₿ Bitcoin Chain
Waiting…
Step 2 Alice Locks BTC
Alice creates HTLC on Bitcoin:
1 BTC locked Hash H = SHA256(R) Timeout: 48h
OP_IF
  OP_SHA256 <H> OP_EQUALVERIFY
  <Bob_pubkey> OP_CHECKSIG
OP_ELSE
  <48h> OP_CHECKLOCKTIMEVERIFY
  OP_DROP <Alice_pubkey> OP_CHECKSIG
OP_ENDIF
Waiting for Bob to verify…
Bob locks ETH on Ethereum →
Alice claims ETH on Ethereum →
Step 6 Bob Claims BTC
Bob sees R on Ethereum blockchain.
Bob submits R to Alice's Bitcoin HTLC.
📡 R propagates BTC ← ETH
Ξ Ethereum Chain
Step 1 Alice Creates Secret
Alice generates random secret R (256-bit).
Computes H = SHA256(R).
H is the "hash lock" — public, shared with Bob.
R = 0x3f7a9c2b…d4e8f1a0 (known only to Alice)
H = SHA256(R) = 0xa1b2c3d4…e5f6 (public)
Step 3 Bob Verifies Alice's Lock
Bob checks Alice's Bitcoin HTLC:
✓ Amount: 1 BTC ✓ Hash: H matches ✓ Timeout: 48h
Satisfied, Bob proceeds to lock his ETH.
Step 4 Bob Locks ETH
Bob creates HTLC on Ethereum:
15 ETH locked Hash H (same) Timeout: 24h ⚠
Note: 24h < 48h — Bob uses shorter timeout (security reason!)
Step 5 Alice Claims ETH
Alice calls Bob's Ethereum HTLC with secret R.
Alice receives 15 ETH.
🔓 R is now public on Ethereum
R = 0x3f7a9c2b…d4e8f1a0 (REVEALED on-chain!)
Bob is claiming BTC on Bitcoin →
Press "Auto-play" or "Next →" to begin the walkthrough. Both blockchain timelines update simultaneously.
Section 3

Why Must Bob's Timeout Be Shorter?

This is a critical security insight. If Bob's timeout ≥ Alice's timeout, Alice can double-refund and Bob loses his ETH. The asymmetric timeout design prevents this.

Interactive Clock Simulation — drag the time arrow
0h
12h
0h
36h
48h
Ξ ETH Lock
(Bob's, 24h)
Active
₿ BTC Lock
(Alice's, 48h)
Active
Drag the slider to simulate time passing and see what happens at each moment.
Broken Design: Bob Timeout ≥ Alice Timeout
1
Alice and Bob both lock at t=0h. Both timeouts are 48h.
2
Alice waits until t=47h without revealing R.
3
At t=48h, Alice claims BTC refund (never used her own HTLC).
4
At t=48h, Alice also claims ETH refund (Bob's timeout also expired).
Result: Alice gets both refunds. Bob loses opportunity cost.
Correct Design: Bob Timeout (24h) < Alice Timeout (48h)
1
Alice locks BTC (48h). Bob locks ETH (24h). Alice has R.
2
If Alice reveals R before 24h → Bob claims BTC, Alice gets ETH. ✓
3
If Alice doesn't reveal by 24h → Bob reclaims ETH. Alice gets nothing.
4
Alice still has 24h remaining on her BTC HTLC to reclaim BTC.
Safety invariant: Bob always has the option to recover before Alice can double-refund.
Section 4

Griefing Attack — The Flaw

Even with correct timeout design, HTLC swaps expose Bob to a griefing attack. Alice holds an implicit option: proceed if price moves favorably, or grief if not.

Attack Scenario (Alice = Malicious)
1
Alice initiates the swap — locks 1 BTC (HTLC, 48h).
2
Bob verifies and locks 15 ETH (HTLC, 24h).
3
Alice disappears. She waits to see price movement.
4
Bob's 15 ETH is locked for up to 24 hours — cannot use elsewhere.
5
If BTC/ETH price moved favorably → Alice reveals R, completes swap.
6
If price moved against Alice → Alice lets both HTLCs expire, reclaims BTC.
Cost Asymmetry — Alice Holds a Free Option

The swap acts like an American call option for Alice. She pays nothing for this optionality — Bob bears all the risk.

ALICE'S COST

BTC locked for 48h

She owns BTC anyway — no real loss

BOB'S COST

15 ETH locked for 24h

Real opportunity cost — DeFi yields, other trades

Normal swap: ~5 min. With griefing: up to 24–48h capital lockup.

Alice's Payoff Table — BTC/ETH Price Movement
±0%

Agreed rate: 1 BTC = 15 ETH. Move the slider to simulate price change.

Scenario Alice Action Alice P&L Bob P&L Outcome
Section 5

Solutions to Griefing

Three distinct approaches have been proposed to fix or mitigate the griefing problem in cross-chain atomic swaps.

1. Premium / Option Model
Transferable Options (AFT 2022)

Bob charges Alice an upfront premium before locking ETH. The premium compensates Bob for Alice's optionality — converting the griefing exploit into a properly priced call option.

Alice pays ~0.1% of ETH value upfront (non-refundable).
If Alice griefs, Bob keeps premium = compensation.

Griefing: Partial Complexity: Medium Status: Research
2. Rapidash (FC 2025)
Simultaneous-reveal via Adaptor Signatures

Uses PTLC-style adaptor signatures to enable simultaneous reveal. Both parties reveal their secrets at the same time — eliminating the sequential window that enables griefing.

Requires Schnorr signatures on both chains (e.g., Bitcoin Taproot + ETH EIP-7212).

Griefing: Resistant Privacy: Point-based Status: Research
3. 4-Swap (AFT 2025)
Griefing-free via Economic Deposits

Multi-party protocol where the party that griefs loses a deposit. Economically disincentivizes griefing. Extends to 4-party scenarios with full safety proofs.

Works across 4 parties, not just 2 — enabling more complex cross-chain topologies.

Griefing: Resistant Complexity: High Status: Research
Protocol vs Griefing Resistance — Comparison
Approach Griefing Privacy Chain Support Complexity
HTLC Classic Vulnerable Hash visible Any HTLC chain Low
Premium Model Partial Hash visible BTC-ETH Medium
Rapidash Resistant Point-based Schnorr chains Medium
4-Swap Resistant Point-based Multi-party High
Section 6

PTLC-Based Atomic Swaps

Modern approach using Adaptor Signatures. Instead of a hash H = SHA256(R), use an elliptic curve point S = s·G. The on-chain footprint becomes indistinguishable from a normal Schnorr signature.

Core Idea: Adaptor Signatures

An adaptor signature σ_A is a "pre-signature" tied to a public point S = s·G. Completing it requires knowing the scalar s. This creates the same atomicity as HTLC but with no hash visible on-chain.

HTLC Setup

Alice generates R (secret), H = SHA256(R) (public hash lock)

Contract: "reveal R to unlock payment"

H is visible on-chain → privacy leak, linkable across chains

PTLC Setup

Alice generates scalar s, S = s·G (EC point, public)

Adaptor: "reveal s to complete Schnorr signature"

On-chain looks like normal key-path Taproot spend → no linkage

Protocol Steps — PTLC Swap
1
Alice creates scalar s, computes S = s·G.
S is the "point lock" — analogous to H in HTLC. Alice publishes S.
2
Alice sends Bob adaptor signature σ_A tied to S.
σ_A proves Alice committed to the swap. Bob can verify the pre-signature but cannot complete it without s.
3
Bob sends Alice adaptor signature σ_B tied to S.
σ_B is Bob's commitment to his side of the swap on Ethereum.
4
Alice extracts s from σ_B + S → broadcasts on Ethereum to claim ETH.
Alice uses σ_B and her scalar s to create a valid Schnorr sig and claim the ETH. The broadcast reveals s on-chain.
5
Bob extracts s from Alice's Ethereum broadcast → claims BTC.
Bob sees the completed Schnorr sig on Ethereum, extracts s, uses it with σ_A to claim the BTC. Atomicity preserved.
On-Chain Footprint Comparison
HTLC Swap — Bitcoin Script
OP_IF
  OP_SHA256 <H> OP_EQUALVERIFY
  <Bob_pk> OP_CHECKSIG
OP_ELSE
  <48h> OP_CLTV OP_DROP
  <Alice_pk> OP_CHECKSIG
OP_ENDIF

Hash H visible Script visible

Linkable across chains (same H). Identifiable as a swap.

PTLC Swap — Taproot Key Path
// On-chain: just a Schnorr sig
<sig> <pubkey>

// No OP_IF, no hash, no script
// Looks identical to a normal spend

No hash on-chain Single-sig appearance

Undetectable as a swap. No cross-chain linkage. Privacy-preserving.

Key Benefits of PTLC Swaps
Privacy: No hash visible on-chain, no cross-chain linkage
Atomicity: Same all-or-nothing guarantee as HTLC
Taproot: Works with key-path spend, no script overhead
Composable: Works with Schnorr multi-hop (AMHL equivalent)
Section 7

Protocol Comparison Table

Click a row to highlight relevant details. Each protocol represents a distinct design point in the griefing–privacy–complexity trade-off space.

Protocol Chain Support Griefing Privacy Complexity Status
Nolan HTLC BTC↔BTC (originally) Vulnerable Hash visible Simple Original (2013)
Herlihy HTLC Any HTLC chain Vulnerable Hash visible Simple Classic baseline
Transferable Options BTC↔ETH Partial (premium) Hash visible Medium Research (AFT 2022)
Rapidash BTC↔ETH (Schnorr) Resistant Point-based Medium Research (FC 2025)
4-Swap Multi-party Resistant Point-based Complex Research (AFT 2025)
Submarine Swap BTC on-chain ↔ LN N/A Hash visible Medium Deployed (Loop)
Section 8 — Bonus

Submarine Swap

A special case of HTLC-based atomic swaps enabling on-chain BTC ↔ Lightning Network balance conversion. Used by Lightning Labs Loop for channel rebalancing.

Bitcoin On-Chain
Alice (user) Has on-chain BTC, wants LN balance
Step 1 → Alice generates secret R, hash H = SHA256(R)
Step 2 → Alice sends BTC on-chain to Bob's HTLC
Lock: H, Timeout: 48h
Final ✓ Alice receives LN payment
Reveals R to claim
Submarine
Lightning Network
Bob (Loop service) Lightning Labs Loop, routing node
Step 3 → Bob sees Alice's on-chain BTC locked with H
Step 4 → Bob sends LN payment to Alice
HTLC: same hash H, Timeout: 24h
Step 5 → Alice reveals R over LN to claim payment
Bob claims on-chain BTC with R
Use Cases

Loop Out — Convert on-chain BTC → LN inbound capacity. Alice gets LN balance.

Loop In — Reverse: drain LN balance → receive on-chain BTC.

Rebalancing — Node operators use Loop to rebalance channels without closing them.

Why "Submarine"?

The payment "dives below" the on-chain layer and resurfaces as an LN payment — hence the name.

The HTLC hash H links the on-chain and off-chain legs, ensuring atomicity.

Deployed in production by Lightning Labs Loop and other services. Well-understood security model.

Key Difference vs Standard Atomic Swap

Standard atomic swap: chain A ↔ chain B (different blockchain assets). Submarine swap: on-chain layer ↔ off-chain LN layer of the same blockchain. The "two chains" are just two payment layers — Bitcoin base layer and the Lightning payment channel network on top.