Skip to content

Commit f554dfc

Browse files
sage: Reorganize files
* Move curve parameters to separate file * Rename main prover script for clarity
1 parent 13c88ef commit f554dfc

3 files changed

+33
-6
lines changed

sage/gen_exhaustive_groups.sage

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
# Define field size and field
2-
P = 2^256 - 2^32 - 977
3-
F = GF(P)
4-
BETA = F(0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee)
5-
6-
assert(BETA != F(1) and BETA^3 == F(1))
1+
load("secp256k1_params.sage")
72

83
orders_done = set()
94
results = {}
File renamed without changes.

sage/secp256k1_params.sage

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Prime order of finite field underlying secp256k1 (2^256 - 2^32 - 977)"""
2+
P = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
3+
4+
"""Finite field underlying secp256k1"""
5+
F = FiniteField(P)
6+
7+
"""Elliptic curve secp256k1: y^2 = x^3 + 7"""
8+
C = EllipticCurve([F(0), F(7)])
9+
10+
"""Base point of secp256k1"""
11+
G = C.lift_x(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798)
12+
13+
"""Prime order of secp256k1"""
14+
N = C.order()
15+
16+
"""Finite field of scalars of secp256k1"""
17+
Z = FiniteField(N)
18+
19+
""" Beta value of secp256k1 non-trivial endomorphism: lambda * (x, y) = (beta * x, y)"""
20+
BETA = F(2)^((P-1)/3)
21+
22+
""" Lambda value of secp256k1 non-trivial endomorphism: lambda * (x, y) = (beta * x, y)"""
23+
LAMBDA = Z(3)^((N-1)/3)
24+
25+
assert is_prime(P)
26+
assert is_prime(N)
27+
28+
assert BETA != F(1)
29+
assert BETA^3 == F(1)
30+
31+
assert LAMBDA != Z(1)
32+
assert LAMBDA^3 == Z(1)

0 commit comments

Comments
 (0)