mirror of
https://github.com/arnaucube/gnark-plonky2-verifier.git
synced 2026-01-12 00:51:33 +01:00
fix: Support range checking non aligned bitwidth values (#47)
* initial commit * most of the code done * made global poseidon chip * changed decompSize and added some panics * made all gl chip as pointers * working code * revert go.mod and go.sum * cleanup and comments * cleaned up range checker selection * renamed gnarkRangeCheckSelector to gnarkRangeCheckerSelector * addressed PR comment * addressed overflow issue identified by Veridise * added some comments * fixed some comment typos * restore change made from commit hash85d20ceand9617141
This commit is contained in:
@@ -58,7 +58,7 @@ func (g *ArithmeticExtensionGate) wiresIthOutput(i uint64) Range {
|
||||
|
||||
func (g *ArithmeticExtensionGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
const0 := vars.localConstants[0]
|
||||
|
||||
@@ -59,7 +59,7 @@ func (g *ArithmeticGate) WireIthOutput(i uint64) uint64 {
|
||||
|
||||
func (g *ArithmeticGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
const0 := vars.localConstants[0]
|
||||
|
||||
@@ -65,7 +65,7 @@ func (g *BaseSumGate) limbs() []uint64 {
|
||||
|
||||
func (g *BaseSumGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
sum := vars.localWires[BASESUM_GATE_WIRE_SUM]
|
||||
|
||||
@@ -56,7 +56,7 @@ func (g *ConstantGate) WireOutput(i uint64) uint64 {
|
||||
|
||||
func (g *ConstantGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
constraints := []gl.QuadraticExtensionVariable{}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (g *CosetInterpolationGate) wiresShiftedEvaluationPoint() Range {
|
||||
|
||||
func (g *CosetInterpolationGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
constraints := []gl.QuadraticExtensionVariable{}
|
||||
|
||||
@@ -67,7 +67,7 @@ func (g *EvaluateGatesChip) evalFiltered(
|
||||
|
||||
vars.RemovePrefix(numSelectors)
|
||||
|
||||
unfiltered := gate.EvalUnfiltered(g.api, *glApi, vars)
|
||||
unfiltered := gate.EvalUnfiltered(g.api, glApi, vars)
|
||||
for i := range unfiltered {
|
||||
unfiltered[i] = glApi.MulExtension(unfiltered[i], filter)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (g *ExponentiationGate) wireIntermediateValue(i uint64) uint64 {
|
||||
|
||||
func (g *ExponentiationGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
base := vars.localWires[g.wireBase()]
|
||||
|
||||
@@ -12,7 +12,7 @@ type Gate interface {
|
||||
Id() string
|
||||
EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable
|
||||
}
|
||||
|
||||
@@ -697,7 +697,7 @@ func (circuit *TestGateCircuit) Define(api frontend.API) error {
|
||||
|
||||
vars := gates.NewEvaluationVars(localConstants[numSelectors:], localWires, publicInputsHash)
|
||||
|
||||
constraints := circuit.testGate.EvalUnfiltered(api, *glApi, *vars)
|
||||
constraints := circuit.testGate.EvalUnfiltered(api, glApi, *vars)
|
||||
|
||||
if len(constraints) != len(circuit.ExpectedConstraints) {
|
||||
return errors.New("gate constraints length mismatch")
|
||||
|
||||
@@ -54,7 +54,7 @@ func (g *MultiplicationExtensionGate) wiresIthOutput(i uint64) Range {
|
||||
|
||||
func (g *MultiplicationExtensionGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
const0 := vars.localConstants[0]
|
||||
|
||||
@@ -27,7 +27,7 @@ func (g *NoopGate) Id() string {
|
||||
|
||||
func (g *NoopGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
return []gl.QuadraticExtensionVariable{}
|
||||
|
||||
@@ -91,7 +91,7 @@ func (g *PoseidonGate) WiresEnd() uint64 {
|
||||
|
||||
func (g *PoseidonGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
constraints := []gl.QuadraticExtensionVariable{}
|
||||
|
||||
@@ -75,7 +75,7 @@ func (g *PoseidonMdsGate) mdsLayerAlgebra(
|
||||
|
||||
func (g *PoseidonMdsGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
constraints := []gl.QuadraticExtensionVariable{}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (g *PublicInputGate) WiresPublicInputsHash() []uint64 {
|
||||
|
||||
func (g *PublicInputGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
constraints := []gl.QuadraticExtensionVariable{}
|
||||
|
||||
@@ -130,7 +130,7 @@ func (g *RandomAccessGate) WireBit(i uint64, copy uint64) uint64 {
|
||||
|
||||
func (g *RandomAccessGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
two := gl.NewVariable(2).ToQuadraticExtension()
|
||||
|
||||
@@ -76,7 +76,7 @@ func (g *ReducingExtensionGate) wiresAccs(i uint64) Range {
|
||||
|
||||
func (g *ReducingExtensionGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
alpha := vars.GetLocalExtAlgebra(g.wiresAlpha())
|
||||
|
||||
@@ -76,7 +76,7 @@ func (g *ReducingGate) wiresAccs(i uint64) Range {
|
||||
|
||||
func (g *ReducingGate) EvalUnfiltered(
|
||||
api frontend.API,
|
||||
glApi gl.Chip,
|
||||
glApi *gl.Chip,
|
||||
vars EvaluationVars,
|
||||
) []gl.QuadraticExtensionVariable {
|
||||
alpha := vars.GetLocalExtAlgebra(g.wiresAlpha())
|
||||
|
||||
Reference in New Issue
Block a user