From 7eb9702ee9069b35c1196a376a7d5ae766dd99d4 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Mon, 28 Oct 2024 11:18:17 +0000 Subject: [PATCH] use big endian in sha256 --- noir/noir-repo/noir_stdlib/src/hash/sha256.nr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noir/noir-repo/noir_stdlib/src/hash/sha256.nr b/noir/noir-repo/noir_stdlib/src/hash/sha256.nr index a3ac0b9e5da..41df099c15d 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/sha256.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/sha256.nr @@ -508,9 +508,9 @@ fn hash_final_block(msg_block: MSG_BLOCK, mut state: STATE) -> HASH { // Return final hash as byte array for j in 0..8 { - let h_bytes: [u8; 4] = (state[7 - j] as Field).to_le_bytes(); + let h_bytes: [u8; 4] = (state[j] as Field).to_be_bytes(); for k in 0..4 { - out_h[31 - 4 * j - k] = h_bytes[k]; + out_h[4 * j + k] = h_bytes[k]; } }