Open
Conversation
0afe16c to
9a213c7
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #798 +/- ##
==========================================
- Coverage 64.71% 61.11% -3.60%
==========================================
Files 91 91
Lines 10900 10966 +66
==========================================
- Hits 7054 6702 -352
- Misses 3846 4264 +418 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e0a4c12 to
4cd1d78
Compare
4cd1d78 to
723eb96
Compare
723eb96 to
6b67ea8
Compare
c929f1b to
c513363
Compare
7d20915 to
e969049
Compare
d2214ea to
36c7696
Compare
36c7696 to
a11ba8b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Keyset ID Version 2 Implementation
Warning
This PR bumps Nutshell's version to
0.20.0Overview
This PR implements the Keyset ID Version 2 specification, which changes how keyset IDs are derived and introduces support for short keyset IDs. This change improves determinism, security, and functionality of keysets while maintaining backward compatibility.
Key Changes
1. New Keyset ID Derivation
Version-based ID derivation:
00, 16 chars)01, 66 chars)V2 Keyset ID calculation:
01to indicate V2 formatunit:{unit_name})final_expiry:{timestamp})2. Short Keyset ID Support
3. Keyset Rotation Improvements
rotate_next_keysetto support thefinal_expiryparameter4. DB Fetching Rearrangement
final_expiryfield in keyset database tables5. Version-based Secret Derivation
message = "Cashu_KDF_HMAC_SHA256" || keyset_id || counterTechnical Details
Keyset ID Derivation Changes
The V2 keyset ID derivation now includes:
unit:{unit_name}to the byte arrayfinal_expiry:{timestamp}if provided01to indicate V2 formatThis creates a more robust, deterministic ID that properly includes all relevant keyset information, unlike previous versions that only used public keys.
Secret Derivation Implementation
The wallet now detects keyset version and uses the appropriate secret derivation method:
For V2 keysets (version 01):
For V1 keysets (version 00) and Base64 keysets:
The secret derivation mechanism is critical for wallet restoration and token recovery. This change ensures compatibility with all keyset formats while introducing a more robust derivation method for V2 keysets.
Rotate-Next-Keyset Behavior
When
rotate_next_keysetis called:final_expiryparameter is passed through to the new keysetKeyset Fetching Rearrangement
Previously, keysets were fetched from DB by their ID, which could cause issues when trying to load a keyset whose ID calculation might have changed. Now:
activate_keysetmethodBackward Compatibility
Testing