pub trait TapTweak {
    type TweakedAux;
    type TweakedKey;

    fn tap_tweak<C: Verification>(
        self,
        secp: &Secp256k1<C>,
        merkle_root: Option<TapBranchHash>
    ) -> Self::TweakedAux; fn dangerous_assume_tweaked(self) -> Self::TweakedKey; }
Expand description

A trait for tweaking BIP340 key types (x-only public keys and key pairs).

Required Associated Types

Tweaked key type with optional auxiliary information

Tweaked key type

Required Methods

Tweaks an untweaked key with corresponding public key value and optional script tree merkle root. For the KeyPair type this also tweaks the private key in the pair.

This is done by using the equation Q = P + H(P|c)G, where

  • Q is the tweaked public key
  • P is the internal public key
  • H is the hash function
  • c is the commitment data
  • G is the generator point
Returns

The tweaked key and its parity.

Directly converts an UntweakedPublicKey to a TweakedPublicKey

This method is dangerous and can lead to loss of funds if used incorrectly. Specifically, in multi-party protocols a peer can provide a value that allows them to steal.

Implementors