Files
serai/crypto/schnorrkel/src/tests.rs
Luke Parker 19305aebc9 Finally make modular-frost work with alloc alone
Carries the update to `frost-schnorrkel` and `bitcoin-serai`.
2025-09-18 17:06:57 -04:00

27 lines
764 B
Rust

use rand_core::OsRng;
use ciphersuite::group::GroupEncoding;
use frost::{
Participant,
tests::{key_gen, algorithm_machines, sign},
};
use schnorrkel::{keys::PublicKey, context::SigningContext};
use crate::Schnorrkel;
#[test]
fn test() {
const CONTEXT: &[u8] = b"FROST Schnorrkel Test";
const MSG: &[u8] = b"Hello, World!";
let keys = key_gen(&mut OsRng);
let key = keys[&Participant::new(1).unwrap()].group_key();
let algorithm = Schnorrkel::new(CONTEXT);
let machines = algorithm_machines(&mut OsRng, &algorithm, &keys);
let signature = sign(&mut OsRng, &algorithm, keys, machines, MSG);
let key = PublicKey::from_bytes(key.to_bytes().as_ref()).unwrap();
key.verify(&mut SigningContext::new(CONTEXT).bytes(MSG), &signature).unwrap()
}