omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / g1 / reference.py
| 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. |
| 5 | import sys |
| 6 | M = 2**64 |
| 7 | VALUES = [0, 1, 2, 2**32, 2**63 - 1, 2**63, 2**63 + 1, 2**64 - 2, 2**64 - 1] |
| 8 | if sys.argv[1:] == ["vectors"]: |
| 9 | for a in VALUES: |
| 10 | for b in VALUES: |
| 11 | print(a, b) |
| 12 | elif 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) |
| 16 | else: |
| 17 | sys.exit("usage: reference.py vectors|expect") |