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

bip32: add PrivateKey::derive_tweak() and PublicKey::derive_tweak() #1186

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

fjarri
Copy link
Contributor

@fjarri fjarri commented Jul 12, 2024

Closes #1185

Adds PublicKey::derive_tweak() and PrivateKey::derive_tweak() exposing the tweak-generation API that extended keys use. These methods have default implementations, so it's not a breaking change. This is the minimum that I need to use BIP-32 with DKG shares.

Alternatively, these can be separate functions, to illustrate that the implementation is standardized and should not be overridden.

Possible further work:

  • Add methods to generate a tweak chain for the given derivation path and apply it to a PrivateKey or PublicKey. I currently do it manually in my own code.
  • Wrap the tweak in its own ZeroizeOnDrop-able type instead of using plain PrivateKeyBytes. This will be a breaking change.
  • Implement the logic generically using ecdsa and elliptic-curve traits. This will be a major breaking change, given how many hardcoded constant-sized arrays are there now. In particular this will allow us to have tweaks of Scalar type instead of just byte arrays, which will mean more localized error checking and an ability to sum them.

@fjarri fjarri force-pushed the bip32-derive-tweak branch from 880b236 to 316a36b Compare July 12, 2024 23:03
@fjarri fjarri changed the title Add ExtendedPrivateKey::new_from_private_key() bip32: add PrivateKey::derive_tweak() and PublicKey::derive_tweak() Jul 12, 2024
@tony-iqlusion
Copy link
Member

This seems fine as a general direction. I'll try to do a more detailed review of it soon.

@tony-iqlusion tony-iqlusion merged commit c6b4711 into iqlusioninc:main Jul 17, 2024
15 checks passed
@fjarri
Copy link
Contributor Author

fjarri commented Jul 17, 2024

Thanks! Would you mind cutting a release too?

@tony-iqlusion tony-iqlusion mentioned this pull request Jul 17, 2024
@fjarri fjarri deleted the bip32-derive-tweak branch September 10, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bip32: add a method to create ExtendedPrivateKey from SigningKey
2 participants