mirror of
https://github.com/arnaucube/gnark-plonky2-verifier.git
synced 2026-01-12 09:01:32 +01:00
deserialization
This commit is contained in:
75
plonky2_verifier/data/common_circuit_data.json
Normal file
75
plonky2_verifier/data/common_circuit_data.json
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"num_wires": 135,
|
||||||
|
"num_routed_wires": 80,
|
||||||
|
"num_constants": 2,
|
||||||
|
"use_base_arithmetic_gate": true,
|
||||||
|
"security_bits": 100,
|
||||||
|
"num_challenges": 2,
|
||||||
|
"zero_knowledge": false,
|
||||||
|
"max_quotient_degree_factor": 8,
|
||||||
|
"fri_config": {
|
||||||
|
"rate_bits": 3,
|
||||||
|
"cap_height": 4,
|
||||||
|
"proof_of_work_bits": 16,
|
||||||
|
"reduction_strategy": { "ConstantArityBits": [4, 5] },
|
||||||
|
"num_query_rounds": 28
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fri_params": {
|
||||||
|
"config": {
|
||||||
|
"rate_bits": 3,
|
||||||
|
"cap_height": 4,
|
||||||
|
"proof_of_work_bits": 16,
|
||||||
|
"reduction_strategy": { "ConstantArityBits": [4, 5] },
|
||||||
|
"num_query_rounds": 28
|
||||||
|
},
|
||||||
|
"hiding": false,
|
||||||
|
"degree_bits": 3,
|
||||||
|
"reduction_arity_bits": []
|
||||||
|
},
|
||||||
|
"degree_bits": 3,
|
||||||
|
"selectors_info": {
|
||||||
|
"selector_indices": [0, 0, 0, 1],
|
||||||
|
"groups": [
|
||||||
|
{ "start": 0, "end": 3 },
|
||||||
|
{ "start": 3, "end": 4 }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"quotient_degree_factor": 8,
|
||||||
|
"num_gate_constraints": 123,
|
||||||
|
"num_constants": 4,
|
||||||
|
"num_public_inputs": 3,
|
||||||
|
"k_is": [
|
||||||
|
1, 7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249,
|
||||||
|
1977326743, 13841287201, 96889010407, 678223072849, 4747561509943,
|
||||||
|
33232930569601, 232630513987207, 1628413597910449, 11398895185373143,
|
||||||
|
79792266297612001, 558545864083284007, 3909821048582988049,
|
||||||
|
8922003270666332022, 7113790686420571191, 12903046666114829695,
|
||||||
|
16534350385145470581, 5059988279530788141, 16973173887300932666,
|
||||||
|
8131752794619022736, 1582037354089406189, 11074261478625843323,
|
||||||
|
3732854072722565977, 7683234439643377518, 16889152938674473984,
|
||||||
|
7543606154233811962, 15911754940807515092, 701820169165099718,
|
||||||
|
4912741184155698026, 15942444219675301861, 916645121239607101,
|
||||||
|
6416515848677249707, 8022122801911579307, 814627405137302186,
|
||||||
|
5702391835961115302, 3023254712898638472, 2716038920875884983,
|
||||||
|
565528376716610560, 3958698637016273920, 9264146389699333119,
|
||||||
|
9508792519651578870, 11221315429317299127, 4762231727562756605,
|
||||||
|
14888878023524711914, 11988425817600061793, 10132004445542095267,
|
||||||
|
15583798910550913906, 16852872026783475737, 7289639770996824233,
|
||||||
|
14133990258148600989, 6704211459967285318, 10035992080941828584,
|
||||||
|
14911712358349047125, 12148266161370408270, 11250886851934520606,
|
||||||
|
4969231685883306958, 16337877731768564385, 3684679705892444769,
|
||||||
|
7346013871832529062, 14528608963998534792, 9466542400916821939,
|
||||||
|
10925564598174000610, 2691975909559666986, 397087297503084581,
|
||||||
|
2779611082521592067, 1010533508236560148, 7073734557655921036,
|
||||||
|
12622653764762278610, 14571600075677612986, 9767480182670369297
|
||||||
|
],
|
||||||
|
"num_partial_products": 9,
|
||||||
|
"circuit_digest": {
|
||||||
|
"elements": [
|
||||||
|
7754113318730736048, 18436136620016916513, 18054530212389526288,
|
||||||
|
5893739326632906028
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
6286
plonky2_verifier/data/proof_with_public_inputs.json
Normal file
6286
plonky2_verifier/data/proof_with_public_inputs.json
Normal file
File diff suppressed because it is too large
Load Diff
100
plonky2_verifier/data/verifier_only_circuit_data.json
Normal file
100
plonky2_verifier/data/verifier_only_circuit_data.json
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
"constants_sigmas_cap": [
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
2913805118787558759, 15605217703384212484, 9293436862297178555,
|
||||||
|
10529947991695419448
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
1937331278189251620, 17537260089483183877, 10458485670158100707,
|
||||||
|
4116443229550247591
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
8142760542024755709, 3845244796524514577, 16191049345326767258,
|
||||||
|
7348433903875207214
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
18274477257392359471, 9341197367296335592, 14314312946600883535,
|
||||||
|
17431979896521737468
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
12713790163422286570, 9838614764658999419, 3024549327814176904,
|
||||||
|
6544549858431318793
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
17461063081201329467, 1929790214678747830, 14738190695567211833,
|
||||||
|
4502436664569676311
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
17446087997043032816, 17518692693064701003, 4915378766449394412,
|
||||||
|
10675325761198739044
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
11349186227918507635, 7105572536043210156, 13296927306801261929,
|
||||||
|
6138189381388819111
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
17427080957162886576, 4310228111529328877, 16109317445338921222,
|
||||||
|
11923676504992192083
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
11292141569337462929, 7213981967192374125, 4837353949249389782,
|
||||||
|
13157524938508720907
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
17221477633935993097, 7905315334616496868, 2950048088611741910,
|
||||||
|
16851660641249290423
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
1918571898367258879, 14473285549490778842, 16456257732802770188,
|
||||||
|
16611801325745795527
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
7880989808200689690, 16935107633380717766, 8956194191973051375,
|
||||||
|
1103945341495739535
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
4501339912027744074, 12142665268233044767, 9270990890291324944,
|
||||||
|
45374981263348191
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
13657768796246999470, 2899654677720502418, 7228867285602519410,
|
||||||
|
3363587770111123806
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
18227101298896629706, 12986849723013952028, 16815808278639394978,
|
||||||
|
16460725848109409638
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -8,53 +8,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// type HashRaw = []uint64
|
|
||||||
|
|
||||||
// type MerkleCapRaw struct {
|
|
||||||
// Elements []HashRaw `json:"elements"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type QuadraticExtensionRaw = [2]uint64
|
|
||||||
|
|
||||||
// type OpeningSetRaw struct {
|
|
||||||
// Constants []QuadraticExtensionRaw `json:"constants"`
|
|
||||||
// PlonkSigmas []QuadraticExtensionRaw `json:"plonk_sigmas"`
|
|
||||||
// Wires []QuadraticExtensionRaw `json:"wires"`
|
|
||||||
// PlonkZs []QuadraticExtensionRaw `json:"plonk_zs"`
|
|
||||||
// PlonkZsNext []QuadraticExtensionRaw `json:"plonk_zs_next"`
|
|
||||||
// PartialProducts []QuadraticExtensionRaw `json:"partial_products"`
|
|
||||||
// QuotientPolys []QuadraticExtensionRaw `json:"quotient_polys"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type FriQueryRoundRaw struct {
|
|
||||||
// InitialTreesProof struct {
|
|
||||||
// EvalsProofs [][]interface{} `json:"evals_proofs"`
|
|
||||||
// } `json:"initial_trees_proof"`
|
|
||||||
// Steps []uint64 `json:"steps"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type PolynomialCoeffsRaw struct {
|
|
||||||
// Coeffs []uint64 `json:"coeffs"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type FriProofRaw struct {
|
|
||||||
// CommitPhaseMerkleCaps []MerkleCapRaw `json:"commit_phase_merkle_caps"`
|
|
||||||
// QueryRoundProofs FriQueryRoundRaw `json:"query_round_proofs"`
|
|
||||||
// FinalPoly PolynomialCoeffsRaw `json:"final_poly"`
|
|
||||||
// PowWitness uint64 `json:"pow_witness"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type ProofWithPublicInputsRaw struct {
|
|
||||||
// Proof struct {
|
|
||||||
// WiresCap MerkleCapRaw `json:"wires_cap"`
|
|
||||||
// PlonkZsPartialProductsCap MerkleCapRaw `json:"plonk_zs_partial_products_cap"`
|
|
||||||
// QuotientPolysCap MerkleCapRaw `json:"quotient_polys_cap"`
|
|
||||||
// Openings OpeningSetRaw `json:"openings"`
|
|
||||||
// OpeningProof FriProofRaw `json:"opening_proof"`
|
|
||||||
// } `json:"proof"`
|
|
||||||
// PublicInputs []uint64 `json:"public_inputs"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
type ProofWithPublicInputsRaw struct {
|
type ProofWithPublicInputsRaw struct {
|
||||||
Proof struct {
|
Proof struct {
|
||||||
WiresCap []struct {
|
WiresCap []struct {
|
||||||
@@ -107,7 +60,7 @@ type CommonCircuitDataRaw struct {
|
|||||||
CapHeight uint64 `json:"cap_height"`
|
CapHeight uint64 `json:"cap_height"`
|
||||||
ProofOfWorkBits uint64 `json:"proof_of_work_bits"`
|
ProofOfWorkBits uint64 `json:"proof_of_work_bits"`
|
||||||
ReductionStrategy struct {
|
ReductionStrategy struct {
|
||||||
ConstantArityBits []uint64 `json:"ConstantArityBits"`
|
ConstantArityBits []int `json:"ConstantArityBits"`
|
||||||
} `json:"reduction_strategy"`
|
} `json:"reduction_strategy"`
|
||||||
NumQueryRounds uint64 `json:"num_query_rounds"`
|
NumQueryRounds uint64 `json:"num_query_rounds"`
|
||||||
} `json:"fri_config"`
|
} `json:"fri_config"`
|
||||||
@@ -134,12 +87,12 @@ type CommonCircuitDataRaw struct {
|
|||||||
End uint64 `json:"end"`
|
End uint64 `json:"end"`
|
||||||
} `json:"groups"`
|
} `json:"groups"`
|
||||||
} `json:"selectors_info"`
|
} `json:"selectors_info"`
|
||||||
QuotientDegreeFactor uint64 `json:"quotient_degree_factor"`
|
QuotientDegreeFactor uint64 `json:"quotient_degree_factor"`
|
||||||
NumGateConstraints uint64 `json:"num_gate_constraints"`
|
NumGateConstraints uint64 `json:"num_gate_constraints"`
|
||||||
NumConstants uint64 `json:"num_constants"`
|
NumConstants uint64 `json:"num_constants"`
|
||||||
NumPublicInputs uint64 `json:"num_public_inputs"`
|
NumPublicInputs uint64 `json:"num_public_inputs"`
|
||||||
KIs []interface{} `json:"k_is"`
|
KIs []uint64 `json:"k_is"`
|
||||||
NumPartialProducts uint64 `json:"num_partial_products"`
|
NumPartialProducts uint64 `json:"num_partial_products"`
|
||||||
CircuitDigest struct {
|
CircuitDigest struct {
|
||||||
Elements []uint64 `json:"elements"`
|
Elements []uint64 `json:"elements"`
|
||||||
} `json:"circuit_digest"`
|
} `json:"circuit_digest"`
|
||||||
@@ -239,3 +192,41 @@ func DeserializeProofWithPublicInputs(path string) ProofWithPublicInputs {
|
|||||||
|
|
||||||
return proofWithPis
|
return proofWithPis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeserializeCommonCircuitData(path string) CommonCircuitDataRaw {
|
||||||
|
jsonFile, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer jsonFile.Close()
|
||||||
|
rawBytes, _ := ioutil.ReadAll(jsonFile)
|
||||||
|
|
||||||
|
var raw CommonCircuitDataRaw
|
||||||
|
err = json.Unmarshal(rawBytes, &raw)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return raw
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeserializeVerifierOnlyCircuitData(path string) VerifierOnlyCircuitData {
|
||||||
|
jsonFile, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer jsonFile.Close()
|
||||||
|
rawBytes, _ := ioutil.ReadAll(jsonFile)
|
||||||
|
|
||||||
|
var raw VerifierOnlyCircuitDataRaw
|
||||||
|
err = json.Unmarshal(rawBytes, &raw)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return VerifierOnlyCircuitData{
|
||||||
|
ConstantSigmasCap: DeserializeMerkleCap([]struct{ Elements []uint64 }(raw.ConstantsSigmasCap)),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package plonky2_verifier
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDeserializeProofWithPublicInputs(t *testing.T) {
|
|
||||||
proofWithPis := DeserializeProofWithPublicInputs("./fibonacci_proof.json")
|
|
||||||
fmt.Printf("%+v\n", proofWithPis)
|
|
||||||
panic("look at stdout")
|
|
||||||
}
|
|
||||||
24
plonky2_verifier/deserialize_test.go
Normal file
24
plonky2_verifier/deserialize_test.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package plonky2_verifier
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDeserializeProofWithPublicInputs(t *testing.T) {
|
||||||
|
proofWithPis := DeserializeProofWithPublicInputs("./data/proof_with_public_inputs.json")
|
||||||
|
fmt.Printf("%+v\n", proofWithPis)
|
||||||
|
panic("look at stdout")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeserializeCommonCircuitData(t *testing.T) {
|
||||||
|
proofWithPis := DeserializeCommonCircuitData("./data/common_circuit_data.json")
|
||||||
|
fmt.Printf("%+v\n", proofWithPis)
|
||||||
|
panic("look at stdout")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeserializeVerifierOnlyCircuitData(t *testing.T) {
|
||||||
|
proofWithPis := DeserializeVerifierOnlyCircuitData("./data/verifier_only_circuit_data.json")
|
||||||
|
fmt.Printf("%+v\n", proofWithPis)
|
||||||
|
panic("look at stdout")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user