Add Display and LowerHex to TweakedPublicKey

This commit is contained in:
Dr. Maxim Orlovsky 2021-12-12 16:23:57 +02:00
parent ed40f3d3a6
commit 37352d1df5
1 changed files with 13 additions and 0 deletions

View File

@ -21,6 +21,7 @@ pub use secp256k1::schnorrsig::{PublicKey, KeyPair};
use secp256k1::{Secp256k1, Verification};
use hashes::Hash;
use util::taproot::{TapBranchHash, TapTweakHash};
use core::fmt;
/// Untweaked Schnorr public key
pub type UntweakedPublicKey = PublicKey;
@ -29,6 +30,18 @@ pub type UntweakedPublicKey = PublicKey;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TweakedPublicKey(PublicKey);
impl fmt::LowerHex for TweakedPublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::LowerHex::fmt(&self.0, f)
}
}
impl fmt::Display for TweakedPublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
/// A trait for tweaking Schnorr public keys
pub trait TapTweak {
/// Tweaks an untweaked public key given an untweaked key and optional script tree merkle root.