SHA-256 SIMD qualification — 2026-10-26

The selected explicit four-message SHA-256 API reduces the complete N100 call by 29.13–51.86% at 32–2048 bytes. The same-message four-block scheduler helps longer inputs; a 64 KiB N1 call improves 15.32% despite an extra 80,000 page instructions. The ordinary sha256 and Sha256 defaults remain unchanged.

Production source is 9f37abc5; the benchmark-only adapter is 4ce03c0a. The final prepared Wasm is b1676095f70a1d44a45b8db3758410b2d2497b173081838e43015bfd2f1b44e0. Its current 10,432 captured source inputs still match. The machine-readable summary, qualification and evidence index pin the complete records.

Measured contract

The SHA rows are STAGED: setup generates and admits the input buffers in a separate update. Every timed update constructs fresh hash state and hashes the complete requested cohort once. Its group_len=N, iterations=1; N100 is 100 operations in one physical call. Three samples reuse the input/output storage, without a hash-state or result cache. Output slots are overwritten; all three reported counter tuples are identical.

Every complete 32-byte digest is retained and compared after timing with the independent pinned RustCrypto reference. Raw compression compares every complete resulting state. The host also reconstructs complete-message SHA-256 with Python hashlib and binds the returned checksum to the exact deterministic corpus. Checksums supplement the full in-canister comparisons. The staged endpoint returns checksum metadata, not every digest byte.

The whole endpoint includes Wire metadata decoding, runtime work, check/response costs and all page charges. Body is the unadjusted Counter 0 interval, including driver calls, checksum writes, state destruction and faults between probes. Page fees overlap whole/body and are never subtracted. Setup, noop and loop controls are separately retained.

Independent-message SIMD4

Values below are whole / body / heap-page instructions. Each scope has three separate identical physical-call samples. The arrays contain 100 different deterministic messages.

Bytes per message Scalar N100 SIMD4 N100 Whole saving
32 898,465 / 477,900 / 400,000 636,761 / 216,196 / 400,000 29.13%
128 1,924,869 / 1,504,300 / 400,000 1,036,740 / 616,171 / 400,000 46.14%
256 2,885,097 / 2,464,300 / 400,000 1,475,078 / 1,054,421 / 400,000 48.87%
512 4,884,919 / 4,464,300 / 480,000 2,431,470 / 2,010,921 / 480,000 50.22%
2048 16,805,079 / 16,304,300 / 880,000 8,090,700 / 7,589,921 / 880,000 51.86%

The API computes four ordinary independent SHA-256 digests per SIMD group. It preserves each message and its standard padding. Scalar tails handle cohorts not divisible by four. N3/4/5/8/32/128 diagnostics and N500 passed every full-output check. At N3 the scalar tail adds eight instructions; N4 already wins.

N1 bytes Scalar SIMD4 adapter scalar tail SMS4
32 419,561 / 5,175 / 400,000 419,569 / 5,183 / 400,000 419,579 / 5,193 / 400,000
128 429,825 / 15,439 / 400,000 429,833 / 15,447 / 400,000 509,678 / 95,222 / 480,000
256 439,389 / 25,039 / 400,000 439,397 / 25,047 / 400,000 515,498 / 101,148 / 480,000
512 458,589 / 44,239 / 400,000 458,597 / 44,247 / 400,000 531,146 / 116,796 / 480,000
2048 573,895 / 159,439 / 400,000 573,903 / 159,447 / 400,000 625,140 / 210,684 / 480,000

These N1 values are actual single-operation updates, not N100 divided by 100. The SIMD4 adapter uses the existing scalar primitive at N1 and adds eight body instructions.

Same-message block schedules

sha256_sms4 schedules four consecutive 64-byte blocks with SIMD and then applies their compression steps in their original chaining order. It remains standard single-message SHA-256. It does not hash a tree or treat consecutive blocks as independent digests.

Bytes Scalar N100 SMS4 N100 Whole saving
32 898,465 / 477,900 / 400,000 900,265 / 479,700 / 400,000 -0.20%
128 1,924,869 / 1,504,300 / 400,000 1,983,169 / 1,562,600 / 480,000 -3.03%
256 2,885,097 / 2,464,300 / 400,000 2,575,997 / 2,155,200 / 480,000 10.71%
512 4,884,919 / 4,464,300 / 480,000 4,220,619 / 3,800,000 / 560,000 13.60%
2048 16,805,079 / 16,304,300 / 880,000 14,009,579 / 13,508,800 / 960,000 16.63%

