Skip to content

Instantly share code, notes, and snippets.

View hellresistor's full-sized avatar
💭
I may be slow to respond.

hellresistor hellresistor

💭
I may be slow to respond.
View GitHub Profile
@hellresistor
hellresistor / secp256k1_key_recover.sage
Created July 22, 2025 20:25 — forked from jaonoctus/secp256k1_key_recover.sage
How can you extract secret keys from ECDSA by doing: d = (((s1 * k) - h1) * r^-1) % n and how RFC6979 fix it
# Import needed libraries
import hashlib
# secp256k1 parameters
p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
a = 0
b = 7
n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240
Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424