What changed, and why it matters
This commit fixes a bug in the MuSig2 multi-signature code where reading a partial signature from an input stream could fail silently. Previously, if the stream ended early or had a read error, the function would return 'no error' as if the signature had been decoded successfully. Now it correctly returns the actual read error. This could have allowed malformed or truncated signatures to be treated as valid, potentially leading to incorrect multi-signature behavior.
Treat as a low-to-moderate correctness/security fix. Review callers of PartialSignature.Decode to ensure they now handle returned errors and do not process signatures when decoding fails. Include in release notes as a bug fix; consider whether any protocol path could have accepted a zero scalar signature.
Security signals we found
Silent failure in cryptographic decode path
Partial signature scalar left uninitialized on read error
MuSig2 signing correctness dependency
Evidence from the diff
In btcec/schnorr/musig2/sign.go, PartialSignature.Decode reads 32 bytes for the scalar S. The original code returned nil when io.ReadFull failed, masking read errors and leaving p.S in a zero/default state while reporting success. The patch returns err instead. This is a correctness fix in cryptographic signature parsing; downstream callers that trust the nil error may have accepted an all-zero scalar as a valid partial signature.
Changed components
btcec/schnorr/musig2/sign.goPartialSignature.DecodeInspect captured patch +1 / −1
diff --git a/btcec/schnorr/musig2/sign.go b/btcec/schnorr/musig2/sign.go
index 67d194d..fadae01 100644
--- a/btcec/schnorr/musig2/sign.go
+++ b/btcec/schnorr/musig2/sign.go
@@ -91,7 +91,7 @@ func (p *PartialSignature) Decode(r io.Reader) error {
var sBytes [32]byte
if _, err := io.ReadFull(r, sBytes[:]); err != nil {
- return nil
+ return err
}
overflows := p.S.SetBytes(&sBytes)
Why this scored 48/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.