Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch p2p messages in one round instead of flushing immediately #127

Open
wants to merge 1 commit into
base: m
Choose a base branch
from

Conversation

maurges
Copy link
Contributor

@maurges maurges commented Dec 20, 2024

I removed p2p message tracing from signing because I couldn't make sense of it. Ideas of how to track it are welcome

@maurges maurges requested a review from survived December 20, 2024 15:32
Copy link

github-actions bot commented Dec 20, 2024

Crate direct deps

Direct deps
cggmp21-keygen v0.5.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21-keygen)
digest v0.10.6
futures v0.3.24
generic-ec v0.4.1
generic-ec-zkp v0.4.1
hex v0.4.3
key-share v0.6.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share)
paillier-zk v0.4.1
rand_core v0.6.4
rand_hash v0.1.0
round-based v0.4.0
serde v1.0.193
serde_with v2.3.3
sha2 v0.10.6
thiserror v1.0.48
udigest v0.2.1

Compared to base branch

Diff
--- direct-deps-base	2024-12-20 15:33:24.664181841 +0000
+++ direct-deps-pr	2024-12-20 15:33:24.948181422 +0000
@@ -1 +1 @@
-cggmp21-keygen v0.5.0 (/home/runner/work/cggmp21/cggmp21/base_branch/cggmp21-keygen)
+cggmp21-keygen v0.5.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21-keygen)
@@ -7 +7 @@
-key-share v0.6.0 (/home/runner/work/cggmp21/cggmp21/base_branch/key-share)
+key-share v0.6.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share)

All deps

