Skip to content
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

Add api to generate child keys from master key #87

Closed
notmandatory opened this issue Nov 12, 2021 · 5 comments
Closed

Add api to generate child keys from master key #87

notmandatory opened this issue Nov 12, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request summer-of-bitcoin Summer of Bitcoin Project
Milestone

Comments

@notmandatory
Copy link
Member

notmandatory commented Nov 12, 2021

Description

Add an API to bdk-ffi to derive a child key pair from a master extended key and a derivation path string (eg. "m/84'/1'/0'/0" or "m/84h/1h/0h/0"). Also test the new bdk-ffi functions and structs via the bdk-kotlin and/or bdk-swift projects. See the bdk-cli key -> derive subcommand as an example.

Expected Outcomes

  • Update bdk.udl and lib.rs with functions and structs as needed
  • Update bdk-kotlin or bdk-swift and add tests to cover new key generation functionality

Resources

Skills Required

  • Experience with git. Guide
  • Basic familiarity with rust. First seven chapters of the book
  • Basic familiarity with Kotlin or Swift
  • Familiarity with bitcoin descriptors and address generation

Mentor(s)

@artfuldev @notmandatory

Difficulty

Medium

Competency Test (optional)

  • Install rust, compile bdk-ffi and build and test bdk-swift or bdk-kotlin.
  • Read through the BDK docs.
  • Install and run example bdk-kotlin or bdk-swift example wallet.
  • Familiarity with basic rust, should be able to write basic structs and functions.
@notmandatory notmandatory added the enhancement New feature or request label Nov 12, 2021
@notmandatory notmandatory added this to the Stackmate Core Support milestone Nov 12, 2021
@notmandatory notmandatory modified the milestones: 0.3.0, 0.4.0 Feb 2, 2022
@notmandatory notmandatory added the summer-of-bitcoin Summer of Bitcoin Project label Feb 3, 2022
@notmandatory notmandatory moved this to Todo in BDK-Bindings Feb 14, 2022
@notmandatory notmandatory moved this from Todo to In Progress in BDK-Bindings May 12, 2022
@notmandatory
Copy link
Member Author

@dhruv-1001 will be working on this issue this year's summer of bitcoin program.

@kirillzh
Copy link
Contributor

kirillzh commented Jun 30, 2022

@notmandatory, @dhruv-1001, @artfuldev, what are your thoughts on providing full descriptor extended key with the master derivation path and master fingerprint in addition to the xpub, as opposed to just the xpub? As far as I can tell, current WIP implementation in #154 only provides the xpub key, in a format like: xpub123 but not the full descriptor extended key, in a format like: [asdfgast/84'/1'/0'/0']xpub/*. The fingerprint and origin derivation path seem to be important when working with hardware wallets and signing PSBTs:

In order to describe scripts whose signing keys reside on another device, it may be necessary to identify the master key and derivation path an xpub was derived with.

For example, when following BIP44, it would be useful to describe a change chain directly as xpub.../44'/0'/0'/1/* where xpub... corresponds with the master key m. Unfortunately, since there are hardened derivation steps that follow the xpub, this descriptor does not let you compute scripts without access to the corresponding private keys. Instead, it should be written as xpub.../1/*, where xpub corresponds to m/44'/0'/0'.

When interacting with a hardware device, it may be necessary to include the entire path from the master down. BIP174 standardizes this by providing the master key fingerprint (first 32 bit of the Hash160 of the master pubkey), plus all derivation steps. To support constructing these, we permit providing this key origin information inside the descriptor language, even though it does not affect the actual scriptPubKeys it refers to.

@notmandatory
Copy link
Member Author

@kirillzh that is a good idea to include the key origin with the derived key. I'll work with @dhruv-1001 and see if we can get it into #154.

@dhruv-1001
Copy link
Contributor

dhruv-1001 commented Jul 7, 2022

We have updated the derivation to include key origin information @kirillzh . You can see the tests as examples.
Does the new API and it's parameters makes sense?

notmandatory added a commit that referenced this issue Aug 18, 2022
5944756 Added tests for DescriptorSecretKey and DescriptorPublicKey (dhruvbaliyan)
58fea6b Added interfaces DescriptorSecretKey and DescriptorPublicKey (dhruvbaliyan)
4977cb6 Added interface DerivationPath (dhruvbaliyan)
930a1f1 Added generate_mnemonic method (dhruvbaliyan)
973013c Removed ExtendedKeyInfo & related methods (dhruvbaliyan)

Pull request description:

  Would like to know if anything can be improved. Completes #87

Top commit has no ACKs.

Tree-SHA512: a480535c8965015d860336c717ec3c394778ac08194b0336eeba4209f3e3eff2072873a190dd8c9e4fac1e2f712c7040c838dc1c1a757d53c28866f118c99c17
@dhruv-1001
Copy link
Contributor

This issue can be closed, as it was implemented through PR #154, and released in v0.9.0
@notmandatory @thunderbiscuit

Repository owner moved this from In Progress to Done in BDK-Bindings Oct 25, 2022
@notmandatory notmandatory added this to the Release 0.9.0 milestone Oct 25, 2022
thunderbiscuit added a commit to thunderbiscuit/bdk-ffi that referenced this issue Nov 14, 2022
…ging

Publish bdk-jvm and bdk-android to Maven Central
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request summer-of-bitcoin Summer of Bitcoin Project
Projects
Archived in project
Development

No branches or pull requests

5 participants