Ed448-Rust
This is an implementation of Edwards-Curve Digital Signature Algorithm (EdDSA)
from the RFC8032 in pure Rust,
but only the ed448 support is implemented.
It's a EdDSA for ed448 signing/verifying.
This is direct port of the Python code in the RFC, so it's the same warning
as it:
Note: This code is not intended for production. Although it should
produce correct results for every input, it is slow and makes no
attempt to avoid side-channel attacks.
Usage
use core::convert::TryFrom;
use rand_core::OsRng;
use ed448_rust::{PrivateKey, PublicKey};
fn main () {
let private_key = PrivateKey::new(&mut OsRng);
let pkey_stored = private_key.as_bytes();
let private_key = PrivateKey::try_from(pkey_stored).unwrap();
let public_key = PublicKey::from(&private_key);
let pubkey_stored = public_key.as_byte();
let signature = private_key.sign(b"Message to sign", None).unwrap();
let signature_ctx = private_key.sign(b"Message to sign", Some(&[0x01, 0xA6])).unwrap();
let signature_ph = private_key.sign_ph(b"Message to sign", None).unwrap();
assert!(public_key.verify(b"Message to sign", &signature, None).is_ok());
assert!(public_key.verify(b"Message to sign", &signature_ctx, Some(&[0x01, 0xA6])).is_ok());
assert!(public_key.verify_ph(b"Message to sign", &signature_ph, None).is_ok());
}
License
This code is licensed under MIT / Apache2.0