Keyset ID V2 Implementation (NUT-02) #1505
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements Keyset ID V2 generation and validation as specified in cashubtc/nuts#182. It updates the keyset ID derivation logic to include fees and expiration in the preimage, and ensures consistent handling of optional fields across the codebase.
Changes
NUT-02 Keyset ID V2
v2_from_dataincrates/cashu/src/nuts/nut02.rsto derive V2 IDs.keys:{amount}:{pubkey},...|unit:{unit}|input_fee_ppk:{fee}|final_expiry:{expiry}.input_fee_ppkandfinal_expiryare only included in the preimage if they are present (Some) and non-zero.Consistency Improvements
KeySetInfoandMintKeySetInfoto useOption<u64>forinput_fee_ppk, aligning it withfinal_expiry.input_fee_ppkin favor of standardOptionhandling.input_fee_ppk(defaulting to 0 where necessary).Affected Crates
cashu: Core ID generation logic.cdk-common: Struct updates forMintKeySetInfo.cdk-signatory: Updated keyset generation and storage to support optional fees.cdk-sql-common: DB schema handling for nullable fee columns.cdk: Wallet fee calculation updates.References