Deterministic Currency Unit Derivation Paths #1181
Closed
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.
Description
Hard coding currency units and their corresponding derivation paths for deterministic secrets is an unsustainable strategy because it forces us to update all cashu implementations for each new currency unit. We've gotten away with it this far because cashu only supports a limited set of currencies, with sats being the most popular by far.
Ehash will have very different requirements because each mining epoch (time in between mining rewards) will use a different currency unit. So we need a way to dynamically map currency units to derivation paths.
This PR introduces an algorithm to deterministically generate a derivation path based on the currency unit name.
First, some code cleanup. This PR moves the currency unit code from the nut00 crate to nut01 where it belongs. (The spec was updated after the initial cdk CurrencyUnit implementation.)
Now to business: we force all currency unit names to uppercase and calculate the derivation path in this way:
Opening this draft PR to get initial feedback on the implementation. I will also open a NUT PR to propose this new specification.
Notes to the reviewers
Suggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just final-checkbefore committing