pub struct OutputPk(/* private fields */);
Expand description
Output taproot key - an InternalPk
tweaked with merkle root of the
script tree - or its own hash. Used only inside addresses and raw taproot
descriptors.
Implementations§
Source§impl OutputPk
impl OutputPk
pub fn from_unchecked(pk: XOnlyPk) -> OutputPk
pub fn from_byte_array(data: [u8; 32]) -> Result<OutputPk, InvalidPubkey<32>>
pub fn from_bytes( bytes: impl AsRef<[u8]>, ) -> Result<OutputPk, InvalidPubkey<33>>
pub fn to_xonly_pk(&self) -> XOnlyPk
pub fn to_script_pubkey(&self) -> ScriptPubkey
pub fn to_byte_array(&self) -> [u8; 32]
Methods from Deref<Target = XOnlyPublicKey>§
Sourcepub fn cmp_fast_unstable(&self, other: &XOnlyPublicKey) -> Ordering
pub fn cmp_fast_unstable(&self, other: &XOnlyPublicKey) -> Ordering
Like cmp::Cmp
but faster and with no guarantees across library versions.
The Cmp
implementation for FFI types is stable but slow because it first
serializes self
and other
before comparing them. This function provides a faster
comparison if you know that your types come from the same library version.
Sourcepub fn eq_fast_unstable(&self, other: &XOnlyPublicKey) -> bool
pub fn eq_fast_unstable(&self, other: &XOnlyPublicKey) -> bool
Like cmp::Eq
but faster and with no guarantees across library versions.
The Eq
implementation for FFI types is stable but slow because it first serializes
self
and other
before comparing them. This function provides a faster equality
check if you know that your types come from the same library version.
Sourcepub fn as_ptr(&self) -> *const XOnlyPublicKey
👎Deprecated since 0.25.0: Use Self::as_c_ptr if you need to access the FFI layer
pub fn as_ptr(&self) -> *const XOnlyPublicKey
Obtains a raw const pointer suitable for use with FFI functions.
Sourcepub fn as_mut_ptr(&mut self) -> *mut XOnlyPublicKey
👎Deprecated since 0.25.0: Use Self::as_mut_c_ptr if you need to access the FFI layer
pub fn as_mut_ptr(&mut self) -> *mut XOnlyPublicKey
Obtains a raw mutable pointer suitable for use with FFI functions.
Sourcepub fn serialize(&self) -> [u8; 32]
pub fn serialize(&self) -> [u8; 32]
Serializes the key as a byte-encoded x coordinate value (32 bytes).
Sourcepub fn tweak_add_check<V>(
&self,
secp: &Secp256k1<V>,
tweaked_key: &XOnlyPublicKey,
tweaked_parity: Parity,
tweak: Scalar,
) -> boolwhere
V: Verification,
pub fn tweak_add_check<V>(
&self,
secp: &Secp256k1<V>,
tweaked_key: &XOnlyPublicKey,
tweaked_parity: Parity,
tweak: Scalar,
) -> boolwhere
V: Verification,
Verifies that a tweak produced by XOnlyPublicKey::add_tweak
was computed correctly.
Should be called on the original untweaked key. Takes the tweaked key and output parity from
XOnlyPublicKey::add_tweak
as input.
Currently this is not much more efficient than just recomputing the tweak and checking equality. However, in future this API will support batch verification, which is significantly faster, so it is wise to design protocols with this in mind.
§Returns
True if tweak and check is successful, false otherwise.
§Examples
use secp256k1::{Secp256k1, Keypair, Scalar};
let secp = Secp256k1::new();
let tweak = Scalar::random();
let mut keypair = Keypair::new(&secp, &mut rand::thread_rng());
let (mut public_key, _) = keypair.x_only_public_key();
let original = public_key;
let (tweaked, parity) = public_key.add_tweak(&secp, &tweak).expect("Improbable to fail with a randomly generated tweak");
assert!(original.tweak_add_check(&secp, &tweaked, parity, tweak));
Sourcepub fn public_key(&self, parity: Parity) -> PublicKey
pub fn public_key(&self, parity: Parity) -> PublicKey
Returns the PublicKey
for this XOnlyPublicKey
.
This is equivalent to using [PublicKey::from_xonly_and_parity(self, parity)
].
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OutputPk
impl<'de> Deserialize<'de> for OutputPk
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OutputPk, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OutputPk, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for OutputPk
impl Ord for OutputPk
Source§impl PartialOrd for OutputPk
impl PartialOrd for OutputPk
Source§impl Serialize for OutputPk
impl Serialize for OutputPk
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl StrictDecode for OutputPk
impl StrictDecode for OutputPk
fn strict_decode(reader: &mut impl TypedRead) -> Result<OutputPk, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDumb for OutputPk
impl StrictDumb for OutputPk
fn strict_dumb() -> OutputPk
Source§impl StrictEncode for OutputPk
impl StrictEncode for OutputPk
fn strict_encode<W>(&self, writer: W) -> Result<W, Error>where
W: TypedWrite,
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictTuple for OutputPk
impl StrictTuple for OutputPk
const FIELD_COUNT: u8 = 1u8
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for OutputPk
impl StrictType for OutputPk
const STRICT_LIB_NAME: &'static str = LIB_NAME_BITCOIN
fn strict_name() -> Option<TypeName>
Source§impl Wrapper for OutputPk
impl Wrapper for OutputPk
Source§fn from_inner(inner: <OutputPk as Wrapper>::Inner) -> OutputPk
fn from_inner(inner: <OutputPk as Wrapper>::Inner) -> OutputPk
Source§fn as_inner(&self) -> &<OutputPk as Wrapper>::Inner
fn as_inner(&self) -> &<OutputPk as Wrapper>::Inner
Source§fn into_inner(self) -> <OutputPk as Wrapper>::Inner
fn into_inner(self) -> <OutputPk as Wrapper>::Inner
Source§impl WrapperMut for OutputPk
impl WrapperMut for OutputPk
impl Copy for OutputPk
impl Eq for OutputPk
impl StrictProduct for OutputPk
impl StructuralPartialEq for OutputPk
Auto Trait Implementations§
impl Freeze for OutputPk
impl RefUnwindSafe for OutputPk
impl Send for OutputPk
impl Sync for OutputPk
impl Unpin for OutputPk
impl UnwindSafe for OutputPk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.