From 8b66ae4a745ade3121e72a5d420c061e71656fd2 Mon Sep 17 00:00:00 2001 From: Alexander Wagner Date: Fri, 6 Sep 2024 20:24:05 +0200 Subject: [PATCH] WIP add new sk test --- src/hss/reference_impl_private_key.rs | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/hss/reference_impl_private_key.rs b/src/hss/reference_impl_private_key.rs index adb577d..e42c75f 100644 --- a/src/hss/reference_impl_private_key.rs +++ b/src/hss/reference_impl_private_key.rs @@ -389,6 +389,7 @@ impl CompressedUsedLeafsIndexes { #[cfg(test)] mod tests { use super::{CompressedParameterSet, ReferenceImplPrivateKey}; + use crate::sst::parameters::SstsParameter; use crate::util::helper::test_helper::gen_random_seed; use crate::{ constants::MAX_ALLOWED_HSS_LEVELS, hss::definitions::HssPrivateKey, HssParameter, @@ -398,6 +399,36 @@ mod tests { type Hasher = Sha256_256; + #[test] + fn generate_sst_impl_private_key() { + const L0_TOP_DIV: u32 = 4; + const SIGNING_ENTITY_IDX: u32 = 3; + + let seed = gen_random_seed::(); + let mut hss_parameters = ArrayVec::new(); + hss_parameters.extend_from_slice(&[ + HssParameter::construct_default_parameters(), + HssParameter::construct_default_parameters(), + ]); + let ssts_parameter = SstsParameter::::new( + hss_parameters, + L0_TOP_DIV as u8, + SIGNING_ENTITY_IDX as u8, + ); + let impl_private_key = ReferenceImplPrivateKey::generate( + ssts_parameter.get_hss_parameters(), + &seed, + Some(ssts_parameter.sst_extension().clone()), + ) + .unwrap(); + assert_eq!( + impl_private_key + .compressed_used_leafs_indexes + .to(&hss_parameters)[0], + 2u32.pow(SIGNING_ENTITY_IDX - 1) + ); + } + #[test] fn exhaust_state() { let lmots = LmotsAlgorithm::LmotsW4;