interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / om / sha256 / parity / run.sh

31 lines · 2265 bytes Raw Blame History
1#!/bin/sh
2# Parity of the Omega SHA-256 (om/sha256/sha256-om2.om, generated into src/omega_om_units.c and called
3# through src/sha256.h -> src/omega_api_decl.h) against the C it replaced: src/sha256.c at a647b6a9 (sha256
4# a8fb88611e68ea5a876ee1658e1665994a03bfbed215983618d769f0e7205473), retrieved from git history with
5# its own header and compiled only here, as an oracle outside the delivered closure.
6# 2000 inputs (fixed boundary lengths, 0..299 bytes, up to 2 MiB) hashed one-shot and in random
7# update splits, every length 0..9000 one-shot and split, the FIPS 180-2 vectors (empty, abc, 448-bit,
8# one million 'a'), and the section 7 / erratum E3 receipts (receipts.c).
9set -eu
10ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
11T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
12ORACLE=a647b6a9821fffcf52ba9ce813f75afa4b84be62
13git -C "$ROOT" show "$ORACLE:src/sha256.c" > "$T/c.c"
14[ "$(sha256sum < "$T/c.c" | cut -c1-64)" = a8fb88611e68ea5a876ee1658e1665994a03bfbed215983618d769f0e7205473 ]
15git -C "$ROOT" show "$ORACLE:src/sha256.h" > "$T/sha256.h"
16sed 's/sha256_\(init\|update\|final\|hash\|transform\)/orc_sha256_\1/g; s/^static const uint32_t K\b/static const uint32_t ORC_K/; s/\bK\[/ORC_K[/g' "$T/c.c" > "$T/oracle.c"
17CF="-std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2"
18cc $CF -c "$ROOT/src/omega_om_units.c" -o "$T/new.o"
19cc -std=gnu11 -O2 -c "$T/oracle.c" -o "$T/oracle.o" # finds the historical header beside it
20for p in par every receipts; do cc $CF -I"$ROOT/src" "$(dirname "$0")/$p.c" "$T/new.o" "$T/oracle.o" -o "$T/$p" -pthread; done
21# every length 0..9000: one shot and an update split
22"$T/every" | tee "$T/every.out"
23[ "$(cat "$T/every.out")" = "lengths 0..9000: diff=0" ] || { echo "SHA256-PARITY FAIL"; exit 1; }
24"$T/receipts" receipts | tee "$T/receipts.out" || { echo "SHA256-PARITY FAIL (receipts)"; exit 1; }
25"$T/par" > "$T/out"
26cat "$T/out"
27printf '%s\n' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 \
28 ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad \
29 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 \
30 cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 "cases=2000 diff=0" | cmp -s - "$T/out" \
31 && echo "SHA256-PARITY PASS" || { echo "SHA256-PARITY FAIL"; exit 1; }