Skip to content

Commit

Permalink
Support args (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
xander42280 authored Oct 18, 2024
1 parent c09abde commit db996f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions host-program/src/bin/zkm-prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
private_inputstream: "".into(),
seg_size: 0,
execute_only: false,
args: "".into(),
}
}
};
Expand Down Expand Up @@ -164,6 +165,7 @@ fn set_sha2_rust_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<
private_inputstream: pri_buf,
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand Down Expand Up @@ -236,6 +238,7 @@ fn set_sha2_go_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<Pr
private_inputstream: "".into(),
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand All @@ -249,6 +252,7 @@ fn set_mem_alloc_vec_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Res
private_inputstream: "".into(),
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand All @@ -263,6 +267,7 @@ fn set_revme_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<Prov
private_inputstream: "".into(),
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand Down
7 changes: 6 additions & 1 deletion sdk/src/local/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ pub fn prove_stark(
let seg_size = input.seg_size as usize;
let file = ElfBytes::<AnyEndian>::minimal_parse(input.elf.as_slice())
.expect("opening elf file failed");
let mut args: Vec<&str> = input.args.split_whitespace().collect();
if args.len() > 2 {
args.truncate(2);
}
log::info!("args: {:?}", args);
let mut state = State::load_elf(&file);
state.patch_elf(&file);
state.patch_stack(vec![]);
state.patch_stack(args);

state.input_stream.push(input.public_inputstream.clone());
state.input_stream.push(input.private_inputstream.clone());
Expand Down
1 change: 1 addition & 0 deletions sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl Prover for NetworkProver {
public_input_stream: input.public_inputstream.clone(),
private_input_stream: input.private_inputstream.clone(),
execute_only: input.execute_only,
args: input.args.clone(),
..Default::default()
};
self.sign_ecdsa(&mut request).await;
Expand Down
1 change: 1 addition & 0 deletions sdk/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct ProverInput {
pub private_inputstream: Vec<u8>,
pub seg_size: u32,
pub execute_only: bool,
pub args: String,
}

#[derive(Debug, Default, Deserialize, Serialize, Clone)]
Expand Down

0 comments on commit db996f8

Please sign in to comment.