cargo tree
cggmp21 v0.6.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21)
├── cggmp21-keygen v0.5.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21-keygen)
│   ├── digest v0.10.6
│   │   ├── block-buffer v0.10.3
│   │   │   └── generic-array v0.14.6
│   │   │       ├── serde v1.0.193
│   │   │       │   └── serde_derive v1.0.193 (proc-macro)
│   │   │       │       ├── proc-macro2 v1.0.92
│   │   │       │       │   └── unicode-ident v1.0.4
│   │   │       │       ├── quote v1.0.37
│   │   │       │       │   └── proc-macro2 v1.0.92 (*)
│   │   │       │       └── syn v2.0.90
│   │   │       │           ├── proc-macro2 v1.0.92 (*)
│   │   │       │           ├── quote v1.0.37 (*)
│   │   │       │           └── unicode-ident v1.0.4
│   │   │       └── typenum v1.15.0
│   │   └── crypto-common v0.1.6
│   │       ├── generic-array v0.14.6 (*)
│   │       └── typenum v1.15.0
│   ├── displaydoc v0.2.5 (proc-macro)
│   │   ├── proc-macro2 v1.0.92 (*)
│   │   ├── quote v1.0.37 (*)
│   │   └── syn v2.0.90 (*)
│   ├── 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.92 (*)
│   │   │       │   ├── quote v1.0.37 (*)
│   │   │       │   └── syn v1.0.101
│   │   │       │       ├── proc-macro2 v1.0.92 (*)
│   │   │       │       ├── quote v1.0.37 (*)
│   │   │       │       └── 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.4.1
│   │   ├── digest v0.10.6 (*)
│   │   ├── generic-ec-core v0.2.0
│   │   │   ├── generic-array v0.14.6 (*)
│   │   │   ├── rand_core v0.6.4
│   │   │   ├── serde v1.0.193 (*)
│   │   │   ├── subtle v2.4.1
│   │   │   └── zeroize v1.6.0
│   │   │       └── zeroize_derive v1.3.2 (proc-macro)
│   │   │           ├── proc-macro2 v1.0.92 (*)
│   │   │           ├── quote v1.0.37 (*)
│   │   │           ├── syn v1.0.101 (*)
│   │   │           └── synstructure v0.12.6
│   │   │               ├── proc-macro2 v1.0.92 (*)
│   │   │               ├── quote v1.0.37 (*)
│   │   │               ├── syn v1.0.101 (*)
│   │   │               └── unicode-xid v0.2.4
│   │   ├── hex v0.4.3
│   │   │   └── serde v1.0.193 (*)
│   │   ├── 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.92 (*)
│   │   │       │   ├── quote v1.0.37 (*)
│   │   │       │   └── syn v1.0.101 (*)
│   │   │       ├── proc-macro2 v1.0.92 (*)
│   │   │       ├── quote v1.0.37 (*)
│   │   │       └── syn v1.0.101 (*)
│   │   ├── rand_core v0.6.4
│   │   ├── rand_hash v0.1.0
│   │   │   ├── digest v0.10.6 (*)
│   │   │   ├── rand_core v0.6.4
│   │   │   └── udigest v0.2.1
│   │   │       ├── digest v0.10.6 (*)
│   │   │       └── udigest-derive v0.3.0 (proc-macro)
│   │   │           ├── proc-macro2 v1.0.92 (*)
│   │   │           ├── quote v1.0.37 (*)
│   │   │           └── syn v2.0.90 (*)
│   │   ├── serde v1.0.193 (*)
│   │   ├── serde_with v2.3.3
│   │   │   ├── serde v1.0.193 (*)
│   │   │   └── 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.92 (*)
│   │   │       │   │   ├── quote v1.0.37 (*)
│   │   │       │   │   ├── strsim v0.10.0
│   │   │       │   │   └── syn v2.0.90 (*)
│   │   │       │   └── darling_macro v0.20.1 (proc-macro)
│   │   │       │       ├── darling_core v0.20.1 (*)
│   │   │       │       ├── quote v1.0.37 (*)
│   │   │       │       └── syn v2.0.90 (*)
│   │   │       ├── proc-macro2 v1.0.92 (*)
│   │   │       ├── quote v1.0.37 (*)
│   │   │       └── syn v2.0.90 (*)
│   │   ├── subtle v2.4.1
│   │   ├── udigest v0.2.1 (*)
│   │   └── zeroize v1.6.0 (*)
│   ├── generic-ec-zkp v0.4.1
│   │   ├── generic-array v0.14.6 (*)
│   │   ├── generic-ec v0.4.1 (*)
│   │   ├── rand_core v0.6.4
│   │   ├── serde v1.0.193 (*)
│   │   ├── subtle v2.4.1
│   │   └── udigest v0.2.1 (*)
│   ├── hex v0.4.3 (*)
│   ├── key-share v0.6.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share)
│   │   ├── displaydoc v0.2.5 (proc-macro) (*)
│   │   ├── generic-ec v0.4.1 (*)
│   │   ├── generic-ec-zkp v0.4.1 (*)
│   │   ├── hex v0.4.3 (*)
│   │   ├── serde v1.0.193 (*)
│   │   ├── serde_with v2.3.3 (*)
│   │   └── thiserror v1.0.48
│   │       └── thiserror-impl v1.0.48 (proc-macro)
│   │           ├── proc-macro2 v1.0.92 (*)
│   │           ├── quote v1.0.37 (*)
│   │           └── syn v2.0.90 (*)
│   ├── rand_core v0.6.4
│   ├── round-based v0.4.0
│   │   ├── futures-util v0.3.24 (*)
│   │   ├── phantom-type v0.3.1
│   │   │   └── educe v0.4.19 (proc-macro) (*)
│   │   ├── round-based-derive v0.2.2 (proc-macro)
│   │   │   ├── proc-macro2 v1.0.92 (*)
│   │   │   ├── quote v1.0.37 (*)
│   │   │   └── syn v1.0.101 (*)
│   │   ├── thiserror v2.0.4
│   │   │   └── thiserror-impl v2.0.4 (proc-macro)
│   │   │       ├── proc-macro2 v1.0.92 (*)
│   │   │       ├── quote v1.0.37 (*)
│   │   │       └── syn v2.0.90 (*)
│   │   └── tracing v0.1.36
│   │       ├── cfg-if v1.0.0
│   │       ├── pin-project-lite v0.2.9
│   │       └── tracing-core v0.1.29
│   ├── serde v1.0.193 (*)
│   ├── serde_with v2.3.3 (*)
│   ├── sha2 v0.10.6
│   │   ├── cfg-if v1.0.0
│   │   ├── cpufeatures v0.2.12
│   │   └── digest v0.10.6 (*)
│   ├── thiserror v1.0.48 (*)
│   └── udigest v0.2.1 (*)
├── digest v0.10.6 (*)
├── futures v0.3.24 (*)
├── generic-ec v0.4.1 (*)
├── generic-ec-zkp v0.4.1 (*)
├── hex v0.4.3 (*)
├── key-share v0.6.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share) (*)
├── paillier-zk v0.4.1
│   ├── digest v0.10.6 (*)
│   ├── fast-paillier v0.1.0
│   │   ├── bytemuck v1.13.1
│   │   │   └── bytemuck_derive v1.4.1 (proc-macro)
│   │   │       ├── proc-macro2 v1.0.92 (*)
│   │   │       ├── quote v1.0.37 (*)
│   │   │       └── syn v2.0.90 (*)
│   │   ├── rand_core v0.6.4
│   │   ├── rug v1.21.0
│   │   │   ├── az v1.2.1
│   │   │   ├── gmp-mpfr-sys v1.6.1
│   │   │   │   └── libc v0.2.153
│   │   │   ├── libc v0.2.153
│   │   │   └── serde v1.0.193 (*)
│   │   ├── serde v1.0.193 (*)
│   │   └── thiserror v1.0.48 (*)
│   ├── generic-ec v0.4.1 (*)
│   ├── rand_core v0.6.4
│   ├── rand_hash v0.1.0 (*)
│   ├── rug v1.21.0 (*)
│   ├── serde v1.0.193 (*)
│   ├── serde_with v3.0.0
│   │   ├── serde v1.0.193 (*)
│   │   └── serde_with_macros v3.0.0 (proc-macro)
│   │       ├── darling v0.20.1 (*)
│   │       ├── proc-macro2 v1.0.92 (*)
│   │       ├── quote v1.0.37 (*)
│   │       └── syn v2.0.90 (*)
│   ├── thiserror v1.0.48 (*)
│   └── udigest v0.2.1 (*)
├── rand_core v0.6.4
├── rand_hash v0.1.0 (*)
├── round-based v0.4.0 (*)
├── serde v1.0.193 (*)
├── serde_with v2.3.3 (*)
├── sha2 v0.10.6 (*)
├── thiserror v1.0.48 (*)
└── udigest v0.2.1 (*)

