Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify: use hash_raw_pod_slice to hash journal without trailer #291

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion risc0/zkp/src/verify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ where
}
}
} else {
let journal_digest = hal.sha().hash_words(journal);
let journal_digest = hal.sha().hash_raw_pod_slice(journal);
let journal_hash = journal_digest.as_slice();
for i in 0..journal_hash.len() {
if journal_hash[i]
Expand Down
24 changes: 24 additions & 0 deletions risc0/zkvm/methods/std/src/bin/hello_commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022 Risc0, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![no_std]
#![no_main]

use risc0_zkvm::guest::env;

risc0_zkvm::entry!(main);

pub fn main() {
env::commit(b"hello world");
}
16 changes: 15 additions & 1 deletion risc0/zkvm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use anyhow::Result;
use risc0_zeroio::{from_slice, to_vec};
use risc0_zkp::core::sha::Digest;
use risc0_zkvm_methods::{
multi_test::MultiTestSpec, FIB_CONTENTS, FIB_ID, MULTI_TEST_CONTENTS, MULTI_TEST_ID,
multi_test::MultiTestSpec, FIB_CONTENTS, FIB_ID, HELLO_COMMIT_CONTENTS, HELLO_COMMIT_ID,
MULTI_TEST_CONTENTS, MULTI_TEST_ID,
};
use risc0_zkvm_platform::{
memory::{COMMIT, HEAP},
Expand Down Expand Up @@ -195,6 +196,19 @@ fn long_fib() {
);
}

#[test]
#[cfg_attr(feature = "insecure_skip_seal", ignore)]
fn commit_hello_world() {
let receipt = {
let mut prover = Prover::new(HELLO_COMMIT_CONTENTS, HELLO_COMMIT_ID).unwrap();
prover.run().expect("Could not get receipt")
};

receipt
.verify(HELLO_COMMIT_ID)
.expect("Could not verify receipt");
}

#[test]
fn host_sendrecv() {
let expected: Vec<Vec<u8>> = vec![
Expand Down