Skip to content

Commit

Permalink
WIP add new sk test
Browse files Browse the repository at this point in the history
  • Loading branch information
aewag committed Sep 6, 2024
1 parent c464898 commit 8b66ae4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/hss/reference_impl_private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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::<Hasher>();
let mut hss_parameters = ArrayVec::new();
hss_parameters.extend_from_slice(&[
HssParameter::construct_default_parameters(),
HssParameter::construct_default_parameters(),
]);
let ssts_parameter = SstsParameter::<Hasher>::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;
Expand Down

0 comments on commit 8b66ae4

Please sign in to comment.