ShieldedAtomicSwap

spec · config

A shielded atomic swap: P2P cross-chain settlement with unlinkability. Standard HTLCs have a known privacy flaw — the same hash H appears on both chains, allowing an observer to link the two legs of the swap. Even on privacy chains like Zcash, the HTLC hash pattern leaks cross-chain linkage.

ShieldedAtomicSwap replaces the hash reveal with a ZK proof of preimage knowledge. Each leg uses a different commitment on-chain, but the ZK proof guarantees they correspond to the same secret. An observer sees two independent shielded transactions — unlinkable.

How it differs from ShieldedDEX

ShieldedDEXShieldedAtomicSwap
Use caseExchange (many-to-many)Settlement (one-to-one)
ParticipantsMany traders, batchedTwo counterparties
Price discoveryBatch clearing finds pricePrice negotiated bilaterally
CoordinatorBatch coordinator neededNone — fully P2P
LatencyMust wait for batchImmediate (when both online)
Cross-chainSingle chain/shielded poolCross-chain native
Zcash changesMatching engine (new ZIP)HTLC in shielded pool (new ZIP)

Use cases

ShieldedAtomicSwap is not an exchange — it's private settlement between two parties who already agreed on terms. It trades price discovery for trustless cross-chain execution without linkability.

Where ShieldedAtomicSwap wins:

  • Cross-chain swaps without bridges — bridges are the #1 hack target in crypto. Atomic swaps eliminate the bridge entirely — no custodian, no multisig, no wrapped tokens. Each party locks on their own chain and claims with a ZK proof.
  • OTC trades between known counterparties — two parties who already agreed on a price (e.g., institutional OTC, treasury-to-treasury). They don't need price discovery — they need private, trustless settlement.
  • Privacy-preserving cross-chain migration — moving value from one chain to another without leaving a linkable trail. Standard HTLCs leak the link via the shared hash. Shielded swaps break that link.
  • Small P2P trades — no minimum batch size, no liquidity pool needed, no fees beyond gas. Two people can swap any amount directly.

Where other mechanisms are better:

NeedBetter choiceWhy
Price discoveryShieldedDEX or AMMAtomic swap price is whatever you negotiate
Many counterpartiesShieldedDEXAtomic swap is strictly 1-to-1
No liveness requirementShieldedDEXBob must be online to claim
Single-chain tradingAMM or ShieldedDEXAtomic swap is designed for cross-chain

Protocol

sequenceDiagram
    participant A as Alice<br/>(has asset A on Chain 1)
    participant C1 as Chain 1
    participant C2 as Chain 2
    participant B as Bob<br/>(has asset B on Chain 2)
    participant O as Observer

    Note over A,B: AGREE (off-chain, P2P)
    A-->>B: negotiate terms

    Note over A,B: LOCK

    A->>C1: lock A with shielded commitment C1
    Note over O: sees: shielded_lock on Chain 1

    B->>C2: lock B with shielded commitment C2
    Note over O: sees: shielded_lock on Chain 2<br/>C1 ≠ C2 — CANNOT link them

    Note over A,B: CLAIM

    A->>C2: claim B with ZK proof (not hash reveal)
    Note over O: sees: shielded_claim on Chain 2<br/>no secret revealed on-chain

    B->>C1: claim A with ZK proof
    Note over O: sees: shielded_claim on Chain 1<br/>still cannot link to Chain 2

    Note over A,B: DONE — swap complete
    Note over O: saw 4 independent shielded txs<br/>cannot determine they are related

Standard HTLC vs Shielded

PropertyStandard HTLCShieldedAtomicSwap
Hash visible on-chainYes (same H on both chains)No (ZK proof, nothing revealed)
Cross-chain linkableYes (match by H)No (different commitments)
Amounts visibleYes (or partially hidden)No (shielded)
Asset types visibleYesNo (ZSA)
Atomic settlementYesYes (verified)
Timeout refundYesYes (verified)

Zcash protocol changes needed

ComponentWhat's neededStatus
Shielded custom tokensZIP-226 (issuance), ZIP-227 (transfer)Specified, not yet activated
Shielded time-locksLocking UTXOs in shielded pool with time conditionsDoes not exist
ZK-contingent claimsProving preimage knowledge without revealing hashDoes not exist
Cross-chain relayVerifying events on other chainsDoes not exist

Verified properties (32 states)

PropertyTypeDescription
AtomicSettlementInvariantBoth legs execute, both refund, or Alice claims + Bob offline (3 terminal states, no partial loss without liveness failure)
NoCounterpartyRiskInvariantTimeoutA > TimeoutB ensures Bob's claim window is open whenever Alice can claim
ConservationAInvariantTotal asset A preserved across all states
ConservationBInvariantTotal asset B preserved across all states
UnlinkabilityInvariantObserver sees different values on each chain — cannot link the two legs
SecretNeverRevealedInvariantObserver never sees the secret — only opaque shielded commitments, claims, and refunds
NoCoordinatorInvariantProtocol has only two participants, no matching engine/pool/batch

Properties expected to fail

Add as INVARIANT to see counterexamples:

PropertyDescription
NoPriceDiscoveryThe exchange rate is whatever Alice and Bob agreed — no market mechanism to ensure fairness (FAILS: AmountA ≠ AmountB with nothing to prevent it)
NoWaitingRequiredAlice must wait for TimeoutA if Bob disappears (FAILS: liveness vs safety tradeoff)
BobCanLoseIf Bob goes offline after Alice claims, Alice gets both assets (FAILS: Alice claims B, timeout refunds A → Alice has 10A + 5B)
StandardHTLCWouldBeLinkedStandard HTLCs use the same hash on both chains (FAILS in our shielded model: commitments are always different)

The liveness vs safety tradeoff

The BobCanLose counterexample reveals a fundamental tradeoff in atomic swaps:

  • Safety (timeouts) requires liveness (both parties online)
  • If Bob goes offline after Alice claims, Alice gets both assets
  • This is not a bug — it's the structural cost of no coordinator
  • ShieldedDEX doesn't have this problem (batch coordinator ensures both sides clear)

This is a new dimension in the impossibility space: P2P settlement requires mutual liveness.