dfns / cggmp21

State-of-art threshold ECDSA in Rust
Apache License 2.0
41 stars 6 forks source link

Add support for stark curve #60

Closed maurges closed 9 months ago

maurges commented 9 months ago

Tests compatability using StarkNet. Would also be nice to check that prehashed messages are deserialized in an expected way in signers.

github-actions[bot] commented 9 months ago

Crate direct deps

Direct deps ```text digest v0.10.6 futures v0.3.24 generic-ec v0.0.0 (https://github.com/dfns-labs/generic-ec?branch=m#bb2e7109) generic-ec-zkp v0.1.0 (https://github.com/dfns-labs/generic-ec?branch=m#bb2e7109) hex v0.4.3 paillier-zk v0.1.0 (https://github.com/dfns-labs/paillier-zk?branch=m#ffdddb74) rand_chacha v0.3.1 rand_core v0.6.4 round-based v0.2.0 (https://github.com/Zengo-X/round-based-protocol?branch=round-based2#f626f96e) serde v1.0.188 serde_json v1.0.107 serde_with v2.3.3 sha2 v0.10.6 thiserror v1.0.48 ```

Compared to base branch

Diff ```text --- direct-deps-base 2023-09-29 10:03:44.979202000 +0000 +++ direct-deps-pr 2023-09-29 10:03:46.271186218 +0000 @@ -6 +6 @@ -paillier-zk v0.1.0 (https://github.com/dfns-labs/paillier-zk?branch=m#79477c4e) +paillier-zk v0.1.0 (https://github.com/dfns-labs/paillier-zk?branch=m#ffdddb74) @@ -10,3 +10,3 @@ -serde v1.0.160 -serde_json v1.0.89 -serde_with v2.0.1 +serde v1.0.188 +serde_json v1.0.107 +serde_with v2.3.3 @@ -14 +14 @@ -thiserror v1.0.37 +thiserror v1.0.48 ```

All deps