Compared to base branch

Diff
--- all-deps-base	2024-12-20 15:33:24.801181639 +0000
+++ all-deps-pr	2024-12-20 15:33:25.085181220 +0000
@@ -6 +6 @@
-cggmp21-keygen v0.5.0 (/home/runner/work/cggmp21/cggmp21/base_branch/cggmp21-keygen)
+cggmp21-keygen v0.5.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21-keygen)
@@ -34 +34 @@
-key-share v0.6.0 (/home/runner/work/cggmp21/cggmp21/base_branch/key-share)
+key-share v0.6.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share)

Copy link

github-actions bot commented Dec 20, 2024

Benchmark Result

Benchmarks
RUST_TESTS_SEED=61b3d6a8fd96e5151943c968de859375b34b287e1ce6798bb115858c5f937c80
n = 3

Non-threshold DKG
Protocol Performance:
  - Protocol took 425.62µs to complete
In particular:
  - Stage: 6.63µs
    - Setup networking: 6.35µs (95.8%)
    - Unstaged: 280.00ns (4.2%)
  - Round 1: 145.37µs
    - Sample x_i, rid_i, chain_code: 65.14µs (44.8%)
    - Sample schnorr commitment: 58.50µs (40.2%)
    - Commit to public data: 21.43µs (14.7%)
    - Unstaged: 300.00ns (0.2%)
  - Round 2: 1.23µs
    - Hash received msgs (reliability check): 1.06µs (86.2%)
    - Unstaged: 170.00ns (13.8%)
  - Round 3: 280.00ns
    - Assert other parties hashed messages (reliability check): 160.00ns (57.1%)
    - Unstaged: 120.00ns (42.9%)
  - Round 4: 35.97µs
    - Validate decommitments: 32.92µs (91.5%)
    - Calculate chain_code: 742.00ns (2.1%)
    - Calculate challege rid: 1.95µs (5.4%)
    - Prove knowledge of `x_i`: 211.00ns (0.6%)
    - Unstaged: 142.00ns (0.4%)
  - Round 5: 236.14µs
    - Validate schnorr proofs: 235.83µs (99.9%)
    - Unstaged: 310.00ns (0.1%)


Threshold DKG
Protocol Performance:
  - Protocol took 1.31ms to complete
In particular:
  - Stage: 2.14µs
    - Setup networking: 2.07µs (96.7%)
    - Unstaged: 71.00ns (3.3%)
  - Round 1: 201.36µs
    - Sample rid_i, schnorr commitment, polynomial, chain_code: 176.46µs (87.6%)
    - Commit to public data: 24.70µs (12.3%)
    - Unstaged: 200.00ns (0.1%)
  - Round 2: 1.25µs
    - Hash received msgs (reliability check): 1.07µs (85.6%)
    - Unstaged: 180.00ns (14.4%)
  - Round 3: 350.00ns
    - Assert other parties hashed messages (reliability check): 230.00ns (65.7%)
    - Unstaged: 120.00ns (34.3%)
  - Round 4: 803.36µs
    - Validate decommitments: 48.12µs (6.0%)
    - Validate data size: 421.00ns (0.1%)
    - Validate Feldmann VSS: 352.11µs (43.8%)
    - Compute rid: 260.00ns (0.0%)
    - Compute chain_code: 822.00ns (0.1%)
    - Compute Ys: 368.40µs (45.9%)
    - Compute sigma: 431.00ns (0.1%)
    - Calculate challenge: 32.34µs (4.0%)
    - Prove knowledge of `sigma_i`: 311.00ns (0.0%)
    - Unstaged: 151.00ns (0.0%)
  - Round 5: 299.44µs
    - Validate schnorr proofs: 298.16µs (99.6%)
    - Derive resulting public key and other data: 1.00µs (0.3%)
    - Unstaged: 271.00ns (0.1%)


