Skip to content

Commit

Permalink
Merge pull request #18 from originalworks/use-groth16-in-guest-code
Browse files Browse the repository at this point in the history
Use groth16 for proof generation
  • Loading branch information
cezary-stroczynski authored Dec 10, 2024
2 parents c850f03 + 8ff7379 commit b0a228c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
7 changes: 4 additions & 3 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ shared = { path = "shared" }
risc0-zkvm = { version = "1.1.2" }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
serde = "1.0"
ddex_schema = {path = '../parser/ddex_schema'}
ddex_schema = { path = '../parser/ddex_schema' }
env_logger = "0.11.5"
blob_codec = {path = '../blob_codec'}
blob_codec = { path = '../blob_codec' }
risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum", tag = "v1.1.4" }

[features]
cuda = ["risc0-zkvm/cuda"]
default = []
metal = ["risc0-zkvm/metal"]
prove = ["risc0-zkvm/prove"]
prove = ["risc0-zkvm/prove"]
27 changes: 21 additions & 6 deletions prover/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use blob_codec::BlobCodec;
use core::str;
use methods::{DDEX_PARSER_GUEST_ELF, DDEX_PARSER_GUEST_ID};
use risc0_zkvm::{default_prover, ExecutorEnv};
use risc0_ethereum_contracts::encode_seal;
use risc0_zkvm::{default_prover, ExecutorEnv, ProverOpts, VerifierContext};
use shared::PublicOutputs;
use std::time::Instant;

pub struct StopWatch {
timer: Instant,
}
Expand Down Expand Up @@ -40,16 +40,31 @@ fn main() {

let prover = default_prover();

let receipt = prover.prove(env, DDEX_PARSER_GUEST_ELF).unwrap().receipt;
let receipt = prover
.prove_with_ctx(
env,
&VerifierContext::default(),
DDEX_PARSER_GUEST_ELF,
&ProverOpts::groth16(),
)
.unwrap()
.receipt;

let seal = encode_seal(&receipt).unwrap();

let journal = receipt.journal.bytes.clone();

let public_outputs: PublicOutputs = receipt.journal.decode().unwrap();

println!(
"Values decoded from receipt:: Verified: {}, Digest: {}",
public_outputs.is_valid,
String::from_utf8_lossy(&public_outputs.digest),
"Values decoded from receipt:: Verified: {}",
public_outputs.is_valid
);

println!("public outputs: {public_outputs:?}");
println!("journal: {journal:?}");
println!("seal: {seal:?}");

timer.stop("produce the proof");

timer = StopWatch::start();
Expand Down

0 comments on commit b0a228c

Please sign in to comment.