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

Use #[udigest(as = ...)] attribute #106

Merged
merged 10 commits into from
Aug 27, 2024
Merged

Use #[udigest(as = ...)] attribute #106

merged 10 commits into from
Aug 27, 2024

Conversation

survived
Copy link
Contributor

No description provided.

Signed-off-by: Denis Varlakov <[email protected]>
Copy link

github-actions bot commented Aug 22, 2024

Crate direct deps

Direct deps
cggmp21-keygen v0.3.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.4.1 (/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.3.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-08-27 12:19:16.442688972 +0000
+++ direct-deps-pr	2024-08-27 12:19:16.830687663 +0000
@@ -1 +1 @@
-cggmp21-keygen v0.3.0 (/home/runner/work/cggmp21/cggmp21/base_branch/cggmp21-keygen)
+cggmp21-keygen v0.3.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21-keygen)
@@ -4,2 +4,2 @@
-generic-ec v0.4.0
-generic-ec-zkp v0.4.0
+generic-ec v0.4.1
+generic-ec-zkp v0.4.1
@@ -7,2 +7,2 @@
-key-share v0.4.1 (/home/runner/work/cggmp21/cggmp21/base_branch/key-share)
-paillier-zk v0.4.0
+key-share v0.4.1 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share)
+paillier-zk v0.4.1
@@ -16 +16 @@
-udigest v0.2.0
+udigest v0.2.1

All deps

