feat(cmd): derive node key from bip39 mnemonic#562
Merged
Conversation
shotonoff
previously approved these changes
Jan 26, 2023
Collaborator
shotonoff
left a comment
There was a problem hiding this comment.
LGTM
please look at a couple of minor comments
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.
Issue being fixed or feature implemented
DIP-0009 defines feature path that should be used to derive cryptographic keys for various usages, in accordance to BIP-43 and BIP-44. Tenderdash doesn't support these schemes.
As we requested to add node ID to Deterministic Masternode Lists (DML, see DIP-0003), a practical problem arises: Masternode owners don't have Tenderdash deployed yet, and they cannot easily retrieve node ID without generating tenderdash node key ("p2p key"). This means they would need to generate - and manage - their keys when deploying planned enhancement (most likely, with Dash Core v19).
With BIP39 mnemonic support in Tenderdash, it will be enough to use their mnemonic to generate node ID. On Platform launch, they can use the same mnemonic to generate final private key. This also solves a problem of backing up the keys - standard offline BIP39 mnemonic should be enough for this.
This solution must be compatible with other implementations, to ensure interoperability.
What was done?
In this PR,
--from-mnemonicflag was added totenderdash gen-node-keycommand, to support key derivation fromBIP-39 compatible mnemonic. It uses implementation of SLIP-0010 from Oasis Protocol to generate ED25519 private key, basedon provided mnemonic , passphrase and BIP32 derivation path.
Added flags:
This command outputs JSON containing:
idfieldpriv_keyfieldidfield can be used as "node id" to register masternode in DML.How Has This Been Tested?
Local execution
Added unit test
crypto/ed25519/bip39.go
Compared to javascript implementation
Using https://npm.runkit.com/ed25519-hd-key , compared results of execution of our unit tests with javascript library
ed25519-hd-key.Result:
Javascript library adds a null in the beginning of public key
Sample Tenderdash result: 9041e8deaddde890e6041b28a9239aa73bdaf7743531646ede9f198e53b1bed6
Sample Javascript result: 009041e8deaddde890e6041b28a9239aa73bdaf7743531646ede9f198e53b1bed6
Test code
Breaking Changes
None
Checklist:
For repository code-owners and collaborators only