1"""Theoretical cost models used as reference curves (group operations) — see paper §5."""2import math34def rho_expected(n, class_size=1, r=20):5 """Random-mapping expectation √(π n /(2·class_size)); Teske's r-adding walk is within a few % of this for r ≥ 16."""6 return math.sqrt(math.pi * n / (2 * class_size))78def rho_dp_overhead(threads, dp_bits):9 """Extra operations after the collision in the vOW method: ≈ threads · 2^dp_bits."""10 return threads * (1 << dp_bits)1112def bsgs_cost(n, m=None):13 m = m or math.isqrt(n) + 114 return m + n / m, m # (time, memory entries)1516def kangaroo_expected(w):17 return 2 * math.sqrt(w)1819def preprocessing_online(n, T):20 return math.sqrt(n / T)2122def rayleigh_cv():23 """Coefficient of variation of the number of rho iterations (Rayleigh-like first-collision law)."""24 return math.sqrt((4 - math.pi) / math.pi)25