address veridise feedback for V-SCT-VUL-007 and V-SCT-VUL-011 (hasInv needed to be constrained)
Kevin Jue kjue235@gmail.com
Tue, 26 Dec 2023 07:49:55 -0800
1 files changed,
3 insertions(+),
8 deletions(-)
jump to
M
goldilocks/base.go
→
goldilocks/base.go
@@ -224,13 +224,14 @@ }
// Computes the inverse of a field element x such that x * x^-1 = 1. func (p *Chip) Inverse(x Variable) (Variable, frontend.Variable) { - result, err := p.api.Compiler().NewHint(InverseHint, 2, x.Limb) + result, err := p.api.Compiler().NewHint(InverseHint, 1, x.Limb) if err != nil { panic(err) } inverse := NewVariable(result[0]) - hasInv := frontend.Variable(result[1]) + isZero := p.api.IsZero(x.Limb) + hasInv := p.api.Sub(1, isZero) p.RangeCheck(inverse) product := p.Mul(inverse, x)@@ -259,12 +260,6 @@ resultGl.Inverse(&inputGl)
result := big.NewInt(0) results[0] = resultGl.BigInt(result) - - hasInvInt64 := int64(0) - if !inputGl.IsZero() { - hasInvInt64 = 1 - } - results[1] = big.NewInt(hasInvInt64) return nil }