pub struct PublicKey(/* private fields */);Expand description
Uncompressed secp256k1 public key (X || Y, 64 bytes).
Constructors accept the 33-byte SEC1-compressed encoding too.
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn new(b: &[u8]) -> Result<Self, Error>
pub fn new(b: &[u8]) -> Result<Self, Error>
Construct from bytes. Accepts 64-byte uncompressed (X || Y)
or 33-byte compressed (SEC1).
Sourcepub fn from_hex(s: &str) -> Result<Self, Error>
pub fn from_hex(s: &str) -> Result<Self, Error>
Parse from hex (with or without 0x prefix). Length must be 33
(compressed) or 64 (uncompressed).
Sourcepub fn address(&self) -> EthAddress
pub fn address(&self) -> EthAddress
Ethereum address: last 20 bytes of keccak256(X || Y).
Sourcepub fn compressed_hex(&self) -> Result<String, Error>
pub fn compressed_hex(&self) -> Result<String, Error>
Lowercase hex of the compressed encoding, no 0x prefix.
Trait Implementations§
impl Copy for PublicKey
impl Eq for PublicKey
impl StructuralPartialEq 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 UnsafeUnpin 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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.