Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions circuits/benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ From this directory:

Options and secure-only **config** circuit behavior are documented in the script and `config.json`.

### What gets stored (secure / insecure)

A full `./run_benchmarks.sh --mode <mode>` run writes:

- `results_<mode>/raw/*.json` — Nargo timing + artifact sizes (source for the **Circuit Benchmarks**
table)
- `results_<mode>/crisp_verify_gas.json` — verify gas, calldata gas, artifact sizes, and
**`integration_summary`** from `test_trbfv_actor` when gas extraction succeeds
- `results_<mode>/integration_summary.json` — snapshot of `.integration_summary` (phase timings,
folded proofs, **multithread / operation_timings** after a fresh integration export)
- `results_<mode>/report.md` — rendered summary of all of the above

### Regenerate `report.md` only (no integration re-run)

From this directory, after you already have `raw/` + `crisp_verify_gas.json`:

```bash
./regenerate_report.sh
./regenerate_report.sh --mode insecure
```

`crisp_verify_gas.json` embeds the integration timings; if you also keep `integration_summary.json`
in the same folder, the script passes it explicitly (useful when gas JSON is missing a field but the
snapshot is complete). `regenerate_report.sh` itself does not re-run `test_trbfv_actor`; it renders
from `results_<mode>/raw`, `crisp_verify_gas.json`, and (optionally) `integration_summary.json`.

## Refresh after parameter changes

