mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-01-11 09:33:08 +00:00
introduce risc0_images and risc0_images_police
This commit is contained in:
parent
bc8c3b6f73
commit
2bfb707e30
@ -8,6 +8,8 @@ members = [
|
||||
"bundle_risc0_proof",
|
||||
"tx_risc0_proof",
|
||||
"ledger_validity_proof"
|
||||
"risc0_images",
|
||||
"risc0_images_police",
|
||||
]
|
||||
|
||||
# Always optimize; building and running the risc0_proofs takes much longer without optimization.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "nomos_cl_bundle_risc0_proof"
|
||||
name = "nomos_mantle_bundle_risc0_proof"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ risc0-zkvm = { version = "1.0", default-features = false, features = ['std'] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
cl = { path = "../../cl" }
|
||||
ledger_proof_statements = { path = "../../ledger_proof_statements" }
|
||||
nomos_cl_tx_risc0_proof = { path = "../../tx_risc0_proof" }
|
||||
nomos_mantle_tx_risc0_proof = { path = "../../tx_risc0_proof" }
|
||||
|
||||
|
||||
[patch.crates-io]
|
||||
|
||||
@ -5,7 +5,11 @@ fn main() {
|
||||
let bundle_private: BundleWitness = env::read();
|
||||
|
||||
for tx in &bundle_private.txs {
|
||||
env::verify(nomos_cl_tx_risc0_proof::TX_ID, &serde::to_vec(&tx).unwrap()).unwrap();
|
||||
env::verify(
|
||||
nomos_mantle_tx_risc0_proof::TX_ID,
|
||||
&serde::to_vec(&tx).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
env::commit(&bundle_private.commit());
|
||||
|
||||
@ -7,8 +7,8 @@ edition = "2021"
|
||||
cl = { path = "../cl" }
|
||||
ledger_proof_statements = { path = "../ledger_proof_statements" }
|
||||
nomos_mantle_risc0_proofs = { path = "../risc0_proofs" }
|
||||
nomos_cl_bundle_risc0_proof = { path = "../bundle_risc0_proof" }
|
||||
nomos_cl_tx_risc0_proof = { path = "../tx_risc0_proof" }
|
||||
nomos_mantle_bundle_risc0_proof = { path = "../bundle_risc0_proof" }
|
||||
nomos_mantle_tx_risc0_proof = { path = "../tx_risc0_proof" }
|
||||
ledger_validity_proof = { path = "../ledger_validity_proof" }
|
||||
risc0-zkvm = { version = "1.0", features = ["prove", "metal"] }
|
||||
risc0-groth16 = { version = "1.0" }
|
||||
|
||||
@ -23,7 +23,7 @@ impl ProvedBundle {
|
||||
|
||||
let opts = risc0_zkvm::ProverOpts::succinct();
|
||||
let prove_info = prover
|
||||
.prove_with_opts(env, nomos_cl_bundle_risc0_proof::BUNDLE_ELF, &opts)
|
||||
.prove_with_opts(env, nomos_mantle_bundle_risc0_proof::BUNDLE_ELF, &opts)
|
||||
.unwrap();
|
||||
|
||||
println!(
|
||||
@ -46,7 +46,7 @@ impl ProvedBundle {
|
||||
|
||||
pub fn verify(&self) -> bool {
|
||||
self.risc0_receipt
|
||||
.verify(nomos_cl_bundle_risc0_proof::BUNDLE_ID)
|
||||
.verify(nomos_mantle_bundle_risc0_proof::BUNDLE_ID)
|
||||
.is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ impl ProvedTx {
|
||||
// This struct contains the receipt along with statistics about execution of the guest
|
||||
let opts = risc0_zkvm::ProverOpts::succinct();
|
||||
let prove_info = prover
|
||||
.prove_with_opts(env, nomos_cl_tx_risc0_proof::TX_ELF, &opts)
|
||||
.prove_with_opts(env, nomos_mantle_tx_risc0_proof::TX_ELF, &opts)
|
||||
.map_err(|_| Error::Risc0ProofFailed)?;
|
||||
|
||||
println!(
|
||||
@ -57,7 +57,7 @@ impl ProvedTx {
|
||||
|
||||
pub fn verify(&self) -> bool {
|
||||
self.risc0_receipt
|
||||
.verify(nomos_cl_tx_risc0_proof::TX_ID)
|
||||
.verify(nomos_mantle_tx_risc0_proof::TX_ID)
|
||||
.is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ risc0-zkvm = { version = "1.0", default-features = false, features = ['std'] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
cl = { path = "../../cl" }
|
||||
ledger_proof_statements = { path = "../../ledger_proof_statements" }
|
||||
nomos_cl_bundle_risc0_proof = { path = "../../bundle_risc0_proof" }
|
||||
nomos_mantle_bundle_risc0_proof = { path = "../../bundle_risc0_proof" }
|
||||
|
||||
[patch.crates-io]
|
||||
# add RISC Zero accelerator support for all downstream usages of the following crates.
|
||||
|
||||
@ -23,7 +23,7 @@ fn main() {
|
||||
} in bundles
|
||||
{
|
||||
env::verify(
|
||||
nomos_cl_bundle_risc0_proof::BUNDLE_ID,
|
||||
nomos_mantle_bundle_risc0_proof::BUNDLE_ID,
|
||||
&serde::to_vec(&bundle).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
7
emmarin/cl/risc0_images/Cargo.toml
Normal file
7
emmarin/cl/risc0_images/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "risc0_images"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
binary_macros = "1.0.0"
|
||||
16
emmarin/cl/risc0_images/src/lib.rs
Normal file
16
emmarin/cl/risc0_images/src/lib.rs
Normal file
File diff suppressed because one or more lines are too long
13
emmarin/cl/risc0_images_police/Cargo.toml
Normal file
13
emmarin/cl/risc0_images_police/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "risc0_images_police"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.22"
|
||||
risc0_images = { path = "../risc0_images" }
|
||||
nomos_mantle_risc0_proofs = { path = "../risc0_proofs" }
|
||||
nomos_mantle_bundle_risc0_proof = { path = "../bundle_risc0_proof" }
|
||||
nomos_mantle_tx_risc0_proof = { path = "../tx_risc0_proof" }
|
||||
ledger_validity_proof = { path = "../ledger_validity_proof" }
|
||||
25
emmarin/cl/risc0_images_police/src/bin/gen_risc0_images.rs
Normal file
25
emmarin/cl/risc0_images_police/src/bin/gen_risc0_images.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use base64::prelude::*;
|
||||
|
||||
macro_rules! gen_risc0_image {
|
||||
($module:ident, $id:ident, $elf:ident) => {
|
||||
println!("pub mod {} {{", stringify!($module));
|
||||
println!(
|
||||
" pub const {}: [u32; 8] = {:?};",
|
||||
stringify!($id),
|
||||
$module::$id
|
||||
);
|
||||
println!(
|
||||
" pub const {}: &[u8] = binary_macros::base64!({:?});",
|
||||
stringify!($elf),
|
||||
BASE64_STANDARD.encode(&$module::$elf)
|
||||
);
|
||||
println!("}}");
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
gen_risc0_image!(nomos_mantle_risc0_proofs, STF_NOP_ID, STF_NOP_ELF);
|
||||
gen_risc0_image!(nomos_mantle_bundle_risc0_proof, BUNDLE_ID, BUNDLE_ELF);
|
||||
gen_risc0_image!(nomos_mantle_tx_risc0_proof, TX_ID, TX_ELF);
|
||||
gen_risc0_image!(ledger_validity_proof, LEDGER_ID, LEDGER_ELF);
|
||||
}
|
||||
38
emmarin/cl/risc0_images_police/src/lib.rs
Normal file
38
emmarin/cl/risc0_images_police/src/lib.rs
Normal file
@ -0,0 +1,38 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn ensure_images_are_correct() {
|
||||
assert_eq!(
|
||||
risc0_images::nomos_mantle_risc0_proofs::STF_NOP_ID,
|
||||
nomos_mantle_risc0_proofs::STF_NOP_ID
|
||||
);
|
||||
assert_eq!(
|
||||
risc0_images::nomos_mantle_risc0_proofs::STF_NOP_ELF,
|
||||
nomos_mantle_risc0_proofs::STF_NOP_ELF
|
||||
);
|
||||
assert_eq!(
|
||||
risc0_images::nomos_mantle_bundle_risc0_proof::BUNDLE_ID,
|
||||
nomos_mantle_bundle_risc0_proof::BUNDLE_ID
|
||||
);
|
||||
assert_eq!(
|
||||
risc0_images::nomos_mantle_bundle_risc0_proof::BUNDLE_ELF,
|
||||
nomos_mantle_bundle_risc0_proof::BUNDLE_ELF
|
||||
);
|
||||
assert_eq!(
|
||||
risc0_images::nomos_mantle_tx_risc0_proof::TX_ID,
|
||||
nomos_mantle_tx_risc0_proof::TX_ID
|
||||
);
|
||||
assert_eq!(
|
||||
risc0_images::nomos_mantle_tx_risc0_proof::TX_ELF,
|
||||
nomos_mantle_tx_risc0_proof::TX_ELF
|
||||
);
|
||||
assert_eq!(
|
||||
risc0_images::ledger_validity_proof::LEDGER_ID,
|
||||
ledger_validity_proof::LEDGER_ID
|
||||
);
|
||||
assert_eq!(
|
||||
risc0_images::ledger_validity_proof::LEDGER_ELF,
|
||||
ledger_validity_proof::LEDGER_ELF
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "nomos_cl_tx_risc0_proof"
|
||||
name = "nomos_mantle_tx_risc0_proof"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user