embassy-crypto

Crates

git

Versions

default

Flavors

Skip to main content

Ed25519

Trait Ed25519 

Source
pub trait Ed25519 {
    // Required methods
    fn public_key(k: &Ed25519SecretKey) -> Result<Ed25519PublicKey, Error>;
    fn sign(k: &Ed25519SecretKey, msg: &[u8]) -> Result<Ed25519Signature, Error>;
    fn verify(
        a: &Ed25519PublicKey,
        msg: &[u8],
        sig: &Ed25519Signature,
    ) -> Result<(), Error>;
}
Expand description

Ed25519 (EdDSA over edwards25519, RFC 8032) driver.

Pure Ed25519: the message is signed directly, not pre-hashed, and there is no context string.

§Contract

  • No secret-dependent timing with respect to the private key.
  • Implementations wipe copies of secrets they materialize in RAM.

Required Methods§

Source

fn public_key(k: &Ed25519SecretKey) -> Result<Ed25519PublicKey, Error>

The public key A = s * B of the seed k, as in RFC 8032 section 5.1.5.

Source

fn sign(k: &Ed25519SecretKey, msg: &[u8]) -> Result<Ed25519Signature, Error>

Sign msg with the seed k, as in RFC 8032 section 5.1.6.

Ed25519 signatures are deterministic: the nonce is derived from the key and the message, so no random source is used.

Source

fn verify( a: &Ed25519PublicKey, msg: &[u8], sig: &Ed25519Signature, ) -> Result<(), Error>

Verify the signature of msg with the public key a, as in RFC 8032 section 5.1.7.

a and sig are untrusted. Implementations decode a and R, rejecting encodings that are not points on the curve, and reject S outside [0, L), where L is the group order, so that signatures are not malleable (RFC 8032 section 8.4). Failure of any kind is reported as Error::InvalidSignature, except an undecodable a, which is Error::InvalidKey. Only public data is handled, so this may be variable-time.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§