Portable crypto function costs — round 3
The selected GC backend uses eight-lane SIMD AES with paired garbling and scratch reuse. The separate ChaCha profiles use direct output writers and a batch API for independent 32-byte secrets. Both final AES64 control and selected SIMD images pass all 88 populations; their existing outputs match the frozen earlier contracts.
All costs below are measured IC instructions from prepared Wasm64 on pinned PocketIC normal13: two fresh samples per body and separate empty harness. Counter 0 body, whole checked update and page fees are separate columns; page fees are already part of whole updates. No harness subtraction or N=1 projection is used. Values are rounded to 0.1; exact totals and sample transcripts remain in JSON.
Current selected function costs:
| Function/profile | Actual invocations | Per | Raw body | Whole update | Page fees |
|---|---|---|---|---|---|
| GC xor | 1,000 | operation/query | 154.3 | 1,552.6 | 400.0 |
| GC gf-double | 1,000 | operation/query | 174.3 | 1,571.0 | 400.0 |
| GC aes-setup | 1,000 | operation/query | 7.1 | 6,622.4 | 400.0 |
| GC aes-block | 1,000 | operation/query | 5,347.3 | 6,745.8 | 480.0 |
| GC gate-hash | 1,000 | operation/query | 5,922.3 | 7,319.3 | 480.0 |
| GC and-garble | 1,000 | operation/query | 9,391.3 | 39,472.6 | 720.0 |
| GC and-evaluate | 1,000 | operation/query | 6,951.1 | 8,349.8 | 560.0 |
| GC prg-init | 1,000 | operation/query | 8,339.3 | 11,846.6 | 720.0 |
| GC prg-session-init | 1,000 | operation/query | 6,470.3 | 10,160.6 | 560.0 |
| GC prg-session-stream | 1,000 | operation/query | 1,491.3 | 4,998.6 | 720.0 |
| GC prg-secret32 | 1,000 | operation/query | 2,419.3 | 4,184.6 | 560.0 |
| GC eq8-garble-gate-only | 1,000 | operation/query | 67,154.3 | 109,106.9 | 2,720.0 |
| GC eq8-evaluate-gate-only | 1,000 | operation/query | 36,389.2 | 42,922.4 | 2,960.0 |
| Generic aes32-block | 1,000 | real AES block | 7,060.4 | 11,335.9 | 720.0 |
| Generic aes32-pair | 1,000 | real AES block | 3,654.7 | 5,987.0 | 320.0 |
| Generic aes32-four | 1,000 | real AES block | 3,586.1 | 5,071.3 | 160.0 |
| game-prg-chacha8-v1.secret32 | 1,000 | operation/query | 1,480.4 | 4,082.1 | 560.0 |
| game-prg-chacha12-v1.secret32 | 1,000 | operation/query | 1,764.4 | 4,365.8 | 560.0 |
| control-prg-chacha20-v1.secret32 | 1,000 | operation/query | 2,308.4 | 4,909.6 | 560.0 |
| GC BLAKE3 fill 65,536 B | 1 | actual fill | 986,641.0 | 3,939,147.0 | 560,000.0 |
| GC BLAKE3 fill 1,048,576 B | 1 | actual fill | 15,774,481.0 | 58,019,756.0 | 4,160,000.0 |
| game-prg-chacha8-v1 fill 65,536 B | 1 | actual fill | 608,190.0 | 3,560,381.0 | 560,000.0 |
| game-prg-chacha8-v1 fill 1,048,576 B | 1 | actual fill | 9,716,670.0 | 51,961,736.0 | 4,160,000.0 |
| game-prg-chacha12-v1 fill 65,536 B | 1 | actual fill | 819,134.0 | 3,771,325.0 | 560,000.0 |
| game-prg-chacha12-v1 fill 1,048,576 B | 1 | actual fill | 13,091,774.0 | 55,336,946.0 | 4,160,000.0 |
| control-prg-chacha20-v1 fill 65,536 B | 1 | actual fill | 1,241,022.0 | 4,193,213.0 | 560,000.0 |
| control-prg-chacha20-v1 fill 1,048,576 B | 1 | actual fill | 19,841,982.0 | 62,087,154.0 | 4,160,000.0 |
Generic AES32 remains the general-key fixslice32 reference: widths 1/2/4 mean 1000/2000/4000 real blocks. The single-block wrapper uses one zero dummy lane. The old GC-wide AES32 selection is not retained as a candidate. Selected aes-setup is construction/retention of a zero-sized fixed-public-zero-key owner using an immutable schedule; it is not general secret-key expansion. Cached encrypt/hash/gate rows exclude setup.
The batch API performs one actual call that writes N independent secrets; the stream fixture constructs, fills and retires N streams. Every returned secret equals stream(first_query + i, purpose).fill(32) for the same named profile. Costs per secret use each measured population:
| Profile | Actual N | Stream body/secret | Batch body/secret | Stream whole/secret | Batch whole/secret | Batch page fees/secret |
|---|---|---|---|---|---|---|
| game-prg-chacha8-v1 | 1 | 1,703.0 | 2,420.0 | 335,070.0 | 336,001.0 | 320,000.0 |
| game-prg-chacha8-v1 | 100 | 1,323.8 | 485.6 | 6,860.1 | 6,022.7 | 3,200.0 |
| game-prg-chacha8-v1 | 1000 | 1,480.4 | 640.3 | 4,082.1 | 3,243.0 | 560.0 |
| game-prg-chacha12-v1 | 1 | 1,987.0 | 3,242.0 | 335,460.0 | 336,929.0 | 320,000.0 |
| game-prg-chacha12-v1 | 100 | 1,607.8 | 691.6 | 7,139.4 | 6,223.9 | 3,200.0 |
| game-prg-chacha12-v1 | 1000 | 1,764.4 | 846.3 | 4,365.8 | 3,448.8 | 560.0 |
| control-prg-chacha20-v1 | 1 | 2,531.0 | 4,892.0 | 335,898.0 | 338,473.0 | 320,000.0 |
| control-prg-chacha20-v1 | 100 | 2,151.8 | 1,103.6 | 7,682.2 | 6,634.7 | 3,200.0 |
| control-prg-chacha20-v1 | 1000 | 2,308.4 | 1,258.3 | 4,909.6 | 3,860.5 | 560.0 |
At N=1 the batch body is more expensive than the ordinary stream for every profile; the N=100 and N=1000 rows show the measured amortization. These populations are reported individually, without assuming linear scaling.
Round 2 → final selected, at N=1000 per operation/query:
| GC operation | Body | Whole checked update | Body reduction |
|---|---|---|---|
| gf-double | 174.3 → 174.3 | 1,571.0 → 1,571.0 | 0.00% |
| aes-block | 7,716.3 → 5,347.3 | 9,114.8 → 6,745.8 | 30.70% |
| gate-hash | 8,352.3 → 5,922.3 | 9,749.3 → 7,319.3 | 29.09% |
| and-garble | 10,623.3 → 9,391.3 | 50,560.6 → 39,472.6 | 11.60% |
| and-evaluate | 9,334.3 → 6,951.1 | 10,733.1 → 8,349.8 | 25.53% |
| eq8-garble-gate-only | 99,160.3 → 67,154.3 | 171,939.0 → 109,106.9 | 32.28% |
| eq8-evaluate-gate-only | 67,135.3 → 36,389.2 | 73,668.5 → 42,922.4 | 45.80% |
| prg-secret32 | 2,419.3 → 2,419.3 | 4,184.6 → 4,184.6 | 0.00% |
Checkpoint bodies at N=1000 (per operation/query):
| GC operation | Round 2 | Combined79 | AES screen79 | Final control88 | Final selected88 |
|---|---|---|---|---|---|
| gate-hash | 8,352.3 | 8,352.3 | 6,484.3 | 8,352.3 | 5,922.3 |
| and-garble | 10,623.3 | 10,472.3 | 9,924.3 | 10,272.3 | 9,391.3 |
| and-evaluate | 9,334.3 | 9,224.1 | 7,529.1 | 9,224.1 | 6,951.1 |
| eq8-garble-gate-only | 99,160.3 | 95,100.3 | 69,373.3 | 93,700.3 | 67,154.3 |
| eq8-evaluate-gate-only | 67,135.3 | 41,538.1 | 38,566.2 | 41,545.1 | 36,389.2 |
The final control uses AES64 and the selected image enables SIMD AES with matching fixture contracts. Their comparison includes the compiled feature/kernel and layout differences recorded in their exact source archives. Earlier combined/AES screen images are complete historical artifacts with different compiled layouts. Their changes are not an isolated instruction estimate for scratch reuse or any single patch. The combined checkpoint and AES screening checkpoint retain their narrower proof scopes.
The nine matched SIMD PRG comparisons preserve each profile's bytes and use actual measured populations:
| Profile/population | Round 2 SIMD → final body | Round 2 SIMD → final whole |
|---|---|---|
| game-prg-chacha8-v1 N1000 secret32 | 2,042.4 → 1,480.4 | 4,644.0 → 4,082.1 |
| game-prg-chacha8-v1 64 KiB fill | 683,790.0 → 608,190.0 | 3,635,936.0 → 3,560,381.0 |
| game-prg-chacha8-v1 1 MiB fill | 10,932,750.0 → 9,716,670.0 | 53,177,771.0 → 51,961,736.0 |
| game-prg-chacha12-v1 N1000 secret32 | 2,316.4 → 1,764.4 | 4,917.9 → 4,365.8 |
| game-prg-chacha12-v1 64 KiB fill | 894,734.0 → 819,134.0 | 3,846,880.0 → 3,771,325.0 |
| game-prg-chacha12-v1 1 MiB fill | 14,307,854.0 → 13,091,774.0 | 56,552,981.0 → 55,336,946.0 |
| control-prg-chacha20-v1 N1000 secret32 | 2,862.4 → 2,308.4 | 5,463.5 → 4,909.6 |
| control-prg-chacha20-v1 64 KiB fill | 1,316,622.0 → 1,241,022.0 | 4,268,768.0 → 4,193,213.0 |
| control-prg-chacha20-v1 1 MiB fill | 21,058,062.0 → 19,841,982.0 | 63,303,189.0 → 62,087,154.0 |
The later compile-known constant-round AES candidate passed the same 88 populations but was rejected: equality garbling whole cost rose by 56 instructions/query and its prepared module grew by 34,316 bytes, without a clear whole-GC benefit. The final source was restored to the qualified image above. Its separate screening evidence remains archived.
Current short-secret fixtures use 2,419.3 body / 4,184.6 whole for BLAKE3 versus 1,480.4 body / 4,082.1 whole for stream-based ChaCha8. Cross-profile fixtures have different output layouts and post-checks. Compare both columns; a faster kernel alone does not establish an end-to-end protocol win. Session preparation is outside the secret bodies. Stream secret32 includes construction, overwrite and retirement per query; batch secret32 includes the complete one-call batch operation and helper retirement. Bulk-fill streams are staged.
The GC suite remains c93cec6c2f3fd4e73d9928f5a2634786706b6691feddc055e990e1a6e00f0daf: identical BLAKE3 randomness domains, gate identities, 272-byte garbling draw, 128-byte Alice labels, 224-byte tables and 16-byte return label. The three named ChaCha profiles have null GC suite IDs and separate BLAKE3 key contexts; SIMD/direct writers/batching preserve each profile's bytes, not GC-suite compatibility. ChaCha8/12 remain explicitly experimental reduced-round choices.
| Standalone profile | Session-key derivation context |
|---|---|
| game-prg-chacha8-v1 | p2p-gc-bench/game-prg/chacha8/v1/session-key |
| game-prg-chacha12-v1 | p2p-gc-bench/game-prg/chacha12/v1/session-key |
| control-prg-chacha20-v1 | p2p-gc-bench/game-prg/chacha20-control/v1/session-key |
Session keys derive from the benchmark seed and session once; query streams use LE64(query) || purpose || [0;3] as their IETF nonce. Inputs are deterministic public benchmark fixtures staged outside the body. They are not a source of production entropy.
Qualification and accounting:
- Final control and selected each pass 88 bodies and 88 separate harness populations, with two fresh samples each. Existing 79-population output transcripts match the archived contracts; all nine new batch populations match their stream counterparts.
- The shared native reference checks 65,536 equality pairs. Each installed final image passes 1024 actual-Wasm equality pairs, 64 BLAKE3 byte cases, 50 game-PRG cases, 32 AES cases and 51 batch cases. Probes cover domains, overwrite/canaries, chunking, positions, final counter blocks and atomic range rejection. The selected and separate instrumented images additionally execute 32 × 8 = 256 general-key SIMD AES lanes per probe invocation, covering constructor plus
encrypt_eight; this does not qualify every generic typed SIMD API. Control AES32 and historical screen probes have their own scopes. - Separate instrumented Wasm confirms 28 Alice / 14 Bob hashes per equality (28,672 / 14,336 across 1024 pairs). Its costs are excluded from primary rows. Native oracle checks are correctness evidence, not IC performance.
- Counter 0 includes typed loops, black boxes, output writes and helper retirement. Retained-owner checksums, verification, reply/wrapper work and cleanup remain in the authoritative whole update. Alice garbling's whole update also evaluates its output after timing; it is not pure Alice protocol cost. Empty harnesses and complete attempt/page ledgers remain archived separately.
- Wall-time median/p95 and peak live heap remain null. Two traced samples and host actor durations do not qualify runtime wall-clock statistics. Memory pages are capacities, not peak live allocations. Network bytes, framing and rounds remain null for local function fixtures.
- Wasm64 IC OT integration remains blocked. All 52 base/chosen/cold/warm/preprocessed/full-protocol rows remain BLOCKED with null costs. No local label selection, portable OT reference meter, or linear projection substitutes for a complete private protocol.
Frozen artifacts and reproducibility:
| Image | Prepared Wasm SHA256 | Actual features |
|---|---|---|
| Final control | ccf053c29beadd91d341ee9a15d17b1387352c26afed07ddcf4412a8bfc486da |
batched-aes, game-prg-simd, prg-simd, prg-xof4 |
| Final selected | 29900073999eb19402eaa09cc6f78ca89afdf3ad210f42c8ad7a1968036a9722 |
aes-simd, game-prg-simd, prg-simd, prg-xof4 |
The parent source commit is 4561b26e4e726c8871b2001dda61e5cebc669665; exact canonical archived inputs, not that commit alone or live files, identify the compiled candidate. The SDK pin remains d0e53afc7b7fdc4b7cf4e2ccbe1e55a386133c4b; the SDK, root runtime and allocator are unchanged. PocketIC normal13 executable SHA256 is 6a9a75ad9b4551d2b0f4a0d954ffb8bd5bbd0ebc44ac00290679b06ad0b2f8e6. Primary images have instrumentation disabled.
Permanent evidence: final control JSON, selected JSON, selected CSV, instrumented correctness, independent selected IC audit, final manifest/source receipts, round 2 GC baseline and round 2 SIMD baseline. Original immutable final runs remain at /srv/shared/code/newstack/playground/gc-20261031/round3-final-001; historical combined001 and AES002 remain at their original playground paths. Curated gzip copies are storage encodings; installation receipts retain submitted transport identities.
Regenerate after curation:
python3 crypto/bench/garbled-circuit/report_round3.py