PublicKey

Trait PublicKey 

Source
pub trait PublicKey<C: AsymmetricCrypto + ?Sized>: Clone {
    // Required methods
    fn key_id(&self) -> C::KeyId;
    fn validate_id(&self, id: &C::KeyId) -> bool;
    fn verify<D: AsRef<[u8]>>(&self, data: D, sig: &C::Signature) -> bool;
}
Expand description

A public key (also called shared key or pk in some literature) is that part of an asymmetric keypair which can be used to verify the authenticity of the sender of a message or to encrypt a message that can only be decrypted by a single recipient. In both cases this other party owns the PrivateKey part of the keypair and never shares it with anyone else.

Required Methods§

Source

fn key_id(&self) -> C::KeyId

Calculates the ID (also called fingerprint or address in some literature) of the public key. In some algorithms the public key is only revealed in point-to-point communications and a keypair is identified only by the digest of the public key in all other channels.

Source

fn validate_id(&self, id: &C::KeyId) -> bool

We do not have multiple versions of KeyIds for the same multicipher public key, so for now this comparison is trivial. But when we introduce newer versions, we need to take the version of the key_id argument into account and calculate that possibly older version from self.

Source

fn verify<D: AsRef<[u8]>>(&self, data: D, sig: &C::Signature) -> bool

This method can be used to verify if a given signature for a message was made using the private key that belongs to this public key. See also PrivateKey::sign

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§