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