feat: verify and sign the length-framed NUT-11 SIG_ALL message - #1088
feat: verify and sign the length-framed NUT-11 SIG_ALL message#1088robwoodgate wants to merge 6 commits into
Conversation
The mint accepts the v1 ("Cashu_SigAllSig_v1") and current message
formats, counting unique public keys with valid signatures and
ignoring signatures that do not verify. The wallet signs v1, current
and legacy so its transactions verify on mints at any upgrade stage.
Canonical vectors from the NUT-11 spec tests are pinned in the test
suite.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1088 +/- ##
==========================================
+ Coverage 74.35% 74.46% +0.10%
==========================================
Files 115 115
Lines 13155 13175 +20
==========================================
+ Hits 9782 9811 +29
+ Misses 3373 3364 -9 ☔ View full report in Codecov by Harness. |
My recommendation would be current ('v0') and the proposed 'v1' only, the legacy MTS should be dropped unilaterally. SIG_ALL is a pretty niche feature, so I think the benefit of dropping it outweighs the inconvenience to older wallets. |
Wallets sign v1 and current; the pre-0.21 message (secrets then B_ fields) is no longer produced, as it does not commit to C values or output amounts (cashubtc/nuts#404). Mint verification is unchanged.
|
I have removed the legacy signing format this PR had re-added |
# Conflicts: # cashu/mint/conditions.py # cashu/mint/ledger.py # cashu/wallet/p2pk.py # tests/mint/test_mint_conditions.py # tests/nuts/test_nut11_test_vectors.py
Restore cashu/mint/ledger.py byte-for-byte to main: the merge resolution normalized its mixed line endings, which made the whole file show as changed. Give the transaction unit test outputs even-length hex B_ values: the v1 SIG_ALL message decodes them to raw bytes.
| # ignore signatures that do not verify and count unique pubkeys. | ||
| quote_suffix = quote_id or "" | ||
| messages_to_sign: List[Union[str, bytes]] = [ | ||
| nut11.sigall_message_to_sign_v1(proofs, outputs, quote_id), |
There was a problem hiding this comment.
what exactly is v1? should this be called legacy? legacy code should be clearly wrapped in a BEGIN ... END legacy section
There was a problem hiding this comment.
"v1" is the new version specified (Cashu_SigAllSig_v1), length framed MTS, see cashu/core/nuts/nut11.py#L13
The legacy MTS was removed, the outgoing (currently live, unversioned, not length prefixed) MTS as below, now at line 35 of nut11.py:
nut11.sigall_message_to_sign(proofs, outputs) + quote_suffix,
Implements the length-framed NUT-11 SIG_ALL message aggregation (
Cashu_SigAllSig_v1) proposed in cashubtc/nuts#404. The new format matches the domain separation and length framing already used for NUT-20 mint quote signatures.tests/11-test.mdare pinned intests/nuts/test_nut11_test_vectors.py