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

crypto, refactor: add new KeyPair class #30051

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on May 10, 2024

  1. crypto: Add a KeyPair wrapper class

    The wallet returns an untweaked internal key for taproot outputs. If the
    output commits to a tree of scripts, this key needs to be tweaked with
    the merkle root. Even if the output does not commit to a tree of
    scripts, BIP341/342 recommend commiting to a hash of the public key.
    
    Previously, this logic for applying the taptweak was implemented in the
    ::SignSchnorr method.
    
    Move this tweaking and signing logic to a new class, KeyPair, and add
    a method to CKey for computing a KeyPair, CKey::ComputeKeyPair. This
    class is a wrapper for the `secp256k1_keypair` type.
    
    The motivation is to be able to use the the tweaked internal key outside
    of signing, e.g. in silent payments when retreiving the private key before
    ECDH. Having the KeyPair class is also a general improvement in that we
    almost always convert to `secp256k1_keypair` objects when using taproot
    private keys with libsecp256k1.
    
    Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
    josibake and theuni committed May 10, 2024
    Configuration menu
    Copy the full SHA
    54b3c73 View commit details
    Browse the repository at this point in the history
  2. tests: add test for KeyPair

    Reuse existing bip340 test vectors.
    josibake committed May 10, 2024
    Configuration menu
    Copy the full SHA
    bdc2a65 View commit details
    Browse the repository at this point in the history