pub struct PublicKey { /* private fields */ }Expand description
Ed25519 public key for signature verification (RFC 8032).
Public keys are decoded with the strict RFC 8032 rules: non-canonical encodings and small-order points (the identity and other low-order torsion points) are rejected, as the latter would otherwise permit trivial signature forgeries. Honest Ed25519 public keys are always in the prime-order subgroup and are accepted.
§Verifying a signature
ⓘ
use crypto::curve25519::ed25519::{PublicKey, SecretKey};
let priv_key = SecretKey::generate().unwrap();
let pub_key = priv_key.public_key();
let sig = priv_key.sign(b"message");
assert!(pub_key.verify(b"message", &sig).is_ok());§Deserializing from bytes
ⓘ
use crypto::curve25519::ed25519::PublicKey;
let bytes = [0u8; 32]; // replace with a real public key
let pub_key = PublicKey::from_bytes(&bytes);Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn from_bytes(key: &[u8; 32]) -> Result<PublicKey, EllipticCurveError>
pub fn from_bytes(key: &[u8; 32]) -> Result<PublicKey, EllipticCurveError>
Decodes a public key from its 32-byte encoding.
Returns EllipticCurveError::InvalidKey if the input is not a
canonically encoded curve point, or if it decodes to a small-order
point (which has a torsion component that can be used to forge
signatures).
pub fn verify( &self, message: &[u8], signature: &[u8; 64], ) -> Result<(), EllipticCurveError>
pub fn to_bytes(&self) -> [u8; 32]
pub fn to_montgomery_u(&self) -> Option<FieldElement>
Trait Implementations§
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