aere-research/kat/fetch_acvp_mlkem.py
Aere Network 6cb0140fae Republished from a clean root: the compiled artifact is gone from history, and the local line of work joins the sanitized public line
The public history carried kat/__pycache__/mlkem768_reference.cpython-314.pyc,
a compiled Python artifact embedding the operator's absolute local path. Text
secret scanners do not read compiled binaries, which is exactly how it slipped
through, and removing it from the tip would have left it reachable through the
old root commits. So this repository is republished from a single clean root.

This root also carries, from the previously unpublished line of work:
- corrected LICENSE year, LICENSING.md, VERIFY-POLICY.md, and
  CITATIONS-UNRESOLVED.md remeasured 2026-08-11 (101 paths, README aligned)
- O-018: run_consensus_verification.py ran 19 of 29 models and reported PASS;
  it now runs all 29, and computemarket_smt.py gains resolveByTimeout /
  reclaimUnsettled cases plus a negative control
- O-006: the word 'audited' removed from next to Bouncy Castle, twice, after a
  concurrent edit resurrected it
- O-014: prior art named and dated - Algorand's native falcon_verify shipped
  about ten months before AERE's precompiles; the primacy claim is withdrawn
  where it was implied
- bench/ scripts parametrized so they actually run for an outsider (the
  earlier textual sanitization left $STAGING unexpanded inside Python strings)
- AIP-2/AIP-3 errata with measured figures, spec remeasurements at 2026-08-01,
  and the spec-zk-stack retractions (owner is an operational key, not the
  Foundation; 'maximally sound' withdrawn; aggregator V1 deprecated)
The redacted bench-host environment files from the sanitized line are kept
exactly as published; the unredacted local variants are not carried.
2026-08-15 13:52:14 +03:00

79 lines
2.5 KiB
Python

#!/usr/bin/env python3
# Fetch NIST ACVP ML-KEM-768 ENCAPSULATION vectors and emit them in the flat
# format MlKemAcvpKat.java consumes: tcId|ek_hex|m_hex|c_hex|k_hex
#
# Source: usnistgov/ACVP-Server, ML-KEM-encapDecap-FIPS203 internalProjection.json
# (the "internal projection" carries both the inputs ek/m and expected outputs c/k).
# Encapsulation AFT test groups give ek + m and expected ciphertext c + shared key k.
import json
import sys
import urllib.request
URLS = [
"https://raw.githubusercontent.com/usnistgov/ACVP-Server/master/gen-val/json-files/ML-KEM-encapDecap-FIPS203/internalProjection.json",
"https://raw.githubusercontent.com/usnistgov/ACVP-Server/master/gen-val/json-files/ML-KEM-encapDecap-FIPS203/expectedResults.json",
]
def fetch(url):
req = urllib.request.Request(url, headers={"User-Agent": "aere-kat/1.0"})
with urllib.request.urlopen(req, timeout=60) as r:
return json.loads(r.read().decode())
def get(d, *names):
for n in names:
for k in d:
if k.lower() == n.lower():
return d[k]
return None
def main():
out = sys.argv[1] if len(sys.argv) > 1 else "mlkem768_acvp.txt"
data = None
used = None
for u in URLS:
try:
data = fetch(u)
used = u
break
except Exception as e: # noqa
print(f"fetch failed {u}: {e}", file=sys.stderr)
if data is None:
print("ACVP_FETCH_FAILED", file=sys.stderr)
sys.exit(2)
groups = get(data, "testGroups") or []
lines = []
for g in groups:
pset = str(get(g, "parameterSet") or "")
func = str(get(g, "function") or "")
if "768" not in pset:
continue
if "encap" not in func.lower():
continue
for t in get(g, "tests") or []:
ek = get(t, "ek")
m = get(t, "m")
c = get(t, "c")
k = get(t, "k")
tc = get(t, "tcId")
if ek and m and c and k:
lines.append(f"{tc}|{ek}|{m}|{c}|{k}")
if not lines:
print("ACVP_NO_ENCAP_VECTORS (schema mismatch) source=" + str(used), file=sys.stderr)
sys.exit(2)
with open(out, "w") as f:
f.write("# NIST ACVP ML-KEM-768 encapsulation vectors (ek|m|c|k)\n")
f.write("# source: " + used + "\n")
f.write("\n".join(lines) + "\n")
print(f"ACVP_OK wrote {len(lines)} ML-KEM-768 encapsulation vectors -> {out}")
if __name__ == "__main__":
main()