cargo tree ```text cggmp21 v0.0.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21) ├── digest v0.10.6 │ ├── block-buffer v0.10.3 │ │ └── generic-array v0.14.6 │ │ ├── serde v1.0.188 │ │ │ └── serde_derive v1.0.188 (proc-macro) │ │ │ ├── proc-macro2 v1.0.66 │ │ │ │ └── unicode-ident v1.0.4 │ │ │ ├── quote v1.0.33 │ │ │ │ └── proc-macro2 v1.0.66 (*) │ │ │ └── syn v2.0.32 │ │ │ ├── proc-macro2 v1.0.66 (*) │ │ │ ├── quote v1.0.33 (*) │ │ │ └── unicode-ident v1.0.4 │ │ └── typenum v1.15.0 │ └── crypto-common v0.1.6 │ ├── generic-array v0.14.6 (*) │ └── typenum v1.15.0 ├── futures v0.3.24 │ ├── futures-channel v0.3.24 │ │ ├── futures-core v0.3.24 │ │ └── futures-sink v0.3.24 │ ├── futures-core v0.3.24 │ ├── futures-executor v0.3.24 │ │ ├── futures-core v0.3.24 │ │ ├── futures-task v0.3.24 │ │ └── futures-util v0.3.24 │ │ ├── futures-channel v0.3.24 (*) │ │ ├── futures-core v0.3.24 │ │ ├── futures-io v0.3.24 │ │ ├── futures-macro v0.3.24 (proc-macro) │ │ │ ├── proc-macro2 v1.0.66 (*) │ │ │ ├── quote v1.0.33 (*) │ │ │ └── syn v1.0.101 │ │ │ ├── proc-macro2 v1.0.66 (*) │ │ │ ├── quote v1.0.33 (*) │ │ │ └── unicode-ident v1.0.4 │ │ ├── futures-sink v0.3.24 │ │ ├── futures-task v0.3.24 │ │ ├── memchr v2.5.0 │ │ ├── pin-project-lite v0.2.9 │ │ ├── pin-utils v0.1.0 │ │ └── slab v0.4.7 │ ├── futures-io v0.3.24 │ ├── futures-sink v0.3.24 │ ├── futures-task v0.3.24 │ └── futures-util v0.3.24 (*) ├── generic-ec v0.0.0 (https://github.com/dfns-labs/generic-ec?branch=m#bb2e7109) │ ├── generic-ec-core v0.1.0 (https://github.com/dfns-labs/generic-ec?branch=m#bb2e7109) │ │ ├── generic-array v0.14.6 (*) │ │ ├── rand_core v0.6.4 │ │ ├── serde v1.0.188 (*) │ │ ├── subtle v2.4.1 │ │ └── zeroize v1.6.0 │ │ └── zeroize_derive v1.3.2 (proc-macro) │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ ├── syn v1.0.101 (*) │ │ └── synstructure v0.12.6 │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ ├── syn v1.0.101 (*) │ │ └── unicode-xid v0.2.4 │ ├── getrandom v0.2.10 │ │ ├── cfg-if v1.0.0 │ │ └── libc v0.2.148 │ ├── hex v0.4.3 │ │ └── serde v1.0.188 (*) │ ├── phantom-type v0.4.2 │ │ └── educe v0.4.19 (proc-macro) │ │ ├── enum-ordinalize v3.1.11 (proc-macro) │ │ │ ├── num-bigint v0.4.3 │ │ │ │ ├── num-integer v0.1.45 │ │ │ │ │ └── num-traits v0.2.15 │ │ │ │ └── num-traits v0.2.15 │ │ │ ├── num-traits v0.2.15 │ │ │ ├── proc-macro2 v1.0.66 (*) │ │ │ ├── quote v1.0.33 (*) │ │ │ └── syn v1.0.101 (*) │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ └── syn v1.0.101 (*) │ ├── rand_core v0.6.4 │ ├── serde v1.0.188 (*) │ ├── serde_with v2.3.3 │ │ ├── serde v1.0.188 (*) │ │ └── serde_with_macros v2.3.3 (proc-macro) │ │ ├── darling v0.20.1 │ │ │ ├── darling_core v0.20.1 │ │ │ │ ├── fnv v1.0.7 │ │ │ │ ├── ident_case v1.0.1 │ │ │ │ ├── proc-macro2 v1.0.66 (*) │ │ │ │ ├── quote v1.0.33 (*) │ │ │ │ ├── strsim v0.10.0 │ │ │ │ └── syn v2.0.32 (*) │ │ │ └── darling_macro v0.20.1 (proc-macro) │ │ │ ├── darling_core v0.20.1 (*) │ │ │ ├── quote v1.0.33 (*) │ │ │ └── syn v2.0.32 (*) │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ └── syn v2.0.32 (*) │ ├── subtle v2.4.1 │ └── zeroize v1.6.0 (*) ├── generic-ec-zkp v0.1.0 (https://github.com/dfns-labs/generic-ec?branch=m#bb2e7109) │ ├── digest v0.10.6 (*) │ ├── generic-array v0.14.6 (*) │ ├── generic-ec v0.0.0 (https://github.com/dfns-labs/generic-ec?branch=m#bb2e7109) (*) │ ├── rand_core v0.6.4 │ ├── serde v1.0.188 (*) │ └── subtle v2.4.1 ├── hex v0.4.3 (*) ├── paillier-zk v0.1.0 (https://github.com/dfns-labs/paillier-zk?branch=m#ffdddb74) │ ├── digest v0.10.6 (*) │ ├── fast-paillier v0.1.0 (https://github.com/dfns-labs/fast-paillier?branch=m#2fcc3135) │ │ ├── bytemuck v1.13.1 │ │ │ └── bytemuck_derive v1.4.1 (proc-macro) │ │ │ ├── proc-macro2 v1.0.66 (*) │ │ │ ├── quote v1.0.33 (*) │ │ │ └── syn v2.0.32 (*) │ │ ├── rand_core v0.6.4 │ │ ├── rug v1.21.0 │ │ │ ├── az v1.2.1 │ │ │ ├── gmp-mpfr-sys v1.6.1 │ │ │ │ └── libc v0.2.148 │ │ │ ├── libc v0.2.148 │ │ │ └── serde v1.0.188 (*) │ │ ├── serde v1.0.188 (*) │ │ └── thiserror v1.0.48 │ │ └── thiserror-impl v1.0.48 (proc-macro) │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ └── syn v2.0.32 (*) │ ├── generic-ec v0.0.0 (https://github.com/dfns-labs/generic-ec?branch=m#bb2e7109) (*) │ ├── rand_core v0.6.4 │ ├── rug v1.21.0 (*) │ ├── serde v1.0.188 (*) │ ├── serde_with v3.0.0 │ │ ├── serde v1.0.188 (*) │ │ └── serde_with_macros v3.0.0 (proc-macro) │ │ ├── darling v0.20.1 (*) │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ └── syn v2.0.32 (*) │ └── thiserror v1.0.48 (*) ├── rand_chacha v0.3.1 │ ├── ppv-lite86 v0.2.17 │ └── rand_core v0.6.4 ├── rand_core v0.6.4 ├── round-based v0.2.0 (https://github.com/Zengo-X/round-based-protocol?branch=round-based2#f626f96e) │ ├── async-stream v0.3.3 │ │ ├── async-stream-impl v0.3.3 (proc-macro) │ │ │ ├── proc-macro2 v1.0.66 (*) │ │ │ ├── quote v1.0.33 (*) │ │ │ └── syn v1.0.101 (*) │ │ └── futures-core v0.3.24 │ ├── bincode v1.3.3 │ │ └── serde v1.0.188 (*) │ ├── futures v0.3.24 (*) │ ├── never v0.1.0 │ ├── phantom-type v0.3.1 │ │ └── educe v0.4.19 (proc-macro) (*) │ ├── round-based-derive v0.1.0 (proc-macro) (https://github.com/Zengo-X/round-based-protocol?branch=round-based2#f626f96e) │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ └── syn v1.0.101 (*) │ ├── serde v1.0.188 (*) │ ├── thiserror v1.0.48 (*) │ ├── tokio v1.21.2 │ │ └── pin-project-lite v0.2.9 │ ├── tokio-stream v0.1.10 │ │ ├── futures-core v0.3.24 │ │ ├── pin-project-lite v0.2.9 │ │ ├── tokio v1.21.2 (*) │ │ └── tokio-util v0.7.4 │ │ ├── bytes v1.2.1 │ │ ├── futures-core v0.3.24 │ │ ├── futures-sink v0.3.24 │ │ ├── pin-project-lite v0.2.9 │ │ └── tokio v1.21.2 (*) │ └── tracing v0.1.36 │ ├── cfg-if v1.0.0 │ ├── pin-project-lite v0.2.9 │ ├── tracing-attributes v0.1.22 (proc-macro) │ │ ├── proc-macro2 v1.0.66 (*) │ │ ├── quote v1.0.33 (*) │ │ └── syn v1.0.101 (*) │ └── tracing-core v0.1.29 │ └── once_cell v1.17.0 ├── serde v1.0.188 (*) ├── serde_json v1.0.107 │ ├── itoa v1.0.4 │ ├── ryu v1.0.11 │ └── serde v1.0.188 (*) ├── serde_with v2.3.3 (*) ├── sha2 v0.10.6 │ ├── cfg-if v1.0.0 │ ├── cpufeatures v0.2.5 │ └── digest v0.10.6 (*) └── thiserror v1.0.48 (*) ```

