Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: proper field inversion for bigints #4802

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/pwg/blackbox/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}
BlackBoxFunc::BigIntMul => lhs * rhs,
BlackBoxFunc::BigIntDiv => {
lhs * rhs.modpow(&(&modulus - BigUint::from(1_u32)), &modulus)
lhs * rhs.modpow(&(&modulus - BigUint::from(2_u32)), &modulus)

Check warning on line 108 in acvm-repo/acvm/src/pwg/blackbox/bigint.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (modpow)
} //TODO ensure that modulus is prime
_ => unreachable!("ICE - bigint_op must be called for an operation"),
};
Expand Down
8 changes: 4 additions & 4 deletions test_programs/execution_success/bigint/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ fn main(mut x: [u8; 5], y: [u8; 5]) {
assert(a_bytes[i] == x[i]);
assert(b_bytes[i] == y[i]);
}
//Regression for issue #4578
let d = a * b;
assert(d / b == a);

let d = a * b - b;
let d1 = bigint::Secpk1Fq::from_le_bytes(597243850900842442924.to_le_bytes(10));
assert(d1 == d);
// big_int_example(x[0], x[1]);
big_int_example(x[0], x[1]);
}

// docs:start:big_int_example
Expand Down
Loading