You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
div method error for the new Bn254Fr in BigInt lib has recently been found and fixed, but there are still cases where it doesn't return expected outputs. Also, mul has a similar upper limit issue described below, which might be related to the bug in the division.
Expected Behavior
For the following test code:
fnmain(){// num = Fr's modulus - 1let num = field_to_bn254fr(21888242871839275222246405745257275088548364400416034343698204186575808495616);let num2 = field_to_bn254fr(3189391831712126);let ret = num.mul(num2);println(bn254fr_to_field(ret));// let exp = field_to_bn254fr(21888242871839275222246405745257275088548364400416034343698200997183976783491);// assert(ret.eq(exp));let ret = num.div(num2);println(bn254fr_to_field(ret));// let exp = field_to_bn254fr(17503393246338744135796705401862936143640286084087976183614677346605260623896);// assert(ret.eq(exp));}
where bn254fr_to_field and field_to_bn254fr are found here
expected outputs that can be computed by mul and divFr class in aztec.js is below.
// mul
0x30644e72e131a029b85045b68181585d2833e84879b9709143d6a0d7c8d23e83
// div
0x26b291cadf48b919fc0e28a1ff0727816d942d9bb5bdc03ea7d4d4ad5a985018
but the values i got for println are :
// mul
0x1569498e920eee22ea8c49c802b9f270b61bf490b42c2df555f62eba31994f4b
// div
0x2c441177496e0648260def25a86a4346f60a6df06d09a9032ecf3c751823a89b
Bug
Can't pinpoint what's the bug, but the following are the behaviors of the mul and div methods depending on different inputs, which might help find solutions.
1: when the numerator is not divisible in the normal division
As for division, the division outputs a wrong value if the numerator isn't divisible by the denominator in normal division. The size of numbers doesn't matter.
# Description
## Problem\*
Resolves#4882
## Summary\*
There were typos in bigint templates and also in curve modulus
definitions
## Additional Context
I don't understand how there could be so many typos, I thought I was
being cautious... I triple checked all the parameters this time!
## Documentation\*
Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.
# PR Checklist\*
- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Aim
div
method error for the newBn254Fr
inBigInt
lib has recently been found and fixed, but there are still cases where it doesn't return expected outputs. Also,mul
has a similar upper limit issue described below, which might be related to the bug in the division.Expected Behavior
For the following test code:
where
bn254fr_to_field
andfield_to_bn254fr
are found heremul
anddiv
Fr class in aztec.js is below.println
are :Bug
Can't pinpoint what's the bug, but the following are the behaviors of the
mul
anddiv
methods depending on different inputs, which might help find solutions.1: when the numerator is not divisible in the normal division
As for division, the division outputs a wrong value if the numerator isn't divisible by the denominator in normal division. The size of numbers doesn't matter.
example A:
example B:
but below passes
2: when the product of inputs exceeds bn254fr modulus
0x30644e72e131...3e1f593f0000001
mul
computes the wrong value when the outcome ofx * y
in the normal multiplication exceeds the modulus value.example case A: the product doesn't exceed modulus
example case B: the product does exceed modulus
To Reproduce
Minimal reproduction repo is here
Project Impact
Blocker
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
Compiled from source
Nargo Version
nargo version = 0.27.0 noirc version = 0.27.0+073563568e53f81d8ad0ca71e9e34e03174239ec
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: