modular_frost/curve/
ed448.rs

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