pub struct InternalPk(/* private fields */);
Expand description
Internal taproot public key, which can be present only in key fragment inside taproot descriptors.
Implementations§
Source§impl InternalPk
impl InternalPk
pub fn from_unchecked(pk: XOnlyPk) -> InternalPk
pub fn from_byte_array(data: [u8; 32]) -> Result<InternalPk, InvalidPubkey<32>>
pub fn from_bytes( bytes: impl AsRef<[u8]>, ) -> Result<InternalPk, InvalidPubkey<33>>
pub fn to_byte_array(&self) -> [u8; 32]
pub fn to_xonly_pk(&self) -> XOnlyPk
pub fn to_output_pk( &self, merkle_root: Option<TapNodeHash>, ) -> (OutputPk, Parity)
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 AsMut<<InternalPk as Wrapper>::Inner> for InternalPk
impl AsMut<<InternalPk as Wrapper>::Inner> for InternalPk
Source§impl AsRef<XOnlyPk> for InternalPk
impl AsRef<XOnlyPk> for InternalPk
Source§impl Borrow<XOnlyPk> for InternalPk
impl Borrow<XOnlyPk> for InternalPk
Source§impl BorrowMut<<InternalPk as Wrapper>::Inner> for InternalPk
impl BorrowMut<<InternalPk as Wrapper>::Inner> for InternalPk
Source§fn borrow_mut(&mut self) -> &mut <InternalPk as Wrapper>::Inner
fn borrow_mut(&mut self) -> &mut <InternalPk as Wrapper>::Inner
Source§impl Clone for InternalPk
impl Clone for InternalPk
Source§fn clone(&self) -> InternalPk
fn clone(&self) -> InternalPk
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ConsensusDecode for InternalPk
impl ConsensusDecode for InternalPk
fn consensus_decode( reader: &mut impl Read, ) -> Result<InternalPk, ConsensusDecodeError>
fn consensus_deserialize( bytes: impl AsRef<[u8]>, ) -> Result<Self, ConsensusDecodeError>
Source§impl ConsensusEncode for InternalPk
impl ConsensusEncode for InternalPk
Source§impl Debug for InternalPk
impl Debug for InternalPk
Source§impl Decode for InternalPk
impl Decode for InternalPk
fn decode(reader: &mut impl Read) -> Result<InternalPk, DecodeError>
fn deserialize(bytes: impl AsRef<[u8]>) -> Result<Self, PsbtError>
Source§impl Deref for InternalPk
impl Deref for InternalPk
Source§impl DerefMut for InternalPk
impl DerefMut for InternalPk
Source§impl Display for InternalPk
impl Display for InternalPk
Source§impl Encode for InternalPk
impl Encode for InternalPk
Source§impl From<InternalPk> for XOnlyPk
impl From<InternalPk> for XOnlyPk
Source§fn from(wrapped: InternalPk) -> XOnlyPk
fn from(wrapped: InternalPk) -> XOnlyPk
Source§impl From<XOnlyPk> for InternalPk
impl From<XOnlyPk> for InternalPk
Source§fn from(v: XOnlyPk) -> InternalPk
fn from(v: XOnlyPk) -> InternalPk
Source§impl From<XOnlyPublicKey> for InternalPk
impl From<XOnlyPublicKey> for InternalPk
Source§fn from(v: XOnlyPublicKey) -> InternalPk
fn from(v: XOnlyPublicKey) -> InternalPk
Source§impl FromStr for InternalPk
impl FromStr for InternalPk
Source§impl Hash for InternalPk
impl Hash for InternalPk
Source§impl LowerHex for InternalPk
impl LowerHex for InternalPk
Source§impl Ord for InternalPk
impl Ord for InternalPk
Source§fn cmp(&self, other: &InternalPk) -> Ordering
fn cmp(&self, other: &InternalPk) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for InternalPk
impl PartialEq for InternalPk
Source§impl PartialOrd for InternalPk
impl PartialOrd for InternalPk
Source§impl StrictDecode for InternalPk
impl StrictDecode for InternalPk
fn strict_decode(reader: &mut impl TypedRead) -> Result<InternalPk, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDumb for InternalPk
impl StrictDumb for InternalPk
fn strict_dumb() -> InternalPk
Source§impl StrictEncode for InternalPk
impl StrictEncode for InternalPk
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 InternalPk
impl StrictTuple for InternalPk
const FIELD_COUNT: u8 = 1u8
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for InternalPk
impl StrictType for InternalPk
const STRICT_LIB_NAME: &'static str = LIB_NAME_BITCOIN
fn strict_name() -> Option<TypeName>
Source§impl Wrapper for InternalPk
impl Wrapper for InternalPk
Source§fn from_inner(inner: <InternalPk as Wrapper>::Inner) -> InternalPk
fn from_inner(inner: <InternalPk as Wrapper>::Inner) -> InternalPk
Source§fn as_inner(&self) -> &<InternalPk as Wrapper>::Inner
fn as_inner(&self) -> &<InternalPk as Wrapper>::Inner
Source§fn into_inner(self) -> <InternalPk as Wrapper>::Inner
fn into_inner(self) -> <InternalPk as Wrapper>::Inner
Source§impl WrapperMut for InternalPk
impl WrapperMut for InternalPk
Source§fn as_inner_mut(&mut self) -> &mut <InternalPk as Wrapper>::Inner
fn as_inner_mut(&mut self) -> &mut <InternalPk as Wrapper>::Inner
impl Copy for InternalPk
impl Eq for InternalPk
impl StrictProduct for InternalPk
impl StructuralPartialEq for InternalPk
Auto Trait Implementations§
impl Freeze for InternalPk
impl RefUnwindSafe for InternalPk
impl Send for InternalPk
impl Sync for InternalPk
impl Unpin for InternalPk
impl UnwindSafe for InternalPk
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.