Skip to content

Commit

Permalink
feat: first version of command line interface (#36)
Browse files Browse the repository at this point in the history
* wip on prover cli
* wip on networking
* wip on co-circom binary
* feat: improve configuration for mpc-net
* fix: re-write sharedwitness to also include public values
* feat: working witness splitting and proof gen + verification
* fix: cleanup + clippy fixes
* ci: add deny.toml
* docs: update package keys for crates
* chore: split-witness command now takes witness as argument instead of input
---------

Co-authored-by: Franco Nieddu <[email protected]>
  • Loading branch information
dkales and 0xThemis authored May 29, 2024
1 parent 45f8cfa commit 6abe716
Show file tree
Hide file tree
Showing 43 changed files with 735 additions and 222 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ tokio = { version = "1.34.0", features = [
"io-util",
"macros",
] }
toml = "0.8.13"
8 changes: 7 additions & 1 deletion circom-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
[package]
name = "circom-types"
version = "0.1.0"
edition = "2021"
publish.workspace = true
authors.workspace = true
edition.workspace = true
repository.workspace = true
homepage.workspace = true
license.workspace = true
rust-version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion circom-types/src/groth16/verification_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ where
fn from(value: PreparedVerifyingKey<P>) -> Self {
let vk = value.vk;
Self {
n_public: 1, //how to learn this???
n_public: vk.gamma_abc_g1.len() - 1,
alpha_1: vk.alpha_g1,
beta_2: vk.beta_g2,
gamma_2: vk.gamma_g2,
Expand Down
24 changes: 21 additions & 3 deletions collaborative-circom/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
[package]
name = "collaborative-circom"
version = "0.1.0"
edition = "2021"

publish.workspace = true
authors.workspace = true
edition.workspace = true
repository.workspace = true
homepage.workspace = true
license.workspace = true
rust-version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ark-bn254.workspace = true
bincode.workspace = true
circom-types = { version = "0.1.0", path = "../circom-types" }
clap.workspace = true
collaborative-groth16 = { version = "0.1.0", path = "../collaborative-groth16" }
color-eyre.workspace = true
thiserror.workspace = true
mpc-core = { version = "0.1.0", path = "../mpc-core" }
mpc-net.workspace = true
rand.workspace = true
serde.workspace = true
toml = "0.8.13"
thiserror.workspace = true
toml.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }
tracing.workspace = true
serde_json.workspace = true
ark-groth16.workspace = true
2 changes: 2 additions & 0 deletions collaborative-circom/examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.json
**/*.shared
21 changes: 11 additions & 10 deletions collaborative-circom/examples/configs/party1.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
my_id = 0
bind_addr = "0.0.0.0:8000"

bind_addr = "0.0.0.0:10000"
key_path = "data/key0.der"
[[parties]]
party_id = 0
addr = "localhost:8000"

id = 0
dns_name = "localhost:10000"
cert_path = "data/cert0.der"
[[parties]]
party_id = 1
addr = "localhost:8001"

id = 1
dns_name = "localhost:10001"
cert_path = "data/cert1.der"
[[parties]]
party_id = 2
addr = "localhost:8002"
id = 2
dns_name = "localhost:10002"
cert_path = "data/cert2.der"
21 changes: 11 additions & 10 deletions collaborative-circom/examples/configs/party2.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
my_id = 1
bind_addr = "0.0.0.0:8001"

bind_addr = "0.0.0.0:10001"
key_path = "data/key1.der"
[[parties]]
party_id = 0
addr = "localhost:8000"

id = 0
dns_name = "localhost:10000"
cert_path = "data/cert0.der"
[[parties]]
party_id = 1
addr = "localhost:8001"

id = 1
dns_name = "localhost:10001"
cert_path = "data/cert1.der"
[[parties]]
party_id = 2
addr = "localhost:8002"
id = 2
dns_name = "localhost:10002"
cert_path = "data/cert2.der"
21 changes: 11 additions & 10 deletions collaborative-circom/examples/configs/party3.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
my_id = 2
bind_addr = "0.0.0.0:8002"

bind_addr = "0.0.0.0:10002"
key_path = "data/key2.der"
[[parties]]
party_id = 0
addr = "localhost:8000"

id = 0
dns_name = "localhost:10000"
cert_path = "data/cert0.der"
[[parties]]
party_id = 1
addr = "localhost:8001"

id = 1
dns_name = "localhost:10001"
cert_path = "data/cert1.der"
[[parties]]
party_id = 2
addr = "localhost:8002"
id = 2
dns_name = "localhost:10002"
cert_path = "data/cert2.der"
Binary file added collaborative-circom/examples/data/cert0.der
Binary file not shown.
Binary file added collaborative-circom/examples/data/cert1.der
Binary file not shown.
Binary file added collaborative-circom/examples/data/cert2.der
Binary file not shown.
Binary file added collaborative-circom/examples/data/key0.der
Binary file not shown.
Binary file added collaborative-circom/examples/data/key1.der
Binary file not shown.
Binary file added collaborative-circom/examples/data/key2.der
Binary file not shown.
5 changes: 5 additions & 0 deletions collaborative-circom/examples/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cargo run --bin co-circom -- split-witness --input test_vectors/poseidon/witness.wtns --r1cs test_vectors/poseidon/poseidon.r1cs --protocol bla --out-dir test_vectors/poseidon
cargo run --bin co-circom -- generate-proof --witness test_vectors/poseidon/witness.wtns.0.shared --r1cs test_vectors/poseidon/poseidon.r1cs --zkey test_vectors/poseidon/circuit_0000.zkey --protocol bla --config configs/party1.toml --out proof.0.json &
cargo run --bin co-circom -- generate-proof --witness test_vectors/poseidon/witness.wtns.1.shared --r1cs test_vectors/poseidon/poseidon.r1cs --zkey test_vectors/poseidon/circuit_0000.zkey --protocol bla --config configs/party2.toml --out proof.1.json &
cargo run --bin co-circom -- generate-proof --witness test_vectors/poseidon/witness.wtns.2.shared --r1cs test_vectors/poseidon/poseidon.r1cs --zkey test_vectors/poseidon/circuit_0000.zkey --protocol bla --config configs/party3.toml --out proof.2.json
cargo run --bin co-circom -- verify --proof proof.0.json --vk test_vectors/poseidon/verification_key.json --public-inputs test_vectors/poseidon/witness.wtns.0.shared
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"protocol": "groth16",
"curve": "bn128",
"nPublic": 1,
"vk_alpha_1": [
"20491192805390485299153009773594534940189261866228447918068658471970481763042",
"9383485363053290200918347156157836566562967994039712273449902621266178545958",
"1"
],
"vk_beta_2": [
[
"6375614351688725206403948262868962793625744043794305715222011528459656738731",
"4252822878758300859123897981450591353533073413197771768651442665752259397132"
],
[
"10505242626370262277552901082094356697409835680220590971873171140371331206856",
"21847035105528745403288232691147584728191162732299865338377159692350059136679"
],
[
"1",
"0"
]
],
"vk_gamma_2": [
[
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
],
[
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
],
[
"1",
"0"
]
],
"vk_delta_2": [
[
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
],
[
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
],
[
"1",
"0"
]
],
"vk_alphabeta_12": [
[
[
"2029413683389138792403550203267699914886160938906632433982220835551125967885",
"21072700047562757817161031222997517981543347628379360635925549008442030252106"
],
[
"5940354580057074848093997050200682056184807770593307860589430076672439820312",
"12156638873931618554171829126792193045421052652279363021382169897324752428276"
],
[
"7898200236362823042373859371574133993780991612861777490112507062703164551277",
"7074218545237549455313236346927434013100842096812539264420499035217050630853"
]
],
[
[
"7077479683546002997211712695946002074877511277312570035766170199895071832130",
"10093483419865920389913245021038182291233451549023025229112148274109565435465"
],
[
"4595479056700221319381530156280926371456704509942304414423590385166031118820",
"19831328484489333784475432780421641293929726139240675179672856274388269393268"
],
[
"11934129596455521040620786944827826205713621633706285934057045369193958244500",
"8037395052364110730298837004334506829870972346962140206007064471173334027475"
]
]
],
"IC": [
[
"1655549413518972190198478012616802994254462093161203201613599472264958303841",
"21742734017792296281216385119397138748114275727065024271646515586404591497876",
"1"
],
[
"16497930821522159474595176304955625435616718625609462506360632944366974274906",
"10404924572941018678793755094259635830045501866471999610240845041996101882275",
"1"
]
]
}
Binary file not shown.
Loading

0 comments on commit 6abe716

Please sign in to comment.