Analysis · 2026-11-30
What an HTLC can and cannot buy you
NUT-14 gives you a conditional claim on ecash. It does not give you delivery. Working through exactly where the boundary sits — including the one constraint most designs miss: the mint only ever signs Proof.secret.
The question that started this: can we make packet delivery and packet payment atomic, so the recipient only gets the bytes if the transporter got paid, and the transporter only gets paid if the bytes arrived?
The short answer is that the key exchange can be made atomic, and the delivery question cannot. Those are two different problems that sound like one. NUT-14 solves the first. The second is a judgement call about what counts as delivery, and no mint opcode can make it for you.
(This note was corrected in place: I first argued that gating decryption on payment was impossible. That was wrong — a key held as an HTLC preimage is a scarce resource, because spending publishes it. The section on the second half explains the construction and what it still does not fix.)
This note works through the primitive first, because a lot of designs get into trouble by assuming the mint can see things it cannot.
What NUT-14 actually is
NUT-14 is a hashed timelock contract over Cashu proofs, built on the NUT-10 spending condition format and extended by NUT-11’s P2PK machinery. Concretely:
Secret.datais the SHA-256 hash of a 32-byte preimage, as 64 hex characters.- A receiver pathway spends the proof by presenting that preimage in
Proof.witness.preimage. The spec is emphatic: this pathway is “ALWAYS available to the receivers, as possession of the preimage confirms performance of the Sender’s wishes”. - A sender pathway lets the keys in the
refundtag reclaim the proof afterlocktimeexpires, using the NUT-11 refund multisig rules. - All the NUT-11 tags still apply on top:
pubkeys,locktime,refund,sigflag, and multisig thresholds.
Two footguns worth stating plainly, because both are in the spec and both are quiet:
- No
refundtag means anyone can spend after the locktime. If you build an HTLC and forget the refund keys, your lock does not revert to you — it reverts to the world. - NUT-14 is optional. The spec header says so. Any design that depends on it has to check the mint’s
/v1/infofirst, and has to have an answer for mints that do not advertise it.
The constraint most designs miss
Here is the thing to internalise before drawing any protocol diagram.
The mint only ever verifies signatures over Proof.secret. NUT-11 §52: spending a P2PK-locked proof requires a Schnorr signature on the SHA-256 hash of the message to sign, and “the message to sign is the field Proof.secret in the inputs, unless otherwise indicated by Secret.tags.sigflag.” With SIG_ALL, the signature covers all swap inputs and all outputs — still not an arbitrary message.
There is no NUT, and no tag combination, in which the mint checks a signature over a receipt you invented. A receipt is just bytes; the mint has no opcode that says “and also verify the customer signed off on 4,096 delivered bytes.”
That single fact invalidates the most attractive-sounding design: put the delivery receipt inside the HTLC so the mint enforces it. The mint will settle the swap happily and never learn whether a packet moved.
So the receipt, if you have one, is not enforced by the mint. It is enforced — if at all — by whoever chooses to honour it. Which moves the question from cryptography to governance.
The two halves behave completely differently
Half one: the transporter gets paid only if they delivered
This is achievable in the weak sense and unprovable in the strong sense.
The transporter controls forwarding. The mint sees ecash, not packets. The customer is the only party who observes bytes arriving. So any payment the transporter can claim, they can claim whether or not they delivered — unless the claim requires the customer’s cooperation.
That gives you one real lever: make the claim require a customer signature over the metered quantity. Then:
- The transporter cannot be paid for bytes the customer does not acknowledge.
- The customer can refuse to acknowledge, and then the transporter has forwarded for free.
- The loss is bounded by one interval, not by the session.
This is the post-paid signed receipt option, and note what it is not: it is not atomic. It is bounded-loss release. The transporter goes first, for one chunk.
Half two: the recipient decrypts only if delivery was paid
I got this wrong on the first pass, and the correction is more interesting than the claim was.
What is true: decryption is not a scarce resource in itself. If the transporter simply holds a key, they can hand it over before payment; a gate that gates nothing is a promise. That part stands.
What I missed: the key does not have to be a bare secret. It can be an HTLC preimage, and then it is a scarce resource after all — because the seller cannot collect the payment without publishing it.
The construction:
- The customer locks a proof to the seller’s key with an NUT-14 hashlock, where
Secret.data = SHA256(preimage). The preimage is the packet decryption key. - The
pubkeystag names the seller, so spending requires both the preimage and a valid signature (NUT-14: “the receiver(s) listed in thepubkeystag can spend the proof by providing BOTH”). Without that tag the preimage alone spends it, and then the preimage is public the moment the payment is broadcast. - The seller transmits encrypted chunks and keeps the preimage.
- The customer verifies the chunks against signatures from the sender, then claims the payment by revealing the preimage — which settles the ecash and hands over the key in one act.
So the exchange itself really is atomic, and my “close to impossible” was wrong. The sweep is real: the seller cannot be paid without the key becoming public, because spending is the publication.
What still is not solved, and this is the part that matters:
- Verification is not delivery. Point 4 needs the customer to verify the chunks before releasing the preimage. Signatures prove authorship — that the sender authored these bytes. They do not prove the bytes are the ones the customer needed, that the customer’s stack can parse them, or that they were not replayed from an earlier chunk. If the customer must accept on faith, the seller can deliver garbage and still be paid; if the customer must verify semantically, they are the oracle again and can refuse.
- Chunk granularity, not byte granularity. One preimage per chunk means a round-trip per chunk. On LoRa with minute-scale round trips, that is the liveness problem again, just moved from “gate on settlement” to “gate on each chunk”.
- The customer can still walk. They can leave without revealing the preimage. The seller’s loss is one chunk. That is the same bounded-loss release as the receipt option, only with the key doing double duty as the receipt.
- Mint support is not optional-optional. NUT-14 is an optional NUT. If the mint does not advertise it, there is no hashlock and the whole construction collapses to a bare secret — which is the case I originally (correctly) called a promise.
The honest summary: an HTLC key-swap makes the key transfer atomic with the payment, and that is a genuinely better primitive than a bare secret. It does not make delivery atomic with payment, because delivery is not a thing the mint can see. The gap moved from “does the seller publish the key” — now solved — to “does the customer accept the bytes as delivery” — which is a judgement call, and judgement calls cannot be enforced by a mint.
Why the two-party case cannot be fully fixed
This is not an implementation gap. It is the fair-exchange problem, and it has a literature.
Even, Goldreich and Lempel showed in A Randomized Protocol for Signing Contracts (1983; CACM 1985) that fair exchange is achievable only with gradual release of secrets, and that a correct protocol requires the parties’ computational power to be comparable, with termination only probabilistic. Pagnia and Gärtner’s survey Fair Exchange (The Computer Journal, 2003) is the standard map of the field and states the optimistic-protocol result: without a trusted third party, an optimistically fair exchange either needs a TTP in the abnormal case or accepts that the two-party case has no deterministic fair solution.
Translated to your problem: someone goes first, or someone is trusted. There is no third option. What you can engineer is which side goes first, and how much they lose when the other side defects.
That is why the handover brief’s own §11 is right that a negative result is a valid result. The design space is not “find the atomic protocol”; it is “choose the loss window and say who carries it.”
A capability matrix, so the table does the arguing
| Mechanism | Guarantees | Cannot guarantee | Residual risk |
|---|---|---|---|
| Prepaid token (status quo) | Seller paid before forwarding; customer cannot ride free | Seller may take a token and not forward | Customer: one prepaid increment. Seller: ~none |
| NUT-14 HTLC, bare preimage | Conditional claim; sender refunds after locktime | That delivery happened. Whoever holds the preimage spends | Both, bounded by locktime capital |
| HTLC key-swap (preimage = decryption key) | Key transfer is atomic with payment; seller cannot be paid without the key becoming public | That the bytes the key opens are the bytes the customer needed | Customer: accepts garbage. Seller: one unrevealed chunk |
| Post-paid signed receipt (no HTLC) | Customer pays only for bytes it acknowledges | Transporter is unpaid until the receipt arrives | Transporter: one interval |
| Spilman channel | Streaming micropayments with incremental signed balances | Customer can withhold the last update | Seller: value of the last unsigned increment |
| Mint/escrow attestor | Both sides made whole on dispute | Trustless-ness; the attestor must observe delivery it cannot see | Both: trust in a third party that cannot verify either |
| Bonded challenge | Economic penalty for cheating | That “non-delivery” is provable to an arbiter | Both: capital lockup and a dispute window |
Read the “cannot guarantee” column as the real content of the table. Every row has something in it.
What I would do with this
The HTLC key-swap is the best of the options above and I would prototype it — but know what you are prototyping. You are testing the exchange, and the exchange is the part that already works. The uncertain part is the acceptance rule at point 4.
Concretely, the thing worth measuring first is: what does a customer have to check before it is safe to reveal the preimage? If the answer is “a signature from the sender over the chunk”, you have a working system with a bounded loss. If the answer is “the decoded packet parses and is the one I asked for”, then the customer is an oracle and you are back to the fair-exchange impossibility with a key as the token.
Start with the cheap mechanical check and see how far it gets before it needs to know what the bytes mean.
The fallback remains the customer-signed meter receipt: no mint support needed, fits the existing session state machine, keeps offline admission intact. And the honest baseline is still prepaid with a shorter increment — the same bounded-loss design with a smaller bound and no new counterparty.
The part I am not sure about
Two things in this note are argued rather than measured, and should be tested rather than believed:
- The decryption-gating claim. Corrected once already: a bare key cannot be gated, but an HTLC preimage can, because spending publishes it. What I still have not tested is point 4’s verification step — whether “signed by the sender” is enough for a customer to accept a chunk as delivered, or whether it needs semantic verification that puts the customer back in the oracle seat.
- The loss-window numbers. “One interval” is doing a lot of work in the table above. Its size depends entirely on the transport, and I have not measured it here.
Both are cheap to test on a local mint. Neither needs a router.