Skip to content

Commit b165b1d

Browse files
committed
store verify key alongside proof for the jsonized example
1 parent 0f30e50 commit b165b1d

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

evm-vrfier/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
alloy = { version = "0.14", default-features = false, features = ["contract", "provider-anvil-node"] }
7+
alloy = { version = "1.0.0", default-features = false, features = ["contract", "provider-anvil-node"] }
88
ark-ff = { workspace = true }
99
ark-bls12-381 = { version = "0.5", default-features = false, features = ["curve"] }
1010

w3f-ring-proof/examples/export_sample_ring_proof.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use ark_std::rand::RngCore;
77
use w3f_pcs::pcs::PCS;
88

99
use w3f_plonk_common::domain::Domain;
10-
use w3f_plonk_common::Proof;
10+
use w3f_plonk_common::{verifier, Proof};
1111

1212
use w3f_ring_proof::{index, RingProof};
1313
use w3f_ring_proof::{FixedColumnsCommitted, PiopParams, ProverKey, VerifierKey};
@@ -89,7 +89,7 @@ fn setup<R: Rng, CS: PCS<Fq>>(
8989
(pcs_params, piop_params, h)
9090
}
9191

92-
fn generate_sample_proof<CS: PCS<Fq>>() -> RingProof<Fq, CS> {
92+
fn generate_sample_proof<CS: PCS<Fq>>() -> (RingProof<Fq, CS>, VerifierKey<Fq, CS>) {
9393
// Setup RNG and parameters
9494
let rng = &mut test_rng();
9595

@@ -114,13 +114,18 @@ fn generate_sample_proof<CS: PCS<Fq>>() -> RingProof<Fq, CS> {
114114
);
115115
let proof = ring_prover.prove(secret);
116116

117-
ring_prover.prove(secret)
117+
(ring_prover.prove(secret), verifier_key)
118118
}
119119

120-
fn export_proof_as_json<F: PrimeField, CS: PCS<F>>(proof_to_be_exported: RingProof<F, CS>) {
121-
let proof = proof_to_be_exported;
120+
fn export_proof_as_json<F: PrimeField, CS: PCS<F>>(proof_to_be_exported: RingProof<F, CS>, verifier_key: VerifierKey<F, CS>) {
121+
122+
let verifier_json_obj = json!({
123+
"verification_key": to_hex(&verifier_key),
124+
});
125+
126+
let proof = proof_to_be_exported;
122127
// Build a structured JSON object where each important field is stored as a hex string
123-
let json_obj = json!({
128+
let proof_json_obj = json!({
124129
"column_commitments": to_hex(&proof.column_commitments),
125130
"columns_at_zeta": to_hex(&proof.columns_at_zeta),
126131
"quotient_commitment": to_hex(&proof.quotient_commitment),
@@ -129,22 +134,24 @@ fn export_proof_as_json<F: PrimeField, CS: PCS<F>>(proof_to_be_exported: RingPro
129134
"lin_at_zeta_omega_proof": to_hex(&proof.lin_at_zeta_omega_proof),
130135
});
131136

132-
// Write JSON to temp directory to avoid polluting repo root
137+
let verifier_key_and_proof = json!({"verifier_key": verifier_json_obj, "proof": proof_json_obj});
138+
139+
// Write JSON to temp directory
133140
let mut path = std::env::temp_dir();
134-
path.push("ring_proof_structured.json");
141+
path.push("ring_proof_and_key.json");
135142
fs::write(
136143
&path,
137-
serde_json::to_string_pretty(&json_obj).expect("serialize json"),
144+
serde_json::to_string_pretty(&verifier_key_and_proof).expect("serialize json"),
138145
)
139-
.expect("writing proof json should succeed");
140-
146+
.expect("writing json proof json should succeed");
147+
141148
// Ensure file exists
142149
assert!(path.exists());
143150
// Optionally print path for debugging
144151
println!("Wrote structured proof JSON to {}", path.display());
145152
}
146153

147154
fn main() {
148-
let proof = generate_sample_proof::<KZG<Bls12_381>>();
149-
export_proof_as_json(proof);
155+
let (proof, verifier_key) = generate_sample_proof::<KZG<Bls12_381>>();
156+
export_proof_as_json(proof, verifier_key);
150157
}

0 commit comments

Comments
 (0)