aere-research/bench/make-htp-variant.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

50 lines
1.9 KiB
Python

#!/usr/bin/env python3
# Derive AereFalcon512VerifierHTP.sol from AereFalcon512Verifier.sol by replacing
# ONLY the in-EVM hashToPoint with a call to the native 0x0AE7 precompile. Every
# other step (SHAKE helpers, decode, ring mul, norm check) is byte-identical, so a
# WITH-vs-WITHOUT gas comparison isolates exactly the HashToPoint cost.
import re
import sys
src_path = sys.argv[1]
out_path = sys.argv[2]
s = open(src_path).read()
# 1. rename the contract
s = s.replace("contract AereFalcon512Verifier {", "contract AereFalcon512VerifierHTP {")
# 2. relax `pure` -> `view` on function declarations (the precompile call is a staticcall = view)
s = re.sub(r"\)(\s*)(public|internal|external|private)(\s+)pure", r")\1\2\3view", s)
# 3. replace the whole hashToPoint function body with a precompile-backed one (brace-matched)
start = s.index("function hashToPoint(")
# walk to the opening brace of the body
brace = s.index("{", start)
depth = 0
i = brace
while i < len(s):
if s[i] == "{":
depth += 1
elif s[i] == "}":
depth -= 1
if depth == 0:
break
i += 1
end = i + 1 # inclusive of closing brace
replacement = (
"function hashToPoint(bytes memory nonce, bytes memory message) public view returns (uint256[512] memory cc) {\n"
" // Native AERE Falcon HashToPoint precompile @ 0x0AE7: logn(1)=9 || nonce(40) || message\n"
" bytes memory input = bytes.concat(bytes1(uint8(9)), nonce, message);\n"
" (bool okp, bytes memory outp) = address(0x0AE7).staticcall(input);\n"
" require(okp && outp.length == 1024, \"htp precompile failed\");\n"
" for (uint256 i = 0; i < 512; i++) {\n"
" cc[i] = (uint256(uint8(outp[2 * i])) << 8) | uint256(uint8(outp[2 * i + 1]));\n"
" }\n"
" }"
)
s = s[:start] + replacement + s[end:]
open(out_path, "w").write(s)
print("wrote", out_path)