From 4a96563d4757a893d6c25239f393c77c2cc365c8 Mon Sep 17 00:00:00 2001 From: 0xjei Date: Mon, 27 Apr 2026 14:47:20 +0200 Subject: [PATCH 1/2] update benches to reflect the new structure and metrics --- circuits/benchmarks/README.md | 64 +++ .../results_insecure/crisp_verify_gas.json | 13 + .../benchmarks/results_insecure/report.md | 283 ++-------- .../results_secure/crisp_verify_gas.json | 13 + circuits/benchmarks/results_secure/report.md | 303 ++--------- .../benchmarks/scripts/benchmark_circuit.sh | 57 +- .../scripts/extract_crisp_verify_gas.sh | 121 +++++ .../benchmarks/scripts/generate_report.sh | 508 +++++++----------- circuits/benchmarks/scripts/run_benchmarks.sh | 11 +- crates/tests/tests/integration.rs | 42 ++ .../tests/crisp.contracts.test.ts | 2 + .../scripts/benchmarkGasFromRaw.ts | 170 ++++++ packages/enclave-contracts/tasks/enclave.ts | 12 +- 13 files changed, 784 insertions(+), 815 deletions(-) create mode 100644 circuits/benchmarks/results_insecure/crisp_verify_gas.json create mode 100644 circuits/benchmarks/results_secure/crisp_verify_gas.json create mode 100755 circuits/benchmarks/scripts/extract_crisp_verify_gas.sh create mode 100644 packages/enclave-contracts/scripts/benchmarkGasFromRaw.ts diff --git a/circuits/benchmarks/README.md b/circuits/benchmarks/README.md index 2fa47fddab..ac0258efc5 100644 --- a/circuits/benchmarks/README.md +++ b/circuits/benchmarks/README.md @@ -18,3 +18,67 @@ From this directory: ``` Options and secure-only **config** circuit behavior are documented in the script and `config.json`. + +## Refresh after parameter changes + +If you change circuit/config parameter sets, rerun the full benchmark + gas extraction flow. + +From repository root: + +```bash +# Build CRISP SDK artifacts used by verifier tests +pnpm -C examples/CRISP/packages/crisp-sdk build + +# Recompute benchmark raw JSON and base report (insecure mode) +./circuits/benchmarks/run_benchmarks.sh --mode insecure + +# Extract on-chain verify gas from simulated verifier tests +./circuits/benchmarks/scripts/extract_crisp_verify_gas.sh \ + --output "./circuits/benchmarks/results_insecure/crisp_verify_gas.json" + +# Regenerate report with gas values +./circuits/benchmarks/scripts/generate_report.sh \ + --input-dir "./circuits/benchmarks/results_insecure/raw" \ + --output "./circuits/benchmarks/results_insecure/report.md" \ + --gas-json "./circuits/benchmarks/results_insecure/crisp_verify_gas.json" +``` + +For secure mode, use `--mode secure` and replace `results_insecure` with `results_secure`. + +## Reported protocol tables + +`results_*/report.md` now includes protocol-oriented sections in addition to raw category tables: + +- `Circuit Benchmarks` with rows in fixed order: `C0`, `C1`, `C2a`, `C2b`, `C3a`, `C3b`, `C4a`, + `C4b`, `C5`, `user-data-enc`, `C6`, `C7`. +- `Artifacts` for `Π_DKG`, `Π_user`, `Π_dec` with proof/public-input sizes and gas columns. +- `Role / Phase / Activity` for P1..P4 operational cost summaries. + +## Derivation rules + +- `Constraints`: `gates.total_gates` +- `Prove time (s)`: `proof_generation.time_seconds` +- `Verify time (ms)`: `verification.time_seconds * 1000` +- `Proof size (KB)`: `proof_generation.proof_size_bytes / 1024` +- `Public input size`: `verification.public_inputs_size_bytes / 1024` + +Split rows are deterministic: + +- `C3a` and `C3b` both map to `dkg/share_encryption` benchmark output. +- `C4a` and `C4b` both map to `dkg/share_decryption` benchmark output. + +## Gas measurement source + +`Verify gas` is sourced from the existing CRISP verification test path: + +- Test: `examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts` +- Command path: `circuits/benchmarks/scripts/extract_crisp_verify_gas.sh` +- Benchmark integration: `run_benchmarks.sh` runs that script and passes the JSON to report + generation. + +For `Π_DKG` and `Π_dec`, verifier gas is sourced from folded recursive-aggregation proofs exported +by `cargo test -p e3-tests test_trbfv_actor` (via `BENCHMARK_FOLDED_OUTPUT`) and then replayed into +EVM verifier `estimateGas` in `packages/enclave-contracts/scripts/benchmarkGasFromRaw.ts`. + +`Calldata gas` is computed from benchmark proof/public-input bytes with EVM calldata costs +(`0x00 -> 4`, non-zero byte -> 16) and stored in raw benchmark JSON. diff --git a/circuits/benchmarks/results_insecure/crisp_verify_gas.json b/circuits/benchmarks/results_insecure/crisp_verify_gas.json new file mode 100644 index 0000000000..6169159ee1 --- /dev/null +++ b/circuits/benchmarks/results_insecure/crisp_verify_gas.json @@ -0,0 +1,13 @@ +{ + "verify_gas": { + "dkg": 3037849, + "user": 2972953, + "dec": 3549211 + }, + "source": "crisp_verify_test", + "test_exit_code": { + "crisp": 0, + "folded_export": 0, + "enclave_contracts": 0 + } +} diff --git a/circuits/benchmarks/results_insecure/report.md b/circuits/benchmarks/results_insecure/report.md index b34e927ef6..acdf68b6c4 100644 --- a/circuits/benchmarks/results_insecure/report.md +++ b/circuits/benchmarks/results_insecure/report.md @@ -1,255 +1,48 @@ # Enclave ZK Circuit Benchmarks -**Generated:** 2026-04-07 13:56:44 UTC +**Generated:** 2026-04-27 10:35:23 UTC **Git Branch:** `main` -**Git Commit:** `bae26bfb4e0d6673bff4783c4942384dfbef5a08` +**Git Commit:** `e651f30205117e83a9cc48ac44664d434466724d` --- -## Summary - -### DKG - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -| ---------------------- | ------- | ------- | ------ | ------ | -| e_sm_share_computation | 0.34 s | 0.49 s | 0.89 s | 0.02 s | -| pk | 0.30 s | 0.31 s | 0.12 s | 0.02 s | -| share_decryption | 0.32 s | 0.39 s | 0.51 s | 0.02 s | -| share_encryption | 0.33 s | 0.48 s | 0.60 s | 0.03 s | -| sk_share_computation | 0.33 s | 0.45 s | 0.81 s | 0.02 s | - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -| ---------------------- | ------- | ------- | ------------ | --------- | ------- | ---------- | -| e_sm_share_computation | 75649 | 198.35K | 1.16 MB | 222.06 KB | 3.59 KB | 15.88 KB | -| pk | 344 | 6.85K | 90.54 KB | 29.07 KB | 3.59 KB | 15.88 KB | -| share_decryption | 28577 | 92.52K | 538.83 KB | 151.95 KB | 3.59 KB | 15.88 KB | -| share_encryption | 47758 | 127.05K | 802.98 KB | 512.11 KB | 3.59 KB | 15.88 KB | -| sk_share_computation | 56018 | 142.62K | 936.72 KB | 165.20 KB | 3.59 KB | 15.88 KB | - -### Threshold - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -| ---------------------------- | ------- | ------- | ------ | ------ | -| decrypted_shares_aggregation | 0.33 s | 0.58 s | 0.51 s | 0.02 s | -| pk_aggregation | 0.34 s | 0.45 s | 0.83 s | 0.02 s | -| pk_generation | 0.32 s | 0.40 s | 0.35 s | 0.02 s | -| share_decryption | 0.32 s | 0.43 s | 0.52 s | 0.03 s | -| user_data_encryption_ct0 | 0.32 s | 0.41 s | 0.33 s | 0.03 s | -| user_data_encryption_ct1 | 0.32 s | 0.39 s | 0.32 s | 0.03 s | - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -| ---------------------------- | ------- | ------- | ------------ | --------- | ------- | ---------- | -| decrypted_shares_aggregation | 41673 | 104.27K | 1.12 MB | 111.14 KB | 3.59 KB | 15.88 KB | -| pk_aggregation | 48950 | 151.72K | 837.49 KB | 259.79 KB | 3.59 KB | 15.88 KB | -| pk_generation | 27737 | 57.82K | 501.25 KB | 348.73 KB | 3.59 KB | 15.88 KB | -| share_decryption | 22486 | 75.12K | 466.54 KB | 498.22 KB | 3.59 KB | 15.88 KB | -| user_data_encryption_ct0 | 27573 | 53.73K | 500.84 KB | 358.40 KB | 3.59 KB | 15.88 KB | -| user_data_encryption_ct1 | 21399 | 46.27K | 421.51 KB | 325.19 KB | 3.59 KB | 15.88 KB | - -### Config - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -| ------- | ------- | ------- | ----- | ------ | - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -| ------- | ------- | ----- | ------------ | ------- | ------- | ---------- | - -## Circuit Details - -### DKG - -#### e_sm_share_computation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.34 s | -| **Execution** | 0.49 s | -| **VK Generation** | 0.38 s | -| **Proof Generation** | 0.89 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "75649" | -| **Total Gates** | "198355" | -| **Circuit Size** | 1.16 MB | -| **Witness Size** | 222.06 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### pk - -| Metric | Value | -| -------------------- | -------- | -| **Compilation** | 0.30 s | -| **Execution** | 0.31 s | -| **VK Generation** | 0.05 s | -| **Proof Generation** | 0.12 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "344" | -| **Total Gates** | "6847" | -| **Circuit Size** | 90.54 KB | -| **Witness Size** | 29.07 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### share_decryption - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.32 s | -| **Execution** | 0.39 s | -| **VK Generation** | 0.20 s | -| **Proof Generation** | 0.51 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "28577" | -| **Total Gates** | "92515" | -| **Circuit Size** | 538.83 KB | -| **Witness Size** | 151.95 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### share_encryption - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.33 s | -| **Execution** | 0.48 s | -| **VK Generation** | 0.25 s | -| **Proof Generation** | 0.60 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "47758" | -| **Total Gates** | "127047" | -| **Circuit Size** | 802.98 KB | -| **Witness Size** | 512.11 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### sk_share_computation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.33 s | -| **Execution** | 0.45 s | -| **VK Generation** | 0.28 s | -| **Proof Generation** | 0.81 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "56018" | -| **Total Gates** | "142625" | -| **Circuit Size** | 936.72 KB | -| **Witness Size** | 165.20 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -### Threshold - -#### decrypted_shares_aggregation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.33 s | -| **Execution** | 0.58 s | -| **VK Generation** | 0.23 s | -| **Proof Generation** | 0.51 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "41673" | -| **Total Gates** | "104273" | -| **Circuit Size** | 1.12 MB | -| **Witness Size** | 111.14 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### pk_aggregation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.34 s | -| **Execution** | 0.45 s | -| **VK Generation** | 0.30 s | -| **Proof Generation** | 0.83 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "48950" | -| **Total Gates** | "151717" | -| **Circuit Size** | 837.49 KB | -| **Witness Size** | 259.79 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### pk_generation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.32 s | -| **Execution** | 0.40 s | -| **VK Generation** | 0.14 s | -| **Proof Generation** | 0.35 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "27737" | -| **Total Gates** | "57818" | -| **Circuit Size** | 501.25 KB | -| **Witness Size** | 348.73 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### share_decryption - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.32 s | -| **Execution** | 0.43 s | -| **VK Generation** | 0.17 s | -| **Proof Generation** | 0.52 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "22486" | -| **Total Gates** | "75125" | -| **Circuit Size** | 466.54 KB | -| **Witness Size** | 498.22 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### user_data_encryption_ct0 - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.32 s | -| **Execution** | 0.41 s | -| **VK Generation** | 0.13 s | -| **Proof Generation** | 0.33 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "27573" | -| **Total Gates** | "53732" | -| **Circuit Size** | 500.84 KB | -| **Witness Size** | 358.40 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### user_data_encryption_ct1 - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 0.32 s | -| **Execution** | 0.39 s | -| **VK Generation** | 0.12 s | -| **Proof Generation** | 0.32 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "21399" | -| **Total Gates** | "46270" | -| **Circuit Size** | 421.51 KB | -| **Witness Size** | 325.19 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -### Config +## Protocol Summary + +### Circuit Benchmarks + +| Circuit | Constraints | Prove time (s) | Verify time (ms) | Proof size (KB) | +| -------------------- | ----------- | -------------- | ---------------- | --------------- | +| C0 | 6847 | 0.12 | 25.76 | 15.88 | +| C1 | 57818 | 0.33 | 26.00 | 15.88 | +| C2a | 142625 | 0.77 | 26.58 | 15.88 | +| C2b | 198355 | 0.86 | 26.30 | 15.88 | +| C3a | 132633 | 0.79 | 25.93 | 15.88 | +| C3b | 132633 | 0.79 | 25.93 | 15.88 | +| C4a | 92515 | 0.49 | 25.95 | 15.88 | +| C4b | 92515 | 0.49 | 25.95 | 15.88 | +| C5 | 151717 | 0.79 | 25.87 | 15.88 | +| user_data_encryption | 53732 | 0.32 | 25.68 | 15.88 | +| C6 | 86927 | 0.52 | 26.68 | 15.88 | +| C7 | 104273 | 0.49 | 26.20 | 15.88 | + +### Artifacts + +| Artifact | Proof size | Public input size | Verify gas | Calldata gas | Total gas | +| -------- | ---------- | ----------------- | ---------- | ------------ | --------- | +| Π_DKG | 15.88 KB | 0.12 KB | 3037849 | 179452 | 3217301 | +| Π_user | 31.75 KB | 0.22 KB | 2972953 | 340140 | 3313093 | +| Π_dec | 15.88 KB | 3.25 KB | 3549211 | 188232 | 3737443 | + +### Role / Phase / Activity + +| Role | Phase | Activity | Prove time | Proof size | Bandwidth | +| --------------- | ----- | -------------------------------- | ---------- | ---------- | --------- | +| Each ciphernode | P1 | one-time DKG participation | 3.37 s | 95.25 KB | 96.12 KB | +| Aggregator | P2 | combine folds + C5 | 0.79 s | 15.88 KB | 16.00 KB | +| User | P3 | per user input | 0.64 s | 31.75 KB | 31.97 KB | +| Each ciphernode | P4 | per computation output (C6) | 0.52 s | 15.88 KB | 16.00 KB | +| Aggregator | P4 | per computation output (C7+fold) | 0.49 s | 15.88 KB | 19.12 KB | ## System Information diff --git a/circuits/benchmarks/results_secure/crisp_verify_gas.json b/circuits/benchmarks/results_secure/crisp_verify_gas.json new file mode 100644 index 0000000000..3d47aaccfb --- /dev/null +++ b/circuits/benchmarks/results_secure/crisp_verify_gas.json @@ -0,0 +1,13 @@ +{ + "verify_gas": { + "dkg": 3037824, + "user": 2972929, + "dec": 3549028 + }, + "source": "crisp_verify_test", + "test_exit_code": { + "crisp": 0, + "folded_export": 0, + "enclave_contracts": 0 + } +} diff --git a/circuits/benchmarks/results_secure/report.md b/circuits/benchmarks/results_secure/report.md index 5323aaf554..c02a463ec1 100644 --- a/circuits/benchmarks/results_secure/report.md +++ b/circuits/benchmarks/results_secure/report.md @@ -1,273 +1,48 @@ # Enclave ZK Circuit Benchmarks -**Generated:** 2026-04-15 11:38:26 UTC +**Generated:** 2026-04-27 12:41:40 UTC -**Git Branch:** `up/params` -**Git Commit:** `6359bfdf5bc7a5c8ea59a494a78b00341c318cb1` +**Git Branch:** `fix/configs-circuit` +**Git Commit:** `eca330d9a59f5433c443a2880bc82aeedac8681b` --- -## Summary - -### DKG - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -| ---------------------- | -------- | ------- | ------- | ------ | -| e_sm_share_computation | 288.92 s | 5.88 s | 20.08 s | 0.03 s | -| pk | 22.05 s | 0.62 s | 1.60 s | 0.03 s | -| share_decryption | 126.46 s | 2.96 s | 9.76 s | 0.02 s | -| share_encryption | 778.88 s | 5.14 s | 11.65 s | 0.09 s | -| sk_share_computation | 135.62 s | 4.70 s | 13.34 s | 0.03 s | - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -| ---------------------- | ------- | ------- | ------------ | -------- | ------- | ---------- | -| e_sm_share_computation | 1859606 | 5.74M | 23.81 MB | 8.12 MB | 3.59 KB | 15.88 KB | -| pk | 14568 | 287.76K | 501.04 KB | 1.12 MB | 3.59 KB | 15.88 KB | -| share_decryption | 707266 | 2.56M | 9.72 MB | 4.98 MB | 3.59 KB | 15.88 KB | -| share_encryption | 1167356 | 3.52M | 14.61 MB | 15.09 MB | 3.59 KB | 15.88 KB | -| sk_share_computation | 1360248 | 3.88M | 17.62 MB | 5.05 MB | 3.59 KB | 15.88 KB | - -### Threshold - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -| ---------------------------- | -------- | ------- | ------- | ------ | -| decrypted_shares_aggregation | 1.35 s | 0.66 s | 0.54 s | 0.02 s | -| pk_aggregation | 106.23 s | 4.76 s | 18.09 s | 0.02 s | -| pk_generation | 264.52 s | 3.27 s | 9.66 s | 0.02 s | -| share_decryption | 375.76 s | 3.90 s | 10.14 s | 0.12 s | -| user_data_encryption_ct0 | 100.06 s | 3.36 s | 6.39 s | 0.03 s | -| user_data_encryption_ct1 | 73.23 s | 2.78 s | 5.46 s | 0.02 s | - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -| ---------------------------- | ------- | ------- | ------------ | --------- | ------- | ---------- | -| decrypted_shares_aggregation | 50592 | 128.31K | 1.25 MB | 174.93 KB | 3.59 KB | 15.88 KB | -| pk_aggregation | 1217897 | 4.40M | 16.86 MB | 8.83 MB | 3.59 KB | 15.88 KB | -| pk_generation | 669868 | 2.43M | 8.87 MB | 10.35 MB | 3.59 KB | 15.88 KB | -| share_decryption | 579100 | 2.63M | 8.10 MB | 14.57 MB | 3.59 KB | 15.88 KB | -| user_data_encryption_ct0 | 626751 | 1.68M | 8.12 MB | 10.02 MB | 3.59 KB | 15.88 KB | -| user_data_encryption_ct1 | 506035 | 1.40M | 6.59 MB | 8.44 MB | 3.59 KB | 15.88 KB | - -### Config - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -| ----------------------- | ------- | ------- | ------ | ------ | -| validate_secure_configs | 0.30 s | 0.29 s | 0.00 s | 0.00 s | - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -| ----------------------- | ------- | ----- | ------------ | ------- | ------- | ---------- | -| validate_secure_configs | 0 | 0 | 21.09 KB | 0 B | 0 B | 0 B | - -## Circuit Details - -### DKG - -#### e_sm_share_computation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 288.92 s | -| **Execution** | 5.88 s | -| **VK Generation** | 8.38 s | -| **Proof Generation** | 20.08 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "1859606" | -| **Total Gates** | "5739750" | -| **Circuit Size** | 23.81 MB | -| **Witness Size** | 8.12 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### pk - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 22.05 s | -| **Execution** | 0.62 s | -| **VK Generation** | 0.48 s | -| **Proof Generation** | 1.60 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "14568" | -| **Total Gates** | "287764" | -| **Circuit Size** | 501.04 KB | -| **Witness Size** | 1.12 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### share_decryption - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 126.46 s | -| **Execution** | 2.96 s | -| **VK Generation** | 3.93 s | -| **Proof Generation** | 9.76 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "707266" | -| **Total Gates** | "2564001" | -| **Circuit Size** | 9.72 MB | -| **Witness Size** | 4.98 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### share_encryption - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 778.88 s | -| **Execution** | 5.14 s | -| **VK Generation** | 4.89 s | -| **Proof Generation** | 11.65 s | -| **Verification** | 0.09 s | -| **ACIR Opcodes** | "1167356" | -| **Total Gates** | "3520046" | -| **Circuit Size** | 14.61 MB | -| **Witness Size** | 15.09 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### sk_share_computation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 135.62 s | -| **Execution** | 4.70 s | -| **VK Generation** | 6.34 s | -| **Proof Generation** | 13.34 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "1360248" | -| **Total Gates** | "3879330" | -| **Circuit Size** | 17.62 MB | -| **Witness Size** | 5.05 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -### Threshold - -#### decrypted_shares_aggregation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 1.35 s | -| **Execution** | 0.66 s | -| **VK Generation** | 0.25 s | -| **Proof Generation** | 0.54 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "50592" | -| **Total Gates** | "128310" | -| **Circuit Size** | 1.25 MB | -| **Witness Size** | 174.93 KB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### pk_aggregation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 106.23 s | -| **Execution** | 4.76 s | -| **VK Generation** | 6.46 s | -| **Proof Generation** | 18.09 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "1217897" | -| **Total Gates** | "4395328" | -| **Circuit Size** | 16.86 MB | -| **Witness Size** | 8.83 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### pk_generation - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 264.52 s | -| **Execution** | 3.27 s | -| **VK Generation** | 3.50 s | -| **Proof Generation** | 9.66 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "669868" | -| **Total Gates** | "2432074" | -| **Circuit Size** | 8.87 MB | -| **Witness Size** | 10.35 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### share_decryption - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 375.76 s | -| **Execution** | 3.90 s | -| **VK Generation** | 3.60 s | -| **Proof Generation** | 10.14 s | -| **Verification** | 0.12 s | -| **ACIR Opcodes** | "579100" | -| **Total Gates** | "2628314" | -| **Circuit Size** | 8.10 MB | -| **Witness Size** | 14.57 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### user_data_encryption_ct0 - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 100.06 s | -| **Execution** | 3.36 s | -| **VK Generation** | 2.53 s | -| **Proof Generation** | 6.39 s | -| **Verification** | 0.03 s | -| **ACIR Opcodes** | "626751" | -| **Total Gates** | "1678200" | -| **Circuit Size** | 8.12 MB | -| **Witness Size** | 10.02 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -#### user_data_encryption_ct1 - -| Metric | Value | -| -------------------- | --------- | -| **Compilation** | 73.23 s | -| **Execution** | 2.78 s | -| **VK Generation** | 2.02 s | -| **Proof Generation** | 5.46 s | -| **Verification** | 0.02 s | -| **ACIR Opcodes** | "506035" | -| **Total Gates** | "1398659" | -| **Circuit Size** | 6.59 MB | -| **Witness Size** | 8.44 MB | -| **VK Size** | 3.59 KB | -| **Proof Size** | 15.88 KB | - -### Config - -#### validate_secure_configs - -| Metric | Value | -| -------------------- | -------- | -| **Compilation** | 0.30 s | -| **Execution** | 0.29 s | -| **VK Generation** | 0.00 s | -| **Proof Generation** | 0.00 s | -| **Verification** | 0.00 s | -| **ACIR Opcodes** | "0" | -| **Total Gates** | "0" | -| **Circuit Size** | 21.09 KB | -| **Witness Size** | 0 B | -| **VK Size** | 0 B | -| **Proof Size** | 0 B | +## Protocol Summary + +### Circuit Benchmarks + +| Circuit | Constraints | Prove time (s) | Verify time (ms) | Proof size (KB) | +| -------------------- | ----------- | -------------- | ---------------- | --------------- | +| C0 | 287764 | 1.60 | 26.29 | 15.88 | +| C1 | 2432074 | 10.37 | 30.21 | 15.88 | +| C2a | 3879330 | 10.93 | 24.41 | 15.88 | +| C2b | 5739750 | 19.84 | 25.13 | 15.88 | +| C3a | 3764144 | 12.67 | 31.34 | 15.88 | +| C3b | 3764144 | 12.67 | 31.34 | 15.88 | +| C4a | 2564001 | 10.29 | 30.31 | 15.88 | +| C4b | 2564001 | 10.29 | 30.31 | 15.88 | +| C5 | 4395328 | 19.30 | 29.97 | 15.88 | +| user_data_encryption | 1678200 | 6.34 | 30.13 | 15.88 | +| C6 | 3001847 | 10.46 | 26.15 | 15.88 | +| C7 | 128310 | 0.53 | 25.75 | 15.88 | + +### Artifacts + +| Artifact | Proof size | Public input size | Verify gas | Calldata gas | Total gas | +| -------- | ---------- | ----------------- | ---------- | ------------ | --------- | +| Π_DKG | 15.88 KB | 0.12 KB | 3037824 | 202192 | 3240016 | +| Π_user | 31.75 KB | 0.22 KB | 2972929 | 386136 | 3359065 | +| Π_dec | 15.88 KB | 3.25 KB | 3549028 | 188124 | 3737152 | + +### Role / Phase / Activity + +| Role | Phase | Activity | Prove time | Proof size | Bandwidth | +| --------------- | ----- | -------------------------------- | ---------- | ---------- | --------- | +| Each ciphernode | P1 | one-time DKG participation | 65.70 s | 95.25 KB | 96.41 KB | +| Aggregator | P2 | combine folds + C5 | 19.30 s | 15.88 KB | 16.00 KB | +| User | P3 | per user input | 12.14 s | 31.75 KB | 31.97 KB | +| Each ciphernode | P4 | per computation output (C6) | 10.46 s | 15.88 KB | 16.00 KB | +| Aggregator | P4 | per computation output (C7+fold) | 0.53 s | 15.88 KB | 19.12 KB | ## System Information diff --git a/circuits/benchmarks/scripts/benchmark_circuit.sh b/circuits/benchmarks/scripts/benchmark_circuit.sh index a8b5d45035..03462a1e6d 100755 --- a/circuits/benchmarks/scripts/benchmark_circuit.sh +++ b/circuits/benchmarks/scripts/benchmark_circuit.sh @@ -155,8 +155,33 @@ PROVE_SUCCESS="false" PROOF_SIZE=0 VERIFY_TIME=0 VERIFY_SUCCESS="false" +PUBLIC_INPUT_SIZE=0 +PROOF_CALLDATA_GAS=0 +PUBLIC_INPUT_CALLDATA_GAS=0 +TOTAL_CALLDATA_GAS=0 +PROOF_HEX="0x" +PUBLIC_INPUTS_HEX="0x" ERROR_MSG="" +calculate_calldata_gas() { + local file_path="$1" + if [ ! -f "$file_path" ]; then + echo "0" + return + fi + python3 - "$file_path" <<'PY' +import sys + +path = sys.argv[1] +with open(path, "rb") as f: + data = f.read() + +zero = data.count(0) +non_zero = len(data) - zero +print((zero * 4) + (non_zero * 16)) +PY +} + # 1. COMPILE if [ "$SKIP_COMPILE" = true ]; then echo "" @@ -282,6 +307,15 @@ if [ "$VK_GEN_SUCCESS" = "true" ]; then # Get proof size (bb creates proof file directly in target directory) if [ -f "${TARGET_DIR}/proof" ]; then PROOF_SIZE=$(wc -c < "${TARGET_DIR}/proof" | tr -d ' ') + PROOF_CALLDATA_GAS=$(calculate_calldata_gas "${TARGET_DIR}/proof") + PROOF_HEX=$(python3 - "${TARGET_DIR}/proof" <<'PY' +import binascii +import pathlib +import sys +data = pathlib.Path(sys.argv[1]).read_bytes() +print("0x" + binascii.hexlify(data).decode()) +PY +) fi else END=$(get_timestamp) @@ -302,6 +336,19 @@ if [ "$PROVE_SUCCESS" = "true" ]; then VERIFY_TIME=$(echo "$END - $START" | bc | awk '{printf "%.9f", $0}') VERIFY_SUCCESS="true" echo "✓ Verification successful (${VERIFY_TIME}s)" + if [ -f "${TARGET_DIR}/public_inputs" ]; then + PUBLIC_INPUT_SIZE=$(wc -c < "${TARGET_DIR}/public_inputs" | tr -d ' ') + PUBLIC_INPUT_CALLDATA_GAS=$(calculate_calldata_gas "${TARGET_DIR}/public_inputs") + PUBLIC_INPUTS_HEX=$(python3 - "${TARGET_DIR}/public_inputs" <<'PY' +import binascii +import pathlib +import sys +data = pathlib.Path(sys.argv[1]).read_bytes() +print("0x" + binascii.hexlify(data).decode()) +PY +) + fi + TOTAL_CALLDATA_GAS=$((PROOF_CALLDATA_GAS + PUBLIC_INPUT_CALLDATA_GAS)) else END=$(get_timestamp) VERIFY_TIME=$(echo "$END - $START" | bc | awk '{printf "%.9f", $0}') @@ -390,11 +437,17 @@ cat > "$OUTPUT_JSON" < + +set -e + +OUTPUT_JSON="" + +while [[ $# -gt 0 ]]; do + case $1 in + --output) + OUTPUT_JSON="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + echo "Usage: $0 --output " + exit 1 + ;; + esac +done + +if [ -z "$OUTPUT_JSON" ]; then + echo "Usage: $0 --output " + exit 1 +fi + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)" +CRISP_CONTRACTS_DIR="${REPO_ROOT}/examples/CRISP/packages/crisp-contracts" +TMP_LOG_CRISP="$(mktemp)" +TMP_LOG_FOLDED="$(mktemp)" +TMP_LOG_ENCLAVE="$(mktemp)" +TMP_JSON_ENCLAVE="$(mktemp)" +TMP_JSON_FOLDED="$(mktemp)" + +if [ ! -d "$CRISP_CONTRACTS_DIR" ]; then + cat > "$OUTPUT_JSON" </dev/null +) + +set +e +( + cd "$CRISP_CONTRACTS_DIR" && \ + pnpm hardhat test mocha --grep "should verify the proof correctly with the crisp verifier" +) > "$TMP_LOG_CRISP" 2>&1 +CRISP_TEST_EXIT_CODE=$? +( + cd "$REPO_ROOT" && \ + BENCHMARK_FOLDED_OUTPUT="$TMP_JSON_FOLDED" cargo test -p e3-tests test_trbfv_actor -- --nocapture +) > "$TMP_LOG_FOLDED" 2>&1 +FOLDED_TEST_EXIT_CODE=$? +( + cd "$ENCLAVE_CONTRACTS_DIR" && \ + BENCHMARK_RAW_DIR="$RAW_DIR" BENCHMARK_GAS_OUTPUT="$TMP_JSON_ENCLAVE" BENCHMARK_FOLDED_JSON="$TMP_JSON_FOLDED" \ + pnpm hardhat run scripts/benchmarkGasFromRaw.ts --network hardhat +) > "$TMP_LOG_ENCLAVE" 2>&1 +ENCLAVE_TEST_EXIT_CODE=$? +set -e + +parse_marker() { + local marker="$1" + local file_path="$2" + python3 - "$marker" "$file_path" <<'PY' +import re +import sys + +marker = sys.argv[1] +path = sys.argv[2] +with open(path, "r", encoding="utf-8", errors="ignore") as f: + text = f.read() + +m = re.search(rf"\[bench-gas\]\s+{re.escape(marker)}=(\d+)", text) +if m: + print(m.group(1)) +PY +} + +USER_VERIFY_GAS=$(parse_marker "crisp_user_verify" "$TMP_LOG_CRISP") +DKG_VERIFY_GAS=$(jq -r '.verify_gas.dkg // empty' "$TMP_JSON_ENCLAVE" 2>/dev/null || true) +DEC_VERIFY_GAS=$(jq -r '.verify_gas.dec // empty' "$TMP_JSON_ENCLAVE" 2>/dev/null || true) + +[ -z "$USER_VERIFY_GAS" ] && USER_VERIFY_GAS="null" +[ -z "$DKG_VERIFY_GAS" ] && DKG_VERIFY_GAS="null" +[ -z "$DEC_VERIFY_GAS" ] && DEC_VERIFY_GAS="null" + +cat > "$OUTPUT_JSON" < --output --git-commit --git-branch - set -e INPUT_DIR="" OUTPUT_FILE="" GIT_COMMIT="unknown" GIT_BRANCH="unknown" +GAS_JSON="" -# Parse arguments while [[ $# -gt 0 ]]; do case $1 in - --input-dir) - INPUT_DIR="$2" - shift 2 - ;; - --output) - OUTPUT_FILE="$2" - shift 2 - ;; - --git-commit) - GIT_COMMIT="$2" - shift 2 - ;; - --git-branch) - GIT_BRANCH="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - exit 1 - ;; + --input-dir) INPUT_DIR="$2"; shift 2 ;; + --output) OUTPUT_FILE="$2"; shift 2 ;; + --git-commit) GIT_COMMIT="$2"; shift 2 ;; + --git-branch) GIT_BRANCH="$2"; shift 2 ;; + --gas-json) GAS_JSON="$2"; shift 2 ;; + *) echo "Unknown option: $1"; exit 1 ;; esac done if [ -z "$INPUT_DIR" ] || [ -z "$OUTPUT_FILE" ]; then - echo "Usage: $0 --input-dir --output [--git-commit ] [--git-branch ]" + echo "Usage: $0 --input-dir --output [--git-commit ] [--git-branch ] [--gas-json ]" exit 1 fi -# Helper functions -format_bytes() { - local bytes=$1 - if [ "$bytes" -eq 0 ]; then - echo "0 B" - elif [ "$bytes" -lt 1024 ]; then - echo "${bytes} B" - elif [ "$bytes" -lt 1048576 ]; then - local kb=$(echo "scale=5; $bytes/1024" | bc | awk '{printf "%.2f", $0}') - echo "${kb} KB" - else - local mb=$(echo "scale=5; $bytes/1048576" | bc | awk '{printf "%.2f", $0}') - echo "${mb} MB" +format_s() { awk -v v="$1" 'BEGIN{printf "%.2f", v}'; } +format_ms() { echo "$1 * 1000" | bc -l | awk '{printf "%.2f", $0}'; } +format_kb() { echo "$1 / 1024" | bc -l | awk '{printf "%.2f", $0}'; } + +find_json_by_path_fragment() { + local frag="$1" + for json_file in "$INPUT_DIR"/*.json; do + [ -f "$json_file" ] || continue + local circuit_path + circuit_path=$(jq -r '.circuit_path // ""' "$json_file") + if [[ "$circuit_path" == *"$frag"* ]]; then + echo "$json_file" + return + fi + done + echo "" +} + +emit_circuit_row() { + local label="$1" + local path_fragment="$2" + local json_file + json_file=$(find_json_by_path_fragment "$path_fragment") + if [ -z "$json_file" ]; then + echo "| $label | N/A | N/A | N/A | N/A |" >> "$OUTPUT_FILE" + return fi + local constraints prove verify proof_size + constraints=$(jq -r '.gates.total_gates // 0' "$json_file") + prove=$(jq -r '.proof_generation.time_seconds // 0' "$json_file") + verify=$(jq -r '.verification.time_seconds // 0' "$json_file") + proof_size=$(jq -r '.proof_generation.proof_size_bytes // 0' "$json_file") + echo "| $label | $constraints | $(format_s "$prove") | $(format_ms "$verify") | $(format_kb "$proof_size") |" >> "$OUTPUT_FILE" } -format_time() { - local seconds=$1 - # Format to 2 decimal places - local s=$(echo "$seconds" | awk '{printf "%.2f", $0}') - echo "${s} s" +emit_user_data_enc_row() { + local wrapper ct0 ct1 + wrapper=$(find_json_by_path_fragment "/threshold/user_data_encryption") + ct0=$(find_json_by_path_fragment "/threshold/user_data_encryption_ct0") + ct1=$(find_json_by_path_fragment "/threshold/user_data_encryption_ct1") + + if [ -n "$wrapper" ]; then + local constraints prove verify proof_size + constraints=$(jq -r '.gates.total_gates // 0' "$wrapper") + prove=$(jq -r '.proof_generation.time_seconds // 0' "$wrapper") + verify=$(jq -r '.verification.time_seconds // 0' "$wrapper") + proof_size=$(jq -r '.proof_generation.proof_size_bytes // 0' "$wrapper") + if [ "$proof_size" -gt 0 ]; then + echo "| user_data_encryption | $constraints | $(format_s "$prove") | $(format_ms "$verify") | $(format_kb "$proof_size") |" >> "$OUTPUT_FILE" + return + fi + fi + + if [ -n "$ct0" ] && [ -n "$ct1" ]; then + local constraints prove verify proof_size + constraints=$(echo "$(jq -r '.gates.total_gates // 0' "$ct0") + $(jq -r '.gates.total_gates // 0' "$ct1")" | bc) + prove=$(echo "$(jq -r '.proof_generation.time_seconds // 0' "$ct0") + $(jq -r '.proof_generation.time_seconds // 0' "$ct1")" | bc -l) + verify=$(echo "$(jq -r '.verification.time_seconds // 0' "$ct0") + $(jq -r '.verification.time_seconds // 0' "$ct1")" | bc -l) + proof_size=$(echo "$(jq -r '.proof_generation.proof_size_bytes // 0' "$ct0") + $(jq -r '.proof_generation.proof_size_bytes // 0' "$ct1")" | bc) + echo "| user_data_encryption | $constraints | $(format_s "$prove") | $(format_ms "$verify") | $(format_kb "$proof_size") |" >> "$OUTPUT_FILE" + return + fi + + echo "| user_data_encryption | N/A | N/A | N/A | N/A |" >> "$OUTPUT_FILE" } -format_gates() { - local gates=$1 - if [ "$gates" -ge 1000000 ]; then - local m=$(echo "scale=5; $gates/1000000" | bc | awk '{printf "%.2f", $0}') - echo "${m}M" - elif [ "$gates" -ge 1000 ]; then - local k=$(echo "scale=5; $gates/1000" | bc | awk '{printf "%.2f", $0}') - echo "${k}K" +verify_gas_for_artifact() { + local artifact="$1" + [ -f "$GAS_JSON" ] || { echo "N/A"; return; } + local key="" + case "$artifact" in + Π_DKG) key="dkg" ;; + Π_user) key="user" ;; + Π_dec) key="dec" ;; + *) echo "N/A"; return ;; + esac + local value + value=$(jq -r ".verify_gas.${key} // empty" "$GAS_JSON") + if [ -z "$value" ] || [ "$value" = "null" ]; then + echo "N/A" else - echo "$gates" + echo "$value" fi } +artifact_metrics() { + local name="$1" + local label="$2" + local verify_gas="$3" + + if [ "$label" = "user_data_encryption" ]; then + local ct0 ct1 + ct0=$(find_json_by_path_fragment "/threshold/user_data_encryption_ct0") + ct1=$(find_json_by_path_fragment "/threshold/user_data_encryption_ct1") + if [ -z "$ct0" ] || [ -z "$ct1" ]; then + echo "| $name | N/A | N/A | $verify_gas | N/A | N/A |" >> "$OUTPUT_FILE" + return + fi + local proof_size public_size calldata total + proof_size=$(echo "$(jq -r '.proof_generation.proof_size_bytes // 0' "$ct0") + $(jq -r '.proof_generation.proof_size_bytes // 0' "$ct1")" | bc) + public_size=$(echo "$(jq -r '.verification.public_inputs_size_bytes // 0' "$ct0") + $(jq -r '.verification.public_inputs_size_bytes // 0' "$ct1")" | bc) + calldata=$(echo "$(jq -r '.verification.calldata_gas_total // 0' "$ct0") + $(jq -r '.verification.calldata_gas_total // 0' "$ct1")" | bc) + total="N/A" + if [ "$verify_gas" != "N/A" ]; then total=$((verify_gas + calldata)); fi + echo "| $name | $(format_kb "$proof_size") KB | $(format_kb "$public_size") KB | $verify_gas | $calldata | $total |" >> "$OUTPUT_FILE" + return + fi -# Helper: return "dkg", "threshold", or "config" from circuit_path in JSON -category_of() { - local path - path=$(jq -r '.circuit_path' "$1") - if [[ "$path" == *"/dkg/"* ]]; then - echo "dkg" - elif [[ "$path" == *"/threshold/"* ]]; then - echo "threshold" - elif [[ "$path" == *"config"* ]]; then - echo "config" - else - echo "other" + local json_file + json_file=$(find_json_by_path_fragment "$label") + if [ -z "$json_file" ]; then + echo "| $name | N/A | N/A | $verify_gas | N/A | N/A |" >> "$OUTPUT_FILE" + return fi + local proof_size public_size calldata total + proof_size=$(jq -r '.proof_generation.proof_size_bytes // 0' "$json_file") + public_size=$(jq -r '.verification.public_inputs_size_bytes // 0' "$json_file") + calldata=$(jq -r '.verification.calldata_gas_total // 0' "$json_file") + total="N/A" + if [ "$verify_gas" != "N/A" ]; then total=$((verify_gas + calldata)); fi + echo "| $name | $(format_kb "$proof_size") KB | $(format_kb "$public_size") KB | $verify_gas | $calldata | $total |" >> "$OUTPUT_FILE" +} + +sum_phase_metrics() { + local labels="$1" + local prove_sum="0" + local proof_sum="0" + local bandwidth_sum="0" + local count=0 + for label in $labels; do + local jf + jf=$(find_json_by_path_fragment "$label") + [ -n "$jf" ] || continue + local p ps pub + p=$(jq -r '.proof_generation.time_seconds // 0' "$jf") + ps=$(jq -r '.proof_generation.proof_size_bytes // 0' "$jf") + pub=$(jq -r '.verification.public_inputs_size_bytes // 0' "$jf") + prove_sum=$(echo "$prove_sum + $p" | bc -l) + proof_sum=$(echo "$proof_sum + $ps" | bc -l) + bandwidth_sum=$(echo "$bandwidth_sum + $ps + $pub" | bc -l) + count=$((count + 1)) + done + if [ "$count" -eq 0 ]; then echo "N/A|N/A|N/A"; return; fi + echo "$(format_s "$prove_sum") s|$(format_kb "$proof_sum") KB|$(format_kb "$bandwidth_sum") KB" } -# Start building report TIMESTAMP=$(date -u "+%Y-%m-%d %H:%M:%S UTC") -cat > "$OUTPUT_FILE" << EOF +cat > "$OUTPUT_FILE" < "$OUTPUT_FILE" << EOF --- -## Summary - -### DKG - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -|---------|---------|---------|-------|--------| -EOF - -for json_file in "$INPUT_DIR"/*.json; do - [ -f "$json_file" ] || continue - [ "$(category_of "$json_file")" = "dkg" ] || continue - circuit=$(jq -r '.circuit_name' "$json_file") - compile_time=$(jq -r '.compilation.time_seconds' "$json_file") - execute_time=$(jq -r '.execution.time_seconds' "$json_file") - prove_time=$(jq -r '.proof_generation.time_seconds' "$json_file") - verify_time=$(jq -r '.verification.time_seconds' "$json_file") - compile_fmt=$(format_time "$compile_time") - execute_fmt=$(format_time "$execute_time") - prove_fmt=$(format_time "$prove_time") - verify_fmt=$(format_time "$verify_time") - echo "| $circuit | $compile_fmt | $execute_fmt | $prove_fmt | $verify_fmt |" >> "$OUTPUT_FILE" -done - -cat >> "$OUTPUT_FILE" << EOF - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -|---------|---------|-------|--------------|---------|---------|------------| -EOF - -for json_file in "$INPUT_DIR"/*.json; do - [ -f "$json_file" ] || continue - [ "$(category_of "$json_file")" = "dkg" ] || continue - circuit=$(jq -r '.circuit_name' "$json_file") - opcodes=$(jq -r '.gates.acir_opcodes // 0' "$json_file") - gates=$(jq -r '.gates.total_gates' "$json_file") - circuit_size=$(jq -r '.compilation.circuit_size_bytes' "$json_file") - witness_size=$(jq -r '.execution.witness_size_bytes' "$json_file") - vk_size=$(jq -r '.vk_generation.vk_size_bytes' "$json_file") - proof_size=$(jq -r '.proof_generation.proof_size_bytes' "$json_file") - gates_fmt=$(format_gates "$gates") - circuit_size_fmt=$(format_bytes "$circuit_size") - witness_size_fmt=$(format_bytes "$witness_size") - vk_size_fmt=$(format_bytes "$vk_size") - proof_size_fmt=$(format_bytes "$proof_size") - echo "| $circuit | $opcodes | $gates_fmt | $circuit_size_fmt | $witness_size_fmt | $vk_size_fmt | $proof_size_fmt |" >> "$OUTPUT_FILE" -done - -cat >> "$OUTPUT_FILE" << EOF - -### Threshold - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -|---------|---------|---------|-------|--------| -EOF - -for json_file in "$INPUT_DIR"/*.json; do - [ -f "$json_file" ] || continue - [ "$(category_of "$json_file")" = "threshold" ] || continue - circuit=$(jq -r '.circuit_name' "$json_file") - compile_time=$(jq -r '.compilation.time_seconds' "$json_file") - execute_time=$(jq -r '.execution.time_seconds' "$json_file") - prove_time=$(jq -r '.proof_generation.time_seconds' "$json_file") - verify_time=$(jq -r '.verification.time_seconds' "$json_file") - compile_fmt=$(format_time "$compile_time") - execute_fmt=$(format_time "$execute_time") - prove_fmt=$(format_time "$prove_time") - verify_fmt=$(format_time "$verify_time") - echo "| $circuit | $compile_fmt | $execute_fmt | $prove_fmt | $verify_fmt |" >> "$OUTPUT_FILE" -done +## Protocol Summary -cat >> "$OUTPUT_FILE" << EOF +### Circuit Benchmarks -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -|---------|---------|-------|--------------|---------|---------|------------| +| Circuit | Constraints | Prove time (s) | Verify time (ms) | Proof size (KB) | +|---------|-------------|----------------|------------------|-----------------| EOF -for json_file in "$INPUT_DIR"/*.json; do - [ -f "$json_file" ] || continue - [ "$(category_of "$json_file")" = "threshold" ] || continue - circuit=$(jq -r '.circuit_name' "$json_file") - opcodes=$(jq -r '.gates.acir_opcodes // 0' "$json_file") - gates=$(jq -r '.gates.total_gates' "$json_file") - circuit_size=$(jq -r '.compilation.circuit_size_bytes' "$json_file") - witness_size=$(jq -r '.execution.witness_size_bytes' "$json_file") - vk_size=$(jq -r '.vk_generation.vk_size_bytes' "$json_file") - proof_size=$(jq -r '.proof_generation.proof_size_bytes' "$json_file") - gates_fmt=$(format_gates "$gates") - circuit_size_fmt=$(format_bytes "$circuit_size") - witness_size_fmt=$(format_bytes "$witness_size") - vk_size_fmt=$(format_bytes "$vk_size") - proof_size_fmt=$(format_bytes "$proof_size") - echo "| $circuit | $opcodes | $gates_fmt | $circuit_size_fmt | $witness_size_fmt | $vk_size_fmt | $proof_size_fmt |" >> "$OUTPUT_FILE" -done - -# Config (validate_secure_configs) - only present in secure mode -cat >> "$OUTPUT_FILE" << EOF - -### Config - -#### Timing Metrics - -| Circuit | Compile | Execute | Prove | Verify | -|---------|---------|---------|-------|--------| +emit_circuit_row "C0" "/dkg/pk" +emit_circuit_row "C1" "/threshold/pk_generation" +emit_circuit_row "C2a" "/dkg/sk_share_computation" +emit_circuit_row "C2b" "/dkg/e_sm_share_computation" +emit_circuit_row "C3a" "/dkg/share_encryption" +emit_circuit_row "C3b" "/dkg/share_encryption" +emit_circuit_row "C4a" "/dkg/share_decryption" +emit_circuit_row "C4b" "/dkg/share_decryption" +emit_circuit_row "C5" "/threshold/pk_aggregation" +emit_user_data_enc_row +emit_circuit_row "C6" "/threshold/share_decryption" +emit_circuit_row "C7" "/threshold/decrypted_shares_aggregation" + +cat >> "$OUTPUT_FILE" <> "$OUTPUT_FILE" -done - -cat >> "$OUTPUT_FILE" << EOF - -#### Size & Circuit Metrics - -| Circuit | Opcodes | Gates | Circuit Size | Witness | VK Size | Proof Size | -|---------|---------|-------|--------------|---------|---------|------------| +artifact_metrics "Π_DKG" "/threshold/pk_aggregation" "$(verify_gas_for_artifact Π_DKG)" +artifact_metrics "Π_user" "user_data_encryption" "$(verify_gas_for_artifact Π_user)" +artifact_metrics "Π_dec" "/threshold/decrypted_shares_aggregation" "$(verify_gas_for_artifact Π_dec)" + +p1=$(sum_phase_metrics "/dkg/pk /threshold/pk_generation /dkg/sk_share_computation /dkg/e_sm_share_computation /dkg/share_encryption /dkg/share_decryption") +p2=$(sum_phase_metrics "/threshold/pk_aggregation") +p3=$(sum_phase_metrics "/threshold/user_data_encryption_ct0 /threshold/user_data_encryption_ct1") +p4n=$(sum_phase_metrics "/threshold/share_decryption") +p4a=$(sum_phase_metrics "/threshold/decrypted_shares_aggregation") +IFS='|' read -r p1t p1s p1b <<< "$p1" +IFS='|' read -r p2t p2s p2b <<< "$p2" +IFS='|' read -r p3t p3s p3b <<< "$p3" +IFS='|' read -r p4nt p4ns p4nb <<< "$p4n" +IFS='|' read -r p4at p4as p4ab <<< "$p4a" + +cat >> "$OUTPUT_FILE" <> "$OUTPUT_FILE" -done - -# Detailed metrics by circuit, grouped by DKG / Threshold / Config -cat >> "$OUTPUT_FILE" << EOF - -## Circuit Details - -EOF - -for category in dkg threshold config; do - title="DKG" - [ "$category" = "threshold" ] && title="Threshold" - [ "$category" = "config" ] && title="Config" - echo "### $title" >> "$OUTPUT_FILE" - echo "" >> "$OUTPUT_FILE" - circuits=$(for json_file in "$INPUT_DIR"/*.json; do - [ -f "$json_file" ] || continue - [ "$(category_of "$json_file")" = "$category" ] || continue - jq -r '.circuit_name' "$json_file" - done | sort -u) - for circuit in $circuits; do - json_file="" - for f in "$INPUT_DIR"/*.json; do - [ -f "$f" ] || continue - [ "$(category_of "$f")" = "$category" ] || continue - c=$(jq -r '.circuit_name' "$f") - if [ "$c" = "$circuit" ]; then - json_file="$f" - break - fi - done - [ -z "$json_file" ] && continue - echo "#### $circuit" >> "$OUTPUT_FILE" - echo "" >> "$OUTPUT_FILE" - compile=$(jq -r '.compilation.time_seconds' "$json_file") - execute=$(jq -r '.execution.time_seconds' "$json_file") - opcodes=$(jq -r '.gates.acir_opcodes // 0' "$json_file") - gates=$(jq -r '.gates.total_gates' "$json_file") - vk_gen=$(jq -r '.vk_generation.time_seconds' "$json_file") - prove=$(jq -r '.proof_generation.time_seconds' "$json_file") - verify=$(jq -r '.verification.time_seconds' "$json_file") - circuit_size=$(jq -r '.compilation.circuit_size_bytes' "$json_file") - witness_size=$(jq -r '.execution.witness_size_bytes' "$json_file") - vk_size=$(jq -r '.vk_generation.vk_size_bytes' "$json_file") - proof_size=$(jq -r '.proof_generation.proof_size_bytes' "$json_file") - cat >> "$OUTPUT_FILE" << INNER -| Metric | Value | -|--------|-------| -| **Compilation** | $(format_time "$compile") | -| **Execution** | $(format_time "$execute") | -| **VK Generation** | $(format_time "$vk_gen") | -| **Proof Generation** | $(format_time "$prove") | -| **Verification** | $(format_time "$verify") | -| **ACIR Opcodes** | "${opcodes}" | -| **Total Gates** | "${gates}" | -| **Circuit Size** | $(format_bytes "$circuit_size") | -| **Witness Size** | $(format_bytes "$witness_size") | -| **VK Size** | $(format_bytes "$vk_size") | -| **Proof Size** | $(format_bytes "$proof_size") | - -INNER - done - echo "" >> "$OUTPUT_FILE" -done - -# System info (from first JSON file) first_json=$(ls "$INPUT_DIR"/*.json 2>/dev/null | head -1) if [ -n "$first_json" ]; then - cat >> "$OUTPUT_FILE" << EOF -## System Information - -### Hardware - -EOF - cpu_model=$(jq -r '.system_info.cpu_model // "unknown"' "$first_json") cpu_cores=$(jq -r '.system_info.cpu_cores // "unknown"' "$first_json") ram_gb=$(jq -r '.system_info.ram_gb // "unknown"' "$first_json") - os=$(jq -r '.system_info.os' "$first_json") - arch=$(jq -r '.system_info.arch' "$first_json") - - echo "- **CPU:** $cpu_model" >> "$OUTPUT_FILE" - echo "- **CPU Cores:** $cpu_cores" >> "$OUTPUT_FILE" - echo "- **RAM:** ${ram_gb} GB" >> "$OUTPUT_FILE" - echo "- **OS:** $os" >> "$OUTPUT_FILE" - echo "- **Architecture:** $arch" >> "$OUTPUT_FILE" - - cat >> "$OUTPUT_FILE" << EOF + os=$(jq -r '.system_info.os // "unknown"' "$first_json") + arch=$(jq -r '.system_info.arch // "unknown"' "$first_json") + nargo=$(jq -r '.system_info.nargo_version // "unknown"' "$first_json") + bb=$(jq -r '.system_info.bb_version // "unknown"' "$first_json") + cat >> "$OUTPUT_FILE" <> "$OUTPUT_FILE" - echo "- **Barretenberg Version:** $bb" >> "$OUTPUT_FILE" - echo "" >> "$OUTPUT_FILE" fi echo "✓ Report generated successfully: $OUTPUT_FILE" diff --git a/circuits/benchmarks/scripts/run_benchmarks.sh b/circuits/benchmarks/scripts/run_benchmarks.sh index 65f29cb78a..a18d8ac2d5 100755 --- a/circuits/benchmarks/scripts/run_benchmarks.sh +++ b/circuits/benchmarks/scripts/run_benchmarks.sh @@ -213,13 +213,22 @@ echo "║ Generating Report... ║" echo "╚════════════════════════════════════════════════╝" echo "" +# Try to retrieve verifier gas from the existing CRISP verify test path. +GAS_JSON_FILE="${BENCHMARKS_DIR}/${OUTPUT_DIR}/crisp_verify_gas.json" +if "${SCRIPT_DIR}/extract_crisp_verify_gas.sh" --output "${GAS_JSON_FILE}"; then + echo "✓ CRISP verify gas extracted: ${GAS_JSON_FILE}" +else + echo "⚠️ Could not extract CRISP verify gas; report will show N/A for verify gas" +fi + # Generate markdown report REPORT_FILE="${BENCHMARKS_DIR}/${OUTPUT_DIR}/report.md" "${SCRIPT_DIR}/generate_report.sh" \ --input-dir "${BENCHMARKS_DIR}/${OUTPUT_DIR}/raw" \ --output "${REPORT_FILE}" \ --git-commit "$GIT_COMMIT" \ - --git-branch "$GIT_BRANCH" + --git-branch "$GIT_BRANCH" \ + --gas-json "${GAS_JSON_FILE}" echo "✓ Report generated: ${REPORT_FILE}" echo "" diff --git a/crates/tests/tests/integration.rs b/crates/tests/tests/integration.rs index 465c94054e..7bac038405 100644 --- a/crates/tests/tests/integration.rs +++ b/crates/tests/tests/integration.rs @@ -1152,6 +1152,7 @@ async fn test_trbfv_actor() -> Result<()> { }; let pubkey_bytes = pubkey_event.pubkey.clone(); + let dkg_aggregator_proof = pubkey_event.dkg_aggregator_proof.clone(); let pubkey = PublicKey::from_bytes(&pubkey_bytes, ¶ms_raw)?; @@ -1334,6 +1335,47 @@ async fn test_trbfv_actor() -> Result<()> { "DecryptionAggregator proofs should be present in PlaintextAggregated" ); + if let Ok(path) = std::env::var("BENCHMARK_FOLDED_OUTPUT") { + if let (Some(dkg_proof), Some(dec_proof)) = ( + dkg_aggregator_proof.as_ref(), + decryption_aggregator_proofs.first(), + ) { + fn to_hex(bytes: &[u8]) -> String { + let mut out = String::from("0x"); + for b in bytes { + out.push_str(&format!("{:02x}", b)); + } + out + } + let json = format!( + concat!( + "{{\n", + " \"dkg_aggregator\": {{\n", + " \"proof_hex\": \"{}\",\n", + " \"public_inputs_hex\": \"{}\"\n", + " }},\n", + " \"decryption_aggregator\": {{\n", + " \"proof_hex\": \"{}\",\n", + " \"public_inputs_hex\": \"{}\"\n", + " }}\n", + "}}\n" + ), + to_hex(&dkg_proof.data), + to_hex(&dkg_proof.public_signals), + to_hex(&dec_proof.data), + to_hex(&dec_proof.public_signals), + ); + fs::write(&path, json)?; + println!("Wrote folded benchmark proofs to {path}"); + } else { + println!( + "BENCHMARK_FOLDED_OUTPUT set but folded proofs unavailable (dkg={}, dec={})", + dkg_aggregator_proof.is_some(), + !decryption_aggregator_proofs.is_empty() + ); + } + } + let results = plaintext .into_iter() .map(|a| decode_bytes_to_vec_u64(&a.extract_bytes()).expect("error decoding bytes")) diff --git a/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts b/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts index 7573cca5cb..382f460d3e 100644 --- a/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts +++ b/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts @@ -94,6 +94,8 @@ describe('CRISP Contracts', function () { describe('validate input', () => { it('should verify the proof correctly with the crisp verifier', async function () { + const verifyGas = await honkVerifier.verify.estimateGas(voteProof.proof, voteProof.publicInputs) + console.log(`[bench-gas] crisp_user_verify=${verifyGas.toString()}`) const isValid = await honkVerifier.verify(voteProof.proof, voteProof.publicInputs) expect(isValid).to.be.true diff --git a/packages/enclave-contracts/scripts/benchmarkGasFromRaw.ts b/packages/enclave-contracts/scripts/benchmarkGasFromRaw.ts new file mode 100644 index 0000000000..1e42b1032f --- /dev/null +++ b/packages/enclave-contracts/scripts/benchmarkGasFromRaw.ts @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: LGPL-3.0-only +// +// This file is provided WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. +import { network } from "hardhat"; +import fs from "node:fs"; +import path from "node:path"; + +function findRawJson(rawDir: string, fragment: string): any { + const entries = fs.readdirSync(rawDir).filter((f) => f.endsWith(".json")); + for (const f of entries) { + if (!f.includes(fragment)) continue; + const full = path.join(rawDir, f); + return JSON.parse(fs.readFileSync(full, "utf8")); + } + throw new Error(`Missing raw benchmark JSON for fragment: ${fragment}`); +} + +function hexToBytes32Array(hex: string): string[] { + const clean = hex.startsWith("0x") ? hex.slice(2) : hex; + if (clean.length === 0) return []; + if (clean.length % 64 !== 0) { + throw new Error( + `public_inputs_hex length is not 32-byte aligned: ${clean.length}`, + ); + } + const out: string[] = []; + for (let i = 0; i < clean.length; i += 64) { + out.push(`0x${clean.slice(i, i + 64)}`); + } + return out; +} + +function plaintextHashFromPublicInputs( + publicInputs: string[], + ethersLib: any, +): string { + const messageCoeffsCount = 100; + if (publicInputs.length < messageCoeffsCount) { + throw new Error(`Not enough public inputs: ${publicInputs.length}`); + } + const offset = publicInputs.length - messageCoeffsCount; + const plaintext = new Uint8Array(messageCoeffsCount * 8); + for (let i = 0; i < messageCoeffsCount; i++) { + const coeff = BigInt(publicInputs[offset + i]); + for (let j = 0; j < 8; j++) { + plaintext[i * 8 + j] = Number((coeff >> BigInt(j * 8)) & 0xffn); + } + } + return ethersLib.keccak256(plaintext); +} + +async function main() { + const rawDir = process.env.BENCHMARK_RAW_DIR; + const outputPath = process.env.BENCHMARK_GAS_OUTPUT; + const foldedPath = process.env.BENCHMARK_FOLDED_JSON; + if (!rawDir || !outputPath) { + throw new Error("BENCHMARK_RAW_DIR and BENCHMARK_GAS_OUTPUT are required"); + } + + const { ethers } = await network.connect(); + + let dkgProofHex: string | undefined; + let dkgPublicHex: string | undefined; + let decProofHex: string | undefined; + let decPublicHex: string | undefined; + + if (foldedPath && fs.existsSync(foldedPath)) { + const folded = JSON.parse(fs.readFileSync(foldedPath, "utf8")); + dkgProofHex = folded?.dkg_aggregator?.proof_hex; + dkgPublicHex = folded?.dkg_aggregator?.public_inputs_hex; + decProofHex = folded?.decryption_aggregator?.proof_hex; + decPublicHex = folded?.decryption_aggregator?.public_inputs_hex; + } else { + const dkgRaw = findRawJson(rawDir, "threshold_pk_aggregation"); + const decRaw = findRawJson( + rawDir, + "threshold_decrypted_shares_aggregation", + ); + dkgProofHex = dkgRaw?.proof_generation?.proof_hex; + dkgPublicHex = dkgRaw?.verification?.public_inputs_hex; + decProofHex = decRaw?.proof_generation?.proof_hex; + decPublicHex = decRaw?.verification?.public_inputs_hex; + } + + if (!dkgProofHex || !dkgPublicHex || !decProofHex || !decPublicHex) { + throw new Error( + "Missing proof/public_inputs hex fields in raw benchmark JSON", + ); + } + + const dkgPublicInputs = hexToBytes32Array(dkgPublicHex); + const decPublicInputs = hexToBytes32Array(decPublicHex); + const abiCoder = ethers.AbiCoder.defaultAbiCoder(); + + const libFactory = await ethers.getContractFactory( + "contracts/verifiers/bfv/honk/DkgAggregatorVerifier.sol:ZKTranscriptLib", + ); + const zkTranscriptLib = await libFactory.deploy(); + await zkTranscriptLib.waitForDeployment(); + const zkTranscriptLibAddress = await zkTranscriptLib.getAddress(); + + const dkgAggFactory = await ethers.getContractFactory( + "DkgAggregatorVerifier", + { + libraries: { + "project/contracts/verifiers/bfv/honk/DkgAggregatorVerifier.sol:ZKTranscriptLib": + zkTranscriptLibAddress, + }, + }, + ); + const dkgAgg = await dkgAggFactory.deploy(); + await dkgAgg.waitForDeployment(); + const dkgAggAddress = await dkgAgg.getAddress(); + + const decAggFactory = await ethers.getContractFactory( + "DecryptionAggregatorVerifier", + { + libraries: { + "project/contracts/verifiers/bfv/honk/DecryptionAggregatorVerifier.sol:ZKTranscriptLib": + zkTranscriptLibAddress, + }, + }, + ); + const decAgg = await decAggFactory.deploy(); + await decAgg.waitForDeployment(); + const decAggAddress = await decAgg.getAddress(); + + const bfvPk = await ( + await ethers.getContractFactory("BfvPkVerifier") + ).deploy(dkgAggAddress); + await bfvPk.waitForDeployment(); + + const dkgEncodedProof = abiCoder.encode( + ["bytes", "bytes32[]"], + [dkgProofHex, dkgPublicInputs], + ); + const pkCommitment = dkgPublicInputs[dkgPublicInputs.length - 1]; + const dkgGas = await bfvPk.verify.estimateGas(pkCommitment, dkgEncodedProof); + + const bfvDec = await ( + await ethers.getContractFactory("BfvDecryptionVerifier") + ).deploy(decAggAddress); + await bfvDec.waitForDeployment(); + + const decEncodedProof = abiCoder.encode( + ["bytes", "bytes32[]"], + [decProofHex, decPublicInputs], + ); + const plaintextHash = plaintextHashFromPublicInputs(decPublicInputs, ethers); + const decGas = await bfvDec.verify.estimateGas( + plaintextHash, + decEncodedProof, + ); + + const output = { + verify_gas: { + dkg: Number(dkgGas), + dec: Number(decGas), + }, + source: "benchmark_raw_artifacts", + }; + fs.writeFileSync(outputPath, JSON.stringify(output, null, 2)); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/packages/enclave-contracts/tasks/enclave.ts b/packages/enclave-contracts/tasks/enclave.ts index 57c597e133..2914450fa5 100644 --- a/packages/enclave-contracts/tasks/enclave.ts +++ b/packages/enclave-contracts/tasks/enclave.ts @@ -3,7 +3,13 @@ // This file is provided WITHOUT ANY WARRANTY; // without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. -import { BigNumberish, ZeroAddress, ZeroHash, isHexString, zeroPadValue } from "ethers"; +import { + BigNumberish, + ZeroAddress, + ZeroHash, + isHexString, + zeroPadValue, +} from "ethers"; import fs from "fs"; import { task } from "hardhat/config"; import { ArgumentType } from "hardhat/types/arguments"; @@ -369,7 +375,9 @@ export const publishCommittee = task( throw new Error("pkCommitment must not be the zero hash"); } if (!isHexString(publicKey) || publicKey === "0x") { - throw new Error("publicKey is required and must be a non-empty hex string"); + throw new Error( + "publicKey is required and must be a non-empty hex string", + ); } const tx = await ciphernodeRegistry.publishCommittee( From 60e9be42bc1502bb81223c6b910e9f02f9fb5dd0 Mon Sep 17 00:00:00 2001 From: 0xjei Date: Mon, 27 Apr 2026 15:10:54 +0200 Subject: [PATCH 2/2] small nits from review --- circuits/benchmarks/README.md | 2 +- circuits/benchmarks/scripts/extract_crisp_verify_gas.sh | 7 +++++-- circuits/benchmarks/scripts/run_benchmarks.sh | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/circuits/benchmarks/README.md b/circuits/benchmarks/README.md index ac0258efc5..ddd61292d0 100644 --- a/circuits/benchmarks/README.md +++ b/circuits/benchmarks/README.md @@ -50,7 +50,7 @@ For secure mode, use `--mode secure` and replace `results_insecure` with `result `results_*/report.md` now includes protocol-oriented sections in addition to raw category tables: - `Circuit Benchmarks` with rows in fixed order: `C0`, `C1`, `C2a`, `C2b`, `C3a`, `C3b`, `C4a`, - `C4b`, `C5`, `user-data-enc`, `C6`, `C7`. + `C4b`, `C5`, `user-data-encryption`, `C6`, `C7`. - `Artifacts` for `Π_DKG`, `Π_user`, `Π_dec` with proof/public-input sizes and gas columns. - `Role / Phase / Activity` for P1..P4 operational cost summaries. diff --git a/circuits/benchmarks/scripts/extract_crisp_verify_gas.sh b/circuits/benchmarks/scripts/extract_crisp_verify_gas.sh index c44404b5e5..bd4d34ee36 100755 --- a/circuits/benchmarks/scripts/extract_crisp_verify_gas.sh +++ b/circuits/benchmarks/scripts/extract_crisp_verify_gas.sh @@ -35,6 +35,11 @@ TMP_LOG_ENCLAVE="$(mktemp)" TMP_JSON_ENCLAVE="$(mktemp)" TMP_JSON_FOLDED="$(mktemp)" +cleanup_tmp_files() { + rm -f "$TMP_LOG_CRISP" "$TMP_LOG_FOLDED" "$TMP_LOG_ENCLAVE" "$TMP_JSON_ENCLAVE" "$TMP_JSON_FOLDED" +} +trap cleanup_tmp_files EXIT + if [ ! -d "$CRISP_CONTRACTS_DIR" ]; then cat > "$OUTPUT_JSON" < "$OUTPUT_JSON" <