Skip to content

Commit

Permalink
ambitious
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas committed Aug 1, 2024
1 parent d5c510e commit 9e980eb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions recursion/gnark-ffi/go/sp1/babybear/babybear.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,18 @@ func (c *Chip) negF(a Variable) Variable {
return Variable{Value: c.api.Sub(modulus, a.Value), NbBits: 31}
}

negOne := NewF("2013265920")
return c.MulF(a, negOne)
ub := new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(a.NbBits)), big.NewInt(0))
divisor := new(big.Int).Div(ub, modulus)
divisorPlusOne := new(big.Int).Add(divisor, big.NewInt(1))
liftedModulus := new(big.Int).Mul(divisorPlusOne, modulus)

return Variable{
Value: c.api.Sub(liftedModulus, a.Value),
NbBits: a.NbBits,
}

// negOne := NewF("2013265920")
// return c.MulF(a, negOne)
}

func (c *Chip) invF(in Variable) Variable {
Expand Down

0 comments on commit 9e980eb

Please sign in to comment.