Skip to content

ECDSA secp256{k,r}1 builtin and reference semantics #296

Open
Eduardogbg wants to merge 2 commits into
edu/embedded-curve-opsfrom
edu/ecdsa
Open

ECDSA secp256{k,r}1 builtin and reference semantics #296
Eduardogbg wants to merge 2 commits into
edu/embedded-curve-opsfrom
edu/ecdsa

Conversation

@Eduardogbg
Copy link
Copy Markdown
Collaborator

@Eduardogbg Eduardogbg commented May 21, 2026

  • Based on Bump Lean and Mathlib to v4.22 #295 (bump to v4.22). Should be rebased and retargeted to main once that lands.
  • Reference implementations of Noir's two foreign ECDSA builtins (ecdsa_secp256k1::verify_signature, ecdsa_secp256r1::verify_signature) on top of Mathlib's WeierstrassCurve.Affine.Point (computable in v4.22 via PR #27299). Each curve has 3 RFC 6979 deterministic test vectors validated by native_decide.
  • Pratt primality certificates for both secp field primes, generated by a new scripts/gen_pratt.py.
  • Generic decidability instances for W.Equation, W.Nonsingular, DecidableEq W.Point at Crypto/MathlibBridge.lean. (maybe upstream to Mathlib?)
  • Builtin with on-curve preconditions and call Mathlib's + / nsmul directly

@Eduardogbg Eduardogbg closed this May 21, 2026
@Eduardogbg Eduardogbg reopened this May 21, 2026
@Eduardogbg Eduardogbg changed the title Concrete crypto primitives: ECDSA, Keccak, BLAKE3 Concrete ECDSA secp256k1 / secp256r1 + EmbeddedCurve refactor May 21, 2026
@Eduardogbg Eduardogbg changed the title Concrete ECDSA secp256k1 / secp256r1 + EmbeddedCurve refactor ECDSA secp256{k,r}1 builtin and reference semantics May 21, 2026
@Eduardogbg Eduardogbg force-pushed the edu/bump-lean-4.22 branch from 41979c5 to 0578532 Compare May 21, 2026 07:06
Base automatically changed from edu/bump-lean-4.22 to edu/embedded-curve-ops May 21, 2026 07:06
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from db5b7a5 to f9a4876 Compare May 21, 2026 07:21
Comment thread Lampe/Lampe/Crypto/Secp256k1.lean Outdated
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from f9a4876 to 4615896 Compare May 21, 2026 23:27
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from 4615896 to f40eef0 Compare May 22, 2026 05:16
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from f40eef0 to c4b4d9d Compare May 27, 2026 08:17
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from c4b4d9d to 625a2eb Compare May 29, 2026 04:31
@Eduardogbg Eduardogbg marked this pull request as ready for review May 29, 2026 04:52
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from 625a2eb to 1a3dd4e Compare May 29, 2026 05:02
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from 1a3dd4e to 6d7d1c0 Compare May 29, 2026 08:13
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from 6d7d1c0 to 7845022 Compare May 29, 2026 12:27
@Eduardogbg Eduardogbg force-pushed the edu/embedded-curve-ops branch from 7845022 to 565250b Compare May 29, 2026 15:16
Formalizes Noir's `#[foreign(ecdsa_secp256k1)]` and
`#[foreign(ecdsa_secp256r1)]` builtins, with concrete Lean
reference implementations to certify agreement with Barretenberg.

- `Lampe/Builtin/Crypto/Ecdsa.lean`: precondition-style
  descriptors for both builtins. The output forwards to
  `Lampe.Crypto.Ecdsa.secp256{k,r}1Verify`.

- `Lampe/Crypto/Secp256{k1,r1}.lean`: per-curve FIPS 186-4 §6.4.2
  verification on Mathlib's `WeierstrassCurve.Affine.Point`. The
  curve, generator, and order are spelled out concretely; ECDSA
  test vectors close by `native_decide` against RFC 6979
  deterministic signatures.

- `Lampe/Crypto/Secp256{k1,r1}/Prime.lean`: Pratt primality
  certificates for the secp field primes, mechanically generated
  by `scripts/gen_pratt.py`.

- `Lampe/Crypto/Ecdsa.lean`: thin Lean wrappers exposing the
  Noir-typed (`[u8;32]`, `[u8;64]`) view of the builtins.

`Point.some` uses are written with explicit `(x := …) (y := …)`
named arguments (and `@Point.some _ _ _ x y _` for patterns)
under Mathlib v4.29's stricter implicit-argument transparency
rules (leanprover/lean4#12179).
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