If you change circuit/config parameter sets, rerun the full benchmark + gas extraction flow.
Expand All @@ -43,6 +69,30 @@ pnpm -C examples/CRISP/packages/crisp-sdk build
--gas-json "./circuits/benchmarks/results_insecure/crisp_verify_gas.json"
```

If Π_DKG / Π_dec **verify gas** is `N/A` because `crisp_verify_gas.json` came from a failed extract,
but your integration summary still has `folded_artifacts`, replay only the Hardhat `estimateGas`
step and merge **dkg** / **dec** into the gas file (no Rust re-run):

```bash
# For secure folded proofs, align Solidity verifiers first (--build may take a while).
./circuits/benchmarks/scripts/replay_folded_verify_gas.sh \
--summary "/tmp/summary_secure.json" \
--gas-json "./circuits/benchmarks/results_secure/crisp_verify_gas.json" \
--build secure-8192
```

If `crisp_verify_gas.json` has `integration_summary: null` but you still have the JSON written by
`BENCHMARK_SUMMARY_OUTPUT` from a successful `test_trbfv_actor` run (e.g.
`/tmp/summary_secure.json`), pass it so phase timings and folded sizes match that run:

```bash
./circuits/benchmarks/scripts/generate_report.sh \
--input-dir "./circuits/benchmarks/results_secure/raw" \
--output "./circuits/benchmarks/results_secure/report.md" \
--gas-json "./circuits/benchmarks/results_secure/crisp_verify_gas.json" \
--integration-summary "/tmp/summary_secure.json"
```

For secure mode, use `--mode secure` and replace `results_insecure` with `results_secure`.

## Reported protocol tables
Expand All @@ -53,6 +103,10 @@ For secure mode, use `--mode secure` and replace `results_insecure` with `result
`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.
- When `integration_summary` is present, the report also includes:
- an `Integration test` section (end-to-end phase wall-clock timings)
- a `Thread pool` section (Rayon threads / cores)
- `CPU-bound operation timings` (tracked in-process averages/totals)

## Derivation rules

Expand Down
1 change: 0 additions & 1 deletion circuits/benchmarks/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"dkg/e_sm_share_computation",
"dkg/share_encryption",
"dkg/share_decryption",
"threshold/user_data_encryption",
"threshold/user_data_encryption_ct0",
"threshold/user_data_encryption_ct1",
"threshold/pk_generation",
Expand Down
3 changes: 3 additions & 0 deletions circuits/benchmarks/regenerate_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "${SCRIPT_DIR}/scripts/regenerate_report.sh" "$@"
77 changes: 73 additions & 4 deletions circuits/benchmarks/results_insecure/crisp_verify_gas.json

Large diffs are not rendered by default.

171 changes: 171 additions & 0 deletions circuits/benchmarks/results_insecure/integration_summary.json

Large diffs are not rendered by default.

122 changes: 100 additions & 22 deletions circuits/benchmarks/results_insecure/report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Enclave ZK Circuit Benchmarks

**Generated:** 2026-04-27 10:35:23 UTC
**Generated:** 2026-04-29 10:02:54 UTC

**Git Branch:** `main`
**Git Commit:** `e651f30205117e83a9cc48ac44664d434466724d`
**Git Branch:** `feat/benches`
**Git Commit:** `36c01c62b86e2527279842280337f2f4724d2487`

**Committee Size:** `H=3`, `N=3`, `T=1`

---

Expand All @@ -13,36 +15,107 @@

| 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 |
| C0 | 6847 | 0.12 | 24.97 | 15.88 |
| C1 | 57818 | 0.34 | 25.84 | 15.88 |
| C2a | 142625 | 0.78 | 25.50 | 15.88 |
| C2b | 198355 | 0.85 | 26.06 | 15.88 |
| C3a | 132633 | 0.78 | 25.14 | 15.88 |
| C3b | 132633 | 0.78 | 25.14 | 15.88 |
| C4a | 92515 | 0.50 | 25.00 | 15.88 |
| C4b | 92515 | 0.50 | 25.00 | 15.88 |
| C5 | 151717 | 0.79 | 26.28 | 15.88 |
| user_data_encryption | 53732 | 0.33 | 24.58 | 15.88 |
| C6 | 86927 | 0.52 | 25.34 | 15.88 |
| C7 | 104273 | 0.49 | 25.42 | 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 |
| Π_DKG | 10.69 KB | 0.41 KB | 3037922 | 175616 | 3213538 |
| Π_user | 15.88 KB | 0.12 KB | 2973073 | 170272 | 3143345 |
| Π_dec | 10.69 KB | 3.41 KB | 3549077 | 186764 | 3735841 |

### 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 | P1 | one-time DKG participation | 379.38 s | 127.00 KB | 128.19 KB |
| Aggregator | P2 | combine folds + C5 | 0.79 s | 10.69 KB | 11.09 KB |
| User | P3 | per user input | 0.65 s | 15.88 KB | 16.00 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 |
| Aggregator | P4 | per computation output (C7+fold) | 80.31 s | 10.69 KB | 14.09 KB |

## Integration test (`test_trbfv_actor`)

### End-to-end phase timings (wall clock)

| Phase | Duration (s) |
| ------------------------------------------- | ------------ |
| Starting trbfv actor test | 0.00 |
| Setup completed | 2.98 |
| Committee Setup Completed | 20.25 |
| Committee Finalization Complete | 0.01 |
| ThresholdShares -> PublicKeyAggregated | 379.38 |
| E3Request -> PublicKeyAggregated | 381.92 |
| Application CT Gen | 0.31 |
| Running FHE Application | 0.00 |
| Ciphertext published -> PlaintextAggregated | 80.31 |
| Entire Test | 485.79 |

### Thread pool (same process as integration test)

| Setting | Value |
| ---------------------------- | ----- |
| Rayon threads | 13 |
| Max simultaneous Rayon tasks | 1 |
| Cores available | 14 |

### CPU-bound operation timings (tracked in-process)

| Name | Avg (s) | Runs | Total (s) |
| ----------------------------- | ------- | ---- | --------- |
| CalculateDecryptionKey | 0.11 | 3 | 0.33 |
| CalculateDecryptionShare | 0.61 | 3 | 1.84 |
| CalculateThresholdDecryption | 0.57 | 1 | 0.57 |
| GenEsiSss | 0.12 | 3 | 0.37 |
| GenPkShareAndSkSss | 0.22 | 3 | 0.67 |
| ZkDecryptedSharesAggregation | 8.54 | 1 | 8.54 |
| ZkDecryptionAggregation | 49.65 | 1 | 49.65 |
| ZkDkgAggregation | 20.66 | 1 | 20.66 |
| ZkDkgShareDecryption | 1.45 | 6 | 8.68 |
| ZkNodeDkgFold | 78.08 | 3 | 234.23 |
| ZkPkAggregation | 2.19 | 1 | 2.19 |
| ZkPkBfv | 0.33 | 3 | 0.99 |
| ZkPkGeneration | 1.34 | 3 | 4.01 |
| ZkShareComputation | 2.65 | 6 | 15.91 |
| ZkShareEncryption | 2.47 | 36 | 89.00 |
| ZkThresholdShareDecryption | 6.20 | 3 | 18.59 |
| ZkVerifyShareDecryptionProofs | 0.10 | 3 | 0.30 |
| ZkVerifyShareProofs | 0.22 | 5 | 1.08 |

Sum of tracked operation wall time: **457.62 s** (often much larger than end-to-end wall clock
because work runs in parallel).

## Raw circuit benchmark JSON (Nargo)

Source files for the **Circuit Benchmarks** table. Persist this directory with
`crisp_verify_gas.json` (and optional `integration_summary.json`) to regenerate the report without
re-running the integration test.

| File |
| ----------------------------------------------------- |
| `dkg_e_sm_share_computation_default.json` |
| `dkg_pk_default.json` |
| `dkg_share_decryption_default.json` |
| `dkg_share_encryption_default.json` |
| `dkg_sk_share_computation_default.json` |
| `threshold_decrypted_shares_aggregation_default.json` |
| `threshold_pk_aggregation_default.json` |
| `threshold_pk_generation_default.json` |
| `threshold_share_decryption_default.json` |
| `threshold_user_data_encryption_ct0_default.json` |
| `threshold_user_data_encryption_ct1_default.json` |

## System Information

Expand All @@ -60,3 +133,8 @@
1.0.0-beta.16+2d46fca7203545cbbfb31a0d0328de6c10a8db95 (git version hash:
2d46fca7203545cbbfb31a0d0328de6c10a8db95, is dirty: false)
- **Barretenberg Version:** 3.0.0-nightly.20260102

## Notes

- All nodes are executed on the same machine in this benchmark run, so inter-node network latency is
effectively 0.
79 changes: 74 additions & 5 deletions circuits/benchmarks/results_secure/crisp_verify_gas.json

Large diffs are not rendered by default.

Loading
Loading