Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Baby-step giant-step: existence of a match below n\sqrt{n}n​

Proved
ECDLP.bsgs

by LG · Nov 16, 2026 · Mathlib 0df444a (Lean v4.33.1)

cryptographygroup-theorynumber-theory

Let GGG be an additive commutative group, P∈GP \in GP∈G of order n>0n > 0n>0, and Q=xPQ = xPQ=xP with 0≤x<n0 \le x < n0≤x<n. Put m=⌊n⌋+1m = \lfloor\sqrt{n}\rfloor + 1m=⌊n​⌋+1. Then there exist natural numbers i,j<mi, j < mi,j<m such that

jP=Q−i(mP).jP = Q - i(mP).jP=Q−i(mP).

This is the correctness core of Shanks's baby-step giant-step method: writing x=im+jx = im + jx=im+j with i,j<mi, j < mi,j<m, the baby step jPjPjP matches the giant step Q−i(mP)Q - i(mP)Q−i(mP), so a collision search over two lists of length m=O(n)m = O(\sqrt{n})m=O(n​) recovers x=im+jx = im + jx=im+j. For the challenge instance m≈2127m \approx 2^{127}m≈2127, which is why the method is infeasible there.

Formalization Note. Nat.sqrt is the integer square root; the bound m=⌊n⌋+1m = \lfloor\sqrt{n}\rfloor + 1m=⌊n​⌋+1 ensures m2>nm^2 > nm2>n, so the quotient and remainder of xxx by mmm are both <m< m<m.

Preamble
import Mathlib
Formal statement
namespace ECDLP

theorem bsgs {G : Type*} [AddCommGroup G] {P Q : G} {n x : ℕ} (hn : 0 < n)
    (hP : addOrderOf P = n) (hx : x < n) (hQ : Q = x • P) :
    let m := Nat.sqrt n + 1
    ∃ i j : ℕ, i < m ∧ j < m ∧ j • P = Q - i • (m • P) := by sorry

end ECDLP
Source
Shanks, baby-step giant-step method (1971, unpublished); Washington, Elliptic Curves: Number Theory and Cryptography, 2nd ed., Chapman & Hall/CRC 2008, §5.2.1, https://doi.org/10.1201/9781420071474.
Human review
  • Endorsed by Shuze Chen · Nov 17, 2026

    Confirmed by the moderator at approval.

  • Endorsed by LG · Nov 17, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me