Skip to content

Commit

Permalink
replace println with log
Browse files Browse the repository at this point in the history
  • Loading branch information
tolak committed Aug 16, 2024
1 parent b5139bb commit 03d317a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
13 changes: 6 additions & 7 deletions apps/src/local_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ impl LocalProver {
/// Generates a snark proof as a triplet (`Vec<u8>`, `FixedBytes<32>`,
/// `Vec<u8>) for the given elf and input.
pub fn prove(elf: &[u8], input: &[u8]) -> Result<(Vec<u8>, FixedBytes<32>, Vec<u8>)> {
println!("start local proving");
log::info!("Start local proving");
let env = ExecutorEnv::builder()
.write_slice(input)
// .unwrap()
.build()
.unwrap();

println!("execute");
log::info!("Create execution session");
let mut exec = ExecutorImpl::from_elf(env, elf).unwrap();
let session = exec.run().unwrap();

println!("prove");
log::info!("Generate STARK proof");
let opts = ProverOpts::default();
let ctx = VerifierContext::default();
let prover = get_prover_server(&opts).unwrap();
Expand All @@ -51,13 +51,12 @@ impl LocalProver {
let succinct_receipt = prover.compress(composite_receipt).unwrap();
let journal: Vec<u8> = session.journal.unwrap().bytes;

println!("identity_p254");
let ident_receipt = identity_p254(&succinct_receipt).unwrap();
let seal_bytes = ident_receipt.get_seal_bytes();

println!("Start translate STARK to SNARK");
log::info!("Start translate STARK to SNARK");
let seal = stark_to_snark(&seal_bytes).unwrap().to_vec();
println!(
log::info!(
"Transform finish, proof size decrease from {:} bytes to {:} bytes, snark proof {:?}",
seal_bytes.len(),
seal.len(),
Expand All @@ -83,7 +82,7 @@ mod tests {
let (journal, _post_state_digest, seal) =
super::LocalProver::prove(DCAP_VERIFIER_ELF, &even_number.abi_encode()).unwrap();

println!("Snark proof: {:?}", hex::encode(&seal));
log::info!("Snark proof: {:?}", hex::encode(&seal));
let x = U256::abi_decode(&journal, true).unwrap();
assert_eq!(x, even_number);
}
Expand Down
1 change: 1 addition & 0 deletions methods/guest/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions methods/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ chrono = { version = "0.4.31", default-features = false, features = ["alloc", "s

anyhow = { version = "1.0.79", default-features = false }
thiserror = "1.0.50"
log = { version = "0.4" }

asn1_der = { version = "0.7", default-features = false, features = [
"native_types",
Expand Down
4 changes: 2 additions & 2 deletions methods/guest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() {
// Deserialize input bytes
let input: Inputs = bincode::deserialize(&input_bytes).unwrap();

println!("Guest: check if dcap input is valid");
log::info!("Check if dcap input is valid");
let now = input.now;
let raw_quote = input.quote;
let raw_quote_collateral = input.quote_collateral;
Expand All @@ -51,7 +51,7 @@ fn main() {
advisory_ids
};

println!("Guest: check passed, commit output to host");
log::info!("Check passed, commit output to host");

// write public output to the journal
env::commit_slice(bincode::serialize(&output).unwrap().as_slice());
Expand Down

0 comments on commit 03d317a

Please sign in to comment.