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
|
use zkvms_host_io::{read_args, RunType::{Execute, Prove, Verify}};
use std::io::{self, Write};
use std::process::{Command, Stdio};
static K: &str = "19";
static SCHEME: &str = "shplonk";
type Input = (Vec<Vec<bool>>, u32, Vec<Vec<u32>>);
fn build_input((graph, colors, coloring): &Input) -> String {
let mut ret = String::new();
for vec in graph {
for b in vec {
ret.push_str(&(*b as i32).to_string());
ret.push_str(":i64,");
}
}
ret.push_str(&colors.to_string());
ret.push_str(":i64,");
for vec in coloring {
for c in vec {
ret.push_str(&c.to_string());
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"));
},
}
}
|