diff --git a/src/sha256.nr b/src/sha256.nr index 7cb67d8..3994847 100644 --- a/src/sha256.nr +++ b/src/sha256.nr @@ -335,6 +335,7 @@ fn verify_msg_block_equals_last( } // Set the rightmost `zeros` number of bytes to 0. +#[inline_always] fn set_item_zeros(item: u32, zeros: u8) -> u32 { lshift8(rshift8(item, zeros), zeros) } @@ -360,6 +361,7 @@ fn get_item_byte(mut msg_item: u32, msg_byte_ptr: BLOCK_BYTE_PTR) -> u8 { // Project a byte into a position in a field based on the overall block pointer. // For example putting 1 into pointer 5 would be 100, because overall we would // have [____, 0100] with indexes [0123,4567]. +#[inline_always] fn byte_into_item(msg_byte: u8, msg_byte_ptr: BLOCK_BYTE_PTR) -> u32 { let mut msg_item = msg_byte as u32; // How many times do we have to shift to the left to get to the position we want? @@ -369,6 +371,7 @@ fn byte_into_item(msg_byte: u8, msg_byte_ptr: BLOCK_BYTE_PTR) -> u32 { } // Construct a field out of 4 bytes. +#[inline_always] fn make_item(b0: u8, b1: u8, b2: u8, b3: u8) -> u32 { let mut item = b0 as u32; item = lshift8(item, 1) + b1 as u32; @@ -380,6 +383,7 @@ fn make_item(b0: u8, b1: u8, b2: u8, b3: u8) -> u32 { // Shift by 8 bits to the left between 0 and 4 times. // Checks `is_unconstrained()` to just use a bitshift if we're running in an unconstrained context, // otherwise multiplies by 256. +#[inline_always] fn lshift8(item: u32, shifts: u8) -> u32 { if is_unconstrained() { // Brillig wouldn't shift 0<<4 without overflow.