cargo tree
cggmp21 v0.4.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21)
├── cggmp21-keygen v0.3.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.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
│   ├── displaydoc v0.2.4 (proc-macro)
│   │   ├── proc-macro2 v1.0.66 (*)
│   │   ├── quote v1.0.33 (*)
│   │   └── syn v2.0.32 (*)
│   ├── 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.66 (*)
│   │   │           ├── quote v1.0.33 (*)
│   │   │           ├── syn v1.0.101
│   │   │           │   ├── proc-macro2 v1.0.66 (*)
│   │   │           │   ├── quote v1.0.33 (*)
│   │   │           │   └── unicode-ident v1.0.4
│   │   │           └── synstructure v0.12.6
│   │   │               ├── proc-macro2 v1.0.66 (*)
│   │   │               ├── quote v1.0.33 (*)
│   │   │               ├── 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.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
│   │   ├── 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.66 (*)
│   │   │           ├── quote v1.0.33 (*)
│   │   │           └── syn v2.0.32 (*)
│   │   ├── 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.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
│   │   ├── 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.4.1 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share)
│   │   ├── displaydoc v0.2.4 (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.66 (*)
│   │           ├── quote v1.0.33 (*)
│   │           └── syn v2.0.32 (*)
│   ├── rand_core v0.6.4
│   ├── round-based v0.3.0
│   │   ├── displaydoc v0.2.4 (proc-macro) (*)
│   │   ├── futures-util v0.3.24
│   │   │   ├── futures-channel v0.3.24
│   │   │   │   ├── futures-core v0.3.24
│   │   │   │   └── futures-sink 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 (*)
│   │   │   ├── 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
│   │   ├── phantom-type v0.3.1
│   │   │   └── educe v0.4.19 (proc-macro) (*)
│   │   ├── round-based-derive v0.2.1 (proc-macro)
│   │   │   ├── proc-macro2 v1.0.66 (*)
│   │   │   ├── quote v1.0.33 (*)
│   │   │   └── syn v1.0.101 (*)
│   │   ├── thiserror v1.0.48 (*)
│   │   └── 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
│   ├── futures-channel 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-io v0.3.24
│   ├── futures-sink v0.3.24
│   ├── futures-task v0.3.24
│   └── futures-util v0.3.24 (*)
├── generic-ec v0.4.1 (*)
├── generic-ec-zkp v0.4.1 (*)
├── hex v0.4.3 (*)
├── key-share v0.4.1 (/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.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.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.66 (*)
│   │       ├── quote v1.0.33 (*)
│   │       └── syn v2.0.32 (*)
│   ├── thiserror v1.0.48 (*)
│   └── udigest v0.2.1 (*)
├── rand_core v0.6.4
├── rand_hash v0.1.0 (*)
├── round-based v0.3.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-08-27 12:19:16.590688473 +0000
+++ all-deps-pr	2024-08-27 12:19:16.974687177 +0000
@@ -6 +6 @@
-cggmp21-keygen v0.3.0 (/home/runner/work/cggmp21/cggmp21/base_branch/cggmp21-keygen)
+cggmp21-keygen v0.3.0 (/home/runner/work/cggmp21/cggmp21/pr_branch/cggmp21-keygen)
@@ -28 +28 @@
-generic-ec v0.4.0
+generic-ec v0.4.1
@@ -30 +30 @@
-generic-ec-zkp v0.4.0
+generic-ec-zkp v0.4.1
@@ -34 +34 @@
-key-share v0.4.1 (/home/runner/work/cggmp21/cggmp21/base_branch/key-share)
+key-share v0.4.1 (/home/runner/work/cggmp21/cggmp21/pr_branch/key-share)
@@ -40 +40 @@
-paillier-zk v0.4.0
+paillier-zk v0.4.1
@@ -70,2 +70,2 @@
-udigest v0.2.0
-udigest-derive v0.2.0 (proc-macro)
+udigest v0.2.1
+udigest-derive v0.3.0 (proc-macro)

Copy link

github-actions bot commented Aug 22, 2024

The spec was successfully compiled. PDF is available here.

Signed-off-by: Denis Varlakov <[email protected]>
@survived survived marked this pull request as draft August 22, 2024 15:47
Copy link

github-actions bot commented Aug 22, 2024

Benchmark Result

Benchmarks
RUST_TESTS_SEED=d991fc2355c233feca71eb240a42c2ec576af7aa154246da02a11632a3e565a9
n = 3

Non-threshold DKG
Protocol Performance:
  - Protocol took 423.45µs to complete
In particular:
  - Stage: 3.40µs
    - Setup networking: 3.29µs (96.8%)
    - Unstaged: 110.00ns (3.2%)
  - Round 1: 146.52µs
    - Sample x_i, rid_i, chain_code: 67.60µs (46.1%)
    - Sample schnorr commitment: 58.43µs (39.9%)
    - Commit to public data: 20.20µs (13.8%)
    - Unstaged: 301.00ns (0.2%)
  - Round 2: 1.28µs
    - Hash received msgs (reliability check): 1.09µs (85.2%)
    - Unstaged: 190.00ns (14.8%)
  - Round 3: 1.95µs
    - Assert other parties hashed messages (reliability check): 1.84µs (94.4%)
    - Unstaged: 110.00ns (5.6%)
  - Round 4: 35.81µs
    - Validate decommitments: 31.96µs (89.3%)
    - Calculate chain_code: 931.00ns (2.6%)
    - Calculate challege rid: 2.58µs (7.2%)
    - Prove knowledge of `x_i`: 190.00ns (0.5%)
    - Unstaged: 150.00ns (0.4%)
  - Round 5: 234.49µs
    - Validate schnorr proofs: 234.20µs (99.9%)
    - Unstaged: 291.00ns (0.1%)


Threshold DKG
Protocol Performance:
  - Protocol took 1.32ms to complete
In particular:
  - Stage: 2.15µs
    - Setup networking: 2.07µs (96.3%)
    - Unstaged: 80.00ns (3.7%)
  - Round 1: 237.25µs
    - Sample rid_i, schnorr commitment, polynomial, chain_code: 214.08µs (90.2%)
    - Commit to public data: 22.94µs (9.7%)
    - Unstaged: 231.00ns (0.1%)
  - Round 2: 1.31µs
    - Hash received msgs (reliability check): 1.16µs (88.6%)
    - Unstaged: 150.00ns (11.4%)
  - Round 3: 320.00ns
    - Assert other parties hashed messages (reliability check): 200.00ns (62.5%)
    - Unstaged: 120.00ns (37.5%)
  - Round 4: 784.68µs
    - Validate decommitments: 42.66µs (5.4%)
    - Validate data size: 421.00ns (0.1%)
    - Validate Feldmann VSS: 353.38µs (45.0%)
    - Compute rid: 180.00ns (0.0%)
    - Compute chain_code: 1.03µs (0.1%)
    - Compute Ys: 354.27µs (45.1%)
    - Compute sigma: 310.00ns (0.0%)
    - Calculate challenge: 29.02µs (3.7%)
    - Prove knowledge of `sigma_i`: 3.29µs (0.4%)
    - Unstaged: 120.00ns (0.0%)
  - Round 5: 289.44µs
    - Validate schnorr proofs: 288.28µs (99.6%)
    - Derive resulting public key and other data: 992.00ns (0.3%)
    - Unstaged: 170.00ns (0.1%)


Auxiliary data generation protocol
Protocol Performance:
  - Protocol took 9.51s to complete
In particular:
  - Stage: 11.35µs
    - Retrieve auxiliary data: 200.00ns (1.8%)
    - Setup networking: 11.08µs (97.6%)
    - Unstaged: 70.00ns (0.6%)
  - Round 1: 1.15s
    - Retrieve primes (p and q): 90.00ns (0.0%)
    - Compute paillier decryption key (N): 6.10µs (0.0%)
    - Generate auxiliary params r, λ, t, s: 8.99ms (0.8%)
    - Prove Πprm (ψˆ_i): 1.14s (99.2%)
    - Sample random bytes: 1.96µs (0.0%)
    - Compute hash commitment and sample decommitment: 270.74µs (0.0%)
    - Unstaged: 220.00ns (0.0%)
  - Round 2: 1.41µs
    - Hash received msgs (reliability check): 1.10µs (77.9%)
    - Unstaged: 312.00ns (22.1%)
  - Round 3: 511.00ns
    - Assert other parties hashed messages (reliability check): 341.00ns (66.7%)
    - Unstaged: 170.00ns (33.3%)
  - Round 4: 5.87s
    - Validate round 1 decommitments: 550.23µs (0.0%)
    - Validate П_prm (ψ_i): 2.27s (38.7%)
    - Add together shared random bytes: 601.00ns (0.0%)
    - Compute П_mod (ψ_i): 3.43s (58.4%)
    - Assemble security params for П_fac (ф_i): 4.54µs (0.0%)
    - Compute П_fac (ф_i^j): 170.92ms (2.9%)
    - Unstaged: 1.01µs (0.0%)
  - Round 5: 2.48s
    - Validate ψ_j (П_mod): 2.31s (93.1%)
    - Validate ф_j (П_fac): 172.19ms (6.9%)
    - Assemble auxiliary info: 143.10µs (0.0%)
    - Unstaged: 591.00ns (0.0%)


Signing protocol
Protocol Performance:
  - Protocol took 4.16s to complete
In particular:
  - Stage: 135.15µs
    - Map t-out-of-n protocol to t-out-of-t: 64.07µs (47.4%)
    - Retrieve auxiliary data: 66.80µs (49.4%)
    - Precompute execution id and security params: 471.00ns (0.3%)
    - Setup networking: 3.60µs (2.7%)
    - Unstaged: 210.00ns (0.2%)
  - Round 1: 188.50ms
    - Generate local ephemeral secrets (k_i, y_i, p_i, v_i): 48.02µs (0.0%)
    - Encrypt G_i and K_i: 107.40ms (57.0%)
    - Prove ψ0_j: 81.05ms (43.0%)
    - Unstaged: 691.00ns (0.0%)
  - Round 2: 13.52µs
    - Hash received msgs (reliability check): 13.33µs (98.6%)
    - Unstaged: 190.00ns (1.4%)
  - Round 3: 2.22s
    - Assert other parties hashed messages (reliability check): 621.00ns (0.0%)
    - Verify psi0 proofs: 268.43ms (12.1%)
    - Sample random r, hat_r, s, hat_s, beta, hat_beta: 12.89µs (0.0%)
    - Encrypt D_ji: 70.28ms (3.2%)
    - Encrypt F_ji: 35.73ms (1.6%)
    - Encrypt hat_D_ji: 559.32ms (25.1%)
    - Encrypt hat_F_ji: 35.74ms (1.6%)
    - Prove psi_ji: 789.45ms (35.5%)
    - Prove psiˆ_ji: 208.80ms (9.4%)
    - Prove psi_prime_ji : 257.20ms (11.6%)
    - Unstaged: 1.02µs (0.0%)
  - Round 4: 1.56s
    - Retrieve auxiliary data: 4.25µs (0.0%)
    - Validate psi: 164.85ms (10.6%)
    - Validate hat_psi: 164.69ms (10.6%)
    - Validate psi_prime: 932.79ms (59.9%)
    - Compute Gamma, Delta_i, delta_i, chi_i: 214.94ms (13.8%)
    - Prove psi_prime_prime: 81.00ms (5.2%)
    - Unstaged: 432.00ns (0.0%)
  - Presig output: 184.68ms
    - Validate psi_prime_prime: 184.55ms (99.9%)
    - Calculate presignature: 131.91µs (0.1%)
    - Unstaged: 692.00ns (0.0%)
  - Partial signing: 7.05µs
  - Signature reconstruction: 196.92µs


Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Cargo.toml Outdated Show resolved Hide resolved
wasm/no_std/Cargo.toml Outdated Show resolved Hide resolved
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
@survived survived marked this pull request as ready for review August 23, 2024 08:19
@survived survived requested a review from maurges August 23, 2024 08:19
@maurges
Copy link
Contributor

maurges commented Aug 23, 2024

Looks good. This one nicely demonstrates the advantage of the new udigest feature

Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
@survived survived merged commit b453100 into m Aug 27, 2024
18 checks passed
@survived survived deleted the udigest_as branch August 27, 2024 12:40
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.

2 participants