From b1da315ccb7831d0a654d4e903b7daef3b4dce2a Mon Sep 17 00:00:00 2001 From: Tamir Hemo Date: Fri, 27 Sep 2024 10:22:43 -0700 Subject: [PATCH] fix: gnark ffi fixes (#1554) --- .../gnark-ffi/go/sp1/babybear/babybear.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/recursion/gnark-ffi/go/sp1/babybear/babybear.go b/crates/recursion/gnark-ffi/go/sp1/babybear/babybear.go index 55cacdc51a..4d448c5d19 100644 --- a/crates/recursion/gnark-ffi/go/sp1/babybear/babybear.go +++ b/crates/recursion/gnark-ffi/go/sp1/babybear/babybear.go @@ -313,7 +313,7 @@ func (c *Chip) ToBinary(in Variable) []frontend.Variable { } func (p *Chip) reduceFast(x Variable) Variable { - if x.NbBits >= uint(120) { + if x.NbBits >= uint(126) { return Variable{ Value: p.reduceWithMaxBits(x.Value, uint64(x.NbBits)), NbBits: 31, @@ -344,12 +344,12 @@ func (p *Chip) reduceWithMaxBits(x frontend.Variable, maxNbBits uint64) frontend quotient := result[0] remainder := result[1] - // TODO: Fix before 1.3.0. - // if os.Getenv("GROTH16") != "1" { - // p.RangeChecker.Check(quotient, int(maxNbBits-30)) - // } else { - // p.api.ToBinary(quotient, int(maxNbBits-30)) - // } + if os.Getenv("GROTH16") != "1" { + p.RangeChecker.Check(quotient, int(maxNbBits-30)) + } else { + p.api.ToBinary(quotient, int(maxNbBits-30)) + } + // Check that the remainder has size less than the BabyBear modulus, by decomposing it into a 27 // bit limb and a 4 bit limb. new_result, new_err := p.api.Compiler().NewHint(SplitLimbsHint, 2, remainder)