Initializes the internal state, uses the same variable names as the paper
(
stack: &mut StackTracker,
chaining: bool,
counter: u32,
block_len: u32,
flags: u32,
)
| 434 | |
| 435 | /// Initializes the internal state, uses the same variable names as the paper |
| 436 | fn init_state( |
| 437 | stack: &mut StackTracker, |
| 438 | chaining: bool, |
| 439 | counter: u32, |
| 440 | block_len: u32, |
| 441 | flags: u32, |
| 442 | ) -> HashMap<u8, StackVariable> { |
| 443 | let mut state = Vec::new(); |
| 444 | |
| 445 | if chaining { |
| 446 | for i in 0..8 { |
| 447 | state.push(stack.from_altstack_joined(8, &format!("prev-hash[{}]", i))); |
| 448 | } |
| 449 | } else { |
| 450 | for u32 in IV { |
| 451 | state.push(stack.number_u32(u32)); |
| 452 | } |
| 453 | } |
| 454 | for u32 in &IV[0..4] { |
| 455 | state.push(stack.number_u32(*u32)); |
| 456 | } |
| 457 | state.push(stack.number_u32(counter)); |
| 458 | state.push(stack.number_u32(0)); |
| 459 | state.push(stack.number_u32(block_len)); |
| 460 | state.push(stack.number_u32(flags)); |
| 461 | |
| 462 | let mut state_map = HashMap::new(); |
| 463 | for (i, s) in state.iter().enumerate() { |
| 464 | state_map.insert(i as u8, *s); |
| 465 | stack.rename(*s, &format!("state_{}", i)); |
| 466 | } |
| 467 | state_map |
| 468 | } |
| 469 | |
| 470 | /// Applies the blake3 compression function to the given 512 bit message, consumes everything and leaves only the final value |
| 471 | #[allow(clippy::too_many_arguments)] |