Returns a Result
to let the caller choose an error handling strategy.
Follows the edDSA curve25519 verification.
public_key
: [b256] - The public key that signed the message.signature
: [B512] - The signature generated by signing a message.msg
: [Bytes] - The signed data.use std::{ecr::ed_verify, b512::B512, bytes::Bytes};
fn foo() {
let pub_key = 0x314fa58689bbe1da2430517de2d772b384a1c1d2e9cb87e73c6afcf246045b10;
let msg = b256::zero();
let msg_hash = sha256(msg);
let hi = 0xf38cef9361894be6c6e0eddec28a663d099d7ddff17c8077a1447d7ecb4e6545;
let lo = 0xf5084560039486d3462dd65a40c80a74709b2f06d450ffc5dc00345c6b2cdd00;
let signature: B512 = B512::from((hi, lo));
// A verified public key with signature
let verified = ed_verify(pub_key, signature, Bytes::from(msg_hash)).unwrap();
assert(verified);
}