-
Notifications
You must be signed in to change notification settings - Fork 74
Deterministic pay to public key generation #331
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,18 @@ The HMAC-SHA256 KDF is built as the following: | |||||||||||||||||||||||||||
| 2. `hmac_digest = HMAC_SHA256(seed, message)`, where `HMAC_SHA256` is the [hash-based message authentication code](https://en.wikipedia.org/wiki/HMAC) using SHA-256 as the hashing algorithm. | ||||||||||||||||||||||||||||
| 3. `secret = hmac_digest` and `blinding_factor = hmac_digest % N`. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #### P2PK Derivation | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Wallet are able to generate private keys is a deterministic way to have proofs locked to them. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| The following BIP32 derivation path for derivation of the key: `m/129372'/10'/0'/0'/{counter}`: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - 129372': Registered SLIP-0044 coin type for Cashu. | ||||||||||||||||||||||||||||
| - 10': Purpose for generating private keys for usage in P2PK. | ||||||||||||||||||||||||||||
| - {counter}: Incrementing counter encoded as an unsigned 64-bit integer in big-endian format. | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this using BIP32? Should be more clear.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I'll make it clearer |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| This will allow wallets to swap proof that are still locked to a public key during a restore process. | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Code Examples | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #### Versioned Secret Derivation | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why the last element is not hardened?
Is the xpub of
m/129372'/10'/0'/0'ever shared anywhere?If it is not shared, then instead of hardening it, I propose we change the scheme to
Cashu_KDF_HMAC_SHA256(same as used in Keyset v2, since BIP32 used in Keyset v1 is deprecated).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are following what Bitcoin does when it comes to key derivation for locking.
there is no reason right now for sharing an XPUB but can't guarantee that in the future.
The reason we want to use bip32 is because Bip32 is specifically made for this case.The
Cashu_KDF_HMAC_SHA256scheme is used because of aggregation to avoid certain issues when generating the keyset id.This keys are never aggregated and are use individually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not. BIP32 usecase is when you need to share a pubkey for a certain key subtree. Unless you need this requirement, going with
Cashu_KDF_HMAC_SHA256is simply faster and easier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prusnak if we get the option to query the mint for quotes connected to a pubkey via NUT-20, public key derivation would become more meaningful than it currently is. I can not think of a usecase right now, but with this, extended keys would be able to essentially create a watch-only wallet of a wallets quotes, without spending from it.
So either we think about proper usecases for this for 2 weeks and go with HMAC if we can't find any, or we take the performance L, go with BIP32 and hope someone finds a usecase some day in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we want to have a watch-only wallet eventually which should show p2pk tokens too, this seems like a good use-case. ACK