-
-
Notifications
You must be signed in to change notification settings - Fork 139
feat: keysets v2 #798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
a1denvalu3
wants to merge
7
commits into
cashubtc:main
Choose a base branch
from
a1denvalu3:keysets-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: keysets v2 #798
Conversation
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
0afe16c to
9a213c7
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #798 +/- ##
===========================================
- Coverage 64.71% 52.30% -12.42%
===========================================
Files 91 90 -1
Lines 10900 10673 -227
===========================================
- Hits 7054 5582 -1472
- Misses 3846 5091 +1245 ☔ 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
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.19.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