#![allow(dead_code)]
use core::marker::PhantomData;
pub const Q: i32 = 8380417;
pub const N: usize = 256;
pub const D: usize = 13;
pub trait MlDsaParams: Clone + 'static {
const K: usize;
const L: usize;
const ETA: usize;
const BETA: u32;
const GAMMA1: u32;
const GAMMA2: u32;
const TAU: usize;
const LAMBDA: usize;
const OMEGA: usize;
const PK_SIZE: usize;
const SK_SIZE: usize;
const SIG_SIZE: usize;
const ALGORITHM: &'static str;
const SECURITY_LEVEL: usize;
}
#[derive(Clone, Copy, Debug)]
pub struct Params44;
impl MlDsaParams for Params44 {
const K: usize = 4;
const L: usize = 4;
const ETA: usize = 2;
const BETA: u32 = 78;
const GAMMA1: u32 = 1 << 17; const GAMMA2: u32 = (Q as u32 - 1) / 88; const TAU: usize = 39;
const LAMBDA: usize = 128;
const OMEGA: usize = 80;
const PK_SIZE: usize = 1312;
const SK_SIZE: usize = 2560;
const SIG_SIZE: usize = 2420;
const ALGORITHM: &'static str = "ML-DSA-44";
const SECURITY_LEVEL: usize = 2;
}
#[derive(Clone, Copy, Debug)]
pub struct Params65;
impl MlDsaParams for Params65 {
const K: usize = 6;
const L: usize = 5;
const ETA: usize = 4;
const BETA: u32 = 196;
const GAMMA1: u32 = 1 << 19; const GAMMA2: u32 = (Q as u32 - 1) / 32; const TAU: usize = 49;
const LAMBDA: usize = 192;
const OMEGA: usize = 55;
const PK_SIZE: usize = 1952;
const SK_SIZE: usize = 4032;
const SIG_SIZE: usize = 3309;
const ALGORITHM: &'static str = "ML-DSA-65";
const SECURITY_LEVEL: usize = 3;
}
#[derive(Clone, Copy, Debug)]
pub struct Params87;
impl MlDsaParams for Params87 {
const K: usize = 8;
const L: usize = 7;
const ETA: usize = 2;
const BETA: u32 = 120;
const GAMMA1: u32 = 1 << 19; const GAMMA2: u32 = (Q as u32 - 1) / 32; const TAU: usize = 60;
const LAMBDA: usize = 256;
const OMEGA: usize = 75;
const PK_SIZE: usize = 2592;
const SK_SIZE: usize = 4896;
const SIG_SIZE: usize = 4627;
const ALGORITHM: &'static str = "ML-DSA-87";
const SECURITY_LEVEL: usize = 5;
}
pub struct MlDsaAlgorithm<P: MlDsaParams> {
_params: PhantomData<P>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_params44_constants() {
assert_eq!(Params44::K, 4);
assert_eq!(Params44::L, 4);
assert_eq!(Params44::ETA, 2);
assert_eq!(Params44::PK_SIZE, 1312);
assert_eq!(Params44::SK_SIZE, 2560);
assert_eq!(Params44::SIG_SIZE, 2420);
}
#[test]
fn test_params65_constants() {
assert_eq!(Params65::K, 6);
assert_eq!(Params65::L, 5);
assert_eq!(Params65::ETA, 4);
assert_eq!(Params65::PK_SIZE, 1952);
assert_eq!(Params65::SK_SIZE, 4032);
assert_eq!(Params65::SIG_SIZE, 3309);
}
#[test]
fn test_params87_constants() {
assert_eq!(Params87::K, 8);
assert_eq!(Params87::L, 7);
assert_eq!(Params87::ETA, 2);
assert_eq!(Params87::PK_SIZE, 2592);
assert_eq!(Params87::SK_SIZE, 4896);
assert_eq!(Params87::SIG_SIZE, 4627);
}
#[test]
fn test_gamma2_calculation() {
assert_eq!(Params44::GAMMA2, 95232);
assert_eq!(Params65::GAMMA2, 261888);
assert_eq!(Params87::GAMMA2, 261888);
}
#[test]
fn test_modulus_properties() {
assert_eq!(Q, 8380417);
assert_eq!(Q % 512, 1);
assert!(Q > 0);
assert!(Q < i32::MAX);
}
}