#!/usr/bin/env python """Generate larger synthetic instances (40–62 bits) for throughput measurements of rho_engine. Usage: PYTHONPATH=src .venv/bin/python experiments/synthetic_ecdlp/rho_engine/scripts/gen_bench_instances.py Writes experiments/synthetic_ecdlp/rho_engine/bench/instances.json (decimal strings, with d for verification). """ import json, random, pathlib, sys, time ROOT = pathlib.Path(__file__).resolve().parents[4] sys.path.insert(0, str(ROOT / "src")) from wp34.ec import random_prime_order_curve, cube_roots_of_unity, endomorphism_lambda # noqa: E402 rng = random.Random(3434) out = [] for bits, j0 in [(40, False), (40, True), (48, False), (56, False), (62, False), (62, True)]: E = random_prime_order_curve(bits, rng, j0=j0) d = rng.randrange(1, E.n) Q = E.mul(d, E.G) rec = {"label": f"{bits}b{'-j0' if j0 else ''}", "bits": bits, "j0": j0, "p": str(E.p), "a": str(E.a), "b": str(E.b), "n": str(E.n), "gx": str(E.G[0]), "gy": str(E.G[1]), "qx": str(Q[0]), "qy": str(Q[1]), "d": str(d)} if j0: beta = cube_roots_of_unity(E.p, rng)[0] rec["beta"], rec["lambda"] = str(beta), str(endomorphism_lambda(E, beta)) out.append(rec) print(rec["label"], E.p, E.n, file=sys.stderr) path = ROOT / "experiments/synthetic_ecdlp/rho_engine/bench/instances.json" path.write_text(json.dumps({"seed": 3434, "instances": out}, indent=1) + "\n") print("wrote", path, file=sys.stderr)