File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
target_chains/starknet/contracts/src Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,12 @@ impl HasherPrivateImpl of HasherPrivateTrait {
97
97
// Adds specified number of bytes to the buffer.
98
98
fn push_num_bytes (ref self : Hasher , value : u64 , num_bytes : u8 ) {
99
99
assert! (num_bytes <= 8 , " num_bytes too high in Hasher::push_num_bytes" );
100
+ if num_bytes != 8 {
101
+ assert! (
102
+ value / one_shift_left_bytes_u64 (num_bytes ) == 0 ,
103
+ " Hasher::push_num_bytes: value is too large"
104
+ );
105
+ }
100
106
let num_high_bytes = min (num_bytes , 8 - self . num_last_bytes);
101
107
let num_low_bytes = num_bytes - num_high_bytes ;
102
108
let divisor = one_shift_left_bytes_u64 (num_low_bytes ). try_into (). expect (UNEXPECTED_ZERO );
@@ -107,6 +113,12 @@ impl HasherPrivateImpl of HasherPrivateTrait {
107
113
108
114
fn push_to_last (ref self : Hasher , value : u64 , num_bytes : u8 ) {
109
115
assert! (num_bytes <= 8 - self . num_last_bytes, " num_bytes too high in Hasher::push_to_last" );
116
+ if num_bytes != 8 {
117
+ assert! (
118
+ value / one_shift_left_bytes_u64 (num_bytes ) == 0 ,
119
+ " Hasher::push_to_last: value is too large"
120
+ );
121
+ }
110
122
if num_bytes == 8 {
111
123
self . last_be = value ;
112
124
} else {
You can’t perform that action at this time.
0 commit comments