NUT-20: deterministic quote locking key derivation - #2
Merged
Conversation
Adds the m/129373'/20'/0'/0'/{counter} derivation from cashubtc/nuts#373,
covered by the vectors in tests/20-test.md. The counter is its own
DerivationPurpose, which the spec requires to be independent of the NUT-13
keyset counters.
WithDeterministicPubkey locks a quote to the derived key instead of one the
caller has to keep, and the handler then signs the mint request itself. The
point is recovery: a quote that was locked but not yet minted is otherwise
lost with the key.
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.
Stacked on
feat/deterministic-p2pk(upstream PR Kukks#33), so the diff here is the one commit on top of it. Retarget tomasteronce Kukks#33 lands.Adds the derivation from cashubtc/nuts#373:
Verified against the vectors in
tests/20-test.md(same mnemonic as the NUT-13 ones), plus a test that quote keys and P2PK keys never collide, since they differ only in the account index.The counter is its own
DerivationPurpose.MintQuoteLock, which the spec calls out as independent from the NUT-13 keyset counters.Why it matters
Today a NUT-20 lock uses a key the caller generates and has to store somewhere. If it is lost, so is any quote that was locked but not yet minted — the ecash cannot be claimed. Deriving from the seed makes those quotes recoverable on restore.
WithDeterministicPubkey()locks the quote to the derived key and the mint handler signs the request itself, so neitherWithPubkeynorSignWithPrivkeyis needed:Requires a mnemonic and a counter implementing
IDerivationCounter, both from the base branch.Unit tests: 116 passing. The integration test mints bolt12 end to end against cdk-mintd 0.17.3, checking that the pubkey the mint received is the derived one and that the counter advanced.