Remove `spendfromchanneladdress` nonce after one sig (#3392)
What changed, and why it matters
This commit fixes a cryptographic safety issue in a manual Bitcoin/Lightning recovery tool. When a user runs the `spendfromchanneladdress` operation, the code was re-reading a secret signing nonce from a stored map after using it once. Nonces must never be reused in this signature scheme, because reuse can leak the private key. The change removes the nonce from the map immediately after it is used, so it cannot be reused accidentally or maliciously in a later signature.
Treat as a low-to-moderate security hardening fix. Users who have already used `spendfromchanneladdress` with partial signatures should ensure no nonce was reused in practice and rotate any affected channel funding keys if reuse is suspected. Upgrade to the patched version for the hardening benefit.
Security signals we found
nonce reuse prevention in Schnorr-like/MuSig2 partial signature flow
private nonce removed from in-memory store after single use
manual recovery command affected, not hot path
commit message explicitly frames change as a security/correctness fix
Evidence from the diff
In SpendFromChannelAddress.scala, the partial-signature branch previously fetched the local private nonce with nonces(localNonce_opt.get), leaving it in the mutable nonces map. The patch changes this to nonces.remove(localNonce_opt.get).get, deleting the nonce as it is consumed. This prevents nonce reuse across multiple ChannelSpendSignature.PartialSignatureWithNonce invocations. The fix is straightforward and local, but the commit notes it is a manual recovery operation, limiting exposure.
Changed components
eclair-core/src/main/scala/fr/acinq/eclair/SpendFromChannelAddress.scalaspendfromchanneladdress manual recovery commandInspect captured patch +1 / −1
### eclair-core/src/main/scala/fr/acinq/eclair/SpendFromChannelAddress.scala
@@ -61,7 +61,7 @@ trait SpendFromChannelAddress {
val localSig = tx.sign(localFundingKey, remoteFundingPubkey, extraUtxos = Map.empty)
tx.aggregateSigs(localFundingKey.publicKey, remoteFundingPubkey, localSig, individualRemoteSig)
case remotePartialSig: ChannelSpendSignature.PartialSignatureWithNonce =>
- val localPrivateNonce = nonces(localNonce_opt.get)
+ val localPrivateNonce = nonces.remove(localNonce_opt.get).get
val Right(localSig) = tx.partialSign(localFundingKey, remoteFundingPubkey, extraUtxos = Map.empty, localNonce = localPrivateNonce, publicNonces = Seq(localPrivateNonce.publicNonce, remotePartialSig.nonce))
val Right(signedTx) = tx.aggregateSigs(localFundingKey.publicKey, remoteFundingPubkey, localSig, remotePartialSig, extraUtxos = Map.empty)
signedTxWhy this scored 53/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.