aboutsummaryrefslogtreecommitdiff
path: root/reference_impl/reference_impl.rs
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2021-10-29 14:04:22 -0400
committerJack O'Connor <[email protected]>2021-10-29 14:04:22 -0400
commit600f0b51fe5072559060b1b879fabd4210a177ee (patch)
tree8b24a67dda0379b192554e627d84725efa05dbb2 /reference_impl/reference_impl.rs
parentf35d0315781e81e9b4318f3764ff50aa5a6ac100 (diff)
distinguish between key and key_words in the reference impl
Diffstat (limited to 'reference_impl/reference_impl.rs')
-rw-r--r--reference_impl/reference_impl.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/reference_impl/reference_impl.rs b/reference_impl/reference_impl.rs
index 2488343..78715c9 100644
--- a/reference_impl/reference_impl.rs
+++ b/reference_impl/reference_impl.rs
@@ -181,9 +181,9 @@ struct ChunkState {
}
impl ChunkState {
- fn new(key: [u32; 8], chunk_counter: u64, flags: u32) -> Self {
+ fn new(key_words: [u32; 8], chunk_counter: u64, flags: u32) -> Self {
Self {
- chaining_value: key,
+ chaining_value: key_words,
chunk_counter,
block: [0; BLOCK_LEN],
block_len: 0,
@@ -248,14 +248,14 @@ impl ChunkState {
fn parent_output(
left_child_cv: [u32; 8],
right_child_cv: [u32; 8],
- key: [u32; 8],
+ key_words: [u32; 8],
flags: u32,
) -> Output {
let mut block_words = [0; 16];
block_words[..8].copy_from_slice(&left_child_cv);
block_words[8..].copy_from_slice(&right_child_cv);
Output {
- input_chaining_value: key,
+ input_chaining_value: key_words,
block_words,
counter: 0, // Always 0 for parent nodes.
block_len: BLOCK_LEN as u32, // Always BLOCK_LEN (64) for parent nodes.
@@ -266,26 +266,26 @@ fn parent_output(
fn parent_cv(
left_child_cv: [u32; 8],
right_child_cv: [u32; 8],
- key: [u32; 8],
+ key_words: [u32; 8],
flags: u32,
) -> [u32; 8] {
- parent_output(left_child_cv, right_child_cv, key, flags).chaining_value()
+ parent_output(left_child_cv, right_child_cv, key_words, flags).chaining_value()
}
/// An incremental hasher that can accept any number of writes.
pub struct Hasher {
chunk_state: ChunkState,
- key: [u32; 8],
+ key_words: [u32; 8],
cv_stack: [[u32; 8]; 54], // Space for 54 subtree chaining values:
cv_stack_len: u8, // 2^54 * CHUNK_LEN = 2^64
flags: u32,
}
impl Hasher {
- fn new_internal(key: [u32; 8], flags: u32) -> Self {
+ fn new_internal(key_words: [u32; 8], flags: u32) -> Self {
Self {
- chunk_state: ChunkState::new(key, 0, flags),
- key,
+ chunk_state: ChunkState::new(key_words, 0, flags),
+ key_words,
cv_stack: [[0; 8]; 54],
cv_stack_len: 0,
flags,
@@ -336,7 +336,7 @@ impl Hasher {
// `new_cv` onto the stack. The number of completed subtrees is given
// by the number of trailing 0-bits in the new total number of chunks.
while total_chunks & 1 == 0 {
- new_cv = parent_cv(self.pop_stack(), new_cv, self.key, self.flags);
+ new_cv = parent_cv(self.pop_stack(), new_cv, self.key_words, self.flags);
total_chunks >>= 1;
}
self.push_stack(new_cv);
@@ -351,7 +351,7 @@ impl Hasher {
let chunk_cv = self.chunk_state.output().chaining_value();
let total_chunks = self.chunk_state.chunk_counter + 1;
self.add_chunk_chaining_value(chunk_cv, total_chunks);
- self.chunk_state = ChunkState::new(self.key, total_chunks, self.flags);
+ self.chunk_state = ChunkState::new(self.key_words, total_chunks, self.flags);
}
// Compress input bytes into the current chunk state.
@@ -374,7 +374,7 @@ impl Hasher {
output = parent_output(
self.cv_stack[parent_nodes_remaining],
output.chaining_value(),
- self.key,
+ self.key_words,
self.flags,
);
}