Skip to content

[2/3] aux revocation: exchange revocation AuxSigs in RevokeAndAck - #11111

Open
GeorgeTsagk wants to merge 3 commits into
lightningnetwork:masterfrom
GeorgeTsagk:revocation-aux-sigs
Open

GeorgeTsagk wants to merge 3 commits into
lightningnetwork:masterfrom
GeorgeTsagk:revocation-aux-sigs

Conversation

@GeorgeTsagk

@GeorgeTsagk GeorgeTsagk commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

This is part 2 of the HTLC revocation series for aux/custom (taproot asset) channels, stacked on #11094. Only the last three commits are new here.

When a custom channel with deterministic HTLCs revokes a commitment, the revoking party signs second-level transactions for both spending paths of every non-dust HTLC on the revoked commitment and ships the signatures in the RevokeAndAck. This hands the honest party the asset-level material it needs at breach time: whichever path a cheater later uses to take an HTLC to the second level, a valid asset witness is already in hand.

Scope:

  • lnwire: RevokeAndAck gains CustomRecords. Additive and backward compatible, a message without records is byte-identical to today (pinned by test).
  • Sender: signs both spend paths per non-dust HTLC and packs the sigs per HTLC index into the outgoing RevokeAndAck, one entry per non-dust HTLC in lockstep with the BTC-level sigs (BTC-only HTLCs get a sig-less entry). A signing failure fails the revocation before any state advances.
  • Receiver: verifies every sig against the revoked commitment's key ring before the revocation is accepted, then persists them in the revocation log for breach-time consumption. Presence is enforced, mirroring the aux sig count check on CommitSig: entries are required for every non-dust HTLC, and unknown-index, dust-index, or one-sided entries are rejected.
  • Retransmission: the packed blob is persisted atomically with the commitment advance and re-attached when the RevokeAndAck is retransmitted on reestablish, surviving restarts.
  • Isolation: everything is gated behind a single predicate requiring a tapscript root, an aux signer, and negotiated SigHashDefault. Vanilla channels never sign, attach, read, or verify these records.

No lnd-native channel can enter these paths, so end-to-end coverage lives in the taproot-assets custom channel itest suite; unit tests here cover the happy path, dust exclusion, all rejection cases, retransmission across a restart, and codec round trips.

Previous PR: #11094

Next PR: #11112

@GeorgeTsagk GeorgeTsagk self-assigned this Aug 21, 2026
GeorgeTsagk added a commit to lightninglabs/taproot-assets that referenced this pull request Aug 24, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@github-actions github-actions Bot added the severity-critical Requires expert review - security/consensus critical label Aug 24, 2026
@github-actions

Copy link
Copy Markdown

🔴 PR Severity: CRITICAL

File-path classification | 18 non-test files | ~2181 lines changed (excl. tests)

🔴 Critical (16 files)
  • channeldb/channel.go - channel state persistence
  • contractcourt/chain_arbitrator.go - on-chain dispute resolution coordination
  • contractcourt/chain_watcher.go - on-chain breach/close detection
  • contractcourt/contract_resolver.go - contract resolution logic (+312 lines, new resolver behavior)
  • contractcourt/htlc_success_resolver.go - HTLC success resolution on-chain
  • contractcourt/htlc_timeout_resolver.go - HTLC timeout resolution on-chain
  • htlcswitch/link.go - HTLC forwarding state machine
  • htlcswitch/mock.go - htlcswitch package support code
  • lnwallet/aux_signer.go - auxiliary signing for commitments/HTLCs
  • lnwallet/chanfunding/coin_select.go - channel funding coin selection
  • lnwallet/channel.go - core channel state machine, commitment transactions (+1252/-45, largest change in PR)
  • lnwallet/commitment.go - commitment transaction construction
  • lnwallet/mock.go - lnwallet package support code
  • lnwallet/transactions.go - transaction construction/signing
  • lnwire/revoke_and_ack.go - wire protocol message (RevokeAndAck)
  • server.go - core server coordination
🟠 High (1 file)
  • lnrpc/walletrpc/walletkit_server.go - wallet RPC/API surface
🟡 Medium (1 file)
  • chanstate/open_channel.go - channel state helper, not explicitly categorized
🟢 Low (14 files, tests)
  • channeldb/channel_test.go
  • channeldb/db_test.go
  • contractcourt/breach_arbitrator_test.go
  • contractcourt/commit_sweep_resolver_test.go
  • contractcourt/contract_resolver_test.go
  • htlcswitch/mailbox_test.go
  • input/size_test.go
  • lnrpc/walletrpc/walletkit_server_test.go
  • lnwallet/aux_signer_test.go
  • lnwallet/channel_test.go
  • lnwallet/chanfunding/coin_select_test.go
  • lnwallet/revocation_aux_sig_test.go
  • lnwallet/transactions_test.go
  • lnwire/revoke_and_ack_test.go

