use hybrid_array::ArraySize;
pub(crate) const F_TAIL_LEN: usize = 4;
pub(crate) const MAX_M_VEC_LIMBS: usize = 9;
pub(crate) const MAX_M: usize = 142;
pub trait MayoParameter: Clone + Copy + Send + Sync + 'static {
type CskSize: ArraySize;
const NAME: &'static str;
const N: usize;
const M: usize;
const O: usize;
const K: usize;
const V: usize;
const M_VEC_LIMBS: usize;
const A_COLS: usize;
const M_BYTES: usize;
const O_BYTES: usize;
const V_BYTES: usize;
const R_BYTES: usize;
const P1_BYTES: usize;
const P2_BYTES: usize;
const P3_BYTES: usize;
const CSK_BYTES: usize;
const CPK_BYTES: usize;
const SIG_BYTES: usize;
const SALT_BYTES: usize;
const DIGEST_BYTES: usize;
const PK_SEED_BYTES: usize;
const SK_SEED_BYTES: usize;
const F_TAIL: [u8; F_TAIL_LEN];
const P1_LIMBS: usize;
const P2_LIMBS: usize;
const P3_LIMBS: usize;
}
macro_rules! define_mayo_parameter {
(
$name:ident, $display:expr,
n = $n:expr, m = $m:expr, o = $o:expr, k = $k:expr,
m_vec_limbs = $mvl:expr,
m_bytes = $mb:expr, O_bytes = $ob:expr, v_bytes = $vb:expr, r_bytes = $rb:expr,
P1_bytes = $p1b:expr, P2_bytes = $p2b:expr, P3_bytes = $p3b:expr,
csk_bytes = $cskb:expr, csk_type = $cskt:ty,
cpk_bytes = $cpkb:expr, sig_bytes = $sigb:expr,
salt_bytes = $saltb:expr, digest_bytes = $db:expr,
pk_seed_bytes = $pksb:expr, sk_seed_bytes = $sksb:expr,
f_tail = $ft:expr
) => {
#[doc = concat!("MAYO parameter set ", $display, ".")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct $name;
impl MayoParameter for $name {
type CskSize = $cskt;
const NAME: &'static str = $display;
const N: usize = $n;
const M: usize = $m;
const O: usize = $o;
const K: usize = $k;
const V: usize = $n - $o;
const M_VEC_LIMBS: usize = $mvl;
const A_COLS: usize = $k * $o + 1;
const M_BYTES: usize = $mb;
const O_BYTES: usize = $ob;
const V_BYTES: usize = $vb;
const R_BYTES: usize = $rb;
const P1_BYTES: usize = $p1b;
const P2_BYTES: usize = $p2b;
const P3_BYTES: usize = $p3b;
const CSK_BYTES: usize = $cskb;
const CPK_BYTES: usize = $cpkb;
const SIG_BYTES: usize = $sigb;
const SALT_BYTES: usize = $saltb;
const DIGEST_BYTES: usize = $db;
const PK_SEED_BYTES: usize = $pksb;
const SK_SEED_BYTES: usize = $sksb;
const F_TAIL: [u8; F_TAIL_LEN] = $ft;
const P1_LIMBS: usize = ($n - $o) * (($n - $o) + 1) / 2 * $mvl;
const P2_LIMBS: usize = ($n - $o) * $o * $mvl;
const P3_LIMBS: usize = $o * ($o + 1) / 2 * $mvl;
}
};
}
define_mayo_parameter!(
Mayo1,
"MAYO_1",
n = 86,
m = 78,
o = 8,
k = 10,
m_vec_limbs = 5,
m_bytes = 39,
O_bytes = 312,
v_bytes = 39,
r_bytes = 40,
P1_bytes = 120159,
P2_bytes = 24336,
P3_bytes = 1404,
csk_bytes = 24,
csk_type = hybrid_array::typenum::U24,
cpk_bytes = 1420,
sig_bytes = 454,
salt_bytes = 24,
digest_bytes = 32,
pk_seed_bytes = 16,
sk_seed_bytes = 24,
f_tail = [8, 1, 1, 0]
);
define_mayo_parameter!(
Mayo2,
"MAYO_2",
n = 96,
m = 64,
o = 16,
k = 4,
m_vec_limbs = 4,
m_bytes = 32,
O_bytes = 640,
v_bytes = 40,
r_bytes = 32,
P1_bytes = 103680,
P2_bytes = 40960,
P3_bytes = 4352,
csk_bytes = 24,
csk_type = hybrid_array::typenum::U24,
cpk_bytes = 4368,
sig_bytes = 216,
salt_bytes = 24,
digest_bytes = 32,
pk_seed_bytes = 16,
sk_seed_bytes = 24,
f_tail = [8, 0, 2, 8]
);
define_mayo_parameter!(
Mayo3,
"MAYO_3",
n = 118,
m = 108,
o = 10,
k = 11,
m_vec_limbs = 7,
m_bytes = 54,
O_bytes = 540,
v_bytes = 54,
r_bytes = 55,
P1_bytes = 317844,
P2_bytes = 58320,
P3_bytes = 2970,
csk_bytes = 32,
csk_type = hybrid_array::typenum::U32,
cpk_bytes = 2986,
sig_bytes = 681,
salt_bytes = 32,
digest_bytes = 48,
pk_seed_bytes = 16,
sk_seed_bytes = 32,
f_tail = [8, 0, 1, 7]
);
define_mayo_parameter!(
Mayo5,
"MAYO_5",
n = 154,
m = 142,
o = 12,
k = 12,
m_vec_limbs = 9,
m_bytes = 71,
O_bytes = 852,
v_bytes = 71,
r_bytes = 72,
P1_bytes = 720863,
P2_bytes = 120984,
P3_bytes = 5538,
csk_bytes = 40,
csk_type = hybrid_array::typenum::U40,
cpk_bytes = 5554,
sig_bytes = 964,
salt_bytes = 40,
digest_bytes = 64,
pk_seed_bytes = 16,
sk_seed_bytes = 40,
f_tail = [4, 0, 8, 1]
);