Skip to content
38 changes: 24 additions & 14 deletions vm/src/hint_processor/builtin_hint_processor/secp/secp_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ mod tests {
.to_biguint()
.expect("Couldn't convert to BigUint"),
);
//TODO, Check SecpSplitutOfRange limit
let array_4 = bigint3_split(
&bigint_str!(
"773712524553362671811952647737125245533626718119526477371252455336267181195264"
)
.to_biguint()
.expect("Couldn't convert to BigUint"),
);

let max_value = &*BASE * &*BASE * &*BASE - BigUint::from(1u32);
let over_max_value = &*BASE * &*BASE * &*BASE;
let way_over_max_value = &*BASE * &*BASE * &*BASE * &*BASE;

let array_max = bigint3_split(&max_value);
let array_over_max = bigint3_split(&over_max_value);
let array_way_over_max = bigint3_split(&way_over_max_value);

assert_matches!(
array_1,
Expand Down Expand Up @@ -158,14 +158,24 @@ mod tests {
.expect("Couldn't convert to BigUint")
]
);

assert_matches!(
array_4,
Err(HintError::SecpSplitOutOfRange(bx)) if *bx == bigint_str!(
"773712524553362671811952647737125245533626718119526477371252455336267181195264"
)
.to_biguint()
.expect("Couldn't convert to BigUint")
array_max,
Ok(x) if x == [
BASE_MINUS_ONE.clone(),
BASE_MINUS_ONE.clone(),
BASE_MINUS_ONE.clone()
]
);

assert_matches!(
array_over_max,
Err(HintError::SecpSplitOutOfRange(bx)) if *bx == over_max_value
);

assert_matches!(
array_way_over_max,
Err(HintError::SecpSplitOutOfRange(bx)) if *bx == way_over_max_value
);
}
}
Loading