File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
vm/src/hint_processor/builtin_hint_processor Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -60,23 +60,25 @@ fn sha256_main(
6060) -> Result < ( ) , HintError > {
6161 let input_ptr = get_ptr_from_var_name ( "sha256_start" , vm, ids_data, ap_tracking) ?;
6262
63- // The original code gets it from `ids` in both cases, and this makes it easier
64- // to implement the arbitrary length one
63+ // The code gets the value from `ids.SHA256_INPUT_CHUNK_SIZE_FELTS ` in both
64+ // constant and arbitrary input length cases.
6565 let input_chunk_size_felts = get_constant_from_var_name (
6666 "SHA256_INPUT_CHUNK_SIZE_FELTS" ,
6767 identifiers,
6868 accessible_scopes,
69- ) ?
70- . to_usize ( )
71- . unwrap_or ( 100 ) ; // Hack: enough to fail the assertion
72-
73- if input_chunk_size_felts >= 100 {
74- return Err ( HintError :: AssertionFailed (
75- "assert 0 <= _sha256_input_chunk_size_felts < 100"
76- . to_string ( )
77- . into_boxed_str ( ) ,
78- ) ) ;
79- }
69+ ) ?;
70+
71+ // The input chunk size must be less than 100.
72+ let input_chunk_size_felts = match input_chunk_size_felts. to_usize ( ) {
73+ Some ( size) if size < 100 => size,
74+ _ => {
75+ return Err ( HintError :: AssertionFailed (
76+ "assert 0 <= _sha256_input_chunk_size_felts < 100"
77+ . to_string ( )
78+ . into_boxed_str ( ) ,
79+ ) ) ;
80+ }
81+ } ;
8082
8183 let mut message: Vec < u8 > = Vec :: with_capacity ( 4 * input_chunk_size_felts) ;
8284
You can’t perform that action at this time.
0 commit comments