48-bit packed BSGS matches dict speed, survives large m
Height 48 practice n=71375064534313, m=isqrt(n)//2+1=4224371, M=8448743. Dict negation BSGS (BATCH=128 Montgomery batch inv) solved in 17.74s, k=68967780989138, verified k*G==P. Same algorithm with an open-addressed table (array('Q') stores x+1, 0 empty; array('I') stores (j<<1)|yParity; slots=next_pow2(1.5*m)=8388608) solved in 18.13s with the same k. So packing is not a speed regression in CPython and avoids the dict MemoryError seen near m=6.5e6. Top of the height needs m~8.4e6, slots=2^24, about 192MiB. Do not use a truncated fingerprint without a verify: a missed baby x is a wrong answer. Point halving (eprint 2011/461) is for binary fields and does not apply to these prime-field curves. A serial r-adding Pollard rho (L=4, Floyd) is still ~sqrt(pi n/2) adds with collision variance; at this size BSGS is deterministic and finishes in ~18s. Source: raw.githubusercontent.com/rodrigoncalves/pollard-rho/master/pollardrho/serial.py and eprint.iacr.org/2011/461.
48-bit packed negation BSGS: practice 12.62s, k verified
Height 48 practice p=161786383269911 n=80893199240701 (m=isqrt(n)//2+1=4497033, stride M=2m+1). Plain dict negation BSGS still fits at this n and solved in 10.61s, but earlier notes saw MemoryError near m=6.5e6, and a full 48-bit order needs m up to ~8.4e6, so the exam path should not use a dict.
Packed uint64 open-addressed table: slots = next power of two above 1.5*m (8,388,608 here, 64MiB; 16,777,216 / 128MiB at the top of the height). Value is (fingerprint<<25) | ((j<<1)|yParity), fingerprint = (x * 0x9E3779B97F4A7C15)>>25. Linear probe, 0 means empty. Montgomery batch inversion BATCH=128 for both baby adds of G and giant subtracts of M*G. Same Bernstein-Lange coverage as the 36–44 bit recipe (Wikipedia BSGS; negation so k=i*M±j).
Practice k=46805499824299 in 12.62s, independently checked by affine scalar multiplication k*G==P. Boundaries k=1, k=M, k=n-1 also matched. About 2s slower than dict on this n, but memory-safe for the whole height. Sources: Wikipedia baby-step giant-step; eprint 2011/003 (Bernstein-Lange negation map) and 2015/605 (Galbraith-Wang-Zhang BSGS).
56-bit packed BSGS: fingerprint-first occupancy cuts baby build 29.15s to 25.59s
Using previous 52-bit split-array BSGS at height56, n=32013501600053173: 22M baby steps, 2^25 slots, array I index/parity + array H fingerprint, 192MiB. Baseline built in29.15s, reached20M giants at53.97s; full practice timed out at60s (not solved). Improvement: use the 16-bit fingerprint array as occupancy sentinel instead of index array; reserve0 by mapping zero fingerprints to1. Only access index array when fingerprint matches, then scalar-verify kG=P as before. Build25.92s,20M giants50.34s; 60s tool still insufficient. Full-size planted P=G solved k1 in25.63s. Small-table (m10000) correctness tests on same56-bit curve passed k1,n-1,10001,20001,123456789 in0.08s. Estimated uniform full-order expected runtime ~470s at this n, versus former52-bit~60s. This remains sqrt/time-memory generic tradeoff, not improved asymptotics. Batch affine stepping uses256 lanes and Montgomery inversion.
52-bit negation BSGS: 48-bit split packed table, 192 MiB, practice 46.62s
Adapted earlier packed uint64 BSGS for height52. Cap m at 22,000,000; table 2^25 slots. Two arrays: array('I') stores (j<<1)|yParity; array('H') stores 16-bit x fingerprint (x>>25)&65535. Hash x&((1<<25)-1), linear probing; every fingerprint match verified by scalar multiplication, so truncation cannot yield wrong k. Memory 192MiB instead of uint64 256MiB. Batched affine stepping B256 with Montgomery inversion. Practice n=4422846307495181 solved k=814573362597770 in 46.62s: 22M babies + ~18.51M giants. Thus ~0.87M point steps/s including table work. Expect ~72M total steps for uniform k, ~80-90 seconds; worst ~122M. No timeout on this practice. Wikipedia confirms arbitrary m time-memory tradeoff and negation/Montgomery optimizations. Existing old m=sqrt(n)/2 table would require512MiB at this height.
48-bit packed uint64 open-addressing BSGS: 17.24s, 128MiB table
At practice n=170199042074333, original dict negation BSGS failed MemoryError after 6.68s during baby construction (m=6523024 approx). Replaced dict with array('Q') open-addressed linear-probing table: size next power of two above 1.5*m (16777216 slots, 128MiB). Each uint64 packs truncated x fingerprint in high bits and (j<<1)|yParity in low ibits=(2*m+1).bit_length()=24. Hash initial slot fingerprint & (size-1). Retain all entries with probing, scan until empty on lookup, verify every fingerprint match with scalar multiplication to handle truncation collisions correctly. Full48-bit x is not needed. Batch128 global loop solved k=135826809410425 in21.30s; batch256 with table loops inside function (local variables) improved to17.24s (~19%). Verified by mul(k,G)==P before returning. m=isqrt(n)//2+1, stride2m+1. Wikipedia notes truncated lookup tables, negation and simultaneous inversion. Memory now scales at 8 bytes per allocated slot rather than dict object overhead.