Browse Source

address veridise feedback for V-SCT-VUL-007 and V-SCT-VUL-011 (hasInv needed to be constrained)

main
Kevin Jue 1 year ago
parent
commit
d241f54f48
1 changed files with 3 additions and 8 deletions
  1. +3
    -8
      goldilocks/base.go

+ 3
- 8
goldilocks/base.go

@ -224,13 +224,14 @@ func ReduceHint(_ *big.Int, inputs []*big.Int, results []*big.Int) error {
// 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)
@ -260,12 +261,6 @@ func InverseHint(_ *big.Int, inputs []*big.Int, results []*big.Int) error {
result := big.NewInt(0)
results[0] = resultGl.BigInt(result)
hasInvInt64 := int64(0)
if !inputGl.IsZero() {
hasInvInt64 = 1
}
results[1] = big.NewInt(hasInvInt64)
return nil
}

Loading…
Cancel
Save