Skip to main content

Module sign

Module sign 

Source
Expand description

Ed448 digital signatures implementation

§Example

Creating an ed448 signature.

Generate a SigningKey, which includes both the public and secret halves, using a cryptographically secure pseudorandom number generator (CSPRNG). Next sign a message to produce a Signature. Then verify the signature using the corresponding VerifyingKey.

use ed448_goldilocks::{SigningKey, elliptic_curve::Generate};

let signing_key = SigningKey::generate();
let signature = signing_key.sign_raw(b"Hello, world!");
let verifying_key = signing_key.verifying_key();

assert!(verifying_key.verify_raw(&signature, b"Hello, world!").is_ok());

This crate also supports using context specific strings when creating and verifying signatures. In addition, it supports the PKCS#8 standard for encoding and decoding keys, or raw byte forms using to_bytes and from_bytes methods. These store the SecretKey which is the prehash seed of the SigningKey.

§PKCS#8 Key Encoding

PKCS#8 is a private key format with support for multiple algorithms. It can be encoded as binary (DER) or text (PEM). Use the pkcs8 feature to enable this option.

§Using Serde

This crate supports serialization and deserialization using the serde if the preference is to encode the keys as other formats. Use the serde feature to enable this option.

§Using Signature

This crate supports signing using the traits defined in the signature crate like

  • [Signer]
  • [DigestSigner]
  • [PrehashSigner]
  • [Verifier]
  • [DigestVerifier]

The crate is re-exported as crypto-signature for use in other crates.

§Other Features

Signing and verifying also supports custom digest and prehash algorithms. Any algorithm that implements PreHash and [Digest] can be used. However, there are two implementations provided in this crate:

  • PreHasherXmd which supports any implementation of a fixed length digest like SHA3-512.
  • PreHasherXof which supports any implementation of expandable output functions like SHAKE-256.

§Example

This is an example of using the SHAKE-256 algorithm to sign and verify a message which is the normal default anyway but performed explicitly.

use ed448_goldilocks::{SigningKey, PreHasherXof, elliptic_curve::Generate};
use shake::{Shake256, digest::Update};

let msg = b"Hello World";

let signing_key = SigningKey::generate();
let signature = signing_key.sign_prehashed::<PreHasherXof<Shake256>>(
    None,
    Shake256::default().chain(msg).into(),
).unwrap();

let verifying_key = signing_key.verifying_key();
assert!(verifying_key.verify_prehashed::<PreHasherXof<Shake256>>(
   &signature,
   None,
   Shake256::default().chain(msg).into()
).is_ok());

Re-exports§

pub use elliptic_curve::pkcs8;
pub use signature;
pub use context::*;
pub use error::*;
pub use signing_key::*;
pub use verifying_key::*;

Modules§

context 🔒
error 🔒
expanded 🔒
signing_key 🔒
Much of this code is borrowed from Thomas Pornin’s CRRL Project and adapted to mirror ed25519-dalek’s API.
verifying_key 🔒
Much of this code is borrowed from Thomas Pornin’s CRRL Project and adapted to mirror ed25519-dalek’s API.

Structs§

InnerSignature 🔒
Signature
Ed448 signature.

Constants§

ALGORITHM_ID
The AlgorithmIdentifier for Ed448 as defined in [RFC8410 §2]
ALGORITHM_OID
The OID for Ed448 as defined in [RFC8410 §2]
HASH_HEAD 🔒
Constant string “SigEd448”.
PUBLIC_KEY_LENGTH
Length of a public key in bytes
SECRET_KEY_LENGTH
Length of a secret key in bytes
SIGNATURE_LENGTH
Length of a signature in bytes