Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
The scalar to be multiplied by should be at most num_limbs long (#171)
Browse files Browse the repository at this point in the history
Co-authored-by: Pratyush Mishra <[email protected]>
  • Loading branch information
mmagician and Pratyush authored Sep 11, 2023
1 parent 7e4b4bf commit 8765798
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions curve-constraint-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,14 @@ pub mod curves {
}
assert!(cs.is_satisfied().unwrap());

let modulus = <C::ScalarField as PrimeField>::MODULUS.as_ref().to_vec();
let modulus = C::ScalarField::MODULUS.as_ref().to_vec();
let mut max = modulus.clone();
for limb in &mut max {
*limb = u64::MAX;
}

let num_limbs = max.len();

let modulus_num_bits_mod_64 = <C::ScalarField as PrimeField>::MODULUS_BIT_SIZE % 64;
if modulus_num_bits_mod_64 != 0 {
*max.last_mut().unwrap() >>= 64 - modulus_num_bits_mod_64;
Expand All @@ -332,10 +334,10 @@ pub mod curves {
.to_vec(),
vec![u64::rand(&mut rng)],
(-C::ScalarField::one()).into_bigint().as_ref().to_vec(),
<C::ScalarField as PrimeField>::MODULUS.as_ref().to_vec(),
modulus,
max,
vec![0; 50],
vec![1000012341233u64; 36],
vec![0u64; num_limbs],
vec![1000012341233u64; num_limbs],
];

let mut input = vec![];
Expand Down

0 comments on commit 8765798

Please sign in to comment.