The actual 65,536-byte N1 comparison is scalar 5,415,529 / 5,001,039 / 480,000 versus SMS4 4,585,878 / 4,171,388 / 560,000, three identical calls each (15.32% whole saving). SMS4 loses the tested short N1 calls because its additional page admission exceeds the computation saved. This supports an explicit long-message API, not a default replacement.

Streaming SMS4 uses the parallel scheduler only when one update supplies complete four-block groups. With 256-byte update chunks:

Total bytes, N100 Scalar streaming SMS4 streaming Whole saving
256 2,958,697 / 2,537,900 / 400,000 2,552,297 / 2,131,500 / 400,000 13.74%
2048 17,063,479 / 16,562,700 / 880,000 14,065,679 / 13,564,900 / 880,000 17.57%

Certificate-shaped hashing

The exact input is one byte containing the domain length, the ASCII domain, then each child or payload. Forks have two 32-byte children; labeled nodes use the seven-byte rechain label and a 32-byte child; leaves contain 32 bytes. The streaming cases issue separate length/domain/child updates, matching ic-certification. Empty-node inputs are necessarily identical, even though the runner uses the distinct flag. The nominal setup size is 32; the actual hash input sizes below are authoritative for these shapes.

Shape Actual bytes Scalar one-shot N100 SIMD4 N100
empty 18 977,293 / 556,600 / 400,000 723,314 / 302,621 / 400,000
fork 81 1,457,087 / 1,036,500 / 400,000 943,408 / 522,821 / 400,000
labeled 59 1,461,693 / 1,041,000 / 400,000 898,289 / 477,596 / 400,000
leaf32 49 980,265 / 559,700 / 400,000 726,286 / 305,721 / 400,000
Shape Existing scalar streaming N100 SMS4 streaming N100
empty 1,051,893 / 631,200 / 400,000 1,030,793 / 610,100 / 400,000
fork 1,592,687 / 1,172,100 / 400,000 1,570,987 / 1,150,400 / 400,000
labeled 1,551,393 / 1,130,700 / 400,000 1,553,993 / 1,133,300 / 400,000
leaf32 1,071,365 / 650,800 / 400,000 1,071,520 / 650,700 / 400,000

SMS4 streaming is mixed on these short shapes: small empty/fork improvements, small labeled/leaf regressions. The existing generic streaming certificate kernel stays selected. SIMD4 is useful when four node hashes are independently ready; these N100 node fixtures do not establish that a dependent tree can be evaluated four nodes at a time.

Capacity and profiling

2048-byte messages, N500 Whole / body / pages Samples
sha256-scalar-cohort 81,966,087 / 81,439,900 / 2,400,000 1
sha256-simd4 38,394,008 / 37,867,821 / 2,400,000 1
sha256-sms4-cohort 67,668,587 / 67,142,400 / 2,480,000 1

Raw-compression controls at 64/256/2048 bytes also passed; their unpadded-state costs are kept separately in the JSON. They are not whole-hash measurements.

At 2048 bytes ×100, three matched reference/profile pairs have zero observer instruction delta, complete origin/page/charge ledgers and zero unexplained or adjusted instructions. Physical entry counts are scalar sha256_general=100, SIMD hash_aligned=25, and SMS4 compress256_sms4=800 (eight four-block groups per message). Full source coverage counts and functions remain in the profile audit. Source locations describe prepaid block-boundary attribution, not exact executed source-line costs.

Correctness and owned-buffer erasure

The hash package passes 43 native tests, including NIST known answers, independent Python/RustCrypto checks, all short padding tails, arbitrary raw states, ragged streaming, snapshots, reset, rejection atomicity and explicit guard wipes. Native SIMD execution is a scalar-lane model. The focused registry test separately passes at N8/N100 with the exact case IDs and logical work counts. This is targeted qualification, not a claim that a new full-workspace native run occurred.

Every successful case preparation runs an uncached actual-Wasm setup gate: three ragged length groups, multi-update streaming, snapshots, clone finalization, empty updates/reset, plus opaque raw compression unequal/incomplete rejection and zero-length no-op checks. All 79 traced preparations succeeded; six additional diagnostic profile preparations were checked by the host. Synthetic u64 overflow and maximum bit-length padding remain native-only.