Analysis

This PR modifies core commitment-transaction and HTLC-resolution logic across lnwallet/* (most significantly lnwallet/channel.go, a >1,200-line change), contractcourt/* (new resolver logic in contract_resolver.go and the HTLC success/timeout resolvers), htlcswitch/link.go, lnwire/revoke_and_ack.go, and channeldb/channel.go. These packages govern channel state, on-chain breach/dispute handling, and HTLC forwarding — the highest-risk surfaces in lnd. The combination of touching multiple distinct critical packages plus well over 500 non-test lines changed both independently justify CRITICAL severity; expert review is warranted, particularly for the commitment/resolver changes and the revocation/aux-signer logic (likely related to custom channels / taproot assets aux signing).


To override, add a severity-override-{critical,high,medium,low} label.

GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 25, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 26, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 28, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

3 similar comments
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@GeorgeTsagk
GeorgeTsagk force-pushed the revocation-aux-sigs branch 2 times, most recently from bc2e49b to 27ebd33 Compare September 29, 2026 08:16
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Oct 6, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

2 similar comments
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

1 similar comment
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000 litbot-9000 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with the rest of the stack and with taproot-assets#1994 (which pins this at 2069f100d). I confirmed the three blockers inline (index collision, sig-less entries, unbounded allocation) with scratch tests against this branch.

These parts are correct: key ring and height selection on both sides, the dust classification agreeing between sender and receiver, no side effects on sign failure, atomic persistence of the blob with the commitment, the identical-bytes retransmit, and the gating to custom SigHashDefault channels.

Test gaps:

  • Every test HTLC goes Alice→Bob, so there's no bidirectional or same-index coverage, and the fake verifier accepts any blob. That's why the collision below slipped through.
  • Switching the receiver's dust limit from RemoteChanCfg to LocalChanCfg survives the suite, because the test channels use symmetric dust limits.
  • The "restart" in TestRevocationAuxSigsRetransmission is Refresh() on the same instance, and the retransmitted RevokeAndAck is never fed to Alice, so verification after a restart isn't exercised.
  • TestUnpackRevocationAuxSigsCorrupt doesn't cover duplicates, trailing bytes or an oversized count.

Posted by claudell (automated review agent) at georgetsagk's request.

Comment thread lnwallet/channel.go Resolved
Comment thread lnwallet/channel.go Resolved
Comment thread lnwallet/channel.go Resolved
Comment thread lnwallet/channel.go Resolved
Comment thread lnwallet/aux_signer.go Resolved
Comment thread lnwallet/channel.go Resolved
Comment thread chanstate/open_channel.go Resolved
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 11, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 11, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 12, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@litbot-9000

Copy link
Copy Markdown
Collaborator

@GeorgeTsagk, remember to re-request review from reviewers when ready

GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 23, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@GeorgeTsagk
GeorgeTsagk force-pushed the revocation-aux-sigs branch 2 times, most recently from c8cfca3 to 875ee3c Compare November 25, 2026 12:11
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 25, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 26, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@GeorgeTsagk
GeorgeTsagk requested review from litbot-9000 and removed request for gijswijs November 26, 2026 12:06
@litbot-9000

Copy link
Copy Markdown
Collaborator

@litbot-9000: review reminder

GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 27, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
The RevokeAndAck message gains a CustomRecords field, encoded and
decoded with the standard ParseAndExtractCustomRecords/MergeAndEncode
helpers. The field is additive and backward-compatible on the wire:
peers that send no records produce byte-identical encodings to before
this change, and unknown odd records are tolerated on receive.

The following commits use this field to carry revocation AuxSigs for
aux/custom (taproot asset) channels; a vanilla lnd channel never
populates it.
When an aux/custom (taproot asset) channel revokes a commitment that
was built with DeterministicHTLCs, the revoking party now signs the
second-level HTLC virtual transaction of every non-dust HTLC on the
commitment being revoked, and ships the signatures to the peer inside
the RevokeAndAck message's custom records. This hands the honest party
the asset-level puzzle piece it needs at breach time: if the cheater
later broadcasts the revoked commitment and takes an HTLC to the second
level, the breached party holds the cheater's half of the asset witness
for that transition.

An HTLC has exactly one second-level path on the commitment of the
party that revokes it: the success tx for an HTLC it received, the
timeout tx for one it offered. That is the path that is signed.

Changes:

- Sender: signLocalHtlcAuxSigs derives the second-level tx of each
  non-dust HTLC on the revoked commitment and submits a sign job to the
  aux signer. The signatures are packed as one TLV stream per HTLC,
  tagged with the HTLC's index and direction. The index alone does not
  identify an HTLC: both parties count the HTLCs they offer from zero,
  so a commitment regularly carries an incoming and an outgoing HTLC
  with the same index. One entry is packed per non-dust HTLC even when
  the signer produces no signature for it (a BTC-only HTLC), in
  lockstep with the BTC-level signatures. A signing failure fails the
  revocation as a whole, before any state is advanced: the peer
  requires the sigs, so a sig-less RevokeAndAck would just fail the
  channel on their side.

- Receiver: ReceiveRevocation verifies the received aux sigs against
  the revoked commitment's key ring BEFORE the revocation is accepted
  and the tail advances, then injects the sigs into the remote
  commitment's HTLC custom records so they are persisted in the
  revocation log for breach-time consumption. Presence is enforced,
  mirroring the aux sig count check on CommitSig: an entry is required
  for every non-dust HTLC on the revoked commitment (a peer cannot
  strip our breach protection by withholding the records), and entries
  for unknown or dust HTLCs are rejected. A verify job is handed to the
  aux signer for every non-dust HTLC, with or without a sig, as only
  the aux signer knows whether the HTLC carries aux outputs and
  therefore owes one. Whatever the peer put under our storage record
  type on its own UpdateAddHTLC is dropped before the sigs are
  injected, so only verified sigs reach the revocation log.

- Decoding: the blob comes from the peer and is decoded accordingly.
  The declared entry count never sizes an allocation, every entry must
  consume exactly the length it declares, an HTLC may appear only once
  and nothing may follow the last entry.

- Retransmission: the packed sig blob is persisted in a new optional
  TLV field on the channel info, written atomically with the
  commitment advance in UpdateCommitment, and re-attached when the
  RevokeAndAck is retransmitted on channel reestablish. Only the
  latest revocation can ever be owed, so a single overwritten slot
  suffices. If the write fails the previous blob stays in memory.

- BaseAuxJob gains the WhoseCommit and HtlcTimeout fields needed to
  describe a sign job for our own commitment to the aux signer.

The gate is factored into a single predicate,
exchangesRevocationAuxSigs, used by both hooks and (defense in depth)
inside the sign and verify functions themselves. It requires an
explicit HasTapscriptRoot() on the channel type, and that the
commitment being revoked records SigHashDefault in its own blob. Both
peers hold that record for the same commitment, so they agree on which
revocations carry the signatures even while the sighash type used for
new commitments is changing. A vanilla lnd channel never signs,
attaches, reads, or verifies these records and its RevokeAndAck is
byte-identical to before this change.
Coverage for the revocation AuxSig exchange introduced in the previous
commits:

- lnwire codec: encode/decode round trips for RevokeAndAck with and
  without custom records, including a byte-for-byte assertion that the
  no-records encoding is identical to the legacy wire format.

- TLV blob: pack/unpack round trips, including the same HTLC index in
  both directions, and rejection of corrupt and hostile blobs:
  truncation, garbage, duplicate entries, trailing bytes, undeclared
  entries, lengths beyond the blob, cut-off records, missing or invalid
  index and direction records. A declared entry count in the billions
  must not make the decoder allocate for it.

- Custom-channel-only gating: a non-custom taproot channel with an aux
  signer that pushes SigHashDefault attaches nothing and ignores stray
  records. The gate follows the sighash recorded for the commitment
  being revoked, not the one new commitments use.

- Happy path over a funded tapscript-root channel pair: one sig for
  every non-dust HTLC, the dust decision made with the dust limit of
  the commitment's owner, the sig matched to the right verify job, and
  the verified sig persisted into the revocation log entry of the
  revoked commitment.

- Same HTLC index in both directions: each HTLC is signed once for its
  own path, gets its own entry, and keeps its own sig through
  verification and persistence.

- BTC-only HTLCs: sig-less lockstep entries are attached, and accepted
  once the aux signer has been asked about them.

- Rejection before the remote chain tail advances: unverifiable sigs,
  malformed blob, missing sig for a non-dust HTLC, a sig tagged with
  the wrong direction, withheld blob, a sig withheld from its entry,
  the sig of another HTLC, an extra entry for an unknown HTLC index or
  for the other direction, and entries for HTLCs that are dust for
  both parties or for the signer only.

- A custom record the peer planted under our storage type never
  reaches the revocation log.

- Sign-time failure: an aux signer error fails RevokeCurrentCommitment
  before any state advances, for both batch-level and per-job errors.

- Retransmission: after a restart, with the channel rebuilt from disk,
  a retransmitted RevokeAndAck carries the original aux sigs without
  signing again, and the peer verifies and accepts them.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 30, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog severity-critical Requires expert review - security/consensus critical

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants