mirror of
https://github.com/arnaucube/gnark-plonky2-verifier.git
synced 2026-01-12 09:01:32 +01:00
Upgrade to gnark 0.8 (#18)
* make proof with PIS public input * upgraded to 0.8 gnark * reduced pow witness * fixed bug * fixed test * fixed bug * adding profiling * changed everything to be pointers * convert remaining poseidon constants * added the recursive_very_small * added more outputs for benchmark
This commit is contained in:
@@ -7,40 +7,68 @@ import (
|
||||
|
||||
type MerkleCap = []poseidon.Hash
|
||||
|
||||
func NewMerkleCap(capHeight uint64) MerkleCap {
|
||||
return make([]poseidon.Hash, 1<<capHeight)
|
||||
}
|
||||
|
||||
type MerkleProof struct {
|
||||
Siblings []poseidon.Hash
|
||||
Siblings []poseidon.Hash // Length = CircuitConfig.FriConfig.DegreeBits + CircuitConfig.FriConfig.RateBits - CircuitConfig.FriConfig.CapHeight
|
||||
}
|
||||
|
||||
func NewMerkleProof(merkleProofLen uint64) MerkleProof {
|
||||
return MerkleProof{Siblings: make([]poseidon.Hash, merkleProofLen)}
|
||||
}
|
||||
|
||||
type EvalProof struct {
|
||||
Elements []field.F
|
||||
Elements []field.F // Length = [CommonCircuitData.Constants + CommonCircuitData.NumRoutedWires, CommonCircuitData.NumWires + CommonCircuitData.FriParams.Hiding ? 4 : 0, CommonCircuitData.NumChallenges * (1 + CommonCircuitData.NumPartialProducts) + salt, CommonCircuitData.NumChallenges * CommonCircuitData.QuotientDegreeFactor + salt]
|
||||
MerkleProof MerkleProof
|
||||
}
|
||||
|
||||
func NewEvalProof(elements []field.F, merkleProof MerkleProof) EvalProof {
|
||||
return EvalProof{Elements: elements, MerkleProof: merkleProof}
|
||||
}
|
||||
|
||||
type PolynomialCoeffs struct {
|
||||
Coeffs []field.QuadraticExtension
|
||||
}
|
||||
|
||||
func NewPolynomialCoeffs(numCoeffs uint64) PolynomialCoeffs {
|
||||
return PolynomialCoeffs{Coeffs: make([]field.QuadraticExtension, numCoeffs)}
|
||||
}
|
||||
|
||||
type OpeningSet struct {
|
||||
Constants []field.QuadraticExtension
|
||||
PlonkSigmas []field.QuadraticExtension
|
||||
Wires []field.QuadraticExtension
|
||||
PlonkZs []field.QuadraticExtension
|
||||
PlonkZsNext []field.QuadraticExtension
|
||||
PartialProducts []field.QuadraticExtension
|
||||
QuotientPolys []field.QuadraticExtension
|
||||
Constants []field.QuadraticExtension // Length = CommonCircuitData.Constants
|
||||
PlonkSigmas []field.QuadraticExtension // Length = CommonCircuitData.NumRoutedWires
|
||||
Wires []field.QuadraticExtension // Length = CommonCircuitData.NumWires
|
||||
PlonkZs []field.QuadraticExtension // Length = CommonCircuitData.NumChallenges
|
||||
PlonkZsNext []field.QuadraticExtension // Length = CommonCircuitData.NumChallenges
|
||||
PartialProducts []field.QuadraticExtension // Length = CommonCircuitData.NumChallenges * CommonCircuitData.NumPartialProducts
|
||||
QuotientPolys []field.QuadraticExtension // Length = CommonCircuitData.NumChallenges * CommonCircuitData.QuotientDegreeFactor
|
||||
}
|
||||
|
||||
func NewOpeningSet(numConstants uint64, numRoutedWires uint64, numWires uint64, numChallenges uint64, numPartialProducts uint64, quotientDegreeFactor uint64) OpeningSet {
|
||||
return OpeningSet{
|
||||
Constants: make([]field.QuadraticExtension, numConstants),
|
||||
PlonkSigmas: make([]field.QuadraticExtension, numRoutedWires),
|
||||
Wires: make([]field.QuadraticExtension, numWires),
|
||||
PlonkZs: make([]field.QuadraticExtension, numChallenges),
|
||||
PlonkZsNext: make([]field.QuadraticExtension, numChallenges),
|
||||
PartialProducts: make([]field.QuadraticExtension, numChallenges*numPartialProducts),
|
||||
QuotientPolys: make([]field.QuadraticExtension, numChallenges*quotientDegreeFactor),
|
||||
}
|
||||
}
|
||||
|
||||
type Proof struct {
|
||||
WiresCap MerkleCap
|
||||
PlonkZsPartialProductsCap MerkleCap
|
||||
QuotientPolysCap MerkleCap
|
||||
WiresCap MerkleCap // length = 2^CircuitConfig.FriConfig.CapHeight
|
||||
PlonkZsPartialProductsCap MerkleCap // length = 2^CircuitConfig.FriConfig.CapHeight
|
||||
QuotientPolysCap MerkleCap // length = 2^CircuitConfig.FriConfig.CapHeight
|
||||
Openings OpeningSet
|
||||
OpeningProof FriProof
|
||||
}
|
||||
|
||||
type ProofWithPublicInputs struct {
|
||||
Proof Proof
|
||||
PublicInputs []field.F
|
||||
PublicInputs []field.F // Length = CommonCircuitData.NumPublicInputs
|
||||
}
|
||||
|
||||
type ProofChallenges struct {
|
||||
@@ -52,22 +80,37 @@ type ProofChallenges struct {
|
||||
}
|
||||
|
||||
type FriInitialTreeProof struct {
|
||||
EvalsProofs []EvalProof
|
||||
EvalsProofs []EvalProof // Length = 4
|
||||
}
|
||||
|
||||
func NewFriInitialTreeProof(evalsProofs []EvalProof) FriInitialTreeProof {
|
||||
return FriInitialTreeProof{EvalsProofs: evalsProofs}
|
||||
}
|
||||
|
||||
type FriQueryStep struct {
|
||||
Evals []field.QuadraticExtension
|
||||
MerkleProof MerkleProof
|
||||
Evals []field.QuadraticExtension // Length = [2^arityBit for arityBit in CommonCircuitData.FriParams.ReductionArityBits]
|
||||
MerkleProof MerkleProof // Length = [regularSize - arityBit for arityBit in CommonCircuitData.FriParams.ReductionArityBits]
|
||||
}
|
||||
|
||||
func NewFriQueryStep(arityBit uint64, merkleProofLen uint64) FriQueryStep {
|
||||
return FriQueryStep{
|
||||
Evals: make([]field.QuadraticExtension, 1<<arityBit),
|
||||
MerkleProof: NewMerkleProof(merkleProofLen),
|
||||
}
|
||||
}
|
||||
|
||||
type FriQueryRound struct {
|
||||
InitialTreesProof FriInitialTreeProof
|
||||
Steps []FriQueryStep
|
||||
Steps []FriQueryStep // Length = Len(CommonCircuitData.FriParams.ReductionArityBits)
|
||||
}
|
||||
|
||||
func NewFriQueryRound(steps []FriQueryStep, initialTreesProof FriInitialTreeProof) FriQueryRound {
|
||||
return FriQueryRound{InitialTreesProof: initialTreesProof, Steps: steps}
|
||||
}
|
||||
|
||||
type FriProof struct {
|
||||
CommitPhaseMerkleCaps []MerkleCap
|
||||
QueryRoundProofs []FriQueryRound
|
||||
CommitPhaseMerkleCaps []MerkleCap // Length = Len(CommonCircuitData.FriParams.ReductionArityBits)
|
||||
QueryRoundProofs []FriQueryRound // Length = CommonCircuitData.FriConfig.FriParams.NumQueryRounds
|
||||
FinalPoly PolynomialCoeffs
|
||||
PowWitness field.F
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user