The first artifact exposed an explicit library-owned 416-byte context move on the ragged wrapper path. Only the receiving copy was erased. That artifact is retained as public equal-length diagnostic evidence and was not promoted. The fix uses one private borrowed finalizer for the original context. In the selected artifact the wrapper frame is 480 bytes, has no bulk copy, and the same original 416-byte context is fully erased. Snapshots erase their one owned clone.

The independent selected emitted review checks 20 retained SHA bodies against the fixed artifact, resolving call/static metadata relocations. Packed contexts, byte tails, lengths and SMS4 state cleanup remain intact. SMS4 has 75 v128 locals and no Wasm linear frame or bulk copy. These are bounded explicit-owned-backing guarantees; they do not promise erasure of every SSA value, register or native JIT spill. Caller-owned inputs/outputs remain the caller’s responsibility.

The standalone direct-word whole-hash candidate was rejected: its initial N100 gains were small and inconsistent across sizes. Its public API and benchmark IDs were removed. Its source is retained only as research text; the useful direct padding helper remains private to SMS4. No legacy or compatibility implementation is exported.

Unchanged Schnorr controls

The exact R13 7ea corpus is sent in each complete P/R-hinted request, after a separate traced unmeasured noop. Every returned verdict/counter and every incoming request byte is audited. Three identical samples per scope match the R13 artifact:

| Scope | Whole / body / pages | | --- | ---: | ---: | | Backend0, N1 | 1,970,786 / 1,601,299 / 480,000 | | Backend0, N100 | 100,700,230 / 96,483,265 / 1,280,000 | | Backend6, N100 | 57,221,619 / 53,004,132 / 1,120,000 |

Backend0 retains one independent check per record and zero aggregate attempts; backend6 retains its existing aggregate prototype contract. N1 aggregate backend6 is an additional diagnostic only. No prior key/table/result preparation occurs. Default SHA source is unchanged, so no X25519 requalification was required by this API-only round.

Identity, accounting and reproducibility

The final selected scope comprises 183 timed SHA calls / 13,611 logical hash or compression operations, plus 12 timed Schnorr control calls / 606 logical records, six separate profile diagnostic calls, 83 loop/control calls, 79 traced setups and nine noop primers. All 372 selected traces reconcile and all nine selected owned servers exited cleanly. Earlier public/fixed evidence adds nine closed servers: the whole campaign has 398 timed calls, 784 complete traces and 18 closed servers, kept separate from selected scopes.

The SDK is unchanged at 33f54b62b46a6693ff6e193a752e052eaa124884. Canonical wasm64 +simd128 uses the same six features, pinned nightly and Clang21 (8758596b…). Static data ends at 2,041,913, leaving 55,239 bytes below the existing 2 MiB window. No SDK, allocator, compiler, instruction pricing or Wire protocol change is involved.

The PocketIC16.1 executable pin is 6a9a75ad9b4551d2b0f4a0d954ffb8bd5bbd0ebc44ac00290679b06ad0b2f8e6. The receipt/catalog JSON hash is bc0db6fd…; the underlying cost catalog ID is 593a25a7…. These are distinct identities. Every selected session uses the already verified readonly0555 frozen binary via the pinned hardlink helper. The installed ~/.local/bin/pocket-ic was replaced externally mid-campaign; its mismatch was rejected before any server started, and the failure was preserved. Later calls explicitly name the original verified frozen binary. No executable bytes or settings were changed.

Independent PIC jobs ran concurrently with other project benchmarks. Authoritative IC instructions and simulated IC accounting support this report; host wall times do not establish throughput improvements. Staged requests are reconstructed from the exact archived interface and retained metadata for the payload audit; their raw transport buffers were not retained. Schnorr requests were retained as exact Base64 bytes and compared byte-for-byte.

The standard is FIPS180-4. Layout references are Gueron/Krasnov, Simultaneous hashing of multiple messages and Parallelizing message schedules. The local unrolled rounds derive from the existing Apache-2.0 WITH LLVM-exception Motoko-derived scalar source; MOTOKO-LICENSE and MOTOKO-NOTICE are retained. No Intel implementation source or hardware SHA assumption is introduced.