Skip to content

Commit

Permalink
Using multi-pop in sha256 impl.
Browse files Browse the repository at this point in the history
commit-id:eda144bf
  • Loading branch information
orizi committed May 21, 2024
1 parent 6b7f884 commit eb4fcc1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions corelib/src/sha256.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ pub fn compute_sha256_u32_array(
; 8] {
add_sha256_padding(ref input, last_input_word, last_input_num_bytes);

let arr = input.span();
let mut input = input.span();
let mut state = sha256_state_handle_init(BoxTrait::new(SHA256_INITIAL_STATE));
let mut ind = 0;

while ind != arr.len() {
let input: Box<[u32; 16]> = *arr.slice(ind, 16).try_into().unwrap();
state = starknet::syscalls::sha256_process_block_syscall(state, input).unwrap_syscall();
ind = ind + 16;
while let Option::Some(chunk) = input.multi_pop_front() {
state = starknet::syscalls::sha256_process_block_syscall(state, *chunk).unwrap_syscall();
};

sha256_state_handle_digest(state).unbox()
Expand Down

0 comments on commit eb4fcc1

Please sign in to comment.