Skip to content

Conversation

@callebtc
Copy link
Contributor

@callebtc callebtc commented Jan 8, 2026

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

  • Implemented v2_from_data in crates/cashu/src/nuts/nut02.rs to derive V2 IDs.
  • V2 Preimage format: keys:{amount}:{pubkey},...|unit:{unit}|input_fee_ppk:{fee}|final_expiry:{expiry}.
  • input_fee_ppk and final_expiry are only included in the preimage if they are present (Some) and non-zero.

Consistency Improvements

  • Refactored KeySetInfo and MintKeySetInfo to use Option<u64> for input_fee_ppk, aligning it with final_expiry.
  • Removed custom deserializers for input_fee_ppk in favor of standard Option handling.
  • Updated database and wallet logic to handle nullable input_fee_ppk (defaulting to 0 where necessary).

Affected Crates

  • cashu: Core ID generation logic.
  • cdk-common: Struct updates for MintKeySetInfo.
  • 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

@callebtc callebtc mentioned this pull request Jan 8, 2026
5 tasks
@thesimplekid thesimplekid added this to the 0.15.0 milestone Jan 8, 2026
@callebtc callebtc marked this pull request as draft January 11, 2026 08:52
@callebtc callebtc marked this pull request as ready for review January 11, 2026 09:00
@thesimplekid
Copy link
Collaborator

I rebased and fixed the test in my branch https://github.com/thesimplekid/cdk/tree/keyset-v2-derivation if youre alright with me force pushing here.

callebtc and others added 5 commits January 14, 2026 23:11
Resolved merge conflicts in:
- crates/cashu/src/nuts/nut02.rs
- crates/cdk-sql-common/src/wallet/mod.rs

Updated input_fee_ppk from Option<u64> to u64 in:
- cashu: KeySet, KeySetInfo, MintKeySet
- cdk-common: MintKeySetInfo
- cdk-signatory: SignatoryKeySet, RotateKeyArguments, and conversions
- cdk-sql-common: database schema and queries
- cdk-ffi: KeySet and conversions
- cdk: wallet fee calculation and metadata cache
- Re-added deserialize_input_fee_ppk and default_input_fee_ppk in cashu nut02
- Re-added default_fee in cdk-common mint
- Fixed missing input_fee_ppk in cdk-ffi keys
@thesimplekid thesimplekid merged commit fac0610 into main Jan 15, 2026
89 checks passed
@thesimplekid thesimplekid deleted the keyset-v2-derivation branch January 15, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update keysetv2 to new derivation scheme and any other spec changes

4 participants