Skip to content

Commit

Permalink
support insecure_skip_seal feature in guest (#293)
Browse files Browse the repository at this point in the history
This is done by moving insecure_skip_seal() function from prover to receipt.
This feature is used to faciliate development of the guest code and not
intended for production use.
  • Loading branch information
SchmErik committed Dec 5, 2022
1 parent 5910726 commit 18f9257
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion risc0/r0vm/tests/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::path::Path;
use anyhow::Result;
use assert_cmd::Command;
use assert_fs::{fixture::PathChild, TempDir};
use risc0_zkvm::{prove::insecure_skip_seal, Receipt};
use risc0_zkvm::{receipt::insecure_skip_seal, Receipt};

static EXPECTED_STDOUT: &str = "Hello world on stdout!\n";
static EXPECTED_STDERR: &str = "Hello world on stderr!\n";
Expand Down
14 changes: 7 additions & 7 deletions risc0/zkvm/src/prove/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod plonk;
#[cfg(feature = "profiler")]
pub mod profiler;

use std::{collections::HashMap, env, fmt::Debug, io::Write, rc::Rc};
use std::{collections::HashMap, fmt::Debug, io::Write, rc::Rc};

use anyhow::{bail, Result};
use risc0_zkp::{
Expand All @@ -33,12 +33,12 @@ use risc0_zkvm_platform::{
};

use self::elf::Program;
use crate::{method_id::MethodId, receipt::Receipt, sha::sha, CIRCUIT};

pub fn insecure_skip_seal() -> bool {
cfg!(feature = "insecure_skip_seal")
&& env::var("RISC0_INSECURE_SKIP_SEAL").unwrap_or_default() == "1"
}
use crate::{
method_id::MethodId,
receipt::{insecure_skip_seal, Receipt},
sha::sha,
CIRCUIT,
};

/// Options available to modify the prover's behavior.
pub struct ProverOpts<'a> {
Expand Down
14 changes: 12 additions & 2 deletions risc0/zkvm/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ use serde::{Deserialize, Serialize};

use crate::{method_id::MethodId, CIRCUIT};

#[cfg(not(target_os = "zkvm"))]
pub fn insecure_skip_seal() -> bool {
cfg!(feature = "insecure_skip_seal")
&& std::env::var("RISC0_INSECURE_SKIP_SEAL").unwrap_or_default() == "1"
}

#[cfg(target_os = "zkvm")]
pub fn insecure_skip_seal() -> bool {
cfg!(feature = "insecure_skip_seal")
}

#[derive(Deserialize, Serialize, ZeroioSerialize, ZeroioDeserialize, Clone, Debug)]
pub struct Receipt {
pub journal: Vec<u32>,
Expand Down Expand Up @@ -57,8 +68,7 @@ where
}
};

#[cfg(not(target_os = "zkvm"))]
if crate::prove::insecure_skip_seal() {
if insecure_skip_seal() {
return Ok(());
}

Expand Down

0 comments on commit 18f9257

Please sign in to comment.