2022-12-13 15:41:37 -05:00
|
|
|
use rand::rngs::OsRng;
|
2022-08-29 02:32:59 -05:00
|
|
|
|
2022-10-29 03:54:42 -05:00
|
|
|
use ciphersuite::Ciphersuite;
|
|
|
|
|
|
|
|
|
|
use schnorr::SchnorrSignature;
|
|
|
|
|
|
2022-08-29 02:32:59 -05:00
|
|
|
use crate::{
|
2022-10-29 03:54:42 -05:00
|
|
|
curve::{Ed448, Ietf8032Ed448Hram, IetfEd448Hram},
|
2022-08-29 02:32:59 -05:00
|
|
|
tests::vectors::{Vectors, test_with_vectors},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn ed448_8032_vector() {
|
|
|
|
|
let context = hex::decode("666f6f").unwrap();
|
|
|
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
2022-10-25 23:17:25 -05:00
|
|
|
let A = Ed448::read_G::<&[u8]>(
|
|
|
|
|
&mut hex::decode(
|
2022-08-29 02:32:59 -05:00
|
|
|
"43ba28f430cdff456ae531545f7ecd0ac834a55d9358c0372bfa0c6c".to_owned() +
|
|
|
|
|
"6798c0866aea01eb00742802b8438ea4cb82169c235160627b4c3a94" +
|
|
|
|
|
"80",
|
|
|
|
|
)
|
2022-10-25 23:17:25 -05:00
|
|
|
.unwrap()
|
|
|
|
|
.as_ref(),
|
|
|
|
|
)
|
2022-08-29 02:32:59 -05:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
let msg = hex::decode("03").unwrap();
|
|
|
|
|
|
2022-10-25 23:17:25 -05:00
|
|
|
let sig = hex::decode(
|
|
|
|
|
"d4f8f6131770dd46f40867d6fd5d5055de43541f8c5e35abbcd001b3".to_owned() +
|
|
|
|
|
"2a89f7d2151f7647f11d8ca2ae279fb842d607217fce6e042f6815ea" +
|
|
|
|
|
"00" +
|
|
|
|
|
"0c85741de5c8da1144a6a1aba7f96de42505d7a7298524fda538fccb" +
|
|
|
|
|
"bb754f578c1cad10d54d0d5428407e85dcbc98a49155c13764e66c3c" +
|
|
|
|
|
"00",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
2022-08-29 02:32:59 -05:00
|
|
|
#[allow(non_snake_case)]
|
2022-10-25 23:17:25 -05:00
|
|
|
let R = Ed448::read_G::<&[u8]>(&mut sig.as_ref()).unwrap();
|
|
|
|
|
let s = Ed448::read_F::<&[u8]>(&mut &sig[57 ..]).unwrap();
|
2022-08-29 02:32:59 -05:00
|
|
|
|
2022-10-29 03:54:42 -05:00
|
|
|
assert!(
|
|
|
|
|
SchnorrSignature::<Ed448> { R, s }.verify(A, Ietf8032Ed448Hram::hram(&context, &R, &A, &msg))
|
|
|
|
|
);
|
2022-08-29 02:32:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
2022-10-13 00:38:36 -04:00
|
|
|
fn ed448_vectors() {
|
|
|
|
|
test_with_vectors::<_, Ed448, IetfEd448Hram>(
|
2022-08-29 02:32:59 -05:00
|
|
|
&mut OsRng,
|
2022-10-13 00:38:36 -04:00
|
|
|
Vectors::from(
|
|
|
|
|
serde_json::from_str::<serde_json::Value>(include_str!("vectors/frost-ed448-shake256.json"))
|
|
|
|
|
.unwrap(),
|
|
|
|
|
),
|
2022-08-29 02:32:59 -05:00
|
|
|
);
|
|
|
|
|
}
|