Skip to content

Commit

Permalink
Rename to num_winternitz_chains
Browse files Browse the repository at this point in the history
  • Loading branch information
aewag committed Sep 11, 2024
1 parent 8e67e43 commit 568655d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ The following table shows the mapping between the RFC and the library naming inc

| RFC Naming | Library Naming | Meaning |
|------------|----------------------|-----------------------------------------------------------|
| I | lms_tree_identifier | 16-byte random value to identify a single LMS tree |
| q | lms_leaf_identifier | 4-byte value to identify all leafs in a single LMS tree |
| C | signature_randomizer | 32-byte random value added to every signature |
| Q | message_hash | Output of hashed message together with I, q, D_MESG and C |
| y | signature_data | The actual data of the signature |
| p | hash_chain_count | The number of hash chains for a certain W parameter |
| ls | checksum_left_shift | How many bits the checksum is shifted into the coef-value |
| n | hash_function_output_size | Number of bytes that the lm_ots hash functions generates |
| m | hash_function_output_size | Number of bytes that the lms hash functions generates |
| I | lms_tree_identifier | 16-byte random value to identify a single LMS tree |
| q | lms_leaf_identifier | 4-byte value to identify all leafs in a single LMS tree |
| C | signature_randomizer | 32-byte random value added to every signature |
| Q | message_hash | Output of hashed message together with I, q, D_MESG and C |
| y | signature_data | The actual data of the signature |
| p | num_winternitz_chains | The number of hash chains for a certain W parameter |
| ls | checksum_left_shift | How many bits the checksum is shifted into the coef-value |
| n | hash_function_output_size | Number of bytes that the lm_ots hash functions generates |
| m | hash_function_output_size | Number of bytes that the lms hash functions generates |

## Minimum Supported Rust Version
The crate in this repository supports Rust **1.63** or higher.
Expand Down
4 changes: 2 additions & 2 deletions src/lm_ots/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn generate_public_key<H: HashChain>(private_key: &LmotsPrivateKey<H>) -> Lm
let lmots_parameter = &private_key.lmots_parameter;
let mut hasher = lmots_parameter.get_hasher();

let hash_chain_count: usize = 2_usize.pow(lmots_parameter.get_winternitz() as u32) - 1;
let num_winternitz_chains: usize = 2_usize.pow(lmots_parameter.get_winternitz() as u32) - 1;
let key = &private_key.key;

let mut public_key_data: ArrayVec<[ArrayVec<[u8; MAX_HASH_SIZE]>; MAX_NUM_WINTERNITZ_CHAINS]> =
Expand All @@ -54,7 +54,7 @@ pub fn generate_public_key<H: HashChain>(private_key: &LmotsPrivateKey<H>) -> Lm
i as u16,
key[i].as_slice(),
0,
hash_chain_count,
num_winternitz_chains,
);

public_key_data.push(result);
Expand Down
8 changes: 4 additions & 4 deletions src/lm_ots/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl LmotsAlgorithm {
pub struct LmotsParameter<H: HashChain> {
type_id: u32,
winternitz: u8,
hash_chain_count: u16,
num_winternitz_chains: u16,
checksum_left_shift: u8,
phantom_data: PhantomData<H>,
}
Expand All @@ -99,13 +99,13 @@ impl<H: HashChain> LmotsParameter<H> {
pub fn new(
type_id: u32,
winternitz: u8,
hash_chain_count: u16,
num_winternitz_chains: u16,
checksum_left_shift: u8,
) -> Self {
Self {
type_id,
winternitz,
hash_chain_count,
num_winternitz_chains,
checksum_left_shift,
phantom_data: PhantomData,
}
Expand All @@ -120,7 +120,7 @@ impl<H: HashChain> LmotsParameter<H> {
}

pub fn get_num_winternitz_chains(&self) -> u16 {
self.hash_chain_count
self.num_winternitz_chains
}

pub fn get_checksum_left_shift(&self) -> u8 {
Expand Down
7 changes: 5 additions & 2 deletions src/lm_ots/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,11 @@ mod tests {

// check signature len
let output_size = lmots_parameter.get_hash_function_output_size() as usize;
let hash_chain_count = lmots_parameter.get_num_winternitz_chains() as usize;
assert_eq!(binary_rep.len(), 4 + output_size * (hash_chain_count + 1));
let num_winternitz_chains = lmots_parameter.get_num_winternitz_chains() as usize;
assert_eq!(
binary_rep.len(),
4 + output_size * (num_winternitz_chains + 1)
);

let deserialized_signature = InMemoryLmotsSignature::new(binary_rep.as_slice())
.expect("Deserialization must succeed.");
Expand Down

0 comments on commit 568655d

Please sign in to comment.