Auxiliary data generation protocol
Protocol Performance:
  - Protocol took 9.60s to complete
In particular:
  - Stage: 16.22µs
    - Retrieve auxiliary data: 160.00ns (1.0%)
    - Setup networking: 15.99µs (98.6%)
    - Unstaged: 70.00ns (0.4%)
  - Round 1: 1.18s
    - Retrieve primes (p and q): 100.00ns (0.0%)
    - Compute paillier decryption key (N): 6.04µs (0.0%)
    - Generate auxiliary params r, λ, t, s: 9.08ms (0.8%)
    - Prove Πprm (ψˆ_i): 1.17s (99.2%)
    - Sample random bytes: 2.45µs (0.0%)
    - Compute hash commitment and sample decommitment: 269.01µs (0.0%)
    - Unstaged: 200.00ns (0.0%)
  - Round 2: 1.59µs
    - Hash received msgs (reliability check): 1.18µs (74.2%)
    - Unstaged: 411.00ns (25.8%)
  - Round 3: 462.00ns
    - Assert other parties hashed messages (reliability check): 211.00ns (45.7%)
    - Unstaged: 251.00ns (54.3%)
  - Round 4: 5.92s
    - Validate round 1 decommitments: 548.58µs (0.0%)
    - Validate П_prm (ψ_i): 2.29s (38.7%)
    - Add together shared random bytes: 1.53µs (0.0%)
    - Compute П_mod (ψ_i): 3.46s (58.4%)
    - Assemble security params for П_fac (ф_i): 6.59µs (0.0%)
    - Compute П_fac (ф_i^j): 172.48ms (2.9%)
    - Unstaged: 911.00ns (0.0%)
  - Round 5: 2.50s
    - Validate ψ_j (П_mod): 2.32s (92.8%)
    - Validate ф_j (П_fac): 180.20ms (7.2%)
    - Assemble auxiliary info: 144.31µs (0.0%)
    - Unstaged: 2.83µs (0.0%)


Signing protocol
Protocol Performance:
  - Protocol took 1.60s to complete
In particular:
  - Stage: 142.62µs
    - Map t-out-of-n protocol to t-out-of-t: 71.57µs (50.2%)
    - Retrieve auxiliary data: 66.81µs (46.8%)
    - Precompute execution id and security params: 762.00ns (0.5%)
    - Setup networking: 3.38µs (2.4%)
    - Unstaged: 90.00ns (0.1%)
  - Round 1: 117.60ms
    - Generate local ephemeral secrets (k_i, y_i, p_i, v_i): 50.00µs (0.0%)
    - Encrypt G_i and K_i: 35.97ms (30.6%)
    - Prove ψ0_j: 81.58ms (69.4%)
    - Unstaged: 381.00ns (0.0%)
  - Round 2: 14.58µs
    - Hash received msgs (reliability check): 14.02µs (96.1%)
    - Unstaged: 562.00ns (3.9%)
  - Round 3: 811.83ms
    - Assert other parties hashed messages (reliability check): 611.00ns (0.0%)
    - Verify psi0 proofs: 92.80ms (11.4%)
    - Sample random r, hat_r, s, hat_s, beta, hat_beta: 13.69µs (0.0%)
    - Encrypt D_ji: 70.58ms (8.7%)
    - Encrypt F_ji: 35.94ms (4.4%)
    - Encrypt hat_D_ji: 74.37ms (9.2%)
    - Encrypt hat_F_ji: 36.04ms (4.4%)
    - Prove psi_ji: 210.00ms (25.9%)
    - Prove psiˆ_ji: 210.43ms (25.9%)
    - Prove psi_prime_ji : 81.66ms (10.1%)
    - Unstaged: 300.00ns (0.0%)
  - Round 4: 577.68ms
    - Retrieve auxiliary data: 4.43µs (0.0%)
    - Validate psi: 165.68ms (28.7%)
    - Validate hat_psi: 165.14ms (28.6%)
    - Validate psi_prime: 92.94ms (16.1%)
    - Compute Gamma, Delta_i, delta_i, chi_i: 72.31ms (12.5%)
    - Prove psi_prime_prime: 81.60ms (14.1%)
    - Unstaged: 611.00ns (0.0%)
  - Presig output: 93.76ms
    - Validate psi_prime_prime: 93.63ms (99.9%)
    - Calculate presignature: 132.52µs (0.1%)
    - Unstaged: 992.00ns (0.0%)
  - Partial signing: 8.62µs
  - Signature reconstruction: 196.80µs


Copy link

github-actions bot commented Dec 20, 2024

The spec was successfully compiled. PDF is available here.

@maurges
Copy link
Contributor Author

maurges commented Dec 20, 2024

Welp, wasm build broke, and the error seems unrelated to my changes somehow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant