pub struct PublicKey(/* private fields */);Expand description
An Ed25519 public key used to verify a signature + message.
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> Self
pub fn from_bytes(bytes: &[u8; 32]) -> Self
Builds the public key from an array of bytes.
Sourcepub fn from_der_subject_public_key_info(spki: &[u8]) -> Option<Self>
pub fn from_der_subject_public_key_info(spki: &[u8]) -> Option<Self>
Parse a public key in SubjectPublicKeyInfo format.
Sourcepub fn to_der_subject_public_key_info(&self) -> Buffer
pub fn to_der_subject_public_key_info(&self) -> Buffer
Serialize this key in SubjectPublicKeyInfo format.
Sourcepub fn verify(
&self,
msg: &[u8],
signature: &Signature,
) -> Result<(), InvalidSignatureError>
pub fn verify( &self, msg: &[u8], signature: &Signature, ) -> Result<(), InvalidSignatureError>
Verifies that signature is a valid signature, by this key, of msg.
Sourcepub fn verify_prehashed(
&self,
context: &[u8],
sha512_digest: &[u8; 64],
signature: &Signature,
) -> Result<(), InvalidSignatureError>
pub fn verify_prehashed( &self, context: &[u8], sha512_digest: &[u8; 64], signature: &Signature, ) -> Result<(), InvalidSignatureError>
Verifies that signature is a valid signature under the given context
of sha512_digest using Ed25519ph.
Note that Ed25519ph (pre-hashed) and “pure” Ed25519 are different algorithms
defined in RFC 8032. Calling verify with the digest of a message will not
return the same output as verify_prehashed.
A context longer than 255 bytes, the maximum permitted by RFC 8032, is
reported as an invalid signature.
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