pub struct CompressedPk(/* private fields */);
Implementations§
Source§impl CompressedPk
impl CompressedPk
pub fn from_byte_array( data: [u8; 33], ) -> Result<CompressedPk, InvalidPubkey<33>>
pub fn to_byte_array(&self) -> [u8; 33]
pub fn from_bytes( bytes: impl AsRef<[u8]>, ) -> Result<CompressedPk, InvalidPubkey<33>>
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 AsMut<<CompressedPk as Wrapper>::Inner> for CompressedPk
impl AsMut<<CompressedPk as Wrapper>::Inner> for CompressedPk
Source§impl AsRef<PublicKey> for CompressedPk
impl AsRef<PublicKey> for CompressedPk
Source§impl Borrow<PublicKey> for CompressedPk
impl Borrow<PublicKey> for CompressedPk
Source§impl BorrowMut<<CompressedPk as Wrapper>::Inner> for CompressedPk
impl BorrowMut<<CompressedPk as Wrapper>::Inner> for CompressedPk
Source§fn borrow_mut(&mut self) -> &mut <CompressedPk as Wrapper>::Inner
fn borrow_mut(&mut self) -> &mut <CompressedPk as Wrapper>::Inner
Source§impl Clone for CompressedPk
impl Clone for CompressedPk
Source§fn clone(&self) -> CompressedPk
fn clone(&self) -> CompressedPk
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CompressedPk
impl Debug for CompressedPk
Source§impl Deref for CompressedPk
impl Deref for CompressedPk
Source§impl DerefMut for CompressedPk
impl DerefMut for CompressedPk
Source§impl Derive<CompressedPk> for XpubDerivable
impl Derive<CompressedPk> 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 = CompressedPk>
fn derive_range( &self, keychain: impl Into<Keychain>, from: impl Into<NormalIndex>, to: impl Into<NormalIndex>, ) -> impl Iterator<Item = D>
Source§impl DeriveKey<CompressedPk> for XpubDerivable
impl DeriveKey<CompressedPk> for XpubDerivable
fn xpub_spec(&self) -> &XpubAccount
Source§impl Display for CompressedPk
impl Display for CompressedPk
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<CompressedPk> for PubkeyHash
impl From<CompressedPk> for PubkeyHash
Source§fn from(pk: CompressedPk) -> PubkeyHash
fn from(pk: CompressedPk) -> PubkeyHash
Source§impl From<CompressedPk> for PublicKey
impl From<CompressedPk> for PublicKey
Source§fn from(wrapped: CompressedPk) -> PublicKey
fn from(wrapped: CompressedPk) -> PublicKey
Source§impl From<CompressedPk> for WPubkeyHash
impl From<CompressedPk> for WPubkeyHash
Source§fn from(pk: CompressedPk) -> WPubkeyHash
fn from(pk: CompressedPk) -> WPubkeyHash
Source§impl From<CompressedPk> for XOnlyPk
impl From<CompressedPk> for XOnlyPk
Source§fn from(pubkey: CompressedPk) -> XOnlyPk
fn from(pubkey: CompressedPk) -> XOnlyPk
Source§impl From<PublicKey> for CompressedPk
impl From<PublicKey> for CompressedPk
Source§fn from(v: PublicKey) -> CompressedPk
fn from(v: PublicKey) -> CompressedPk
Source§impl FromStr for CompressedPk
impl FromStr for CompressedPk
Source§type Err = PubkeyParseError<33>
type Err = PubkeyParseError<33>
Source§fn from_str(s: &str) -> Result<CompressedPk, <CompressedPk as FromStr>::Err>
fn from_str(s: &str) -> Result<CompressedPk, <CompressedPk as FromStr>::Err>
s
to return a value of this type. Read moreSource§impl Hash for CompressedPk
impl Hash for CompressedPk
Source§impl LowerHex for CompressedPk
impl LowerHex for CompressedPk
Source§impl Ord for CompressedPk
impl Ord for CompressedPk
Source§fn cmp(&self, other: &CompressedPk) -> Ordering
fn cmp(&self, other: &CompressedPk) -> 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 CompressedPk
impl PartialEq for CompressedPk
Source§impl PartialOrd for CompressedPk
impl PartialOrd for CompressedPk
Source§impl StrictDecode for CompressedPk
impl StrictDecode for CompressedPk
fn strict_decode( reader: &mut impl TypedRead, ) -> Result<CompressedPk, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDumb for CompressedPk
impl StrictDumb for CompressedPk
fn strict_dumb() -> CompressedPk
Source§impl StrictEncode for CompressedPk
impl StrictEncode for CompressedPk
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 CompressedPk
impl StrictTuple for CompressedPk
const FIELD_COUNT: u8 = 1u8
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for CompressedPk
impl StrictType for CompressedPk
const STRICT_LIB_NAME: &'static str = LIB_NAME_BITCOIN
fn strict_name() -> Option<TypeName>
Source§impl Wrapper for CompressedPk
impl Wrapper for CompressedPk
Source§fn from_inner(inner: <CompressedPk as Wrapper>::Inner) -> CompressedPk
fn from_inner(inner: <CompressedPk as Wrapper>::Inner) -> CompressedPk
Source§fn as_inner(&self) -> &<CompressedPk as Wrapper>::Inner
fn as_inner(&self) -> &<CompressedPk as Wrapper>::Inner
Source§fn into_inner(self) -> <CompressedPk as Wrapper>::Inner
fn into_inner(self) -> <CompressedPk as Wrapper>::Inner
Source§impl WrapperMut for CompressedPk
impl WrapperMut for CompressedPk
Source§fn as_inner_mut(&mut self) -> &mut <CompressedPk as Wrapper>::Inner
fn as_inner_mut(&mut self) -> &mut <CompressedPk as Wrapper>::Inner
impl Copy for CompressedPk
impl Eq for CompressedPk
impl StrictProduct for CompressedPk
impl StructuralPartialEq for CompressedPk
Auto Trait Implementations§
impl Freeze for CompressedPk
impl RefUnwindSafe for CompressedPk
impl Send for CompressedPk
impl Sync for CompressedPk
impl Unpin for CompressedPk
impl UnwindSafe for CompressedPk
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.