This commit is contained in:
integritychain 2024-01-30 18:57:53 -06:00
parent 946df93b0b
commit 9b5d6162e5
5 changed files with 252 additions and 132 deletions

View file

@ -21,10 +21,10 @@ rand_chacha = "0.3.1"
[features] [features]
default = ["default-rng", "slh_dsa_shake_128s", "slh_dsa_sha2_128s"] #default = ["default-rng", "slh_dsa_shake_128s", "slh_dsa_sha2_128s"]
#default = ["default-rng", "slh_dsa_sha2_128s"] #, "slh_dsa_shake_128s", "slh_dsa_sha2_128f", "slh_dsa_shake_128f", default = ["default-rng", "slh_dsa_sha2_128s", "slh_dsa_shake_128s", "slh_dsa_sha2_128f", "slh_dsa_shake_128f",
# "slh_dsa_sha2_192s", "slh_dsa_shake_192s", "slh_dsa_sha2_192f", "slh_dsa_shake_192f", "slh_dsa_sha2_192s", "slh_dsa_shake_192s", "slh_dsa_sha2_192f", "slh_dsa_shake_192f",
# "slh_dsa_sha2_256s", "slh_dsa_shake_256s", "slh_dsa_sha2_256f", "slh_dsa_shake_256f"] "slh_dsa_sha2_256s", "slh_dsa_shake_256s", "slh_dsa_sha2_256f", "slh_dsa_shake_256f"]
default-rng = ["rand_core/getrandom"] default-rng = ["rand_core/getrandom"]
slh_dsa_sha2_128s = [] slh_dsa_sha2_128s = []
slh_dsa_shake_128s = [] slh_dsa_shake_128s = []

View file

@ -1116,7 +1116,8 @@ pub(crate) fn slh_sign_with_rng<
// 15: idx_tree ← toInt(tmp_idx_tree, ceil((h-h/d)/8)) mod 2^{hh/d} // 15: idx_tree ← toInt(tmp_idx_tree, ceil((h-h/d)/8)) mod 2^{hh/d}
let idx_tree = let idx_tree =
to_int(tmp_idx_tree, (H::to_usize() - H::to_usize() / D::to_usize()).div_ceil(8)) to_int(tmp_idx_tree, (H::to_usize() - H::to_usize() / D::to_usize()).div_ceil(8))
% 2u64.pow(H::to_u32() - H::to_u32() / D::to_u32()); & (u64::MAX >> (64 - (H::to_u32() - H::to_u32() / D::to_u32())));
// % 2u64.pow(H::to_u32() - H::to_u32() / D::to_u32()); // Can be 2^64
// 16: idx_leaf ← toInt(tmp_idx_leaf, ceil(h/8d) mod 2^{h/d} // 16: idx_leaf ← toInt(tmp_idx_leaf, ceil(h/8d) mod 2^{h/d}
let idx_leaf = to_int(tmp_idx_leaf, H::to_usize().div_ceil(8 * D::to_usize())) let idx_leaf = to_int(tmp_idx_leaf, H::to_usize().div_ceil(8 * D::to_usize()))
@ -1214,7 +1215,8 @@ pub(crate) fn slh_verify<
// 14: idx_tree ← toInt(tmp_idx_tree, ceil((h - h/d)/8)) mod 2^{hh/d} // 14: idx_tree ← toInt(tmp_idx_tree, ceil((h - h/d)/8)) mod 2^{hh/d}
let idx_tree = let idx_tree =
to_int(tmp_idx_tree, (H::to_usize() - H::to_usize() / D::to_usize()).div_ceil(8)) to_int(tmp_idx_tree, (H::to_usize() - H::to_usize() / D::to_usize()).div_ceil(8))
% 2u64.pow(H::to_u32() - H::to_u32() / D::to_u32()); & (u64::MAX >> (64 - (H::to_u32() - H::to_u32() / D::to_u32())));
// % 2u64.pow(H::to_u32() - H::to_u32() / D::to_u32()); // Can be 2^64
// 15: idx_leaf ← toInt(tmp_idx_leaf, ceil(h/8d) mod 2^{h/d} // 15: idx_leaf ← toInt(tmp_idx_leaf, ceil(h/8d) mod 2^{h/d}
let idx_leaf = to_int(tmp_idx_leaf, H::to_usize().div_ceil(8 * D::to_usize())) let idx_leaf = to_int(tmp_idx_leaf, H::to_usize().div_ceil(8 * D::to_usize()))

View file