Compared to base branch

Diff ```text --- all-deps-base 2023-09-29 10:03:45.127200192 +0000 +++ all-deps-pr 2023-09-29 10:03:46.439183766 +0000 @@ -12 +11,0 @@ -darling v0.14.1 @@ -14 +12,0 @@ -darling_core v0.14.1 @@ -16 +13,0 @@ -darling_macro v0.14.1 (proc-macro) @@ -36 +33 @@ -getrandom v0.2.8 +getrandom v0.2.10 @@ -41 +38 @@ -libc v0.2.134 +libc v0.2.148 @@ -48 +45 @@ -paillier-zk v0.1.0 (https://github.com/dfns-labs/paillier-zk?branch=m#79477c4e) +paillier-zk v0.1.0 (https://github.com/dfns-labs/paillier-zk?branch=m#ffdddb74) @@ -55 +52 @@ -quote v1.0.26 +quote v1.0.33 @@ -62,4 +59,4 @@ -serde v1.0.160 -serde_derive v1.0.160 (proc-macro) -serde_json v1.0.89 -serde_with v2.0.1 +serde v1.0.188 +serde_derive v1.0.188 (proc-macro) +serde_json v1.0.107 +serde_with v2.3.3 @@ -67 +64 @@ -serde_with_macros v2.0.1 (proc-macro) +serde_with_macros v2.3.3 (proc-macro) @@ -74 +71 @@ -syn v2.0.15 +syn v2.0.32 @@ -76,2 +73,2 @@ -thiserror v1.0.37 -thiserror-impl v1.0.37 (proc-macro) +thiserror v1.0.48 +thiserror-impl v1.0.48 (proc-macro) @@ -87 +84 @@ -zeroize v1.5.7 +zeroize v1.6.0 ```
github-actions[bot] commented 9 months ago

