Skip to content

Commit

Permalink
Improves error message for scalar limit value check
Browse files Browse the repository at this point in the history
  • Loading branch information
raugfer committed Sep 11, 2024
1 parent 3f33a18 commit 11a5ca6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions tools/garaga_rs/src/msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ where
{
let elements = field_elements_from_big_uints::<F>(values);
let points = parse_g1_points_from_flattened_field_elements_list(&elements)?;
let n = &element_to_biguint(&F::get_curve_params().n);
let max = &(BigUint::from(1usize) << 128);
let limit = if risc0_mode && n > max { max } else { n };
let limit = if risc0_mode {
&(BigUint::from(1usize) << 128)
} else {
&element_to_biguint(&F::get_curve_params().n)
};
if !scalars.iter().all(|x| x < limit) {
return Err(
"Scalar value must be less than the curve order or fit in 128 bits".to_string(),
);
if risc0_mode {
return Err("Scalar value must be less than 2**128".to_string());
} else {
return Err("Scalar value must be less than the curve order".to_string());
}
}
Ok(calldata_builder(
&points,
Expand Down
2 changes: 1 addition & 1 deletion tools/npm/garaga_rs/src/wasm/pkg/garaga_rs_bg.wasm.js

Large diffs are not rendered by default.

0 comments on commit 11a5ca6

Please sign in to comment.