Skip to content

Commit

Permalink
remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
weilzkm committed Nov 29, 2024
1 parent 92c0fb3 commit 1b8912f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
3 changes: 1 addition & 2 deletions prover/examples/sha2-rust/Cargo.lock

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

3 changes: 2 additions & 1 deletion prover/examples/sha2-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ name = "sha2-rust"
edition = "2021"

[dependencies]
zkm-runtime = { git = "https://github.com/zkMIPS/zkm", package = "zkm-runtime" }
#zkm-runtime = { git = "https://github.com/zkMIPS/zkm", package = "zkm-runtime" }
zkm-runtime = { path = "../../../runtime/entrypoint" }
sha2 = { version = "0.10.8", default-features = false }
21 changes: 5 additions & 16 deletions prover/examples/zkmips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ fn split_segments() {
let _ = split_prog_into_segs(state, &seg_path, &block_path, seg_size);
}

const D: usize = 2;
type C = PoseidonGoldilocksConfig;
type F = <C as GenericConfig<D>>::F;

fn prove_single_seg_common(seg_file: &str, basedir: &str, block: &str, file: &str) {
let seg_reader = BufReader::new(File::open(seg_file).unwrap());
let kernel = segment_kernel(basedir, block, file, seg_reader);

const D: usize = 2;
type C = PoseidonGoldilocksConfig;
type F = <C as GenericConfig<D>>::F;

let allstark: AllStark<F, D> = AllStark::default();
let config = StarkConfig::standard_fast_config();
let mut timing = TimingTree::new("prove", log::Level::Info);
Expand Down Expand Up @@ -98,10 +98,6 @@ fn prove_multi_seg_common(
type InnerParameters = DefaultParameters;
type OuterParameters = Groth16WrapperParameters;

type F = GoldilocksField;
const D: usize = 2;
type C = PoseidonGoldilocksConfig;

if seg_file_number < 2 {
panic!("seg file number must >= 2\n");
}
Expand Down Expand Up @@ -304,10 +300,7 @@ fn u32_array_to_u8_vec(u32_array: &[u32; 8]) -> Vec<u8> {
fn prove_sha_5_precompile(
elf_path: &str,
seg_path: &str,
) -> Receipt<<PoseidonGoldilocksConfig as GenericConfig<2>>::F, PoseidonGoldilocksConfig, 2> {
const D: usize = 2;
type C = PoseidonGoldilocksConfig;
type F = <C as GenericConfig<D>>::F;
) -> Receipt<<C as GenericConfig<D>>::F, C, D> {

let mut state = load_elf_with_patch(elf_path, vec![]);
let n: u32 = 5;
Expand Down Expand Up @@ -352,10 +345,6 @@ fn prove_sha_5_precompile(

fn prove_sha2_precompile() {
// 1. split ELF into segs
const D: usize = 2;
type C = PoseidonGoldilocksConfig;
type F = <C as GenericConfig<D>>::F;

let elf_path = env::var("ELF_PATH").expect("ELF file is missing");
let precompile_path = env::var("PRECOMPILE_PATH").expect("PRECOMPILE ELF file is missing");
let seg_path = env::var("SEG_OUTPUT").expect("Segment output path is missing");
Expand Down
1 change: 1 addition & 0 deletions prover/src/generation/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ where
{
pub fn claim_digest(&self) -> [u8; 32] {
let mut hasher = Sha256::new();

hasher.update(self.root_before.clone());
hasher.update(self.userdata.clone());
let digest: [u8; 32] = hasher.finalize().into();
Expand Down
2 changes: 1 addition & 1 deletion runtime/entrypoint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Ported from Entrypoint for SP1 zkVM.
#![feature(asm_experimental_arch)]
//#![feature(asm_experimental_arch)]
pub mod heap;
pub mod syscalls;
pub mod io {
Expand Down

0 comments on commit 1b8912f

Please sign in to comment.