modular_frost/curve/
kp256.rs

1use ciphersuite::{group::GroupEncoding, Ciphersuite};
2
3use crate::{curve::Curve, algorithm::Hram};
4
5macro_rules! kp_curve {
6  (
7    $feature: literal,
8
9    $Curve: ident,
10    $Hram:  ident,
11
12    $CONTEXT: literal
13  ) => {
14    pub use ciphersuite::$Curve;
15
16    impl Curve for $Curve {
17      const CONTEXT: &'static [u8] = $CONTEXT;
18    }
19
20    /// The challenge function for this ciphersuite.
21    #[derive(Clone)]
22    pub struct $Hram;
23    impl Hram<$Curve> for $Hram {
24      #[allow(non_snake_case)]
25      fn hram(
26        R: &<$Curve as Ciphersuite>::G,
27        A: &<$Curve as Ciphersuite>::G,
28        m: &[u8],
29      ) -> <$Curve as Ciphersuite>::F {
30        <$Curve as Curve>::hash_to_F(
31          b"chal",
32          &[R.to_bytes().as_ref(), A.to_bytes().as_ref(), m].concat(),
33        )
34      }
35    }
36  };
37}
38
39#[cfg(feature = "p256")]
40kp_curve!("p256", P256, IetfP256Hram, b"FROST-P256-SHA256-v1");
41
42#[cfg(feature = "secp256k1")]
43kp_curve!("secp256k1", Secp256k1, IetfSecp256k1Hram, b"FROST-secp256k1-SHA256-v1");