Fixed underconstrained in range check and added dummy mode to benchmark.go

This commit is contained in:
Uma Roy
2023-10-11 00:28:20 -07:00
parent e026e73359
commit d8b919a403
2 changed files with 26 additions and 3 deletions

View File

@@ -323,8 +323,18 @@ func (p *GoldilocksApi) RangeCheck(x GoldilocksVariable) {
panic(err)
}
// We check that this is a valid decomposition of the Goldilock's element and range-check each limb.
mostSigBits := result[0]
leastSigBits := result[1]
p.api.AssertIsEqual(
p.api.Add(
p.api.Mul(mostSigBits, uint64(math.Pow(2, 32))),
leastSigBits,
),
x.Limb,
)
rangeChecker.Check(mostSigBits, 32)
rangeChecker.Check(leastSigBits, 32)
// If the most significant bits are all 1, then we need to check that the least significant bits are all zero
// in order for element to be less than the Goldilock's modulus.