1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
use zkvms_host_io::{Input, foreach_input_field, read_args, RunType::{Execute, Prove, Verify}};
use std::io::{self, Write};
use std::process::{Command, Stdio};
use regex::Regex;
static K: &str = "19";
static SCHEME: &str = "shplonk";
fn build_input(input: &Input) -> String {
let numreg: Regex = Regex::new("(?:^|[^A-Za-z])([0-9]+)").unwrap();
let mut ret = String::new();
foreach_input_field!{
let flat = format!("{:?}", input.yield)
.replace("false", "0")
.replace("true", "1");
let numbers: Vec<&str> = numreg
.captures_iter(&flat)
.map(|cap| cap.get(1).unwrap().as_str())
.collect();
for num in numbers {
ret.push_str(num);
ret.push_str(":i64,");
}
}
ret.pop(); // removes trailing comma
ret
}
fn zkwasm_command(subcmd: &str) -> Command {
let mut command = Command::new("zkwasm-cli");
command
.arg("--params").arg("./params")
.arg("prog").arg(subcmd)
.arg("--wasm").arg(env!("GUEST_PATH"));
command
}
fn run(cmd: &mut Command) {
assert!(cmd.status().expect("couldn't execute command!").success());
}
fn main() {
let run_info = read_args();
run(zkwasm_command("setup")
.arg("-k").arg(K)
.arg("--scheme").arg(SCHEME));
let input = build_input(&run_info.input);
match run_info.run_type {
Execute => {
run(zkwasm_command("dry-run")
.arg("--private").arg(input)
.arg("--output").arg("./output"));
},
Prove => {
run(zkwasm_command("prove")
.arg("--private").arg(input)
.arg("--output").arg("./output"));
},
Verify => {
run(zkwasm_command("prove")
.arg("--private").arg(input)
.arg("--output").arg("./output"));
run(Command::new("zkwasm-cli")
.arg("--params").arg("./params")
.arg("prog").arg("verify")
.arg("--output").arg("./output"));
},
}
}
|