mirror of
https://github.com/logos-storage/proof-aggregation.git
synced 2026-01-02 13:53:13 +00:00
clean up to avoid rust warnings.
This commit is contained in:
parent
1daf2dc0ea
commit
b2bb9ebf52
@ -3,7 +3,6 @@
|
||||
use plonky2::hash::hash_types::{HashOut, RichField};
|
||||
use plonky2_field::extension::Extendable;
|
||||
use codex_plonky2_circuits::circuits::sample_cells::Cell;
|
||||
use plonky2_field::types::Sample;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
use crate::merkle_tree::merkle_safe::{MerkleProof, MerkleTree};
|
||||
use crate::params::{InputParams, HF};
|
||||
@ -236,7 +235,7 @@ impl<
|
||||
}
|
||||
/// pad the proof with 0s until max_depth
|
||||
pub fn pad_proof(merkle_proof: &mut MerkleProof<F,D>, max_depth: usize){
|
||||
for i in merkle_proof.path.len()..max_depth{
|
||||
for _i in merkle_proof.path.len()..max_depth{
|
||||
merkle_proof.path.push(HashOut::<F>::ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
use plonky2::hash::hash_types::RichField;
|
||||
use plonky2::plonk::config::{GenericConfig, Hasher};
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::types::Field;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
use crate::params::{Params,InputParams};
|
||||
use crate::utils::{bits_le_padded_to_usize, calculate_cell_index_bits, ceiling_log2, usize_to_bits_le};
|
||||
@ -156,8 +154,8 @@ pub fn build_circuit(n_samples: usize, slot_index: usize) -> anyhow::Result<(Cir
|
||||
pub fn build_circuit_with_targets(n_samples: usize, slot_index: usize) -> anyhow::Result<(CircuitData<F, C, D>, PartialWitness<F>, SampleTargets)>{
|
||||
// get input
|
||||
let mut params = Params::default();
|
||||
params.set_n_samples(n_samples);
|
||||
let mut input_params = params.input_params;
|
||||
input_params.n_samples = n_samples;
|
||||
input_params.testing_slot_index = slot_index;
|
||||
let circ_input = gen_testing_circuit_input::<F,D>(&input_params);
|
||||
|
||||
@ -165,12 +163,11 @@ pub fn build_circuit_with_targets(n_samples: usize, slot_index: usize) -> anyhow
|
||||
let config = CircuitConfig::standard_recursion_config();
|
||||
let mut builder = CircuitBuilder::<F, D>::new(config);
|
||||
|
||||
let mut circuit_params = params.circuit_params;
|
||||
circuit_params.n_samples = n_samples;
|
||||
let circuit_params = params.circuit_params;
|
||||
|
||||
// build the circuit
|
||||
let circ = SampleCircuit::<F,D,HF>::new(circuit_params.clone());
|
||||
let mut targets = circ.sample_slot_circuit_with_public_input(&mut builder)?;
|
||||
let targets = circ.sample_slot_circuit_with_public_input(&mut builder)?;
|
||||
|
||||
// Create a PartialWitness and assign
|
||||
let mut pw = PartialWitness::new();
|
||||
@ -235,10 +232,9 @@ mod tests {
|
||||
fn test_proof_in_circuit() -> anyhow::Result<()> {
|
||||
// get input
|
||||
let mut params = Params::default();
|
||||
let mut input_params = params.input_params;
|
||||
let mut circuit_params = params.circuit_params;
|
||||
input_params.n_samples = 10;
|
||||
circuit_params.n_samples = 10;
|
||||
params.set_n_samples(10);
|
||||
let input_params = params.input_params;
|
||||
let circuit_params = params.circuit_params;
|
||||
let circ_input = gen_testing_circuit_input::<F,D>(&input_params);
|
||||
|
||||
// build the circuit
|
||||
|
||||
@ -1,16 +1,11 @@
|
||||
use codex_plonky2_circuits::Result;
|
||||
use plonky2::field::extension::Extendable;
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
use plonky2::field::types::Field;
|
||||
use plonky2::hash::hash_types::{HashOut, HashOutTarget, NUM_HASH_OUT_ELTS, RichField};
|
||||
use plonky2::hash::hashing::PlonkyPermutation;
|
||||
use plonky2::hash::poseidon::PoseidonHash;
|
||||
use plonky2::iop::witness::{PartialWitness, Witness, WitnessWrite};
|
||||
use plonky2::iop::witness::{PartialWitness, WitnessWrite};
|
||||
use plonky2::plonk::circuit_builder::CircuitBuilder;
|
||||
use plonky2::plonk::circuit_data::CircuitConfig;
|
||||
use plonky2::plonk::config::{AlgebraicHasher, GenericConfig, GenericHashOut, Hasher, PoseidonGoldilocksConfig};
|
||||
use plonky2::plonk::config::{AlgebraicHasher, Hasher};
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
use serde::Serialize;
|
||||
use codex_plonky2_circuits::circuits::merkle_circuit::{MerkleProofTarget, MerkleTreeCircuit, MerkleTreeTargets};
|
||||
use codex_plonky2_circuits::circuits::utils::{assign_bool_targets, assign_hash_out_targets};
|
||||
use codex_plonky2_circuits::error::CircuitError;
|
||||
@ -170,9 +165,6 @@ mod tests {
|
||||
let check = proof.verify(tree.layers[0][leaf_index],tree.root().unwrap()).unwrap();
|
||||
assert_eq!(check, true);
|
||||
|
||||
// get the expected Merkle root
|
||||
let expected_root = tree.root()?;
|
||||
|
||||
// create the circuit
|
||||
let config = CircuitConfig::standard_recursion_config();
|
||||
let mut builder = CircuitBuilder::<F, D>::new(config);
|
||||
|
||||
@ -9,7 +9,6 @@ use plonky2::hash::poseidon::PoseidonHash;
|
||||
use plonky2::plonk::config::Hasher;
|
||||
use std::ops::Shr;
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::types::Field;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
use crate::merkle_tree::key_compress::key_compress;
|
||||
use crate::params::HF;
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
use plonky2::field::types::Field;
|
||||
use plonky2::hash::hash_types::{HashOut, RichField};
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
@ -28,7 +26,6 @@ mod tests {
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
use plonky2::field::types::Field;
|
||||
use plonky2::hash::hash_types::HashOut;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
|
||||
type F = GoldilocksField;
|
||||
const D: usize = 2;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
// params for generating input for proof circuit
|
||||
|
||||
use plonky2::hash::poseidon::PoseidonHash;
|
||||
use plonky2::plonk::config::{GenericConfig, PoseidonGoldilocksConfig};
|
||||
// use plonky2::hash::poseidon::PoseidonHash;
|
||||
// use plonky2::plonk::config::PoseidonGoldilocksConfig;
|
||||
use plonky2::plonk::config::GenericConfig;
|
||||
use std::env;
|
||||
use anyhow::{Result, Context};
|
||||
use codex_plonky2_circuits::circuits::params::CircuitParams;
|
||||
@ -74,6 +75,14 @@ impl Default for Params {
|
||||
}
|
||||
}
|
||||
|
||||
impl Params {
|
||||
/// helper to set the number of samples to given n for both input and circuit params
|
||||
pub fn set_n_samples(&mut self, n: usize){
|
||||
self.input_params.n_samples = n;
|
||||
self.circuit_params.n_samples = n;
|
||||
}
|
||||
}
|
||||
|
||||
/// Implement a new function to create Params with custom values
|
||||
impl InputParams {
|
||||
// GOLDILOCKS_F_SIZE
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use plonky2::plonk::config::{ GenericConfig};
|
||||
use plonky2::plonk::proof::{ProofWithPublicInputs};
|
||||
use codex_plonky2_circuits::circuit_helper::Plonky2Circuit;
|
||||
use codex_plonky2_circuits::circuits::sample_cells::SampleCircuit;
|
||||
@ -34,7 +33,7 @@ mod tests {
|
||||
println!("sampling circuit degree bits = {:?}", inner_verifier_data.common.degree_bits());
|
||||
let inner_proof = samp_circ.prove(&inner_tar, &one_circ_input, &inner_prover_data)?;
|
||||
|
||||
let proofs: Vec<ProofWithPublicInputs<F, C, D>> = (0..T).map(|i| inner_proof.clone()).collect();
|
||||
let proofs: Vec<ProofWithPublicInputs<F, C, D>> = (0..T).map(|_i| inner_proof.clone()).collect();
|
||||
|
||||
// ------------------- tree --------------------
|
||||
// 2-to-1 tree aggregation
|
||||
@ -93,7 +92,7 @@ mod tests {
|
||||
println!("sampling circuit degree bits = {:?}", inner_verifier_data.common.degree_bits());
|
||||
let inner_proof = samp_circ.prove(&inner_tar, &one_circ_input, &inner_prover_data)?;
|
||||
|
||||
let proofs: Vec<ProofWithPublicInputs<F, C, D>> = (0..T).map(|i| inner_proof.clone()).collect();
|
||||
let proofs: Vec<ProofWithPublicInputs<F, C, D>> = (0..T).map(|_i| inner_proof.clone()).collect();
|
||||
|
||||
// ------------------- tree --------------------
|
||||
const N: usize = 1;
|
||||
@ -133,7 +132,6 @@ mod tests {
|
||||
println!("proof size = {:?} bytes", proof.to_bytes().len());
|
||||
|
||||
let pub_input_flat: Vec<F> = inner_pi.iter().cloned().flatten().collect();
|
||||
let num_pi = proof.public_inputs.len();
|
||||
|
||||
// sanity check on public input
|
||||
for (i, e) in proof.public_inputs.iter().enumerate(){
|
||||
|
||||
@ -6,7 +6,6 @@ use anyhow::{anyhow, Error};
|
||||
use codex_plonky2_circuits::circuits::sample_cells::{Cell, MerklePath, SampleCircuitInput};
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Write};
|
||||
use plonky2_field::types::{Field, PrimeField64};
|
||||
use crate::gen_input::gen_testing_circuit_input;
|
||||
use crate::params::InputParams;
|
||||
|
||||
@ -44,6 +43,7 @@ pub fn generate_and_export_circ_input_to_json<
|
||||
|
||||
// Serializable versions of the circuit input
|
||||
// naming here is not Rust friendly but only so that its compatible with Nim code.
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct SerializableCircuitInput<
|
||||
> {
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::Serialize;
|
||||
use std::fs::File;
|
||||
use std::{fs, io};
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::io::BufWriter;
|
||||
use std::path::Path;
|
||||
use crate::gen_input::gen_testing_circuit_input;
|
||||
use plonky2::hash::hash_types::RichField;
|
||||
use plonky2::plonk::config::{GenericConfig, Hasher};
|
||||
use plonky2::plonk::config::GenericConfig;
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::types::Field;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
use codex_plonky2_circuits::circuits::sample_cells::SampleCircuitInput;
|
||||
use plonky2::plonk::proof::ProofWithPublicInputs;
|
||||
@ -48,9 +47,7 @@ mod tests {
|
||||
use crate::params::{C, D, F, HF, Params};
|
||||
use std::time::Instant;
|
||||
use codex_plonky2_circuits::circuits::sample_cells::SampleCircuit;
|
||||
use plonky2::iop::witness::PartialWitness;
|
||||
use plonky2::plonk::circuit_builder::CircuitBuilder;
|
||||
use plonky2::plonk::circuit_data::{CircuitConfig, CircuitData, ProverCircuitData, VerifierCircuitData};
|
||||
use plonky2::plonk::circuit_data::{ ProverCircuitData, VerifierCircuitData};
|
||||
use codex_plonky2_circuits::circuit_helper::Plonky2Circuit;
|
||||
use plonky2_poseidon2::serialization::{DefaultGateSerializer, DefaultGeneratorSerializer};
|
||||
use crate::gen_input::verify_circuit_input;
|
||||
|
||||
@ -3,7 +3,6 @@ use plonky2_field::extension::Extendable;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
use plonky2::plonk::config::Hasher;
|
||||
use plonky2::hash::hashing::PlonkyPermutation;
|
||||
use plonky2_field::types::Field;
|
||||
|
||||
/// sponge function similar to the in-circuit one
|
||||
/// used here for testing / sanity check
|
||||
|
||||
@ -2,7 +2,6 @@ use plonky2::hash::hash_types::{HashOut, RichField};
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2;
|
||||
use crate::params::HF;
|
||||
use plonky2::hash::hashing::PlonkyPermutation;
|
||||
use crate::sponge::hash_n_with_padding;
|
||||
|
||||
// --------- helper functions ---------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user