mirror of
https://github.com/logos-storage/gnark-plonky2-verifier.git
synced 2026-05-01 22:53:09 +00:00
* 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 hash 85d20ce and 9617141
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package gates
|
|
|
|
import (
|
|
"regexp"
|
|
|
|
"github.com/consensys/gnark/frontend"
|
|
gl "github.com/succinctlabs/gnark-plonky2-verifier/goldilocks"
|
|
)
|
|
|
|
var publicInputGateRegex = regexp.MustCompile("PublicInputGate")
|
|
|
|
func deserializePublicInputGate(parameters map[string]string) Gate {
|
|
// Has the format "PublicInputGate"
|
|
return NewPublicInputGate()
|
|
}
|
|
|
|
type PublicInputGate struct {
|
|
}
|
|
|
|
func NewPublicInputGate() *PublicInputGate {
|
|
return &PublicInputGate{}
|
|
}
|
|
|
|
func (g *PublicInputGate) Id() string {
|
|
return "PublicInputGate"
|
|
}
|
|
|
|
func (g *PublicInputGate) WiresPublicInputsHash() []uint64 {
|
|
return []uint64{0, 1, 2, 3}
|
|
}
|
|
|
|
func (g *PublicInputGate) EvalUnfiltered(
|
|
api frontend.API,
|
|
glApi *gl.Chip,
|
|
vars EvaluationVars,
|
|
) []gl.QuadraticExtensionVariable {
|
|
constraints := []gl.QuadraticExtensionVariable{}
|
|
|
|
wires := g.WiresPublicInputsHash()
|
|
hash_parts := vars.publicInputsHash
|
|
for i := 0; i < len(wires); i++ {
|
|
wire := wires[i]
|
|
hash_part := hash_parts[i]
|
|
|
|
tmp := gl.NewQuadraticExtensionVariable(hash_part, gl.Zero())
|
|
diff := glApi.SubExtension(vars.localWires[wire], tmp)
|
|
constraints = append(constraints, diff)
|
|
}
|
|
|
|
return constraints
|
|
}
|