Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
move 16 byte check to fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Sep 12, 2023
1 parent f724ec3 commit bbb307f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions blackbox_solver/src/barretenberg/wasm/scalar_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ impl ScalarMul for Barretenberg {
let low_bytes = low.to_be_bytes();
let high_bytes = high.to_be_bytes();

let low_16_bytes = low_bytes[16..32].to_vec();
let high_16_bytes = high_bytes[16..32].to_vec();

let mut bytes = high_16_bytes.to_vec();
bytes.extend_from_slice(&low_16_bytes);

let two_pow_128 = BigUint::from(2u128).pow(128);
if BigUint::from_bytes_be(&low_16_bytes) >= two_pow_128 {
if BigUint::from_bytes_be(&low_bytes) >= two_pow_128 {
return Err(Error::FromFeature(FeatureError::InvalidGrumpkinScalarLimb {
limb_as_hex: hex::encode(low_16_bytes),
limb_as_hex: hex::encode(low_bytes),
}));
}
if BigUint::from_bytes_be(&high_16_bytes) >= two_pow_128 {
if BigUint::from_bytes_be(&high_bytes) >= two_pow_128 {
return Err(Error::FromFeature(FeatureError::InvalidGrumpkinScalarLimb {
limb_as_hex: hex::encode(high_16_bytes),
limb_as_hex: hex::encode(high_bytes),
}));
}

let low_16_bytes = low_bytes[16..32].to_vec();
let high_16_bytes = high_bytes[16..32].to_vec();

let mut bytes = high_16_bytes.to_vec();
bytes.extend_from_slice(&low_16_bytes);

// Check if this is smaller than the grumpkin modulus
let grumpkin_integer = BigUint::from_bytes_be(&bytes);
let grumpkin_modulus = BigUint::from_bytes_be(&[
Expand Down

0 comments on commit bbb307f

Please sign in to comment.