mirror of
https://github.com/logos-storage/gnark-plonky2-verifier.git
synced 2026-01-05 22:53:09 +00:00
* initial commit of poseidon bn128 * got challenger working * deserialize is working * cleaned up deserialization function a bit * fixed challenger * add in the hack to the challenges * fixed some bugs in poseidon_bn128 * fri verification is working * some changes for benchmarking * added decode_block plonky2 data * initial commit for poseidon_mds_gate * updated gate test cases * working poseidon mds gate * full verifier test case working
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package gates
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
|
|
"github.com/consensys/gnark/frontend"
|
|
"github.com/succinctlabs/gnark-plonky2-verifier/field"
|
|
)
|
|
|
|
type Gate interface {
|
|
Id() string
|
|
EvalUnfiltered(api frontend.API, qeAPI *field.QuadraticExtensionAPI, vars EvaluationVars) []field.QuadraticExtension
|
|
}
|
|
|
|
var gateRegexHandlers = map[*regexp.Regexp]func(parameters map[string]string) Gate{
|
|
aritheticGateRegex: deserializeArithmeticGate,
|
|
aritheticExtensionGateRegex: deserializeExtensionArithmeticGate,
|
|
baseSumGateRegex: deserializeBaseSumGate,
|
|
constantGateRegex: deserializeConstantGate,
|
|
cosetInterpolationGateRegex: deserializeCosetInterpolationGate,
|
|
exponentiationGateRegex: deserializeExponentiationGate,
|
|
mulExtensionGateRegex: deserializeMulExtensionGate,
|
|
noopGateRegex: deserializeNoopGate,
|
|
poseidonGateRegex: deserializePoseidonGate,
|
|
poseidonMdsGateRegex: deserializePoseidonMdsGate,
|
|
publicInputGateRegex: deserializePublicInputGate,
|
|
randomAccessGateRegex: deserializeRandomAccessGate,
|
|
reducingExtensionGateRegex: deserializeReducingExtensionGate,
|
|
reducingGateRegex: deserializeReducingGate,
|
|
}
|
|
|
|
func GateInstanceFromId(gateId string) Gate {
|
|
for regex, handler := range gateRegexHandlers {
|
|
matches := regex.FindStringSubmatch(gateId)
|
|
if matches != nil {
|
|
parameters := make(map[string]string)
|
|
for i, name := range regex.SubexpNames() {
|
|
if i != 0 && name != "" {
|
|
parameters[name] = matches[i]
|
|
}
|
|
}
|
|
|
|
if matches != nil {
|
|
return handler(parameters)
|
|
}
|
|
}
|
|
}
|
|
panic(fmt.Sprintf("Unknown gate ID %s", gateId))
|
|
}
|