modular_frost/curve/
ed448.rs1use digest::Digest;
2
3use minimal_ed448::{Scalar, Point};
4pub use minimal_ed448::Ed448;
5pub use ciphersuite::{group::GroupEncoding, Ciphersuite};
6
7use crate::{curve::Curve, algorithm::Hram};
8
9const CONTEXT: &[u8] = b"FROST-ED448-SHAKE256-v1";
10
11impl Curve for Ed448 {
12 const CONTEXT: &'static [u8] = CONTEXT;
13}
14
15#[derive(Copy, Clone)]
17pub(crate) struct Ietf8032Ed448Hram;
18impl Ietf8032Ed448Hram {
19 #[allow(non_snake_case)]
20 pub(crate) fn hram(context: &[u8], R: &Point, A: &Point, m: &[u8]) -> Scalar {
21 Scalar::wide_reduce(
22 <Ed448 as Ciphersuite>::H::digest(
23 [
24 &[b"SigEd448".as_ref(), &[0, u8::try_from(context.len()).unwrap()]].concat(),
25 context,
26 &[R.to_bytes().as_ref(), A.to_bytes().as_ref(), m].concat(),
27 ]
28 .concat(),
29 )
30 .as_ref()
31 .try_into()
32 .unwrap(),
33 )
34 }
35}
36
37#[derive(Copy, Clone)]
39pub struct IetfEd448Hram;
40impl Hram<Ed448> for IetfEd448Hram {
41 #[allow(non_snake_case)]
42 fn hram(R: &Point, A: &Point, m: &[u8]) -> Scalar {
43 Ietf8032Ed448Hram::hram(&[], R, A, m)
44 }
45}