Skip to content

Commit dd271c2

Browse files
Hakkush-07lynndell | bitlayer
andauthored
[Zellic Audit] 3.27 Blake3 script is incorrect (#390)
* fix #365 Blake3 script inscorrect fix #365 Blake3 script inscorrect for more than 1,024 bytes of input or more than 32 bytes of output * add assert to blake3 compress to check final_rounds is 8 --------- Co-authored-by: lynndell | bitlayer <lynndell.zhong@bitlayer.ltd>
1 parent 880bde5 commit dd271c2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎bitvm/src/hash/blake3_utils.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ fn init_state(
454454
for u32 in &IV[0..4] {
455455
state.push(stack.number_u32(*u32));
456456
}
457-
state.push(stack.number_u32(0));
458457
state.push(stack.number_u32(counter));
458+
state.push(stack.number_u32(0));
459459
state.push(stack.number_u32(block_len));
460460
state.push(stack.number_u32(flags));
461461

@@ -483,6 +483,9 @@ pub(crate) fn compress(
483483
//chaining value needs to be copied for multiple blocks
484484
//every time that is provided
485485

486+
// final_rounds must be 8, if you need more than 32 output bytes, you need to change this
487+
assert_eq!(final_rounds, 8);
488+
486489
let mut state = init_state(stack, chaining, counter, block_len, flags);
487490

488491
for _ in 0..6 {

0 commit comments

Comments
 (0)