IC crypto benchmark
The shared canister runs every registered function from
cases through the ordinary prepared wasm64 SDK runtime,
with bounded Wire endpoints and the SDK allocator. Reusable algorithms have no
benchmark dependency. Synthetic fixtures and algorithm contexts are transient:
clear them between scenarios; restoration does not preserve them. This fixture
does not claim an application upgrade or secret-storage contract.
Dedicated private-computation fixtures have separate matrices and timing scopes:
| Fixture | Current guide | Evidence and report tools |
|---|---|---|
| GC gates, equality, AES and PRGs | GC benchmark | Round5 qualification; round5 report generator |
| Private 2D proximity R1/R2/R4 circuit stages | Proximity benchmark | Stage qualification; proximity report generator; actual N1/N100 with generic Equality8 controls |
| Static private LOS circuit stages | LOS benchmark | Stage qualification; LOS report generator |
| Pinned malicious OT reference | OT reproduction | Backend status; receipt summarizer |
GC, proximity and LOS fixtures measure circuit functions; IC OT and full private protocols remain blocked. The standalone OT reference reports Wasmtime fuel, separately from IC instructions. Dated evidence retains its original source snapshots, receipts and report-tool copies; use the maintained tools above for current reproduction. Proximity reports constructed request/reply bytes with framing and preserves body/query separately from complete checked updates and included page charges. Frozen LOS and synthetic-selector rows have different function contracts; selector visibility-mask preprocessing is unmeasured.
Run from the newstack repository root. Install the existing locked host package once, use the pinned compiler environment, and give the build its own target and temporary directories. Do not share a Cargo target with another build:
npm ci --ignore-scripts --prefix tests/pocketic
export CARGO_TARGET_DIR="$PWD/playground/crypto-target"
export TMPDIR="$PWD/playground/crypto-temp"
source tools/env.sh
cargo test --manifest-path benches/crypto/Cargo.toml --workspace --locked --offline
node --test benches/crypto/*.test.mjs
python3 cdk-rsx/tools/build-app.py \
--manifest-path benches/crypto/Cargo.toml --package cdk-rsx-crypto-bench \
--name crypto-bench --out-dir "$PWD/playground/crypto-artifact-001" \
--debug-artifacts --archive-sources --offline --locked
The workspace lockfile must first be resolved when dependencies are added. The canonical builder supplies the typed-root startup transform, bounded Wire metadata, source archive, hashes and optimized DWARF/origin sidecars. A raw Cargo Wasm is not the artifact accepted by this runner. Preserve the complete artifact directory without moving its absolute-path receipts.
Run all registered cases at actual sizes, batches, input patterns and contexts:
node benches/crypto/run.mjs \
--artifact "$PWD/playground/crypto-artifact-001" \
--out "$PWD/playground/crypto-results-001" \
--pocket-ic /home/devbox/.local/bin/pocket-ic
The default Cartesian matrix uses message lengths
32/63/64/65/127/128/129/256/512/2048/8192 bytes, 100 logical operations in each call,
valid/invalid/mixed patterns, distinct/repeated inputs, and
fresh-message/same-message-warm execution. It performs one sample per row.
This is 132 rows per registered case and can take substantial time, especially
for key generation. Every row runs at its requested size; no result is
extrapolated from a smaller batch. Invalid patterns are interpreted by each case
and need not change operations without a rejection mode; read case descriptions
and adapters before treating two rows as different semantic workloads.
For an initial all-function screen:
node benches/crypto/run.mjs \
--artifact "$PWD/playground/crypto-artifact-001" \
--out "$PWD/playground/crypto-smoke-001" \
--pocket-ic /home/devbox/.local/bin/pocket-ic \
--sizes 256 --batches 100 --patterns valid --inputs distinct \
--contexts fresh-message --samples 1 --profiles 0
Use --cases ID,ID to select exact IDs from plan.json, --samples 1..32, and
the corresponding comma-separated --sizes, --batches, --patterns,
--inputs and --contexts filters. --dry-run --cases ID,ID prints the matrix
without an artifact or server. --help lists all options. Output directories
must be fresh. The runner owns one new server and instance, exports traces and
shuts down only its own server. It neither connects to nor terminates another
process's server or viewer. The primary result is always the actual 100-operation
call. --batches 1,8,32,128,500 selects an explicit diagnostic/capacity sweep;
single-operation timing is never presented as bulk performance.
The staged-fixture Wire endpoints are cases, setup, run, clear, noop
and footprint; the live-ingress comparisons add live_prepare_ecdsa,
live_verify_ecdsa, live_prepare_ecdsa_keys and live_verify_ecdsa_bulk.
Only one fixture is admitted at a time; setup rejects an occupied
slot. The limits are 500 logical operations, 1 MiB per synthetic message and
64 MiB aggregate logical message bytes. These are admission bounds, not an
estimate of all algorithm allocations. Requests are compact metadata; fixture
construction occurs inside a separately traced setup update. footprint reports
heap capacity and the SDK page authority's runtime/Store/control counts outside
captures, plus the active fixture and logical-input count. Capacity and allocated
page runs are not live payload sizes or host RSS. Management status supplies
stable-memory and installed-module evidence separately.
run borrows the staged fixture once before timing and allocates/zeros one
checksum slot per actual Operation::run invocation before the timer. A scalar
case executes batch invocations. A grouped case declares
operations_per_run(), and executes batch / group_len invocations. Zero or
non-dividing groups reject; a batch verifier never accidentally performs
batch * batch logical work. Replies report logical batch, group length,
invocation count and every checksum. The kernel black-boxes the opaque operation,
iteration and returned checksum; case adapters must black-box their complete
inputs and outputs and retain the evidence their check uses.
The body Counter 0 interval includes the driver loop, dynamic dispatch, case
work, checksum-slot writes, the ending probe, and any page faults between probes.
It excludes fixture construction, the driver's checksum-vector allocation and
zeroing, post-kernel check, reply serialization and cleanup. Allocation or
context construction deliberately performed by a case's run remains inside
the interval. check runs after the ending counter; its verification coverage
belongs to the individual case. The driver retains all returned checksums, not
500 copies of a large ciphertext. Published vectors, differential tests and the
case's retained last/full output checks provide complementary evidence; a
checksum transcript alone is not an independent cryptographic oracle.
Samples reuse the staged operation. A case that retains owned outputs for its
post-clock check may drop and wipe the previous output cohort during samples
2/3. That retirement belongs to those measured calls; it is not a prepared-key
cache. For such cases, report the first sample and the steady-state median
separately. fresh-message describes message-local warming, not empty output
storage. The ML-KEM tables record this distinction explicitly.
fresh-message means no explicit same-message warmup. Borrowing metadata or
allocating scratch can touch a 64 KiB region also containing inputs, so this is
not a guarantee of cold input pages. same-message-warm runs and checks a full
batch before the measured batch; its warmup instructions are a separately
reported subset of the prelude, and the actual endpoint total includes both.
Both modes use staged contexts unless a named case constructs one in
run. Fresh ECDSA and BIP340 rows stage only raw bytes and parse keys during
run; prepared-key rows are separate diagnostics. Iterations advance monotonically, including warmup, so adapters can
derive fresh nonces without reusing an identity on repeated messages.
The X25519/DHKEM/HPKE fresh-call.scalar-cohort and
fresh-call.batch-experimental pairs execute exactly batch independent
operations in one grouped invocation. Raw inputs and scalar reference answers
are staged; raw-secret import, public derivation, ephemeral IKM derivation,
public-info preparation, context construction and temporary batch allocations
all execute inside run as applicable. Public info is prepared once within
each call. Distinct inputs select distinct local keys and peer keys; independent
sender IKM remains distinct even with a common recipient. The separate
epoch-key-in-call receiver pair explicitly derives one common recipient key
within the call. It is a separate population from the primary distinct-key
cohort. Batch scratch is cleared and freed before the timed invocation ends.
Seal cases have no rejection mode; open cases check a changed tag for each
invalid record. Every context, encapsulation, shared secret, ciphertext/tag,
rejection wipe and sequence outcome is checked after timing as applicable.
Every primary row retains an actual whole-endpoint execution trace, separate setup/prelude/body/check counters, loop-control reply and out-of-window memory views. Whole-message instructions include the generated Wire wrappers, root entry, warmup, checks, reply, cleanup and actual page fees. They are authoritative for the instruction limit. The no-op and loop controls are separate rows; neither they nor page fees are subtracted from reported instructions.
--profiles N captures up to N bounded diagnostic pairs per selected case,
restricted to at most 100 logical operations and 2048-byte messages. The default
is one pair per case; --profiles 0 disables them and --profile-cases ID,ID
restricts them. Each unprofiled/profiled companion uses a freshly staged fixture
with identical inputs and iteration range. Their outputs must match. Observer
instruction differences remain diagnostics. Complete ledgers distinguish
metered Wasm, API fees, heap/stable page fees and other charges, with separate
origin-map and stack completeness. Missing source detail cannot erase a charge.
Installation sends gzip bytes and records their exact hash in
installation.json. Management module_hash identifies those submitted bytes
on this server. Profile module hashes identify the uncompressed canonical Wasm;
the runner keeps these identities separate rather than confusing transport
compression with a code change.
With canonical debug artifacts, source resolution runs automatically using
llvm-symbolizer on PATH and cdk-rsx-wasm from the configured SDK build
environment or PATH. --symbolize PATH selects the LLVM binary.
--symbolize none disables resolution. Missing sidecars or tools are recorded
as unavailable, while the complete charge ledger remains usable. For a trace
from a different machine, follow the profiling guide
to build a trusted local tool and resolve the trace.
python3 cdk-rsx/tools/wasm-symbolize.py \
--wasm-tool "$CARGO_TARGET_DIR/$ICRUSTMEM_HOST_TARGET/release/cdk-rsx-wasm" \
--artifact /absolute/crypto-bench.manifest.json \
--trace /absolute/trace.json.gz --output /absolute/source-profile.json
The output contains plan.json, immutable-artifact and host receipts,
rows.jsonl, complete results.json, profiles.json, raw compressed traces,
source reports when available, exact cycle snapshots and server/catalog receipts.
Setup rejections, traps, limit failures and failed checks remain explicit rows.
An incomplete trace stops the run and preserves its bytes. PARTIAL results
exit nonzero; they cannot qualify the unmeasured matrix cells. See
measurement notes for binary identity and charging
geometry; TODO records qualification status.
The primary ECDSA workload receives 100 public keys, signatures and hints in the same update, including validation and temporary preparation. It must not rely on a validated key cache populated by an earlier call. Run the uncached incoming-key benchmark. See the fresh-signer contract.
The staged inverse-hint cases do not charge for a client-supplied hint in their
compact run(fixture_id, mode) request. The prepared-key ingress diagnostic
verifies 100 signatures in one actual update:
node benches/crypto/live-bulk.mjs \
--artifact "$PWD/playground/crypto-artifact-001" \
--out "$PWD/playground/crypto-live-bulk-001" \
--pocket-ic /home/devbox/.local/bin/pocket-ic \
--batches 100,1 --samples 1 --profiles 1 \
--profile-populations same-tuple \
--symbolize /run/current-system/sw/bin/llvm-symbolizer
live_prepare_ecdsa_keys validates and prepares a plan of 1..500 public keys in
a separate update, returning its generation. The next request supplies all
records with key index, digest, compact signature and optional inverse. A live
plan cannot be replaced until clear; stale generations reject. Requests are
bounded to 128 KiB, 4 MiB conservative allocation admission, 268,016 visitor
nodes and depth 16. Native Wire roundtrip tests cover 500 maximum-width records
and 500 SEC1 keys. The native encoder charges four traversal nodes per visited
value; 500 fully hinted records need 4 * (500 * 134 + 4) nodes. Byte, allocation
and depth allowances are independent. Outputs contain every record's verdict/error and the exact
logical operation count.
The runner constructs three explicit populations: 100 exact copies of the same key/message/signature/hint; one prepared key with 100 distinct messages and signatures; and 100 prepared keys with distinct signatures. Node's built-in OpenSSL ECDSA signs the synthetic messages independently of the Rust algorithm, normalizes low S, and independently verifies each normalized signature. BigInt computes every inverse. There is no copied-small-cohort substitute for distinct records. OpenSSL chooses random signing nonces, so the exact generated corpus and its hash are archived before the server starts; known synthetic key material is used only for these tests.
Every item is parsed and checked on every verification, including exact repeated tuples. A bad hint or false equation does not skip later items. Normal and hinted 100-record requests differ by exactly 3200 bytes (9903 versus 13103 bytes for the common one-byte generation/index carrier). Actual whole-message traces include the Wire decoding, extra bytes, host copies, memory fees and all record checks. The body interval includes the verification loop, result/error writes and probes; input decoding and result-vector allocation occur outside that interval but remain in the complete endpoint total.
Default bulk captures include valid, expensive changed-digest invalid, mixed and
wrong-hint populations, plus both ordinary/hinted payload loop controls. Every
record's expected verdict is checked. The same-tuple population gets bounded
matched normal/hinted/control profiles for N100 and its N1 diagnostic companion;
select other populations explicitly with --profile-populations. No page or
control subtraction is applied to reported totals. Per-signature values divide
the observed whole call by its actual verified record count.
The singular live-ingress fixture remains available for independent-corpus boundary diagnostics:
node benches/crypto/live-hint.mjs \
--artifact "$PWD/playground/crypto-artifact-001" \
--out "$PWD/playground/crypto-live-hint-001" \
--pocket-ic /home/devbox/.local/bin/pocket-ic \
--count 32 --samples 1 --profiles 1 \
--symbolize /run/current-system/sw/bin/llvm-symbolizer
The runner selects at least 32 distinct valid low-S equations from the pinned
independent Python-oracle ECDSA corpus. JavaScript BigInt computes the public
s^-1 mod n on the client; its time and exact bytes are reported separately.
Each public key is validated and its native affine table prepared in a separate
measured call. A bounded transient cache holds one key, refuses replacement
until clear, and is never a signature or successful-verification cache.
Both verification requests carry the actual key ID, digest and compact signature.
The same endpoint takes None for ordinary native verification or Some(w) for
the checked hint path. Their Wire payloads differ by exactly 32 bytes. The
request bound is 512 bytes; complete endpoint traces include decoding those
additional bytes, their host-copy/page effects and all normal verification
checks. The hinted path validates canonical scalar encoding and s * w == 1;
it trusts no client hint. The runner checks ordinary and hinted successes,
wrong-hint rejection and changed-digest failures for every vector, preserving
the exact request bytes, byte counts, cycle debits and instruction totals.
Normal/hint order alternates to avoid making one mode always follow the other.
live-hint.mjs measures one signature per physical update, with no same-message
cohort throughput claim. Public-key preparation is separate; signature parsing,
scalar checks and verification happen on every actual verification request.
The body Counter 0 starts after Wire decoding; the complete endpoint total is
the fair ingress comparison. Optional matched profiles compare identical actual
requests and retain complete ledgers/source locations. This runner removes only
its own verified executable copy after the owned server has stopped.
Actual incoming authenticated decryption
fresh_open_symmetric and fresh_open_symmetric_packed receive every key,
nonce, AAD, ciphertext and tag in the measured update. They own no root memory,
preparation endpoint or cross-call secret cache. Both admit 1..500 records under
an actual 2 MiB encoded Wire cap. These are new, explicit benchmark routes; no
existing saved-request or participant contract changes. The existing
wire::bytes::ByteBuf adapter keeps Postcard byte-buffer encoding and avoids
per-byte Serde visitor work. Native tests prove the byte representation matches
ordinary Vec<u8>; the public descriptors correctly identify byte fields.
No SDK or Wire protocol changes are required.
The record carrier owns four byte buffers per record. The packed carrier owns five byte arenas plus body/AAD length vectors; its body arena becomes the reply plaintext arena directly. Every size and length sum is checked before crypto. The scalar backends construct one fresh context per incoming key inside the body timer: one shared context for 100 distinct records under one key, or 100 contexts for 100 separately supplied keys. All contexts drop and decoded key bytes are erased before the ending probe. The reply exposes endpoint context construction/drop counts separately from cohort calls, logical key inputs, workspace allocation/bytes and uniform four-record-group eligibility. These counters do not claim to instrument every internal backend temporary.
inplace opens decoded ciphertext storage directly. The explicit record-copy
and shared-scratch diagnostics perform matching copies and return the same
complete bodies. Their allocation/copy/erasure/drop work stays inside the body
counter. Wire argument decoding and reply serialization remain in the complete
endpoint trace, including all actual payload bytes and page charges. No copy,
control or page costs are subtracted.
The request node bounds are 10,036 for records and 4,056 for packed 500-record
cohorts. Native encoding charges four nodes per visited value: the records
argument tuple visits 9+5*N values; packed visits 14+2*N. Byte buffers each
visit once. The decoder charges eight times every visited value's size and
byte-buffer length. With a checked 256-byte maximum DTO/value size, the declared
allocation allowance is 2MiB +8*(2MiB +nodes*256), covering even malformed
node-limited inputs before application admission. Depth is 16. Tests roundtrip
500 actual 2048-byte ciphertexts, maximal-width keys/nonces and 33-byte AAD;
one-node-short encoding budgets reject. The allocation allowance is decoder
admission accounting, not a claim about live or peak process memory.
Run an initial actual-ingress comparison using a freshly built artifact:
node benches/crypto/symmetric-wire.mjs \
--artifact /absolute/new-artifact --out /absolute/new-results \
--pocket-ic /absolute/pocket-ic \
--algorithms chachapoly --sizes 32,128,256,512,2048 --batches 100 \
--backends reference,optimized,cohort,cohort-poly2 \
--layouts records,packed --buffers inplace --samples 1 --profiles 1
Use --help for all options, including the seven algorithms and diagnostic
buffer modes. Primary populations are distinct-keys and one-key, each with
100 distinct plaintexts/nonces and fixed 32-byte AAD containing record-specific
bytes. Uniform body/AAD lengths permit the cohort SIMD path; the report counts
eligible groups explicitly. Native correctness tests also cover ragged AAD and
cohort fallback. Native SIMD-named execution does not qualify installed Wasm.
The host uses OpenSSL ChaCha20-Poly1305/AES-GCM, HChaCha plus OpenSSL for
XChaCha, public BigInt POLYVAL plus OpenSSL AES for RFC 8452 GCM-SIV, and a
CC0-derived final Ascon BigInt reference checked against all 100 retained official
AEAD KATs. The exact public corpus, every primary request and every response's .wire bytes are archived. Binary reply fields also retain compact Base64 in JSON. Valid/invalid/mixed tag populations check every returned status and
every plaintext/wiped byte. symmetric-wire-codec.fixture.json contains the
native method descriptors and their reachable types for host tests. Live runs
load the full canonical artifact interface. The native and host correctness
tests run without a server.
Live bidirectional interoperability
The interop matrix sends fresh laboratory keys and reference signatures into the compiled canister, then checks actual canister-produced keys/signatures against Noble/OpenSSL. It covers Schnorr, ECDSA, Ed25519 and mixed-party X25519, including the optimized hinted/SIMD paths and invalid inputs. Reuse its saved random corpus for matched builds. These signing/DH fixture calls include reference-check and output-construction work; their instruction totals are not isolated primitive benchmark costs.
For 100 different one-signature calls, use the fixed-corpus runner below. It records a preliminary noop update separately, then verifies one fresh P/R-hinted signature in each measured update. It reports actual mean/min/max whole instructions; it never divides a bulk call to claim an unbatched cost. The retained corpus is deliberately pinned for this comparison.
mkdir -p crypto/tmp
gzip -dc crypto/research/experiments/2026-10-26-crypto-r11/evidence/single/corpus.json.gz > crypto/tmp/schnorr-corpus.json
node benches/crypto/schnorr-single-calls.mjs \
--artifact /absolute/new-artifact --out /absolute/new-results \
--pocket-ic /absolute/pocket-ic --corpus crypto/tmp/schnorr-corpus.json
Independent Schnorr backend 0 uses the same incoming schema for scalar and
SIMD routes. P/R-hinted cohorts select scalar below four rows, a four-record
workspace for 4–15 and dense 16-record chunks from 16. Every row retains its
exact verdict; aggregate_attempts stays zero and individual_checks equals
the input count. workspace_bytes includes explicitly borrowed independent
scratch (plus aggregate backing when used by aggregate failure handling),
excluding input/descriptor/output buffers, compiler frames and allocator state.
Controls, N1 and P-only paths report zero independent scratch. The
R13 report separates
read-only generator-table admissions from writable stack pages.