From 718945f63eba23431139ff2e686e579b6ac1e6e9 Mon Sep 17 00:00:00 2001 From: saleel Date: Wed, 2 Oct 2024 22:39:31 +0530 Subject: [PATCH] fix: ignore compression of blocks after msg.len in sha256_var --- noir_stdlib/src/hash/sha256.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir_stdlib/src/hash/sha256.nr b/noir_stdlib/src/hash/sha256.nr index 413c26d6f6b..f608f8c427f 100644 --- a/noir_stdlib/src/hash/sha256.nr +++ b/noir_stdlib/src/hash/sha256.nr @@ -110,7 +110,7 @@ pub fn sha256_var(msg: [u8; N], message_size: u64) -> [u8; 32] { // If the block is filled, compress it. // An un-filled block is handled after this loop. - if msg_byte_ptr == BLOCK_SIZE { + if (msg_start < message_size) & (msg_byte_ptr == BLOCK_SIZE) { h = sha256_compression(msg_u8_to_u32(msg_block), h); } }