Skip to content

Commit d0a87be

Browse files
committed
Add slice 'serialize' method for TweakedPublicKey
1 parent 37352d1 commit d0a87be

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/util/schnorr.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//!
1919
2020
pub use secp256k1::schnorrsig::{PublicKey, KeyPair};
21-
use secp256k1::{Secp256k1, Verification};
21+
use secp256k1::{Secp256k1, Verification, constants};
2222
use hashes::Hash;
2323
use util::taproot::{TapBranchHash, TapTweakHash};
2424
use core::fmt;
@@ -79,7 +79,6 @@ impl TapTweak for UntweakedPublicKey {
7979
}
8080
}
8181

82-
8382
impl TweakedPublicKey {
8483
/// Creates a new [`TweakedPublicKey`] from a [`PublicKey`]. No tweak is applied, consider
8584
/// calling `tap_tweak` on an [`UntweakedPublicKey`] instead of using this constructor.
@@ -97,4 +96,11 @@ impl TweakedPublicKey {
9796
&self.0
9897
}
9998

99+
/// Serialize the key as a byte-encoded pair of values. In compressed form
100+
/// the y-coordinate is represented by only a single bit, as x determines
101+
/// it up to one bit.
102+
#[inline]
103+
pub fn serialize(&self) -> [u8; constants::SCHNORRSIG_PUBLIC_KEY_SIZE] {
104+
self.0.serialize()
105+
}
100106
}

0 commit comments

Comments
 (0)