mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-02-11 16:43:12 +00:00
* introduce risc0_images and risc0_images_police * static instead of const for elfs * gen images in a loop to resolve id changes due to recursion * r0_proofs reference each other through risc0_images when recursing * update ledger to use risc0_images * remove debug panics
57 lines
1.5 KiB
Rust
57 lines
1.5 KiB
Rust
use crate::tx::ProvedTx;
|
|
use cl::crust::{Bundle, BundleWitness};
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct ProvedBundle {
|
|
pub risc0_receipt: risc0_zkvm::Receipt,
|
|
}
|
|
|
|
impl ProvedBundle {
|
|
pub fn prove(bundle: &BundleWitness, txs: Vec<ProvedTx>) -> Self {
|
|
//show that all ptx's are individually valid, and balance to 0
|
|
let mut env = risc0_zkvm::ExecutorEnv::builder();
|
|
|
|
for proved_tx in txs {
|
|
env.add_assumption(proved_tx.risc0_receipt);
|
|
}
|
|
|
|
let env = env.write(&bundle).unwrap().build().unwrap();
|
|
|
|
let prover = risc0_zkvm::default_prover();
|
|
|
|
let start_t = std::time::Instant::now();
|
|
|
|
let opts = risc0_zkvm::ProverOpts::succinct();
|
|
let prove_info = prover
|
|
.prove_with_opts(
|
|
env,
|
|
risc0_images::nomos_mantle_bundle_risc0_proof::BUNDLE_ELF,
|
|
&opts,
|
|
)
|
|
.unwrap();
|
|
|
|
println!(
|
|
"STARK 'bundle' prover time: {:.2?}, user_cycles: {}, total_cycles: {}",
|
|
start_t.elapsed(),
|
|
prove_info.stats.user_cycles,
|
|
prove_info.stats.total_cycles
|
|
);
|
|
|
|
let receipt = prove_info.receipt;
|
|
|
|
Self {
|
|
risc0_receipt: receipt,
|
|
}
|
|
}
|
|
|
|
pub fn public(&self) -> Bundle {
|
|
self.risc0_receipt.journal.decode().unwrap()
|
|
}
|
|
|
|
pub fn verify(&self) -> bool {
|
|
self.risc0_receipt
|
|
.verify(risc0_images::nomos_mantle_bundle_risc0_proof::BUNDLE_ID)
|
|
.is_ok()
|
|
}
|
|
}
|