Skip to content

Commit

Permalink
sage: Reorganize files
Browse files Browse the repository at this point in the history
 * Move curve parameters to separate file
 * Rename main prover script for clarity
  • Loading branch information
real-or-random committed Nov 25, 2020
1 parent 13c88ef commit f554dfc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
7 changes: 1 addition & 6 deletions sage/gen_exhaustive_groups.sage
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# Define field size and field
P = 2^256 - 2^32 - 977
F = GF(P)
BETA = F(0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee)

assert(BETA != F(1) and BETA^3 == F(1))
load("secp256k1_params.sage")

orders_done = set()
results = {}
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions sage/secp256k1_params.sage
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Prime order of finite field underlying secp256k1 (2^256 - 2^32 - 977)"""
P = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F

"""Finite field underlying secp256k1"""
F = FiniteField(P)

"""Elliptic curve secp256k1: y^2 = x^3 + 7"""
C = EllipticCurve([F(0), F(7)])

"""Base point of secp256k1"""
G = C.lift_x(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798)

"""Prime order of secp256k1"""
N = C.order()

"""Finite field of scalars of secp256k1"""
Z = FiniteField(N)

""" Beta value of secp256k1 non-trivial endomorphism: lambda * (x, y) = (beta * x, y)"""
BETA = F(2)^((P-1)/3)

""" Lambda value of secp256k1 non-trivial endomorphism: lambda * (x, y) = (beta * x, y)"""
LAMBDA = Z(3)^((N-1)/3)

assert is_prime(P)
assert is_prime(N)

assert BETA != F(1)
assert BETA^3 == F(1)

assert LAMBDA != Z(1)
assert LAMBDA^3 == Z(1)

0 comments on commit f554dfc

Please sign in to comment.