Expand description
A Bitcoin ECDSA public key
Fields
compressed: bool
Whether this public key should be serialized as compressed
inner: PublicKey
The actual ECDSA key
Implementations
sourceimpl PublicKey
impl PublicKey
sourcepub fn new(key: PublicKey) -> PublicKey
pub fn new(key: PublicKey) -> PublicKey
Constructs compressed ECDSA public key from the provided generic Secp256k1 public key
sourcepub fn new_uncompressed(key: PublicKey) -> PublicKey
pub fn new_uncompressed(key: PublicKey) -> PublicKey
Constructs uncompressed (legacy) ECDSA public key from the provided generic Secp256k1 public key
sourcepub fn pubkey_hash(&self) -> PubkeyHash
pub fn pubkey_hash(&self) -> PubkeyHash
Returns bitcoin 160-bit hash of the public key
sourcepub fn wpubkey_hash(&self) -> Option<WPubkeyHash>
pub fn wpubkey_hash(&self) -> Option<WPubkeyHash>
Returns bitcoin 160-bit hash of the public key for witness program
sourcepub fn write_into<W: Write>(&self, writer: W) -> Result<(), Error>
pub fn write_into<W: Write>(&self, writer: W) -> Result<(), Error>
Write the public key into a writer
sourcepub fn read_from<R: Read>(reader: R) -> Result<Self, Error>
pub fn read_from<R: Read>(reader: R) -> Result<Self, Error>
Read the public key from a reader
This internally reads the first byte before reading the rest, so
use of a BufReader
is recommended.
sourcepub fn to_bytes(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_bytes(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Serialize the public key to bytes
sourcepub fn from_slice(data: &[u8]) -> Result<PublicKey, Error>
pub fn from_slice(data: &[u8]) -> Result<PublicKey, Error>
Deserialize a public key from a slice
sourcepub fn from_private_key<C: Signing>(
secp: &Secp256k1<C>,
sk: &PrivateKey
) -> PublicKey
pub fn from_private_key<C: Signing>(
secp: &Secp256k1<C>,
sk: &PrivateKey
) -> PublicKey
Computes the public key as supposed to be used with this secret
Trait Implementations
sourceimpl Deserialize for PublicKey
impl Deserialize for PublicKey
sourceimpl<'de> Deserialize<'de> for PublicKey
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for PublicKey
serde
only.sourcefn deserialize<D: Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for PublicKey
impl Ord for PublicKey
sourceimpl PartialOrd<PublicKey> for PublicKey
impl PartialOrd<PublicKey> for PublicKey
sourcefn partial_cmp(&self, other: &PublicKey) -> Option<Ordering>
fn partial_cmp(&self, other: &PublicKey) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for PublicKey
impl Eq for PublicKey
impl StructuralEq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more