Skip to content

Commit

Permalink
chore: stash
Browse files Browse the repository at this point in the history
  • Loading branch information
eigmax committed Jan 1, 2024
1 parent 55fb772 commit b1d5796
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 29 deletions.
13 changes: 6 additions & 7 deletions examples/zkmips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,9 @@ fn prove_single_seg() {
log::debug!("Prove done");
}

fn aggregate_proof() {
fn aggregate_proof() {}

}

fn prove_groth16() {

}
fn prove_groth16() {}

fn main() {
env_logger::try_init().unwrap_or_default();
Expand All @@ -104,6 +100,9 @@ fn main() {
"prove" => prove_single_seg(),
"aggregate_proof" => aggregate_proof(),
"prove_groth16" => prove_groth16(),
_ => todo!("Help: {} split | prove | aggregate_proof | prove_groth16", args[0]),
_ => todo!(
"Help: {} split | prove | aggregate_proof | prove_groth16",
args[0]
),
};
}
8 changes: 4 additions & 4 deletions src/cpu/cpu_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ mod tests {
use crate::cpu::bootstrap_kernel::generate_bootstrap_kernel;
use crate::cpu::columns::NUM_CPU_COLUMNS;
use crate::cpu::cpu_stark::CpuStark;
use crate::cpu::kernel::KERNEL;
use crate::cpu::kernel::TEST_KERNEL;
use crate::generation::simulate_cpu;
use crate::generation::state::GenerationState;
use crate::stark_testing::{
Expand Down Expand Up @@ -285,9 +285,9 @@ mod tests {
f: Default::default(),
};

let mut state = GenerationState::<F>::new(40000000, &KERNEL).unwrap();
generate_bootstrap_kernel::<F>(&mut state, &KERNEL);
simulate_cpu::<F, D>(&mut state, &KERNEL).unwrap();
let mut state = GenerationState::<F>::new(40000000, &TEST_KERNEL).unwrap();
generate_bootstrap_kernel::<F>(&mut state, &TEST_KERNEL);
simulate_cpu::<F, D>(&mut state, &TEST_KERNEL).unwrap();

let vals: Vec<[F; NUM_CPU_COLUMNS]> = state
.clone()
Expand Down
3 changes: 1 addition & 2 deletions src/cpu/kernel/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,4 @@ impl Kernel {
/// nontrivial given the circular dependency between an offset and its size.
pub(crate) const BYTES_PER_OFFSET: u8 = 3;

pub static KERNEL: Lazy<Kernel> = Lazy::new(combined_kernel);
//pub static KERNEL: Lazy<Kernel> = Lazy::new(segment_kernel);
pub static TEST_KERNEL: Lazy<Kernel> = Lazy::new(combined_kernel);
2 changes: 1 addition & 1 deletion src/cpu/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pub(crate) mod constants;
pub(crate) mod elf;
pub(crate) mod keccak_util;

pub use assembler::KERNEL;
pub use assembler::TEST_KERNEL;
5 changes: 1 addition & 4 deletions src/generation/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ pub(crate) struct GenerationState<F: Field> {
}

impl<F: Field> GenerationState<F> {
pub(crate) fn new(
step: usize,
kernel: &Kernel,
) -> Result<Self, ProgramError> {
pub(crate) fn new(step: usize, kernel: &Kernel) -> Result<Self, ProgramError> {
Ok(GenerationState {
registers: RegistersState::new(kernel),
memory: MemoryState::new(&kernel.code),
Expand Down
2 changes: 1 addition & 1 deletion src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use crate::cross_table_lookup::{
GrandProductChallengeSet,
};
use crate::evaluation_frame::StarkEvaluationFrame;
use crate::generation::outputs::GenerationOutputs;
use crate::generation::generate_traces;
use crate::generation::outputs::GenerationOutputs;
use crate::get_challenges::observe_public_values;
use crate::lookup::{lookup_helper_columns, Lookup, LookupCheckVars};
use crate::proof::{AllProof, PublicValues, StarkOpeningSet, StarkProof, StarkProofWithMetadata};
Expand Down
4 changes: 2 additions & 2 deletions src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ mod tests {
use crate::all_stark::AllStark;
use crate::config::StarkConfig;

use crate::cpu::kernel::KERNEL;
use crate::cpu::kernel::TEST_KERNEL;
use crate::proof;
use crate::prover::prove;

Expand Down Expand Up @@ -441,7 +441,7 @@ mod tests {

let mut timing = TimingTree::new("prove", log::Level::Debug);
let allproof: proof::AllProof<GoldilocksField, C, D> =
prove(&allstark, &KERNEL, &config, &mut timing).unwrap();
prove(&allstark, &TEST_KERNEL, &config, &mut timing).unwrap();
let mut count_bytes = 0;
let mut row = 0;
for proof in allproof.stark_proofs.clone() {
Expand Down
18 changes: 10 additions & 8 deletions tests/simple_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::time::Duration;

use mips_circuits::all_stark::AllStark;
use mips_circuits::config::StarkConfig;
use mips_circuits::cpu::kernel::KERNEL;
use mips_circuits::cpu::kernel::assembler::TEST_KERNEL;
use mips_circuits::fixed_recursive_verifier::AllRecursiveCircuits;
use mips_circuits::proof::PublicValues;

//use mips_circuits::cpu::kernel::assembler::segment_kernel;
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::plonk::config::PoseidonGoldilocksConfig;
use plonky2::util::timing::TimingTree;
Expand All @@ -29,19 +29,18 @@ fn test_mips_with_aggreg() -> anyhow::Result<()> {
&config,
);

// input_first =
let input_first = &TEST_KERNEL; //segment_kernel();
let mut timing = TimingTree::new("prove root first", log::Level::Info);
let (root_proof_first, first_public_values) =
all_circuits.prove_root(&all_stark, &KERNEL, &config, &mut timing)?;
all_circuits.prove_root(&all_stark, input_first, &config, &mut timing)?;

timing.filter(Duration::from_millis(100)).print();
all_circuits.verify_root(root_proof_first.clone())?;

//let inputs = GenerationInputs {};

let input = &TEST_KERNEL; //segment_kernel();
let mut timing = TimingTree::new("prove root second", log::Level::Info);
let (root_proof, public_values) =
all_circuits.prove_root(&all_stark, &KERNEL, &config, &mut timing)?;
all_circuits.prove_root(&all_stark, input, &config, &mut timing)?;
timing.filter(Duration::from_millis(100)).print();

all_circuits.verify_root(root_proof.clone())?;
Expand All @@ -64,6 +63,9 @@ fn test_mips_with_aggreg() -> anyhow::Result<()> {
let (block_proof, _block_public_values) =
all_circuits.prove_block(None, &agg_proof, updated_agg_public_values)?;

log::info!("proof size: {:?}", serde_json::to_string(&block_proof.proof).unwrap().len());
log::info!(
"proof size: {:?}",
serde_json::to_string(&block_proof.proof).unwrap().len()
);
all_circuits.verify_block(&block_proof)
}

0 comments on commit b1d5796

Please sign in to comment.