FA-15071 / Numerics / Open access
Baby step giant step logarithm: baby group progression · case 01
The exact baby step giant step logarithm result violates the stated contract at baby group progression.
ROOT CAUSE
The baby group progression step uses v+g%p instead of v*g%p.
VERIFIED REPAIR
Use v*g%p at the baby group progression step.
Unsuccessful approach: The partial repair g%p still violates the baby group progression invariant.
Case contract
Input [g,h,p], p prime and nonzero g,h; return least e>=0 with g^e=h mod p or None.
Why this case matters
Exact discrete arithmetic with observable algorithmic state; no floating point approximation is used.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
g,h,p=x;m=math.isqrt(p-1)+1
baby={};v=1
for j in range(m):
if v not in baby:baby[v]=j
v=v+g%p
factor=pow(pow(g,m,p),-1,p)
v=h
answers=[]
for i in range(m+1):
if v in baby:
e=i*m+baby[v]
if pow(g,e,p)==h:answers.append(e)
v=v*factor%p
return min(answers) if answers else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 2, 3], 1), ([2, 4, 5], 2), ([1, 1, 3], 0), ([22, 22, 23], 1), ([1, 2, 3], None), ([2, 1, 3], 0), ([1, 1, 5], 0), ([1, 2, 5], None)], [([2, 2, 5], 1), ([3, 2, 7], 2), ([1, 1, 3], 0), ([22, 22, 23], 1), ([4, 2, 5], None), ([4, 3, 5], None), ([4, 4, 5], 1), ([1, 1, 7], 0)], [([2, 4, 5], 2), ([5, 3, 7], 5), ([1, 1, 3], 0), ([22, 22, 23], 1), ([3, 3, 7], 1), ([3, 4, 7], 4), ([3, 5, 7], 5), ([3, 6, 7], 3)], [([3, 3, 5], 1), ([2, 7, 11], 7), ([1, 1, 3], 0), ([22, 22, 23], 1), ([6, 2, 7], None), ([6, 3, 7], None), ([6, 4, 7], None), ([6, 5, 7], None)], [([3, 4, 5], 2), ([3, 5, 11], 3), ([1, 1, 3], 0), ([22, 22, 23], 1), ([2, 3, 11], 8), ([2, 4, 11], 2), ([2, 5, 11], 4), ([2, 6, 11], 9)]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | None | 1 | Failed |
| explicit oracle 1 | 6 | 2 | Failed |
| explicit oracle 2 | 0 | 0 | Passed |
| explicit oracle 3 | 5 | 1 | Failed |
| explicit oracle 4 | None | None | Passed |
| explicit oracle 5 | 0 | 0 | Passed |
| explicit oracle 6 | 0 | 0 | Passed |
| explicit oracle 7 | None | None | Passed |
SHA-256 / 50a89a8751ba76deceff5849ee87c973cb9df8432f4bde6d920ae9c8e3581b44
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
g,h,p=x;m=math.isqrt(p-1)+1
baby={};v=1
for j in range(m):
if v not in baby:baby[v]=j
v=g%p
factor=pow(pow(g,m,p),-1,p)
v=h
answers=[]
for i in range(m+1):
if v in baby:
e=i*m+baby[v]
if pow(g,e,p)==h:answers.append(e)
v=v*factor%p
return min(answers) if answers else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 2, 3], 1), ([2, 4, 5], 2), ([1, 1, 3], 0), ([22, 22, 23], 1), ([1, 2, 3], None), ([2, 1, 3], 0), ([1, 1, 5], 0), ([1, 2, 5], None)], [([2, 2, 5], 1), ([3, 2, 7], 2), ([1, 1, 3], 0), ([22, 22, 23], 1), ([4, 2, 5], None), ([4, 3, 5], None), ([4, 4, 5], 1), ([1, 1, 7], 0)], [([2, 4, 5], 2), ([5, 3, 7], 5), ([1, 1, 3], 0), ([22, 22, 23], 1), ([3, 3, 7], 1), ([3, 4, 7], 4), ([3, 5, 7], 5), ([3, 6, 7], 3)], [([3, 3, 5], 1), ([2, 7, 11], 7), ([1, 1, 3], 0), ([22, 22, 23], 1), ([6, 2, 7], None), ([6, 3, 7], None), ([6, 4, 7], None), ([6, 5, 7], None)], [([3, 4, 5], 2), ([3, 5, 11], 3), ([1, 1, 3], 0), ([22, 22, 23], 1), ([2, 3, 11], 8), ([2, 4, 11], 2), ([2, 5, 11], 4), ([2, 6, 11], 9)]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | 1 | 1 | Passed |
| explicit oracle 1 | 6 | 2 | Failed |
| explicit oracle 2 | 0 | 0 | Passed |
| explicit oracle 3 | 1 | 1 | Passed |
| explicit oracle 4 | None | None | Passed |
| explicit oracle 5 | 0 | 0 | Passed |
| explicit oracle 6 | 0 | 0 | Passed |
| explicit oracle 7 | None | None | Passed |
SHA-256 / 3bac78d82a9ac11d7f0f99831a1a77e8b17cc893c0d662fd13713615299e23c6
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
g,h,p=x;m=math.isqrt(p-1)+1
baby={};v=1
for j in range(m):
if v not in baby:baby[v]=j
v=v*g%p
factor=pow(pow(g,m,p),-1,p)
v=h
answers=[]
for i in range(m+1):
if v in baby:
e=i*m+baby[v]
if pow(g,e,p)==h:answers.append(e)
v=v*factor%p
return min(answers) if answers else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 2, 3], 1), ([2, 4, 5], 2), ([1, 1, 3], 0), ([22, 22, 23], 1), ([1, 2, 3], None), ([2, 1, 3], 0), ([1, 1, 5], 0), ([1, 2, 5], None)], [([2, 2, 5], 1), ([3, 2, 7], 2), ([1, 1, 3], 0), ([22, 22, 23], 1), ([4, 2, 5], None), ([4, 3, 5], None), ([4, 4, 5], 1), ([1, 1, 7], 0)], [([2, 4, 5], 2), ([5, 3, 7], 5), ([1, 1, 3], 0), ([22, 22, 23], 1), ([3, 3, 7], 1), ([3, 4, 7], 4), ([3, 5, 7], 5), ([3, 6, 7], 3)], [([3, 3, 5], 1), ([2, 7, 11], 7), ([1, 1, 3], 0), ([22, 22, 23], 1), ([6, 2, 7], None), ([6, 3, 7], None), ([6, 4, 7], None), ([6, 5, 7], None)], [([3, 4, 5], 2), ([3, 5, 11], 3), ([1, 1, 3], 0), ([22, 22, 23], 1), ([2, 3, 11], 8), ([2, 4, 11], 2), ([2, 5, 11], 4), ([2, 6, 11], 9)]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | 1 | 1 | Passed |
| explicit oracle 1 | 2 | 2 | Passed |
| explicit oracle 2 | 0 | 0 | Passed |
| explicit oracle 3 | 1 | 1 | Passed |
| explicit oracle 4 | None | None | Passed |
| explicit oracle 5 | 0 | 0 | Passed |
| explicit oracle 6 | 0 | 0 | Passed |
| explicit oracle 7 | None | None | Passed |
SHA-256 / ef4048e1429b4010ed8aab1b0205ce07df58df2464fff4561cc3b15d1dc51834
Verification & scope
A deterministic bounded teaching model. Inputs are restricted to the explicit contract; this is not a production algebra library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:39:23.184023+00:00.
Case digest / 127e918b340b5b35fd428ec7f62e5f55acb6669986f06b16147342407066353c