Skip to content

Commit

Permalink
fix: gnark ffi fixes (#1554)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirhemo authored Sep 27, 2024
1 parent 77f8c5f commit b1da315
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/recursion/gnark-ffi/go/sp1/babybear/babybear.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b1da315

Please sign in to comment.