Commit graph

3 commits

Author SHA1 Message Date
7f166eee12 Phase 2, half-lift prerequisite: the hash-to-scalar entry is canonical
(from_bytes_mod_order_wide_spec, kernel-audited)

Proofs/ScalarPackSpec.lean:
- scalar52_to_bytes_spec: Scalar52::to_bytes (the PACK step - pure
  bit-packing at radix 2^52, no reduction) serializes canonical limbs to
  exactly their value: bytesVal s = scVal a. Second application of the
  ToBytesSpec walk generator; boundary bytes 6 and 19 only (the two
  non-byte-aligned 52j offsets), disjoint ORs to additions as before.
- from_bytes_mod_order_wide_spec: the verifier's k = SHA-512-to-scalar
  entry composes from_bytes_wide_spec (the proven mod-l reduction) with
  the pack: for 64 input bytes of value T, the returned Scalar's 32
  bytes denote V with V < l and V = T (mod l) - precisely the scalar
  premises vartime_double_base_mul_spec consumes (V < l < 2^253).
- byte_split_52_4: the offset-4 chunk split for 52-bit limbs; the five
  ToBytesMath byte_split_* lemmas shed their unused 2^51 premises (pure
  telescopes, valid for all f).

Both certificates exact-standard-three. Full button green fresh.

Half-lift remaining (mapped in memory): dsm dispatch wrapper, recompute
bind-chain inversion, bytesVal injectivity, assembly in PointLiftSpec.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 14:10:09 +02:00
85cfb34a7d Phase 2, brick 1 complete: ed_compress_spec - compress emits the canonical
encoding of the denoted affine point (kernel-audited)

CurveFieldProofs.ed_compress_spec: for any valid extended point Pt
(ExtValid - the invariant every certified curve op guarantees),
    compress Pt = ok s   with
    bytesVal s = (edY Pt).val + ((edX Pt).val % 2) * 2^255
- the 32 wire bytes are the canonical little-endian y-residue with the
x-parity bit at position 255. Compress semantics AND canonicity in one
statement, because to_bytes_spec pins the bytes to the residue itself.

Supporting certificates in Proofs/CompressSpec.lean:
- is_negative_spec: the sign read is the parity of the CANONICAL residue
  (bit 0 of to_bytes) - (feVal x mod p) mod 2.
- Bytes32.exists_bytes: the 32-byte destructuring device (the
  Fe.exists_limbs idiom, 32-wide).
- to_bytes_spec': premise-free restatement of the canonicity brick.
- xor_top_bit (ToBytesMath): setting a clear top bit by XOR is addition -
  proven from xor_div_two_pow + and_xor_distrib_right, no bit-blasting.

The chain is entirely certified code: invert (Fermat), two muls, to_bytes
(canonicity), is_negative, and the sign-bit XOR. Axiom cone of
ed_compress_spec: exactly [propext, Classical.choice, Quot.sound].

check.sh: CompressSpec in PROOFS, ed_compress_spec in CERTS - full button
green fresh.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 13:33:58 +02:00
e07f51c7f7 Phase 2, brick 1a: to_bytes canonicity proven (to_bytes_spec, kernel-audited)
The load-bearing brick of the point-level apex equation:
FieldElement51::to_bytes always succeeds and its 32 output bytes denote
EXACTLY the represented residue - bytesVal s = feVal a mod p. Since the
canonical residue determines the bytes, this is simultaneously
canonicity ("output is the canonical encoding") and the injectivity
compress needs ("equal residues iff equal bytes").

- Proofs/ToBytesMath.lean: the context-free ℕ mathematics (METHOD 4) -
  the 5-rung carry telescope (div_rung/q_telescope), the q-trick facts
  (q = (h+19)/2^255 is a bit, fires iff h >= p), q_mod_p (adding 19q and
  discarding bit 255 subtracts pq exactly), carry_pack (the masked-limb
  assembly mod 2^255), five per-limb byte-chunk splits, and bytes_pack
  (the 32-byte little-endian reassembly, closed by one zify +
  linear_combination over the five splits).
- Proofs/ToBytesSpec.lean: the symbolic execution - at ~150 machine ops
  the longest walk in the repo, loop-free: weak reduce (reduce_spec),
  the q pass, the fold + carry pass, 32 byte extractions (the four
  limb-boundary bytes turn disjoint ORs into additions via
  Nat.two_pow_add_eq_or_of_lt), and the trailing top-bit debug-assert
  DISCHARGED (b31 = f4/2^44 < 2^7), not assumed.
- check.sh: ToBytesMath/ToBytesSpec in PROOFS, to_bytes_spec in CERTS
  (exact standard-three audit) - full button green fresh.

Walk lessons (for the control repo, next push): rw index-equations into
their consumers instead of subst (subst eliminates the wrong side or
dies on dependent do-motives); never rw [Nat.mod_eq_of_lt (by omega)]
(metavariable goal reaches omega) - state the bound with show.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 13:10:43 +02:00