arnaucube
arnaucube/gnark-plonky2-verifierPublic Self-hosted repository
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
commit

d241f54f485be2ba27ee23642aa2090004ef8b83

parent

1a0372621cbc4aa8f76623cae72caec04db530a3

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 }