pub struct PublicKey(/* private fields */);Expand description
Represents a secp256k1 public key.
The key is internally represented using an AffinePoint and the compressed encoding of it.
The AsRef implementation will always return the compressed representation.
However, the TryFrom byte slice accepts any representation.
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub const SIZE_COMPRESSED: usize = 33usize
pub const SIZE_COMPRESSED: usize = 33usize
Size of the compressed public key in bytes
Sourcepub const SIZE_UNCOMPRESSED: usize = 65usize
pub const SIZE_UNCOMPRESSED: usize = 65usize
Size of the uncompressed public key in bytes
pub const SIZE_UNCOMPRESSED_PLAIN: usize = 64usize
Sourcepub fn from_privkey(private_key: &[u8]) -> Result<PublicKey>
pub fn from_privkey(private_key: &[u8]) -> Result<PublicKey>
Computes the public key from the given private_key.
The private key must be a big-endian encoding of a non-zero scalar in the field
of the secp256k1 curve.
Sourcepub fn to_address(&self) -> Address
pub fn to_address(&self) -> Address
Converts the public key to an Ethereum address
Sourcepub fn to_uncompressed_bytes(&self) -> Box<[u8]>
pub fn to_uncompressed_bytes(&self) -> Box<[u8]>
Serializes the public key to a binary uncompressed form.
Sourcepub fn to_uncompressed_hex(&self) -> String
pub fn to_uncompressed_hex(&self) -> String
Serializes the public key to a binary uncompressed form and converts it to hexadecimal string representation.
Trait Implementations§
Source§impl Randomizable for PublicKey
impl Randomizable for PublicKey
impl Copy for PublicKey
impl Eq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> ToHex for Twhere
T: BytesRepresentable,
impl<T> ToHex for Twhere
T: BytesRepresentable,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)