Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions noir_stdlib/src/hash/sha256.nr
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand All @@ -519,11 +519,9 @@ fn hash_final_block(msg_block: MSG_BLOCK, mut state: STATE) -> HASH {

mod tests {
use super::{
attach_len_to_msg_block, build_msg_block, byte_into_item, get_item_byte, lshift8, make_item,
set_item_byte_then_zeros, set_item_zeros,
attach_len_to_msg_block, build_msg_block, byte_into_item, get_item_byte, INT_BLOCK,
make_item, set_item_byte_then_zeros, set_item_zeros, sha256_var,
};
use super::{INT_BLOCK, INT_BLOCK_SIZE, MSG_BLOCK};
use super::sha256_var;

#[test]
fn smoke_test() {
Expand Down