Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using multi-pop in sha256 impl. #5590

Merged
merged 1 commit into from
May 22, 2024
Merged
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
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
Loading