pub struct PublicKey(/* private fields */);Expand description
A public key (safe to share, serialize, etc.).
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub const fn from_bytes(bytes: [u8; 32]) -> Self
pub const fn from_bytes(bytes: [u8; 32]) -> Self
Create from raw bytes.
Sourcepub fn try_from_slice(slice: &[u8]) -> CryptoResult<Self>
pub fn try_from_slice(slice: &[u8]) -> CryptoResult<Self>
Try to create from a slice.
§Errors
Returns CryptoError::InvalidKeyLength if the slice is not exactly 32 bytes.
Sourcepub fn key_id_hex(&self) -> String
pub fn key_id_hex(&self) -> String
Get the key ID as a hex string.
Sourcepub fn from_hex(s: &str) -> CryptoResult<Self>
pub fn from_hex(s: &str) -> CryptoResult<Self>
Sourcepub fn from_base64(s: &str) -> CryptoResult<Self>
pub fn from_base64(s: &str) -> CryptoResult<Self>
Decode from base64 string.
§Errors
Returns an error if the string is not valid base64 or not 32 bytes.
Sourcepub fn verify(&self, message: &[u8], signature: &Signature) -> CryptoResult<()>
pub fn verify(&self, message: &[u8], signature: &Signature) -> CryptoResult<()>
Verify a signature against this public key.
§Errors
Returns CryptoError::SignatureVerificationFailed if verification fails.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PublicKey
impl<'de> Deserialize<'de> for PublicKey
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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> 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)