mirror of
https://github.com/saymrwulf/betrusted-ed25519-verified.git
synced 2026-09-03 20:13:47 +00:00
This v4.1.x fork implements Scalar52::sub with TWO loops (loop0 = borrow chain; loop1 adds L &&& underflow_mask — the arithmetic-mask constant-time conditional), a genuinely different code path from upstream v5's subtle-based conditional_add_l. Verified per R2 against this fork's own gen: - sub_loop_spec (= loop0): borrow chain, verbatim technique from dalek - sub_loop1_zero_spec / sub_loop1_one_spec: the masked-L add, both mask values (0 / 2^64-1), full carry chains - sub_val_spec: denote(sub a b) = denote a - denote b in ZMod l; the underflow mask um = ((borrow>>>63) XOR 1) - 1 resolved per case - add_loop_spec + add_val_spec: denote(add a b) = denote a + denote b (v4 add_loop extracts token-identical to v5; composition through this fork's own sub_val_spec) check-scalar.sh: full manifest, 5/5 kernel axiom audit [propext, Classical.choice, Quot.sound], green at 300-400s/4096MB. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
43 lines
2.2 KiB
Bash
Executable file
43 lines
2.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
||
# Scalar-layer check (Scalar52 arithmetic mod ℓ). Compiles the gen model + the
|
||
# proven foundation. add/sub (Range-loop reductions) and the Montgomery mul
|
||
# path are in progress — see README. Guarded compiles throughout.
|
||
set -uo pipefail
|
||
source ~/aeneas-toolchain/env.sh
|
||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||
AENEAS_LEAN="$AENEAS_HOME/backends/lean"
|
||
GEN=(CurveScalar/TypesExternal CurveScalar/Types CurveScalar/FunsExternal CurveScalar/Funs)
|
||
PROOFS=(ScalarDenote ScalarLoop ScalarSubSpec ScalarAddSpec)
|
||
|
||
echo "=== stub/axiom audit ==="
|
||
grep -rnE '^(private |protected |noncomputable )*axiom ' "$HERE"/Proofs/Scalar*.lean 2>/dev/null && { echo "axiom under Proofs/"; exit 1; }
|
||
echo " clean"
|
||
echo "=== compile (guarded) ==="
|
||
cd "$AENEAS_LEAN"
|
||
lake env bash -c "
|
||
set -uo pipefail
|
||
cd '$HERE/gen' && export LEAN_PATH=\"\$LEAN_PATH:\$PWD:$HERE\"
|
||
for m in ${GEN[*]}; do echo \" · gen \$m\"; LEAN_TIMEOUT=300 LEAN_MEM_MB=6144 '$HERE/lean-guard' \"\$m.lean\" || exit 1; done
|
||
cd '$HERE'
|
||
for m in ${PROOFS[*]}; do echo \" · proof \$m\"; LEAN_TIMEOUT=300 LEAN_MEM_MB=4096 '$HERE/lean-guard' \"Proofs/\$m.lean\" || exit 1; done
|
||
" || { echo FAIL; exit 1; }
|
||
echo "=== Phase 3: axiom audit (kernel-level) ==="
|
||
cd "$AENEAS_LEAN"
|
||
lake env bash -c "
|
||
set -uo pipefail
|
||
export LEAN_PATH=\"\$LEAN_PATH:$HERE/gen:$HERE\"
|
||
cd '$HERE'
|
||
AUD=\$(mktemp '$HERE/.audit-scalar-XXXX.lean')
|
||
{ echo 'import Proofs.ScalarDenote'; echo 'import Proofs.ScalarSubSpec'; echo 'import Proofs.ScalarAddSpec'; echo '#print axioms ScalarProofs.L_val'
|
||
echo '#print axioms ScalarProofs.sub_loop_spec'
|
||
echo '#print axioms ScalarProofs.sub_loop1_one_spec'; echo '#print axioms ScalarProofs.sub_val_spec'; echo '#print axioms ScalarProofs.add_val_spec'; } > \"\$AUD\"
|
||
OUT=\$(LEAN_TIMEOUT=120 LEAN_MEM_MB=4096 '$HERE/lean-guard' \"\$AUD\" 2>&1)
|
||
echo \"\$OUT\"
|
||
rm -f \"\$AUD\" \"\${AUD%.lean}.olean\"
|
||
N=\$(echo \"\$OUT\" | grep -cF \"depends on axioms: [propext, Classical.choice, Quot.sound]\" || true)
|
||
[ \"\$N\" -eq 5 ] || { echo \"AXIOM AUDIT FAILED: \$N/5 clean\"; exit 1; }
|
||
" || { echo FAIL; exit 1; }
|
||
echo " L_val axiom-clean"
|
||
|
||
echo ""
|
||
echo "SCALAR FOUNDATION: gen compiles; denotation + group-order constant (L = ℓ) proven."
|