Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1"""Prime order of finite field underlying secp256k1 (2^256 - 2^32 - 977)"""2P = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F4"""Finite field underlying secp256k1"""5F = FiniteField(P)7"""Elliptic curve secp256k1: y^2 = x^3 + 7"""8C = EllipticCurve([F(0), F(7)])10"""Base point of secp256k1"""11G = C.lift_x(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798)12if int(G[1]) & 1:13# G.y is even14G = -G16"""Prime order of secp256k1"""17N = C.order()19"""Finite field of scalars of secp256k1"""20Z = FiniteField(N)22""" Beta value of secp256k1 non-trivial endomorphism: lambda * (x, y) = (beta * x, y)"""23BETA = F(2)^((P-1)/3)25""" Lambda value of secp256k1 non-trivial endomorphism: lambda * (x, y) = (beta * x, y)"""26LAMBDA = Z(3)^((N-1)/3)28assert is_prime(P)29assert is_prime(N)31assert BETA != F(1)32assert BETA^3 == F(1)33assert BETA^2 + BETA + 1 == 035assert LAMBDA != Z(1)36assert LAMBDA^3 == Z(1)37assert LAMBDA^2 + LAMBDA + 1 == 039assert Integer(LAMBDA)*G == C(BETA*G[0], G[1])
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.