Overview
We’re given two files:
checker.py— verifies a candidate private key against a known secp256k1 public key, and if correct, XOR-decrypts a hardcoded ciphertext with a short repeating key and prints the flag.deadbolt.json— contains the curve, public key, and two ECDSA signatures.
The job: recover the private key d such that d * G == (PUB_X, PUB_Y).
Prerequisites / Setup
- Python 3.8+ (
pow(x, -1, n)for modular inverse) checker.pyanddeadbolt.jsonin the working directory
Recon
Step 1 — Inspect checker.py
Goal: Identify the curve parameters and what the checker does.
PUB_X = 112663615484051465733958221339258257849063613947361413621230845351083321471652
PUB_Y = 20707203924145238549824648964187237183894019142576647064731492330797666162633
CURVE_ORDER = 115792089237316195423570985008687907852837564279074904382605163141518161494337
GEN_X = 55066263022277343669578718895168534326250603453777594175500187360389116729240
GEN_Y = 32670510020758816978083085130507043184471273380659243275938904335757337482424
CURVE_P = 115792089237316195423570985008687907853269984665640564039457584007908834671663
CURVE_A = 0
These are the standard secp256k1 domain parameters (the same curve used by Bitcoin and Ethereum).
check(d)computesd * Gand compares to(PUB_X, PUB_Y).- If it matches,
reveal()XOR-decrypts a hardcoded ciphertext with a short repeating key and prints the flag.
So our job: recover the private key d such that d * G == (PUB_X, PUB_Y).
Step 2 — Inspect deadbolt.json
Goal: Read the public key and the two signatures.
{
"curve": "secp256k1",
"public_key": {
"x": 112663615484051465733958221339258257849063613947361413621230845351083321471652,
"y": 20707203924145238549824648964187237183894019142576647064731492330797666162633
},
"signatures": [
{
"message": "RELEASE-MANIFEST-2026-10-01: build 4471, approved for production rollout",
"r": 81068046878512155195417425815628850251053346547441462714808971338416069090423,
"s": 3840508737756347497406687710396332359740879825496539163063209443880034111304
},
{
"message": "RELEASE-MANIFEST-2026-10-02: build 4472, hotfix for build 4471, approved",
"r": 81068046878512155195417425815628850251053346547441462714808971338416069090423,
"s": 113503929155425957381462365769873416436477654667784827574471421629337517804939
}
]
}
The giveaway: both signatures share the exact same r value.
r₁ = r₂ = 81068046878512155195417425815628850251053346547441462714808971338416069090423
Vulnerability Analysis
The flaw class is ECDSA Nonce Reuse. Subtracting the two signing equations:
s₁ − s₂ ≡ k⁻¹(z₁ − z₂) (mod n)
Rearranged to solve for the nonce:
k = (z₁ − z₂) / (s₁ − s₂) mod n
Now that k is known, recover the private key from either equation:
s₁·k ≡ z₁ + r·d (mod n)
d = (s₁·k − z₁) / r mod n
In ECDSA, z is derived from the message hash. For secp256k1 the standard is SHA-256, so zᵢ = SHA256(messageᵢ) interpreted as a big-endian integer (SHA-256 already satisfies the bit length of n for secp256k1).
Both modular inverses in pow(x, -1, n) exist (Python 3.8+ supports pow(x, -1, n) natively).
Exploitation
Step 3 — Solve for the nonce and private key
Goal: Compute k then d from the two signatures and recover the private key.
#!/usr/bin/env python3
import json
import hashlib
CURVE_ORDER = 115792089237316195423570985008687907852837564279074904382605163141518161494337
def h(msg: str) -> int:
return int.from_bytes(hashlib.sha256(msg.encode()).digest(), "big")
with open("deadbolt.json") as f:
data = json.load(f)
sigs = data["signatures"]
m1, m2 = sigs[0]["message"], sigs[1]["message"]
r = sigs[0]["r"]
s1, s2 = sigs[0]["s"], sigs[1]["s"]
z1, z2 = h(m1), h(m2)
n = CURVE_ORDER
# k = (z1 - z2) / (s1 - s2) mod n
k = ((z1 - z2) * pow(s1 - s2, -1, n)) % n
# d = (s1*k - z1) / r mod n
d = ((s1 * k - z1) * pow(r, -1, n)) % n
print("recovered private key:")
print(d)
print(hex(d))
python3 solver.py
recovered private key:
2656466760151853485113498278724311908926037894305005865198209398276174907706
0x5df81c47561875700a49e3010aeccb422b220c2c3d516b580a3d6ba2af4093a
Step 4 — Verify with the provided checker
Goal: Feed the recovered key into checker.py and confirm it decrypts the flag.
python3 checker.py 0x5df81c47561875700a49e3010aeccb422b220c2c3d516b580a3d6ba2af4093a
Key verified.
r00t{REDACTED}
Flag
r00t{REDACTED}
Printed by checker.py after verifying the recovered ECDSA private key.
Lessons / Takeaways
- Equal
rvalues across two ECDSA signatures ⇒ equal noncek⇒ the private key is algebraically recoverable. - Recover
kfrom(z₁ − z₂)/(s₁ − s₂), thendfrom(s₁·k − z₁)/r. - Python 3.8+’s
pow(x, -1, n)makes modular inverses trivial.
Mitigations
- Use RFC 6979 deterministic nonces (derives
kfrom the private key and message hash via HMAC-DRBG, so the same nonce is never produced for two different messages). - Never reuse
k; each signature must use a cryptographically random, unique nonce. - Use a hardened signing library (OpenSSL, libsecp256k1) that implements RFC 6979 by default.
- Detect reuse at rest: if
rever repeats in a signing log, treat the private key as compromised immediately. - The historic Sony PS3 firmware signing-key compromise (2010) was exactly this bug — a constant nonce across all signatures.
Techniques
References
- “ECDSA nonce reuse” (Sony PS3 hack, 2010): https://en.wikipedia.org/wiki/PlayStation_3_hacking
- RFC 6979: Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA): https://datatracker.ietf.org/doc/html/rfc6979

