From fc095d7f9ba62bdbc382736889097feba9406750 Mon Sep 17 00:00:00 2001 From: Uma Roy Date: Sat, 10 Feb 2024 15:04:47 -0800 Subject: [PATCH] asdf --- Cargo.lock | 7 +++++++ core/src/cpu/trace.rs | 9 ++++++++- examples/ssz-withdrawals/Cargo.toml | 7 +++++++ examples/ssz-withdrawals/src/main.rs | 23 +++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 examples/ssz-withdrawals/Cargo.toml create mode 100644 examples/ssz-withdrawals/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index a767224545..0466946392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2425,6 +2425,13 @@ dependencies = [ "der", ] +[[package]] +name = "ssz" +version = "0.1.0" +dependencies = [ + "succinct-core", +] + [[package]] name = "strsim" version = "0.11.0" diff --git a/core/src/cpu/trace.rs b/core/src/cpu/trace.rs index 9f82b47758..e74a79edc2 100644 --- a/core/src/cpu/trace.rs +++ b/core/src/cpu/trace.rs @@ -63,7 +63,14 @@ impl MachineAir for CpuChip { rows_with_events.into_iter().for_each(|row_with_events| { let (row, alu_events, blu_events, field_events) = row_with_events; rows.extend(row); - new_alu_events.extend(alu_events); + for (key, value) in alu_events { + new_alu_events + .entry(key) + .and_modify(|op_new_events: &mut Vec| { + op_new_events.extend(value.clone()) + }) + .or_insert(value); + } new_blu_events.extend(blu_events); new_field_events.extend(field_events); }); diff --git a/examples/ssz-withdrawals/Cargo.toml b/examples/ssz-withdrawals/Cargo.toml new file mode 100644 index 0000000000..e7c5a5ed8f --- /dev/null +++ b/examples/ssz-withdrawals/Cargo.toml @@ -0,0 +1,7 @@ +[package] +version = "0.1.0" +name = "ssz" +edition = "2021" + +[dependencies] +succinct-core = { path = "../../core" } diff --git a/examples/ssz-withdrawals/src/main.rs b/examples/ssz-withdrawals/src/main.rs new file mode 100644 index 0000000000..c028112d4b --- /dev/null +++ b/examples/ssz-withdrawals/src/main.rs @@ -0,0 +1,23 @@ +use succinct_core::{utils, SuccinctProver, SuccinctStdin, SuccinctVerifier}; + +const ELF: &[u8] = + include_bytes!("../../../programs/demo/ssz-withdrawals/elf/riscv32im-succinct-zkvm-elf"); + +fn main() { + // Generate proof. + // utils::setup_tracer(); + utils::setup_logger(); + + let stdin = SuccinctStdin::new(); + let proof = SuccinctProver::prove(ELF, stdin).expect("proving failed"); + + // Verify proof. + SuccinctVerifier::verify(ELF, &proof).expect("verification failed"); + + // Save proof. + proof + .save("proof-with-pis.json") + .expect("saving proof failed"); + + println!("succesfully generated and verified proof for the program!") +}