interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / g1 / reference.py

17 lines · 799 bytes Raw Blame History
1# Python bigint reference for the G1 sample calc(i0, i1) = (i0 + i1) * (i0 - i1) modulo 2^64.
2# "vectors" prints the boundary vectors, one "i0 i1" line each: every ordered pair of the values below
3# (0, 1, 2^63 and 2^64-1 among them). "expect" reads such lines and prints "i0 i1 0 result", the line
4# each caller must print for a status-0 call. Arbitrary-precision ints, reduced once at the end.
5import sys
6M = 2**64
7VALUES = [0, 1, 2, 2**32, 2**63 - 1, 2**63, 2**63 + 1, 2**64 - 2, 2**64 - 1]
8if sys.argv[1:] == ["vectors"]:
9 for a in VALUES:
10 for b in VALUES:
11 print(a, b)
12elif sys.argv[1:] == ["expect"]:
13 for line in sys.stdin:
14 a, b = map(int, line.split())
15 print(a, b, 0, ((a + b) * (a - b)) % M)
16else:
17 sys.exit("usage: reference.py vectors|expect")