@ -106,44 +106,45 @@ pub(crate) mod shake {
} }
} }
pub(crate) mod sha2_cat1 { pub(crate) mod sha2_cat_1 {
use crate::types::Adrs; use crate::types::Adrs;
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
pub(crate) fn h_msg<M: ArrayLength>( pub(crate) fn h_msg<M: ArrayLength>(
_r: &[u8], _pk_seed: &[u8], _pk_root: &[u8], _m: &[u8], _r: &[u8], _pk_seed: &[u8], _pk_root: &[u8], _m: &[u8],
) -> GenericArray<u8, M> { ) -> GenericArray<u8, M> {
unimplemented!() GenericArray::default()
} }
pub(crate) fn prf<N: ArrayLength>( pub(crate) fn prf<N: ArrayLength>(
_pk_seed: &[u8], _sk_seed: &[u8], _adrs: &Adrs, _pk_seed: &[u8], _sk_seed: &[u8], _adrs: &Adrs,
) -> GenericArray<u8, N> { ) -> GenericArray<u8, N> {
unimplemented!() GenericArray::default()
} }
pub(crate) fn prf_msg<N: ArrayLength>( pub(crate) fn prf_msg<N: ArrayLength>(
_sk_prf: &[u8], _opt_rand: &[u8], _m: &[u8], _sk_prf: &[u8], _opt_rand: &[u8], _m: &[u8],
) -> GenericArray<u8, N> { ) -> GenericArray<u8, N> {
unimplemented!() GenericArray::default()
} }
pub(crate) fn f<N: ArrayLength>(_pk_seed: &[u8], _adrs: &Adrs, _m1: &[u8]) -> GenericArray<u8, N> { pub(crate) fn f<N: ArrayLength>(
unimplemented!() _pk_seed: &[u8], _adrs: &Adrs, _m1: &[u8],
) -> GenericArray<u8, N> {
GenericArray::default()
} }
pub(crate) fn h<N: ArrayLength>( pub(crate) fn h<N: ArrayLength>(
_pk_seed: &[u8], _adrs: &Adrs, _m1: &[u8], _m2: &[u8], _pk_seed: &[u8], _adrs: &Adrs, _m1: &[u8], _m2: &[u8],
) -> GenericArray<u8, N> { ) -> GenericArray<u8, N> {
unimplemented!() GenericArray::default()
} }
// Until a more elegant way is found to covert ml into list of bytes // Until a more elegant way is found to covert ml into list of bytes
pub(crate) fn t_l<LEN: ArrayLength, N: ArrayLength>( pub(crate) fn t_l<LEN: ArrayLength, N: ArrayLength>(
_pk_seed: &[u8], _adrs: &Adrs, _ml: &GenericArray<GenericArray<u8, N>, LEN>, _pk_seed: &[u8], _adrs: &Adrs, _ml: &GenericArray<GenericArray<u8, N>, LEN>,
) -> GenericArray<u8, N> { ) -> GenericArray<u8, N> {
unimplemented!() GenericArray::default()
} }
// TODO: Squash K and LEN versions // TODO: Squash K and LEN versions
@ -151,6 +152,57 @@ pub(crate) mod sha2_cat1 {
pub(crate) fn t_len<K: ArrayLength, N: ArrayLength>( pub(crate) fn t_len<K: ArrayLength, N: ArrayLength>(
_pk_seed: &[u8], _adrs: &Adrs, _ml: &GenericArray<GenericArray<u8, N>, K>, _pk_seed: &[u8], _adrs: &Adrs, _ml: &GenericArray<GenericArray<u8, N>, K>,
) -> GenericArray<u8, N> { ) -> GenericArray<u8, N> {
unimplemented!() GenericArray::default()
}
}
pub(crate) mod sha2_cat_3_5 {
use crate::types::Adrs;
use generic_array::{ArrayLength, GenericArray};
pub(crate) fn h_msg<M: ArrayLength>(
_r: &[u8], _pk_seed: &[u8], _pk_root: &[u8], _m: &[u8],
) -> GenericArray<u8, M> {
GenericArray::default()
}
pub(crate) fn prf<N: ArrayLength>(
_pk_seed: &[u8], _sk_seed: &[u8], _adrs: &Adrs,
) -> GenericArray<u8, N> {
GenericArray::default()
}
pub(crate) fn prf_msg<N: ArrayLength>(
_sk_prf: &[u8], _opt_rand: &[u8], _m: &[u8],
) -> GenericArray<u8, N> {
GenericArray::default()
}
pub(crate) fn f<N: ArrayLength>(
_pk_seed: &[u8], _adrs: &Adrs, _m1: &[u8],
) -> GenericArray<u8, N> {
GenericArray::default()
}
pub(crate) fn h<N: ArrayLength>(
_pk_seed: &[u8], _adrs: &Adrs, _m1: &[u8], _m2: &[u8],
) -> GenericArray<u8, N> {
GenericArray::default()
}
// Until a more elegant way is found to covert ml into list of bytes
pub(crate) fn t_l<LEN: ArrayLength, N: ArrayLength>(
_pk_seed: &[u8], _adrs: &Adrs, _ml: &GenericArray<GenericArray<u8, N>, LEN>,
) -> GenericArray<u8, N> {
GenericArray::default()
}
// TODO: Squash K and LEN versions
// Until a more elegant way is found to covert ml into list of bytes
pub(crate) fn t_len<K: ArrayLength, N: ArrayLength>(
_pk_seed: &[u8], _adrs: &Adrs, _ml: &GenericArray<GenericArray<u8, N>, K>,
) -> GenericArray<u8, N> {
GenericArray::default()
} }
} }

View file

@ -7,8 +7,8 @@
/// crate doc? /// crate doc?
// TODO // TODO
// 1. General clean-up // 1. General clean-up
// 2. Placeholders for other hash functions // 2. Implement remainder of hashers
// 3. Implement all suites (with internal found-trip test function) // 3. Implment KATs
// 4. Separate into proper files // 4. Separate into proper files
// 5. Doc, of course! // 5. Doc, of course!
mod algs; mod algs;
@ -26,7 +26,7 @@ const LEN2: u32 = 3;
macro_rules! functionality { macro_rules! functionality {
() => { () => {
use crate::types::{SlhDsaSig, SlhPrivateKey, SlhPublicKey}; use crate::types::{SlhDsaSig, SlhPrivateKey, SlhPublicKey};
use generic_array::typenum::{Prod, Sum, U2, U3}; //use generic_array::typenum::{Prod, Sum, U2, U3};
use rand_core::CryptoRngCore; use rand_core::CryptoRngCore;
/// blah /// blah
@ -82,9 +82,9 @@ macro_rules! functionality {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_sha2_128s")] #[cfg(feature = "slh_dsa_sha2_128s")]
pub mod slh_dsa_sha2_128s { pub mod slh_dsa_sha2_128s {
use crate::hashers::shake::{f, h, h_msg, prf, prf_msg, t_l, t_len}; use crate::hashers::sha2_cat_1::{f, h, h_msg, prf, prf_msg, t_l, t_len};
use crate::hashers::Hashers; use crate::hashers::Hashers;
use generic_array::typenum::{U12, U14, U16, U30, U63, U7, U9}; use generic_array::typenum::{Prod, Sum, U12, U14, U16, U2, U3, U30, U63, U7, U9};
type N = U16; type N = U16;
type H = U63; type H = U63;
@ -106,17 +106,23 @@ pub mod slh_dsa_sha2_128s {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_shake_128s")] #[cfg(feature = "slh_dsa_shake_128s")]
pub mod slh_dsa_shake_128s { pub mod slh_dsa_shake_128s {
const N: usize = 16; use crate::hashers::shake::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 63; use crate::hashers::Hashers;
const D: u32 = 7; use generic_array::typenum::{Prod, Sum, U12, U14, U16, U2, U3, U30, U63, U7, U9};
const H_PRIME: u32 = 9;
const A: u32 = 12; type N = U16;
const K: u32 = 14; type H = U63;
const LGW: u32 = 4; type D = U7;
const M: u32 = 30; type HP = U9;
const PK_LEN: usize = 32; type A = U12;
type K = U14;
type M = U30;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 7856; const SIG_LEN: usize = 7856;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -124,17 +130,23 @@ pub mod slh_dsa_shake_128s {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_sha2_128f")] #[cfg(feature = "slh_dsa_sha2_128f")]
pub mod slh_dsa_sha2_128f { pub mod slh_dsa_sha2_128f {
const N: usize = 16; use crate::hashers::sha2_cat_1::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 66; use crate::hashers::Hashers;
const D: u32 = 22; use generic_array::typenum::{Prod, Sum, U16, U2, U22, U3, U33, U34, U6, U66};
const H_PRIME: u32 = 3;
const A: u32 = 6; type N = U16;
const K: u32 = 33; type H = U66;
const LGW: u32 = 4; type D = U22;
const M: u32 = 34; type HP = U3;
const PK_LEN: usize = 32; type A = U6;
type K = U33;
type M = U34;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 17088; const SIG_LEN: usize = 17088;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -142,17 +154,23 @@ pub mod slh_dsa_sha2_128f {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_shake_128f")] #[cfg(feature = "slh_dsa_shake_128f")]
pub mod slh_dsa_shake_128f { pub mod slh_dsa_shake_128f {
const N: usize = 16; use crate::hashers::shake::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 66; use crate::hashers::Hashers;
const D: u32 = 22; use generic_array::typenum::{Prod, Sum, U16, U2, U22, U3, U33, U34, U6, U66};
const H_PRIME: u32 = 3;
const A: u32 = 6; type N = U16;
const K: u32 = 33; type H = U66;
const LGW: u32 = 4; type D = U22;
const M: u32 = 34; type HP = U3;
const PK_LEN: usize = 32; type A = U6;
type K = U33;
type M = U34;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 17088; const SIG_LEN: usize = 17088;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -160,17 +178,23 @@ pub mod slh_dsa_shake_128f {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_sha2_192s")] #[cfg(feature = "slh_dsa_sha2_192s")]
pub mod slh_dsa_sha2_192s { pub mod slh_dsa_sha2_192s {
const N: usize = 24; use crate::hashers::sha2_cat_3_5::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 63; use crate::hashers::Hashers;
const D: u32 = 7; use generic_array::typenum::{Prod, Sum, U14, U17, U2, U24, U3, U39, U63, U7, U9};
const H_PRIME: u32 = 9;
const A: u32 = 14; type N = U24;
const K: u32 = 17; type H = U63;
const LGW: u32 = 4; type D = U7;
const M: u32 = 39; type HP = U9;
const PK_LEN: usize = 48; type A = U14;
type K = U17;
type M = U39;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 16224; const SIG_LEN: usize = 16224;
const SK_LEN: usize = 00000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -178,17 +202,23 @@ pub mod slh_dsa_sha2_192s {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_shake_192s")] #[cfg(feature = "slh_dsa_shake_192s")]
pub mod slh_dsa_shake_192s { pub mod slh_dsa_shake_192s {
const N: usize = 24; use crate::hashers::shake::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 63; use crate::hashers::Hashers;
const D: u32 = 7; use generic_array::typenum::{Prod, Sum, U14, U17, U2, U24, U3, U39, U63, U7, U9};
const H_PRIME: u32 = 9;
const A: u32 = 14; type N = U24;
const K: u32 = 17; type H = U63;
const LGW: u32 = 4; type D = U7;
const M: u32 = 39; type HP = U9;
const PK_LEN: usize = 48; type A = U14;
type K = U17;
type M = U39;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 16224; const SIG_LEN: usize = 16224;
const SK_LEN: usize = 00000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -196,17 +226,23 @@ pub mod slh_dsa_shake_192s {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_sha2_192f")] #[cfg(feature = "slh_dsa_sha2_192f")]
pub mod slh_dsa_sha2_192f { pub mod slh_dsa_sha2_192f {
const N: usize = 24; use crate::hashers::sha2_cat_3_5::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 66; use crate::hashers::Hashers;
const D: u32 = 22; use generic_array::typenum::{Prod, Sum, U2, U22, U24, U3, U33, U42, U66, U8};
const H_PRIME: u32 = 3;
const A: u32 = 8; type N = U24;
const K: u32 = 33; type H = U66;
const LGW: u32 = 4; type D = U22;
const M: u32 = 42; type HP = U3;
const PK_LEN: usize = 48; type A = U8;
type K = U33;
type M = U42;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 35664; const SIG_LEN: usize = 35664;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -214,17 +250,23 @@ pub mod slh_dsa_sha2_192f {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_shake_192f")] #[cfg(feature = "slh_dsa_shake_192f")]
pub mod slh_dsa_shake_192f { pub mod slh_dsa_shake_192f {
const N: usize = 24; use crate::hashers::shake::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 66; use crate::hashers::Hashers;
const D: u32 = 22; use generic_array::typenum::{Prod, Sum, U2, U22, U24, U3, U33, U42, U66, U8};
const H_PRIME: u32 = 3;
const A: u32 = 8; type N = U24;
const K: u32 = 33; type H = U66;
const LGW: u32 = 4; type D = U22;
const M: u32 = 42; type HP = U3;
const PK_LEN: usize = 48; type A = U8;
type K = U33;
type M = U42;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 35664; const SIG_LEN: usize = 35664;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -232,17 +274,23 @@ pub mod slh_dsa_shake_192f {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_sha2_256s")] #[cfg(feature = "slh_dsa_sha2_256s")]
pub mod slh_dsa_sha2_256s { pub mod slh_dsa_sha2_256s {
const N: usize = 32; use crate::hashers::sha2_cat_3_5::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 64; use crate::hashers::Hashers;
const D: u32 = 8; use generic_array::typenum::{Prod, Sum, U14, U2, U22, U3, U32, U47, U64, U8};
const H_PRIME: u32 = 8;
const A: u32 = 14; type N = U32;
const K: u32 = 22; type H = U64;
const LGW: u32 = 4; type D = U8;
const M: u32 = 47; type HP = U8;
const PK_LEN: usize = 64; type A = U14;
type K = U22;
type M = U47;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 29792; const SIG_LEN: usize = 29792;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -250,17 +298,23 @@ pub mod slh_dsa_sha2_256s {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_shake_256s")] #[cfg(feature = "slh_dsa_shake_256s")]
pub mod slh_dsa_shake_256s { pub mod slh_dsa_shake_256s {
const N: usize = 32; use crate::hashers::shake::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 64; use crate::hashers::Hashers;
const D: u32 = 8; use generic_array::typenum::{Prod, Sum, U14, U2, U22, U3, U32, U47, U64, U8};
const H_PRIME: u32 = 8;
const A: u32 = 14; type N = U32;
const K: u32 = 22; type H = U64;
const LGW: u32 = 4; type D = U8;
const M: u32 = 47; type HP = U8;
const PK_LEN: usize = 64; type A = U14;
type K = U22;
type M = U47;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 29792; const SIG_LEN: usize = 29792;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -268,17 +322,23 @@ pub mod slh_dsa_shake_256s {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_sha2_256f")] #[cfg(feature = "slh_dsa_sha2_256f")]
pub mod slh_dsa_sha2_256f { pub mod slh_dsa_sha2_256f {
const N: usize = 32; use crate::hashers::sha2_cat_3_5::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 68; use crate::hashers::Hashers;
const D: u32 = 17; use generic_array::typenum::{Prod, Sum, U17, U2, U3, U32, U35, U4, U49, U68, U9};
const H_PRIME: u32 = 4;
const A: u32 = 9; type N = U32;
const K: u32 = 35; type H = U68;
const LGW: u32 = 4; type D = U17;
const M: u32 = 49; type HP = U4;
const PK_LEN: usize = 64; type A = U9;
type K = U35;
type M = U49;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 49856; const SIG_LEN: usize = 49856;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }
@ -286,17 +346,23 @@ pub mod slh_dsa_sha2_256f {
/// TKTK /// TKTK
#[cfg(feature = "slh_dsa_shake_256f")] #[cfg(feature = "slh_dsa_shake_256f")]
pub mod slh_dsa_shake_256f { pub mod slh_dsa_shake_256f {
const N: usize = 32; use crate::hashers::shake::{f, h, h_msg, prf, prf_msg, t_l, t_len};
const H: u32 = 68; use crate::hashers::Hashers;
const D: u32 = 17; use generic_array::typenum::{Prod, Sum, U17, U2, U3, U32, U35, U4, U49, U68, U9};
const H_PRIME: u32 = 4;
const A: u32 = 9; type N = U32;
const K: u32 = 35; type H = U68;
const LGW: u32 = 4; type D = U17;
const M: u32 = 49; type HP = U4;
const PK_LEN: usize = 64; type A = U9;
type K = U35;
type M = U49;
type LEN = Sum<Prod<U2, N>, U3>;
//const PK_LEN: usize = 32;
const SIG_LEN: usize = 49856; const SIG_LEN: usize = 49856;
const SK_LEN: usize = 0000; //const SK_LEN: usize = 0000;
static HASHERS: Hashers<K, LEN, M, N> =
Hashers::<K, LEN, M, N> { h_msg, prf, prf_msg, f, h, t_l, t_len };
functionality!(); functionality!();
} }

View file

@ -40,7 +40,7 @@ mod tests {
} }
use crate::slh_dsa_sha2_128s::{slh_keygen_with_rng, slh_sign_with_rng, slh_verify}; use crate::slh_dsa_shake_128s::{slh_keygen_with_rng, slh_sign_with_rng, slh_verify};
#[test] #[test]
fn vector_debug() { fn vector_debug() {