pub struct PublicKey(/* private fields */);
Expand description
A Secp256k1 public key, used for verification of signatures
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn as_ptr(&self) -> *const PublicKey
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
pub fn as_mut_ptr(&mut self) -> *mut PublicKey
Obtains a raw mutable pointer suitable for use with FFI functions
Sourcepub fn from_secret_key<C>(secp: &Secp256k1<C>, sk: &SecretKey) -> PublicKeywhere
C: Signing,
pub fn from_secret_key<C>(secp: &Secp256k1<C>, sk: &SecretKey) -> PublicKeywhere
C: Signing,
Creates a new public key from a secret key.
Sourcepub fn from_slice(data: &[u8]) -> Result<PublicKey, Error>
pub fn from_slice(data: &[u8]) -> Result<PublicKey, Error>
Creates a public key directly from a slice
Sourcepub fn serialize(&self) -> [u8; 33]
pub fn serialize(&self) -> [u8; 33]
Serialize 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]
Serialize the key as a byte-encoded pair of values, in uncompressed form
Sourcepub fn negate_assign<C>(&mut self, secp: &Secp256k1<C>)where
C: Verification,
pub fn negate_assign<C>(&mut self, secp: &Secp256k1<C>)where
C: Verification,
Negates the pk to the pk self
in place
Will return an error if the pk would be invalid.
Sourcepub fn add_exp_assign<C>(
&mut self,
secp: &Secp256k1<C>,
other: &[u8],
) -> Result<(), Error>where
C: Verification,
pub fn add_exp_assign<C>(
&mut self,
secp: &Secp256k1<C>,
other: &[u8],
) -> Result<(), Error>where
C: Verification,
Adds the pk corresponding to other
to the pk self
in place
Will return an error if the resulting key would be invalid or
if the tweak was not a 32-byte length slice.
Sourcepub fn mul_assign<C>(
&mut self,
secp: &Secp256k1<C>,
other: &[u8],
) -> Result<(), Error>where
C: Verification,
pub fn mul_assign<C>(
&mut self,
secp: &Secp256k1<C>,
other: &[u8],
) -> Result<(), Error>where
C: Verification,
Muliplies the pk self
in place by the scalar other
Will return an error if the resulting key would be invalid or
if the tweak was not a 32-byte length slice.