omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / om / sha256 / README.md
| 1 | # om/sha256: SHA-256 in Omega (OM-2), linked into the product |
| 2 | |
| 3 | The SHA-256 API of `src/sha256.h` (`sha256_ctx`, `sha256_init/update/final/hash`) is the OM-2 unit |
| 4 | `sha256-om2.om`, compiled by the seed-born `omc` and called in-process through the omega-bridge |
| 5 | native call ABI v2 (`docs/NATIVE-ABI.md`, aien-dev/omega-bridge feat/slice-abi a8959fb1). No C computes or |
| 6 | adapts it: `src/sha256.c` and the OM-1 unit with its 4096-byte adapter are gone (#747). The 894 |
| 7 | call sites are unchanged (`om2-evidence/AUDIT-L838.txt`). |
| 8 | |
| 9 | | file | role | |
| 10 | |---|---| |
| 11 | | `om/sha256/sha256-om2.om` | the implementation: `export fn sha256_init/update/final/hash`; `layout shactx 104`, `fresh` schedule scratch, `for ... unroll` rounds and schedule, `rotr`, hex K/IV from the L836 fixtures, unsized `view uchar *` input, `out uchar 32` digest | |
| 12 | | `src/omega_om_units.c` | generated: the unit's machine code byte for byte as omc wrote it, its ABI v2 binding (`omega2_sha256_*`, `omega2_ident_sha256_om2`), the BLAKE3 unit's v1 binding, and the C API `sha256_init/update/final/hash`, each calling `omega2_sha256_*` and `abort()` on a nonzero status | |
| 13 | | `src/omega_om_units_fs.c` | generated: the same unit's freestanding binding for the `-ffreestanding` GPU link (`mk/omega-gpu-engine.mk`): the bridge's output `freest` (ABI v2 on the caller's stack; no thread-local state, heap, stack mapping or `abort`; only `memset` and `memmove`) then output `fapic` (the same C API, `__builtin_trap()` on a nonzero status). `make test-sha256-freestanding-parity` compares its digests with the hosted binding's | |
| 14 | | `src/omega_native.h`, `src/omega_api_decl.h` | generated: declarations only; `sha256_ctx` from the layout (offsets static-asserted), `SHA256_*` defines, the `sha256_*` prototypes. Including them references no C library function, so a freestanding caller (rx_cortex, and `omega_om_units_fs.c`) still needs only `sha256_*` | |
| 15 | | `src/omega_om_units.ident` | generated: each unit's source sha256, compiler pin, ABI and profile | |
| 16 | | `src/sha256.h` | includes `omega_api_decl.h`; no logic | |
| 17 | | `om/units.sh` | regenerates the five generated files; `--check` proves they are what the pinned tools produce (a stale unit, compiler or profile fails) | |
| 18 | | `om/sha256/parity/` | parity against the replaced C retrieved from git history (`run.sh`), section 7 receipts (`receipts.c`), throughput probes (`bench.c`, `small.c`) | |
| 19 | | `om/sha256/om2-evidence/` | caller audit, compile log per compiler slice, baseline at acb3f15c, cutover plan, desk check, S4 run | |
| 20 | |
| 21 | Pins: omc `26540e6de62402d5784b30b24d7c6faae488137c1f8a4b3e784fd0b5d5528991` |
| 22 | (rebuilt by `seed/omega-from-seed.sh`; `om/units.sh` `OMC_PIN`); |
| 23 | generator `src/native.om` of omega-bridge `962924233146f349da8486c7bce726f67b4dac4c` |
| 24 | (omega-bridge#45 merged; `om/omega-bridge.lock`; sha256 `2c1bf63798336e899704217d98f909b31e567289650751a55d83255c7eb8f27d`), |
| 25 | whose outputs `freest` and `fapic` generate `src/omega_om_units_fs.c`. |
| 26 | |
| 27 | ## Behaviour (spec/omegese-om2.md section 7, errata E3) |
| 28 | |
| 29 | - Updates of any length, including 0 (any pointer) and at least 2^32 bytes; any split points. |
| 30 | - `sha256_hash` may write its digest over its input: the digest is copied out after the call. |
| 31 | - A byte copy of a live context is an equivalent context. |
| 32 | - After `sha256_final` the context's contents are unspecified (this unit leaves it unchanged); |
| 33 | `sha256_init` makes it fresh again. No whole-context equality with the old C is claimed. |
| 34 | - A nonzero bridge status (a NULL pointer with a nonzero length, a context overlapping the data, |
| 35 | a trap) aborts the process, as the old adapter did. |
| 36 | - Rolled loops trap after 1,000,000 passes, so whole blocks are hashed in runs of 2^25 bytes. |
| 37 | |
| 38 | ## Evidence |
| 39 | |
| 40 | Qualified by L836 (om2/qualification 478bdecd, candidates/sha/RESULTS.txt): 158 vectors, E3/section 7 |
| 41 | receipts, 17/17 unit mutants killed, dynamic traces 28/28 identical. The static leakage scan of |
| 42 | update/final is NOT_RUN; no constant-time claim is made. Throughput against the replaced C is in the |
| 43 | cutover PR, measured with `parity/bench.c` and `parity/small.c`. |
| 44 | |
| 45 | ## Building the generated binding |
| 46 | |
| 47 | `src/omega_om_units.c` embeds each unit's machine code exactly as the pinned compiler wrote it, and its |
| 48 | runtime entry table is declared with GNU range designators, which ISO C forbids. Every suite that compiles |
| 49 | it with `-pedantic` and `-Werror` therefore appends `-Wno-pedantic` to its flags: only that one diagnostic |
| 50 | is waived, and the handwritten sources in the same commands are pedantic-clean today, so the rest of the |
| 51 | strict set still applies to every file they compile. The waived suites are ANS, estimation and Brownian |
| 52 | active (`mk/ans.mk`, `mk/estimation.mk`, `mk/brownian_active.mk`); the physics baseline, verifier, planner |
| 53 | and both learner builds (`mk/physics0.mk`, `mk/physics0-verify.mk`, `mk/physics0-planner.mk`, |
| 54 | `mk/physics0-learner.mk`, `mk/physics0-learner-v2.mk`); and the TURING family, where `TURING_CFLAGS` in |
| 55 | the Makefile covers `test_turing`, `turing-field` and the mixed-algebra gate binary, and |
| 56 | `mk/turing_exp001_a.mk`, `mk/turing_exp001_b.mk`, `mk/turing_exp001_c.mk`, `mk/turing_exp001_eval.mk`, |
| 57 | `mk/turing_qrecord.mk`, `mk/turing_yield_energy.mk` and `mk/turing_yield_math.mk` carry the same waiver |
| 58 | for their own builds. The generator fix is omega-bridge #17 on the ABI-v2 line; when it lands, regenerate |
| 59 | the binding with it and drop those flags. |