Skip to content

Commit

Permalink
refactor: verifier generate verifier params with SRS in the summa sol…
Browse files Browse the repository at this point in the history
…vency flow example
  • Loading branch information
sifnoc committed Jul 26, 2024
1 parent 2d878e4 commit 1537491
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Note that the `verifier_params.json` file can be used in any other round unless

This is the final step in the Summa process and the only part that occurs on the user side.

Users receive the proof and commitment for a specific round along with the verifier parameters. Unlike the commitment and proof, the verifier parameters are independent of the round.
Users receive the proof and commitment for a specific round along with the verifier parameters. Unlike the commitment and proof, the verifier parameters are independent of the round. Moreover, users have the option to generate the verifier parameters themselves, instead of fetching them from the CEX.

In this step, the user has to:

Expand Down
21 changes: 15 additions & 6 deletions backend/examples/summa_solvency_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ fn main() {
let circuit = SummaHyperplonk::<N_USERS, N_CURRENCIES>::init(entries.to_vec());
let num_vars = K;

let circuit_fn = |num_vars| {
let circuit_fn = |num_vars, initialized_circuit| {
let circuit = Halo2Circuit::<Fp, SummaHyperplonk<N_USERS, N_CURRENCIES>>::new::<
ProvingBackend,
>(num_vars, circuit.clone());
>(num_vars, initialized_circuit);
(circuit.circuit_info().unwrap(), circuit)
};

let (circuit_info, circuit) = circuit_fn(num_vars as usize);
let (circuit_info, circuit) = circuit_fn(num_vars as usize, circuit);
let instances = circuit.instances();

let param = ProvingBackend::setup_custom("../backend/ptau/hyperplonk-srs-17").unwrap();
Expand Down Expand Up @@ -117,11 +117,20 @@ fn main() {

// 3. Verify Inclusion Proof
//
// Load the commitment and verifier parameters from the files
let commitment: KZGProof = load_from_file(commitment_proof_filename).unwrap();
let verifier_params: HyperPlonkVerifierParam<Fp, MultilinearKzg<Bn256>> =
// Users can generate verifier parameters using only the configurations for "N_CURRENCIES" and "N_USERS", along with the SRS.
let dummy_circuit = SummaHyperplonk::<N_USERS, N_CURRENCIES>::init_empty();

let (circuit_info, _) = circuit_fn(num_vars as usize, dummy_circuit);

let param = ProvingBackend::setup_custom("../backend/ptau/hyperplonk-srs-17").unwrap();
let (_, verifier_params) = ProvingBackend::preprocess(&param, &circuit_info).unwrap();

let loaded_verifier_params: HyperPlonkVerifierParam<Fp, MultilinearKzg<Bn256>> =
load_from_file(vp_filename).unwrap();

// Load the commitment from the files
let commitment: KZGProof = load_from_file(commitment_proof_filename).unwrap();

// When verifying the inclusion proof from the user's perspective, the user have to fetch `proof`.
// Assume that the `proof` file has been downloaded from the CEX along with commitment and verifier parameters.
let proof: KZGProof = load_from_file(format!("user_{}_proof.json", USER_INDEX))
Expand Down

0 comments on commit 1537491

Please sign in to comment.