Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@theflyingcodr
Copy link
Contributor

This PR adds new derivePath and deriveSeed methods, used to create deterministic bip32 paths.

This can be used to store an atomic counter in a persistent store and simply increment the counter when you need a new private key created. Pass the seed to DerivePath and will return a deterministic path by splitting the bits into 3 and joining them. This can then be reversed by calling DerivateSeed wherein you provide a path and the seed used is returned.

@theflyingcodr theflyingcodr self-assigned this Jun 14, 2021
@theflyingcodr theflyingcodr requested a review from jadwahab June 14, 2021 15:39
@theflyingcodr theflyingcodr added the enhancement New feature or request label Jun 14, 2021
// This is achieved by the following process:
// We split the seed bits into 3 sections: (b63-b32|b32-b1|b1-b0)
// Each section is then added onto 2^31 and concatenated together which will give us the final path.
func DerivePath(seed uint64) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename seed to counter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought seed may have been more appropriate as it can be any number - we just happen to iterate a counter as part of our implementation.

@theflyingcodr theflyingcodr requested a review from jadwahab June 15, 2021 08:21
@jadwahab jadwahab merged commit 023994c into master Jun 15, 2021
@jadwahab jadwahab deleted the enhancement/seeded_derivationpath branch June 15, 2021 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants