2022-10-29 08:54:42 +00:00
|
|
|
use digest::Digest;
|
2022-08-29 07:32:59 +00:00
|
|
|
|
2022-10-29 08:54:42 +00:00
|
|
|
use minimal_ed448::{Scalar, Point};
|
2023-03-07 08:46:16 +00:00
|
|
|
pub use ciphersuite::{group::GroupEncoding, Shake256_114, Ed448};
|
2022-08-29 07:32:59 +00:00
|
|
|
|
|
|
|
use crate::{curve::Curve, algorithm::Hram};
|
|
|
|
|
2023-07-19 19:47:30 +00:00
|
|
|
const CONTEXT: &[u8] = b"FROST-ED448-SHAKE256-v1";
|
2022-08-29 07:32:59 +00:00
|
|
|
|
|
|
|
impl Curve for Ed448 {
|
2022-10-29 08:54:42 +00:00
|
|
|
const CONTEXT: &'static [u8] = CONTEXT;
|
2022-08-29 07:32:59 +00:00
|
|
|
}
|
|
|
|
|
2023-03-21 00:10:00 +00:00
|
|
|
// The RFC-8032 Ed448 challenge function.
|
2022-08-29 07:32:59 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2023-03-21 00:10:00 +00:00
|
|
|
pub(crate) struct Ietf8032Ed448Hram;
|
2022-08-29 07:32:59 +00:00
|
|
|
impl Ietf8032Ed448Hram {
|
|
|
|
#[allow(non_snake_case)]
|
2023-03-21 00:10:00 +00:00
|
|
|
pub(crate) fn hram(context: &[u8], R: &Point, A: &Point, m: &[u8]) -> Scalar {
|
2022-10-29 08:54:42 +00:00
|
|
|
Scalar::wide_reduce(
|
|
|
|
Shake256_114::digest(
|
2022-11-01 05:03:36 +00:00
|
|
|
[
|
2022-10-29 08:54:42 +00:00
|
|
|
&[b"SigEd448".as_ref(), &[0, u8::try_from(context.len()).unwrap()]].concat(),
|
|
|
|
context,
|
|
|
|
&[R.to_bytes().as_ref(), A.to_bytes().as_ref(), m].concat(),
|
|
|
|
]
|
|
|
|
.concat(),
|
|
|
|
)
|
|
|
|
.as_ref()
|
|
|
|
.try_into()
|
|
|
|
.unwrap(),
|
|
|
|
)
|
2022-08-29 07:32:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-21 00:10:00 +00:00
|
|
|
/// The challenge function for FROST's Ed448 ciphersuite.
|
2022-08-29 07:32:59 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2022-10-13 04:38:36 +00:00
|
|
|
pub struct IetfEd448Hram;
|
|
|
|
impl Hram<Ed448> for IetfEd448Hram {
|
2022-08-29 07:32:59 +00:00
|
|
|
#[allow(non_snake_case)]
|
|
|
|
fn hram(R: &Point, A: &Point, m: &[u8]) -> Scalar {
|
2022-09-16 16:16:37 +00:00
|
|
|
Ietf8032Ed448Hram::hram(&[], R, A, m)
|
2022-08-29 07:32:59 +00:00
|
|
|
}
|
|
|
|
}
|