Benchmark Result

Benchmarks ```text RUST_TESTS_SEED=29cf8fda369f334d1de351d7d7ab31c389c700c511b607e330d4210cd6ef2227 n = 3 Non-threshold DKG Protocol Performance: - Protocol took 637.02µs to complete In particular: - Setup: 8.00µs - Setup networking: 7.60µs (95.0%) - Unstaged: 400.00ns (5.0%) - Round 1: 164.51µs - Compute execution id: 200.00ns (0.1%) - Sample x_i, rid_i: 73.50µs (44.7%) - Sample schnorr commitment: 66.50µs (40.4%) - Commit to public data: 23.80µs (14.5%) - Unstaged: 500.00ns (0.3%) - Round 2: 4.10µs - Hash received msgs (reliability check): 3.80µs (92.7%) - Unstaged: 300.00ns (7.3%) - Round 3: 500.00ns - Assert other parties hashed messages (reliability check): 300.00ns (60.0%) - Unstaged: 200.00ns (40.0%) - Round 4: 59.50µs - Validate decommitments: 56.80µs (95.5%) - Calculate challege rid: 2.20µs (3.7%) - Prove knowledge of `x_i`: 200.00ns (0.3%) - Unstaged: 300.00ns (0.5%) - Round 5: 400.41µs - Validate schnorr proofs: 399.91µs (99.9%) - Unstaged: 500.00ns (0.1%) Threshold DKG Protocol Performance: - Protocol took 1.46ms to complete In particular: - Setup: 2.40µs - Setup networking: 2.30µs (95.8%) - Unstaged: 100.00ns (4.2%) - Round 1: 281.51µs - Compute execution id: 100.00ns (0.0%) - Sample rid_i, schnorr commitment, polynomial: 252.81µs (89.8%) - Commit to public data: 28.30µs (10.1%) - Unstaged: 300.00ns (0.1%) - Round 2: 4.00µs - Hash received msgs (reliability check): 3.90µs (97.5%) - Unstaged: 100.00ns (2.5%) - Round 3: 300.00ns - Assert other parties hashed messages (reliability check): 200.00ns (66.7%) - Unstaged: 100.00ns (33.3%) - Round 4: 872.73µs - Validate decommitments: 55.00µs (6.3%) - Validate data size: 400.00ns (0.0%) - Validate Feldmann VSS: 398.61µs (45.7%) - Compute rid: 300.00ns (0.0%) - Compute Ys: 400.91µs (45.9%) - Compute sigma: 400.00ns (0.0%) - Calculate challenge: 16.60µs (1.9%) - Prove knowledge of `sigma_i`: 200.00ns (0.0%) - Unstaged: 300.00ns (0.0%) - Round 5: 301.31µs - Validate schnorr proofs: 296.81µs (98.5%) - Derive resulting public key and other data: 1.70µs (0.6%) - Unstaged: 2.80µs (0.9%) Auxiliary data generation protocol Protocol Performance: - Protocol took 10.95s to complete In particular: - Setup: 8.00µs - Retrieve auxiliary data: 300.00ns (3.8%) - Setup networking: 6.80µs (85.0%) - Precompute execution id and shared state: 700.00ns (8.8%) - Unstaged: 200.00ns (2.5%) - Round 1: 1.33s - Retrieve primes (p and q): 100.00ns (0.0%) - Compute paillier decryption key (N): 5.90µs (0.0%) - Generate auxiliary params r, λ, t, s: 10.76ms (0.8%) - Prove Πprm (ψˆ_i): 1.32s (99.1%) - Sample random bytes: 2.40µs (0.0%) - Compute hash commitment and sample decommitment: 1.01ms (0.1%) - Unstaged: 300.00ns (0.0%) - Round 2: 4.60µs - Hash received msgs (reliability check): 4.10µs (89.1%) - Unstaged: 500.00ns (10.9%) - Round 3: 600.00ns - Assert other parties hashed messages (reliability check): 200.00ns (33.3%) - Unstaged: 400.00ns (66.7%) - Round 4: 6.75s - Validate round 1 decommitments: 2.03ms (0.0%) - Validate П_prm (ψ_i): 2.61s (38.7%) - Add together shared random bytes: 3.00µs (0.0%) - Compute П_mod (ψ_i): 3.94s (58.4%) - Assemble security params for П_fac (ф_i): 7.80µs (0.0%) - Compute П_fac (ф_i^j): 196.59ms (2.9%) - Unstaged: 1.50µs (0.0%) - Round 5: 2.87s - Validate ψ_j (П_mod): 2.67s (93.1%) - Validate ф_j (П_fac): 197.59ms (6.9%) - Assemble auxiliary info: 192.71µs (0.0%) - Unstaged: 700.00ns (0.0%) Signing protocol Protocol Performance: - Protocol took 1.85s to complete In particular: - Setup: 138.61µs - Map t-out-of-n protocol to t-out-of-t: 9.50µs (6.9%) - Retrieve auxiliary data: 123.80µs (89.3%) - Precompute execution id and security params: 700.00ns (0.5%) - Setup networking: 4.40µs (3.2%) - Unstaged: 200.00ns (0.1%) - Round 1: 134.79ms - Generate local ephemeral secrets (k_i, y_i, p_i, v_i): 66.10µs (0.0%) - Encrypt G_i and K_i: 41.16ms (30.5%) - Prove ψ0_j: 93.56ms (69.4%) - Unstaged: 2.10µs (0.0%) - Round 2: 77.40µs - Hash received msgs (reliability check): 77.10µs (99.6%) - Unstaged: 300.00ns (0.4%) - Round 3: 926.74ms - Assert other parties hashed messages (reliability check): 800.00ns (0.0%) - Verify psi0 proofs: 106.55ms (11.5%) - Sample random r, hat_r, s, hat_s, beta, hat_beta: 52.20µs (0.0%) - Encrypt D_ji: 81.59ms (8.8%) - Encrypt F_ji: 41.15ms (4.4%) - Encrypt hat_D_ji: 81.77ms (8.8%) - Encrypt hat_F_ji: 41.16ms (4.4%) - Prove psi_ji: 240.47ms (25.9%) - Prove psiˆ_ji: 240.65ms (26.0%) - Prove psi_prime_ji : 93.34ms (10.1%) - Unstaged: 1.60µs (0.0%) - Round 4: 677.19ms - Retrieve auxiliary data: 4.90µs (0.0%) - Validate psi: 197.05ms (29.1%) - Validate hat_psi: 197.06ms (29.1%) - Validate psi_prime: 106.77ms (15.8%) - Compute Gamma, Delta_i, delta_i, chi_i: 82.53ms (12.2%) - Prove psi_prime_prime: 93.78ms (13.8%) - Unstaged: 700.00ns (0.0%) - Presig output: 106.40ms - Validate psi_prime_prime: 106.25ms (99.9%) - Calculate presignature: 149.41µs (0.1%) - Unstaged: 900.00ns (0.0%) - Partial signing: 10.60µs - Signature reconstruction: 224.11µs ```