@@ -373,16 +373,6 @@ pub fn poseidon_hash_many_cost(data_length: usize) -> ExecutionResources {
373
373
}
374
374
}
375
375
376
- // Constants that define how felts are encoded into u32s for BLAKE hashing.
377
- mod blake_encoding {
378
- // Number of `u32` words in a single BLAKE input message block.
379
- pub ( crate ) const U32_WORDS_PER_MESSAGE : usize = 16 ;
380
- // Number of `u32` words a large felt expands into.
381
- pub ( crate ) const U32_WORDS_PER_LARGE_FELT : usize = 8 ;
382
- // Number of `u32` words a small felt expands into.
383
- pub ( crate ) const U32_WORDS_PER_SMALL_FELT : usize = 2 ;
384
- }
385
-
386
376
// Constants used for estimating the cost of BLAKE hashing inside Starknet OS.
387
377
// These values are based on empirical measurement by running
388
378
// `encode_felt252_data_and_calc_blake_hash` on various combinations of big and small felts.
@@ -408,16 +398,16 @@ mod blake_estimation {
408
398
/// Big felts encode to 8 u32s each, small felts encode to 2 u32s each.
409
399
fn total_u32s_from_felts ( n_big_felts : usize , n_small_felts : usize ) -> usize {
410
400
let big_u32s = n_big_felts
411
- . checked_mul ( blake_encoding :: U32_WORDS_PER_LARGE_FELT )
401
+ . checked_mul ( FeltSizeCount :: U32_WORDS_PER_LARGE_FELT )
412
402
. expect ( "Overflow computing big felts u32s" ) ;
413
403
let small_u32s = n_small_felts
414
- . checked_mul ( blake_encoding :: U32_WORDS_PER_SMALL_FELT )
404
+ . checked_mul ( FeltSizeCount :: U32_WORDS_PER_SMALL_FELT )
415
405
. expect ( "Overflow computing small felts u32s" ) ;
416
406
big_u32s. checked_add ( small_u32s) . expect ( "Overflow computing total u32s" )
417
407
}
418
408
419
409
fn base_steps_for_blake_hash ( n_u32s : usize ) -> usize {
420
- let rem_u32s = n_u32s % blake_encoding :: U32_WORDS_PER_MESSAGE ;
410
+ let rem_u32s = n_u32s % FeltSizeCount :: U32_WORDS_PER_MESSAGE ;
421
411
if rem_u32s == 0 {
422
412
blake_estimation:: BASE_STEPS_FULL_MSG
423
413
} else {
@@ -461,7 +451,7 @@ fn estimate_steps_of_encode_felt252_data_and_calc_blake_hash(
461
451
fn count_blake_opcode ( felt_size_groups : & FeltSizeCount ) -> usize {
462
452
// Count the total number of u32s to be hashed.
463
453
let total_u32s = total_u32s_from_felts ( felt_size_groups. large , felt_size_groups. small ) ;
464
- total_u32s. div_ceil ( blake_encoding :: U32_WORDS_PER_MESSAGE )
454
+ total_u32s. div_ceil ( FeltSizeCount :: U32_WORDS_PER_MESSAGE )
465
455
}
466
456
467
457
/// Estimates resource usage for `encode_felt252_data_and_calc_blake_hash` in the Starknet OS.
0 commit comments