Skip to content

Commit

Permalink
perf: save 4 scs in lookup2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
yelhousni committed Mar 3, 2024
1 parent 7cc8816 commit a883c92
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions frontend/cs/scs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,11 @@ func (builder *builder) Lookup2(b0, b1 frontend.Variable, i0, i1, i2, i3 fronten
// (3) (in2 - in0) * s1 = RES - tmp2 - in0
// the variables tmp1 and tmp2 are new internal variables and the variables
// RES will be the returned result

// TODO check how it can be optimized for PLONK (currently it's a copy
// paste of the r1cs version)
tmp1 := builder.Add(i3, i0)
tmp1 = builder.Sub(tmp1, i2, i1)
tmp1 := builder.Sub(i3, i2)
tmp := builder.Sub(i0, i1)
tmp1 = builder.Add(tmp1, tmp)
tmp1 = builder.Mul(tmp1, b1)
tmp1 = builder.Add(tmp1, i1)
tmp1 = builder.Sub(tmp1, i0) // (1) tmp1 = s1 * (in3 - in2 - in1 + in0) + in1 - in0
tmp1 = builder.Sub(tmp1, tmp) // (1) tmp1 = s1 * (in3 - in2 - in1 + in0) + in1 - in0
tmp2 := builder.Mul(tmp1, b0) // (2) tmp2 = tmp1 * s0
res := builder.Sub(i2, i0)
res = builder.Mul(res, b1)
Expand Down

0 comments on commit a883c92

Please sign in to comment.