Skip to content

Commit

Permalink
FIXUP sst/gen_key: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aewag committed Sep 6, 2024
1 parent a3eb6dc commit 93fc84e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/sst/gen_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ pub fn finalize_sst_keygen<H: HashChain>(

#[cfg(test)]
mod tests {

use super::*;
use crate::sst::parameters::SstsParameter;
use crate::util::helper::test_helper::gen_random_seed;
Expand All @@ -129,14 +128,19 @@ mod tests {
let ssts_parameter = SstsParameter::<Sha256_128>::new(hss_parameters, 4, 3);
let aux_data = None;

let _ = prepare_sst_keygen::<Sha256_128>(
let (_signing_key, interm_node) = prepare_sst_keygen::<Sha256_128>(
&ssts_parameter,
&seed,
aux_data,
&mut lms_tree_identifier,
)
.unwrap();
assert_ne!(lms_tree_identifier, LmsTreeIdentifier::default());
assert_eq!(
interm_node.as_slice().len(),
LmsTreeIdentifier::default().len()
);
assert_ne!(interm_node.as_slice(), &LmsTreeIdentifier::default());
}

#[test]
Expand Down Expand Up @@ -165,15 +169,17 @@ mod tests {

#[test]
fn test_finalize_sst_keygen() {
const L0_TOP_DIV: u32 = 4;

let mut lms_tree_identifier = LmsTreeIdentifier::default();
let seed = gen_random_seed::<Sha256_128>();
let mut hss_parameters = ArrayVec::new();
hss_parameters.extend_from_slice(&[
HssParameter::construct_default_parameters(),
HssParameter::construct_default_parameters(),
]);
let ssts_parameter = SstsParameter::<Sha256_128>::new(hss_parameters, 4, 3);
let mut aux_data = [0u8; 4 + 16 + 2usize.pow(4) * 16];
let ssts_parameter = SstsParameter::<Sha256_128>::new(hss_parameters, L0_TOP_DIV as u8, 3);
let mut aux_data = [0u8; 4 + 16 + 2usize.pow(L0_TOP_DIV) * 16];
let aux_ref: &mut &mut [u8] = &mut &mut aux_data[..];
let mut aux_option = Some(aux_ref);

Expand All @@ -192,7 +198,7 @@ mod tests {
};
let mut interm_nodes =
ArrayVec::<[ArrayVec<[u8; MAX_HASH_SIZE]>; MAX_SSTS_SIGNING_ENTITIES]>::new();
for _ in 0..2usize.pow(4) {
for _ in 0..2usize.pow(L0_TOP_DIV) {
let mut tmp_node = ArrayVec::<[u8; MAX_HASH_SIZE]>::new();
tmp_node.extend_from_slice(&interm_node);
interm_nodes.push(tmp_node);
Expand All @@ -202,6 +208,7 @@ mod tests {
&interm_nodes,
aux_option,
&lms_tree_identifier,
);
)
.unwrap();
}
}

0 comments on commit 93fc84e

Please sign in to comment.