pub struct LegacyPk {
pub compressed: bool,
pub pubkey: PublicKey,
}
Fields§
§compressed: bool
§pubkey: PublicKey
Implementations§
Methods from Deref<Target = PublicKey>§
Sourcepub fn cmp_fast_unstable(&self, other: &PublicKey) -> Ordering
pub fn cmp_fast_unstable(&self, other: &PublicKey) -> 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: &PublicKey) -> bool
pub fn eq_fast_unstable(&self, other: &PublicKey) -> 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 PublicKey
👎Deprecated since 0.25.0: Use Self::as_c_ptr if you need to access the FFI layer
pub fn as_ptr(&self) -> *const PublicKey
Obtains a raw const pointer suitable for use with FFI functions.
Sourcepub fn as_mut_ptr(&mut self) -> *mut PublicKey
👎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 PublicKey
Obtains a raw mutable pointer suitable for use with FFI functions.
Sourcepub fn serialize(&self) -> [u8; 33]
pub fn serialize(&self) -> [u8; 33]
Serializes the key as a byte-encoded pair of values. In compressed form the y-coordinate is represented by only a single bit, as x determines it up to one bit.
Sourcepub fn serialize_uncompressed(&self) -> [u8; 65]
pub fn serialize_uncompressed(&self) -> [u8; 65]
Serializes the key as a byte-encoded pair of values, in uncompressed form.
Sourcepub fn combine(&self, other: &PublicKey) -> Result<PublicKey, Error>
pub fn combine(&self, other: &PublicKey) -> Result<PublicKey, Error>
Adds a second key to this one, returning the sum.
§Errors
If the result would be the point at infinity, i.e. adding this point to its own negation.
§Examples
use secp256k1::{rand, Secp256k1};
let secp = Secp256k1::new();
let mut rng = rand::thread_rng();
let (_, pk1) = secp.generate_keypair(&mut rng);
let (_, pk2) = secp.generate_keypair(&mut rng);
let sum = pk1.combine(&pk2).expect("It's improbable to fail for 2 random public keys");
Sourcepub fn x_only_public_key(&self) -> (XOnlyPublicKey, Parity)
pub fn x_only_public_key(&self) -> (XOnlyPublicKey, Parity)
Returns the XOnlyPublicKey
(and it’s Parity
) for this PublicKey
.
Trait Implementations§
Source§impl Derive<LegacyPk> for XpubDerivable
impl Derive<LegacyPk> for XpubDerivable
fn default_keychain(&self) -> Keychain
fn keychains(&self) -> BTreeSet<Keychain>
fn derive( &self, keychain: impl Into<Keychain>, index: impl Into<NormalIndex>, ) -> impl Iterator<Item = LegacyPk>
fn derive_range( &self, keychain: impl Into<Keychain>, from: impl Into<NormalIndex>, to: impl Into<NormalIndex>, ) -> impl Iterator<Item = D>
Source§impl DeriveKey<LegacyPk> for XpubDerivable
impl DeriveKey<LegacyPk> for XpubDerivable
fn xpub_spec(&self) -> &XpubAccount
Source§impl From<CompressedPk> for LegacyPk
impl From<CompressedPk> for LegacyPk
Source§fn from(pk: CompressedPk) -> LegacyPk
fn from(pk: CompressedPk) -> LegacyPk
Source§impl From<LegacyPk> for PubkeyHash
impl From<LegacyPk> for PubkeyHash
Source§fn from(pk: LegacyPk) -> PubkeyHash
fn from(pk: LegacyPk) -> PubkeyHash
Source§impl From<UncompressedPk> for LegacyPk
impl From<UncompressedPk> for LegacyPk
Source§fn from(pk: UncompressedPk) -> LegacyPk
fn from(pk: UncompressedPk) -> LegacyPk
Source§impl Ord for LegacyPk
impl Ord for LegacyPk
Source§impl PartialOrd for LegacyPk
impl PartialOrd for LegacyPk
Source§impl StrictDecode for LegacyPk
impl StrictDecode for LegacyPk
fn strict_decode(reader: &mut impl TypedRead) -> Result<LegacyPk, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDumb for LegacyPk
impl StrictDumb for LegacyPk
fn strict_dumb() -> LegacyPk
Source§impl StrictEncode for LegacyPk
impl StrictEncode for LegacyPk
fn strict_encode<W>(&self, writer: W) -> Result<W, Error>where
W: TypedWrite,
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictStruct for LegacyPk
impl StrictStruct for LegacyPk
const ALL_FIELDS: &'static [&'static str]
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for LegacyPk
impl StrictType for LegacyPk
const STRICT_LIB_NAME: &'static str = LIB_NAME_BITCOIN
fn strict_name() -> Option<TypeName>
Source§impl Wrapper for LegacyPk
impl Wrapper for LegacyPk
Source§fn from_inner(inner: <LegacyPk as Wrapper>::Inner) -> LegacyPk
fn from_inner(inner: <LegacyPk as Wrapper>::Inner) -> LegacyPk
Source§fn as_inner(&self) -> &<LegacyPk as Wrapper>::Inner
fn as_inner(&self) -> &<LegacyPk as Wrapper>::Inner
Source§fn into_inner(self) -> <LegacyPk as Wrapper>::Inner
fn into_inner(self) -> <LegacyPk as Wrapper>::Inner
Source§impl WrapperMut for LegacyPk
impl WrapperMut for LegacyPk
impl Copy for LegacyPk
impl Eq for LegacyPk
impl StrictProduct for LegacyPk
impl StructuralPartialEq for LegacyPk
Auto Trait Implementations§
impl Freeze for LegacyPk
impl RefUnwindSafe for LegacyPk
impl Send for LegacyPk
impl Sync for LegacyPk
impl Unpin for LegacyPk
impl UnwindSafe for LegacyPk
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.