Struct sapio_bitcoin::util::key::PublicKey
source · pub struct PublicKey {
pub compressed: bool,
pub inner: PublicKey,
}
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§
source§impl 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 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§
source§impl<'de> Deserialize<'de> for PublicKey
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for PublicKey
Available on crate feature
serde
only.source§fn 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
source§impl Deserialize for PublicKey
impl Deserialize for PublicKey
source§impl Ord for PublicKey
impl Ord for PublicKey
source§impl PartialEq for PublicKey
impl PartialEq for PublicKey
source§impl PartialOrd for PublicKey
impl PartialOrd for PublicKey
1.0.0 · source§fn 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 moreimpl 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§
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
Mutably borrows from an owned value. Read more