Analysis · 2026-11-30
Who holds the key? The three-party case
The two-party version of atomic pay-on-delivery really is impossible, and three independent reviews said so. The three-party version is not — because the funder and the spender can be different people. Working out exactly which one your design is, and the one hole the tags cannot close.
The previous note ended with a correction: I first called gating decryption on payment impossible, then found that a key held as an HTLC preimage is scarce, because spending publishes it. Two of the three reviews I commissioned came back insisting the original “impossible” was right, and cited the spec at me.
Both are defensible, and the disagreement is not about cryptography. It is about who the parties are. The reviews analysed a two-party exchange. The design in question is three-party. That distinction is the whole thing, so this note pins it down.
The two-party objection, which is correct
State it cleanly, because it is sharp:
Before delivery, the key K must sit with exactly one party. If the recipient has it, it decrypts and has no reason to spend. If the transporter has it, it can claim at will. And in NUT-14 the spender must present the preimage — so “reveal K to the payer in exchange for payment” is a no-op, because the payer already knew K in order to spend.
If the recipient is also the payer, this is fatal and nothing in the tag space fixes it. That is the honest content of the reviews’ objection, and it is right.
Why the three-party case is different
Now put the sender back in. In a paid transport there are three roles:
- A, who originates the payload and holds K.
- B, who transports ciphertext and wants paying.
- C, who receives the payload and pays for its delivery.
A ≠ C. That is not a detail; it is the load-bearing assumption. When the funder and the spender are different parties, the “the payer must already know K” objection dissolves:
- A encrypts the payload under K and signs
H(payload)— a hash of the plaintext, not the ciphertext. This signature is the authenticity claim, and A cannot forge a useful one for junk it did not intend to send. - A hands ciphertext to B. B does not need K to transport it.
- C receives ciphertext and verifies A’s signature over it before paying anything.
- C funds an NUT-14 hashlock:
Secret.data = SHA256(K),pubkeys = [B]. C’s money, locked so that only B can claim it, and only with K. - B claims by presenting K. NUT-07 returns the witness, so the preimage becomes readable at exactly the moment the claim lands.
- C reads K and decrypts. It then checks the plaintext against the
H(payload)that A signed in step 1.
Walk the two cheats through it:
- B takes the money and runs without delivering. B cannot — step 4 happens after step 3. C funds only after holding ciphertext. The cheat is unavailable by ordering.
- B delivers garbage and gets paid anyway. B would have to produce ciphertext that carries A’s signature over a plaintext hash. Only A can make that, so the fraud requires A’s collusion — and A is the party C chose to receive from. The garbage risk has moved off B and onto A, which is the correct place for it.
So in the three-party case the exchange does what was asked: C cannot decrypt until C pays, and B cannot be paid without the key becoming public. Both directions, from the same act.
The exact theorem, pinned
The previous notes used the fair-exchange literature loosely. Here is the specific result, because “it is impossible” is a claim that should carry a citation or not be made.
Pagnia and Gärtner’s Theorem 2: “There exists no asynchronous strong fair exchange protocol tolerant against misbehaving nodes.” The conditions are the whole content of it: asynchronous message passing, parties that may crash or stop, strong fairness (resolved inside the protocol, no external dispute), and no trusted third party. Under those assumptions the result is a reduction to consensus, which FLP already forbids.
Two things follow that matter here.
- The conditions are escapable, and this design escapes one of them. The construction above is not claimed to be strongly fair. It is fair up to a bounded loss with an ordering, which is the weaker thing the literature permits. Saying “impossible” without the conditions hides the escape hatch that makes the design worth building.
- Gradual release does not rescue it either. Pagnia and Gärtner again: with an all-or-nothing item there is a point after which one more bit makes the other side’s item useful, and a party that stops there has full advantage. Their remedy is to make each stop cost the stopper comparably — which is the bounded-loss shape, not fairness.
And for the case where delivery is supposed to be atomic rather than bounded, Herlihy’s Theorem 3.5 is the sharper tool: a swap protocol is atomic if and only if the graph of obligations is strongly connected — and the paper says explicitly that the model assumes every transfer is recorded on some ledger. Delivery of a ciphertext to a recipient is not on a ledger, and cannot be made so. So the reason bytes-on-payment is impossible is not timidity: off-chain delivery removes the edge the atomicity theorem needs. Key-on-payment works because the key moves on the ledger; bytes-on-payment does not, and no tag combination changes that.
The hole the tags cannot close
Here is what survives, stated as plainly as I can.
B holds K before delivery. To spend in step 5, B must present the preimage. So B knows the key. Everything above is ordering, not secrecy: B could reveal K early, to C or to anyone, and the only thing stopping it is that doing so forfeits B’s payment. That is an incentive, not a lock.
Concretely, B’s remaining powers:
- Sell K cheaply to a third party. C paid for exclusivity; B cannot deliver it. K is a bearer secret in B’s hands.
- Squat until the last moment. B can spend at any time in the window. Since spending is the reveal, there is no way to “confirm receipt first.”
- Deliver ciphertext to C and to nobody else, then claim. Fine — that is the honest path.
And there is a subtler one. Because K is the thing B must disclose to be paid, K must not also be the traffic key for anything else. One key, one HTLC. Reuse it across two chunks and the first claim publishes the key for both.
The ordering is the design, not a detail
It is worth being explicit that this construction is not atomic in the fair-exchange sense. Three things go first:
| Step | Who carries risk | Magnitude |
|---|---|---|
| B delivers ciphertext before C funds | B | one chunk of transit bandwidth |
| C funds, B has not yet spent | C | full HTLC value, until B spends |
| C holds junk that matches A’s signature | C | full HTLC value; recourse is against A |
Row two is the uncomfortable one: C’s money is committed to a hashlock that B may simply never claim, and C’s refund only unlocks at locktime. So locktime sets how long C’s capital is frozen by a transporter’s inaction. Short locktime shortens that, but also shortens C’s window to read the witness — and if B claims at locktime − ε, C is racing a timer to read a value that is already public.
If refund is omitted, an expired lock is anyone-can-spend. This is in NUT-14’s Sender Pathway section and it is the single most dangerous default in the whole construction. A three-party HTLC without refund keys does not revert to C. It reverts to whoever notices first.
Two spec hazards that decide whether any of this runs
Both verified against the text and against a live mint, not recalled.
NUT-14 is optional, and an unsupporting mint may treat the proof as anyone-can-spend. NUT-14’s own caution, verbatim: “if the mint does not support this type of spending condition, proofs may be treated as regular anyone-can-spend proofs.” This is not a degraded mode — it is an open wallet. An application must check /v1/info and must refuse to lock against a mint that does not advertise 14.
NUT-07 is what makes step 6 work, and it leaks. Witness data is returned to any caller who knows Y = hash_to_curve(secret). Anyone who saw the token can compute that. So K becomes readable to every party who handled the token, not just C. For a payment that is acceptable — the secret is already the bearer instrument — but it means the “reveal” is broadcast in practice, and K can never be reused or kept as a secret.
Measured on a live mint today, mint.minibits.cash: 7, 11, 14, 17, 19, 20 all advertised as supported. So the construction is runnable on real infrastructure, not just in theory.
And it is not one mint’s habit. Both reference implementations enforce NUT-11 and NUT-14 at the transaction level, store the witness in the spent-proof record, and return it from /v1/checkstate — Nutshell since at least 0.22.1 (cashu/core/nuts/nuts.py, BOOLEAN_SUPPORTED_NUTS) and CDK in nut14/mod.rs. Neither needs an operator setting: both advertise 11 and 14 unconditionally, with a bare supported, so there is no configuration in which the check passes and the enforcement is absent. That is the one place where a design like this can be lucky, and it is.
It also confirms the earlier warning was right to be sharp: because support is a bare boolean with no per-NUT fields, an info response tells you a mint claims the condition, not that its enforcement is correct. The probe still has to be a real locked spend.
The deepest constraint is in the transport, not the mint
All of the above is about gating a secret. It says nothing about whether bytes arrived, and FIPS cannot help, because the mesh layer does not try:
FMP provides: best-effort delivery. No acknowledgment, no retransmission. —
docs/design/fips-mesh-layer.md:40
There is no delivery signal at the transport layer to bind to. Every candidate receipt is one side’s self-report. MMP’s cumulative_bytes_sent / cumulative_bytes_recv are each side’s own count, travelling inside the AEAD’d link — diagnostic, not evidentiary.
That is the real reason the reviewers’ “impossible” is the right word for delivery. The construction above buys you key-on-payment, which is a genuine and useful thing. It does not buy you bytes-on-payment, because the network does not produce a fact that either party could point a mint at.
On the npubs
They matter more than I first said, and in a specific way.
The identity is a Nostr keypair, verbatim — core/src/identity/README.md says “A node’s identity is a Nostr secp256k1 keypair.” An npub is bech32 over the 32-byte x-only public key, and there is no HD derivation anywhere in the tree: the nsec is the secret. That is good for this design, because a key that is a key is a key in both places.
It also means the daemon can already produce BIP-340 Schnorr signatures over arbitrary bytes — Identity::sign in core/src/identity/local.rs. Cashu’s P2PK and HTLC paths want exactly that primitive over exactly that curve. But no CLI, control-socket field, or native API exposes it today, so “sign the manifest with your npub” is a small addition inside the daemon, not a call a sidecar can make. Worth saying plainly, because it is the difference between a weekend and a fork.
NodeAddr::from_pubkey is SHA-256(pubkey)[..16] — one-way, no salt, no per-host input. So a npub is a stable long-term identity, and it gives you three things this design needs:
pubkeys = [B]is a npub in form, not in bytes. The spend condition names the transporter by key, and FIPS nodes already prove control of those keys in the Noise handshake — but NUT-11 needs the 33-byte compressed pubkey, and an x-only npub does not carry the parity bit. Nutshell rejects an x-only lock as a malformed compressed key (measured,0003-payer-binding.md, Exp F). So “the binding is free” is one sign bit too generous: either B derives its compressed key from its own secret, or it publishes the compressed key with a Schnorr signature over a message binding both forms — otherwise C has no way to tell B’s real key from one C cannot spend, and a sender embedding a key it controls could build a lock B can never claim and then take the refund.- Attribution at the exit. The overlay source address is the client’s key hash. B knows who is paying without being told.
- A receipt both sides can sign, under identities the network already authenticated.
Three caveats, all verified in the tree rather than assumed:
node.identity.persistentdefaults to false, and an ephemeral node generates a fresh npub on every start. Any payment design must require it to be set, or B’s identity — and therefore itspubkeysentry — changes on restart.- Key rotation creates a new npub with no successor-key migration; that is explicitly future work. Treat rotation as a new account, not a rename.
- A npub cannot prove delivery, and a fresh npub is free. Anything allowance-like keyed to identity rather than to a funded instrument is farmable at zero cost.
What I would actually build
The construction above is the one worth prototyping, and the thing to measure is not whether the crypto works — it does. It is:
- How long can B stall before claiming? That is C’s capital-frozen window, and it is a social parameter wearing a
locktimecostume. - What is one chunk worth? Because that is what B loses by delivering ciphertext and never being funded, which is the whole price of removing the pay-first cheat.
- Does C’s verification in step 3 catch A’s fraud or only A’s absence? If only absence, the garbage risk is real and needs a bond against A, not B.
If the answers are bad — long stalls, cheap chunks, no recourse against A — then the honest move is the boring one: prepaid tranches, small enough that the loss is tolerable, with no new counterparty and no locktime machinery. That is not a defeat. It is the same bounded-loss design with the bound chosen deliberately instead of discovered.
What is still unresolved
- The
H(payload)signature is a design choice I have not validated. It assumes A signs the plaintext hash before encrypting, and that C can act on a mismatch. Neither is free: it makes A’s signature a delivery artefact, which may leak more than intended about what is being sent. - Whether B genuinely needs K. B must present it to spend, so yes — but a variant in which B proves knowledge without revealing it (a NUT-11-style signature instead of a preimage) would remove B’s ability to sell the key early. I do not know whether that construction is expressible in the current tag space, and it is the most interesting open question in the design.
That second one is worth a prototype on a local mint before any hardware is touched.