mirror of
https://github.com/logos-storage/proof-aggregation.git
synced 2026-01-07 08:13:07 +00:00
add uniform recursion tests
This commit is contained in:
parent
9a57b660f2
commit
798d53ba12
@ -10,9 +10,9 @@ use plonky2_poseidon2::poseidon2_hash::poseidon2::Poseidon2Hash;
|
|||||||
|
|
||||||
// test types
|
// test types
|
||||||
pub const D: usize = 2;
|
pub const D: usize = 2;
|
||||||
pub type C = Poseidon2GoldilocksConfig;
|
pub type C = PoseidonGoldilocksConfig;
|
||||||
pub type F = <C as GenericConfig<D>>::F; // this is the goldilocks field
|
pub type F = <C as GenericConfig<D>>::F; // this is the goldilocks field
|
||||||
pub type HF = Poseidon2Hash;
|
pub type HF = PoseidonHash;
|
||||||
|
|
||||||
// hardcoded default params for generating proof input
|
// hardcoded default params for generating proof input
|
||||||
const DEFAULT_MAX_DEPTH: usize = 32; // depth of big tree (slot tree depth, includes block tree depth)
|
const DEFAULT_MAX_DEPTH: usize = 32; // depth of big tree (slot tree depth, includes block tree depth)
|
||||||
|
|||||||
@ -4,3 +4,4 @@ pub mod cyclic_recursion;
|
|||||||
pub mod tree1;
|
pub mod tree1;
|
||||||
pub mod tree2;
|
pub mod tree2;
|
||||||
mod hybrid;
|
mod hybrid;
|
||||||
|
mod uniform;
|
||||||
48
proof-input/src/recursion/uniform.rs
Normal file
48
proof-input/src/recursion/uniform.rs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// some tests for approach 2 of the tree recursion
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use plonky2::iop::witness::{PartialWitness};
|
||||||
|
use plonky2::plonk::circuit_builder::CircuitBuilder;
|
||||||
|
use plonky2::plonk::circuit_data::{CircuitConfig};
|
||||||
|
use plonky2::plonk::config::{ GenericConfig};
|
||||||
|
use plonky2::plonk::proof::{ProofWithPublicInputs};
|
||||||
|
use codex_plonky2_circuits::circuits::sample_cells::SampleCircuit;
|
||||||
|
use crate::params::{F, D, C, HF};
|
||||||
|
use crate::gen_input::gen_testing_circuit_input;
|
||||||
|
use crate::params::Params;
|
||||||
|
use codex_plonky2_circuits::recursion::uniform::{tree::TreeRecursion};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uniform_recursion() -> anyhow::Result<()> {
|
||||||
|
|
||||||
|
let config = CircuitConfig::standard_recursion_config();
|
||||||
|
let mut sampling_builder = CircuitBuilder::<F, D>::new(config);
|
||||||
|
|
||||||
|
//------------ sampling inner circuit ----------------------
|
||||||
|
// Circuit that does the sampling - 100 samples
|
||||||
|
let mut params = Params::default();
|
||||||
|
params.input_params.n_samples = 100;
|
||||||
|
params.circuit_params.n_samples = 100;
|
||||||
|
let one_circ_input = gen_testing_circuit_input::<F,D>(¶ms.input_params);
|
||||||
|
let samp_circ = SampleCircuit::<F,D,HF>::new(params.circuit_params);
|
||||||
|
let inner_tar = samp_circ.sample_slot_circuit_with_public_input(&mut sampling_builder)?;
|
||||||
|
// get generate a sampling proof
|
||||||
|
let mut pw = PartialWitness::<F>::new();
|
||||||
|
samp_circ.sample_slot_assign_witness(&mut pw,&inner_tar,&one_circ_input)?;
|
||||||
|
let inner_data = sampling_builder.build::<C>();
|
||||||
|
println!("sampling circuit degree bits = {:?}", inner_data.common.degree_bits());
|
||||||
|
let inner_proof = inner_data.prove(pw)?;
|
||||||
|
|
||||||
|
let proofs: Vec<ProofWithPublicInputs<F, C, D>> = (0..4).map(|i| inner_proof.clone()).collect();
|
||||||
|
|
||||||
|
// ------------------- tree --------------------
|
||||||
|
|
||||||
|
let mut tree = TreeRecursion::<F,D,C,HF>::build(inner_data.common.clone())?;
|
||||||
|
|
||||||
|
let root = tree.prove_tree(&proofs, inner_data.verifier_data())?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user