Skip to content

Commit

Permalink
wiht inv f opt
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas committed Jul 31, 2024
1 parent b7cfdfe commit b56bb4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions recursion/gnark-ffi/go/sp1/babybear/babybear.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c *Chip) negF(a Variable) Variable {
}

func (c *Chip) invF(in Variable) Variable {
in = c.ReduceSlow(in)
// in = c.ReduceSlow(in)
result, err := c.api.Compiler().NewHint(InvFHint, 1, in.Value)
if err != nil {
panic(err)
Expand Down Expand Up @@ -346,7 +346,9 @@ func ReduceHint(_ *big.Int, inputs []*big.Int, results []*big.Int) error {
}

func InvFHint(_ *big.Int, inputs []*big.Int, results []*big.Int) error {
a := C.uint(inputs[0].Uint64())
p := big.NewInt(15*(1<<27) + 1)
aReduced := new(big.Int).Mod(inputs[0], p)
a := C.uint(aReduced.Uint64())
ainv := C.babybearinv(a)
results[0].SetUint64(uint64(ainv))
return nil
Expand Down

0 comments on commit b56bb4a

Please sign in to comment.