Skip to content

Curve group orders via the Hasse bound, for prime-order curves and for Pallas/Vesta; includes fast SWPoint scalar mul - #2

Merged
daira merged 4 commits into
mainfrom
curve-order
Jun 27, 2026
Merged

Curve group orders via the Hasse bound, for prime-order curves and for Pallas/Vesta; includes fast SWPoint scalar mul#2
daira merged 4 commits into
mainfrom
curve-order

Conversation

@daira

@daira daira commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Pin a prime-order elliptic-curve group's order without point-counting, make the curve scalar action computable, and instantiate at the Pasta curves. Three commits:

1. CurveOrder.lean — order pinning via Hasse

  • Layer 1 (card_eq_of_prime_witness): pure finite-group theory — a prime-order witness plus #G < 2r forces #G = r.
  • Layer 2: hasseInterval / HasseBound (the sqrt-free Hasse bound). Mathlib lacks Hasse's theorem for WeierstrassCurve, so it is taken as a hypothesis (cited to Hasse, Crelle 175 (1936), §3.1/§4.2). Capstones card_eq_of_hasse (explicit gap) and card_eq_of_hasse_of_field_ge_37 (37 ≤ #F + r ∈ hasseInterval #F).

2. ScalarMul.lean — generic fast scalar action •

binNsmul, a generic binary double-and-add over raw add/zero (proven equal to the linear fold linNsmul, supplying nsmul_zero/nsmul_succ). This is stated over raw ops so it can fill the nsmul field of the instance it equips. Used for nsmul in both the SWPoint E and CoordinateSystem.Quot AddCommGroup instances (so affineCoordinateSystem is fast too), plus DecidableEq (SWPoint E). Result: n • P itself is O(log n) and native_decide-friendly for ≈ 2^254 scalars, while staying the genuine group action — all Mathlib lemmas still follow from nsmul_zero and nsmul_succ.

3. PastaOrder.lean — Pallas & Vesta

Instantiate card_eq_of_hasse_of_field_ge_37: assuming HasseBound, the Pallas group has order PALLAS_SCALAR_CARD and the Vesta group PALLAS_BASE_CARD. The witness [order] G = 𝒪 is a one-line native_decide (fast ); the field-size facts are concrete.

No sorry/axiom anywhere; the abstract chain rests only on the standard axioms plus the named Hasse hypothesis. native_decide is confined to concrete closed per-curve facts (Independently re-checkable trust).

Deferred: cofactor curves (#G = h·r); Jubjub (not prime-order, and not short Weierstrass); and rationalising the SWPoint vs affineCoordinateSystem API redundancy.

🤖 Generated with Claude Code

@daira daira changed the title Pin a prime-order curve group's order via the Hasse bound Curve group orders via the Hasse bound (fast SWPoint scalar mult; Pallas & Vesta) Jun 27, 2026
@TalDerei

TalDerei commented Jun 27, 2026

Copy link
Copy Markdown

ACK scaffolding for generic curve in the first commit, haven't reviewed the rest.

@TalDerei

Copy link
Copy Markdown

ACK scope of diff; Hasse bound as an assumed hypothesis, fast scalar mul for SW, and concrete pallas / vesta orders assuming Hasse.

@daira daira changed the title Curve group orders via the Hasse bound (fast SWPoint scalar mult; Pallas & Vesta) Curve group orders via the Hasse bound, for prime-order curves and for Pallas/Vesta; includes fast SWPoint scalar mul Jun 27, 2026

@daira daira left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-ACK

daira and others added 4 commits June 27, 2026 20:57
… bound

Add CompElliptic/CurveOrder.lean: a curve-agnostic argument that fixes a
prime-order elliptic-curve group's order without point-counting.

- Layer 1 (card_eq_of_prime_witness): pure finite-group theory — a prime-order
  witness plus #G < 2r forces #G = r.
- Layer 2: the Hasse bound (hasseInterval / HasseBound), assumed as a hypothesis
  since Mathlib lacks Hasse's theorem for WeierstrassCurve, discharges #G < 2r.
  Two routes to the curve capstone: the explicit gap (card_eq_of_hasse) and
  37 <= #F with r in the Hasse interval (card_eq_of_hasse_of_field_ge_37).
- No sorry/axiom/native_decide; Hasse cited to Crelle 175 (1936), §3.1/§4.2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…oordinateSystem

Add CompElliptic/ScalarMul.lean: `binNsmul`, a generic binary double-and-add over a raw
`add`/`zero` (proven equal to the linear fold `linNsmul`), supplying the `nsmul_zero` /
`nsmul_succ` obligations. Stated over raw ops so it can fill the `nsmul` field of the very
instance it equips.

Use it for the `nsmul` field of both the `SWPoint E` and `CoordinateSystem.Quot` AddCommGroup
instances, so `n • _` computes in O(log n) and is native_decide-friendly for cryptographic-size
scalars (≈ 2^254), while remaining the genuine scalar action (every Mathlib `n • _` lemma still
applies). Add `DecidableEq (SWPoint E)`; `[r] G = 𝒪` is now a one-line native_decide.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Instantiate `card_eq_of_hasse_of_field_ge_37` at both Pasta curves: assuming
`HasseBound`, the Pallas group has order `PALLAS_SCALAR_CARD` and the Vesta group
order `PALLAS_BASE_CARD` (the Pasta cycle). The prime-order witness G = (-1, 2)'s
`[order] G = 𝒪` is a one-line `native_decide` (the SWPoint `•` computes in
O(log n)); the Hasse-interval membership and `37 ≤ #F` facts are concrete.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- New "group order" section: CurveOrder.lean (prime-order pinning via the Hasse
  bound) and Curves/PastaOrder.lean (Pallas/Vesta orders); cofactor variant deferred.
- ShortWeierstrass: fast `•` via the generic binNsmul (ScalarMul.lean) + DecidableEq SWPoint.
- CoordinateSystem.Quot `nsmul` is binNsmul too (affineCoordinateSystem is O(log n));
  note the SWPoint-vs-affineCoordinateSystem redundancy as a deferred ergonomics call.
- Disambiguate the still-pending circuit-windowed smul from the computational binNsmul.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@daira
daira merged commit 6c5b1a6 into main Jun 27, 2026
2 checks passed
@daira
daira deleted the curve-order branch June 27, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants