SPB Git

spb/wp34_uqo

Public
1.4 KB · 28 lines python
1#!/usr/bin/env python2"""Generate larger synthetic instances (40–62 bits) for throughput measurements of rho_engine.34Usage: PYTHONPATH=src .venv/bin/python experiments/synthetic_ecdlp/rho_engine/scripts/gen_bench_instances.py5Writes experiments/synthetic_ecdlp/rho_engine/bench/instances.json (decimal strings, with d for verification).6"""7import json, random, pathlib, sys, time8ROOT = pathlib.Path(__file__).resolve().parents[4]9sys.path.insert(0, str(ROOT / "src"))10from wp34.ec import random_prime_order_curve, cube_roots_of_unity, endomorphism_lambda  # noqa: E4021112rng = random.Random(3434)13out = []14for bits, j0 in [(40, False), (40, True), (48, False), (56, False), (62, False), (62, True)]:15    E = random_prime_order_curve(bits, rng, j0=j0)16    d = rng.randrange(1, E.n)17    Q = E.mul(d, E.G)18    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),19           "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)}20    if j0:21        beta = cube_roots_of_unity(E.p, rng)[0]22        rec["beta"], rec["lambda"] = str(beta), str(endomorphism_lambda(E, beta))23    out.append(rec)24    print(rec["label"], E.p, E.n, file=sys.stderr)25path = ROOT / "experiments/synthetic_ecdlp/rho_engine/bench/instances.json"26path.write_text(json.dumps({"seed": 3434, "instances": out}, indent=1) + "\n")27print("wrote", path, file=sys.stderr)28
Files · c732f7e320257301eb619a8227b914374a41aac4
Menu

Theme