pub trait TapTweak {
type TweakedAux;
type TweakedKey;
// Required methods
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§
sourcetype TweakedAux
type TweakedAux
Tweaked key type with optional auxiliary information
sourcetype TweakedKey
type TweakedKey
Tweaked key type
Required Methods§
sourcefn tap_tweak<C: Verification>(
self,
secp: &Secp256k1<C>,
merkle_root: Option<TapBranchHash>
) -> Self::TweakedAux
fn tap_tweak<C: Verification>( self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash> ) -> Self::TweakedAux
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.
sourcefn dangerous_assume_tweaked(self) -> Self::TweakedKey
fn dangerous_assume_tweaked(self) -> Self::TweakedKey
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.