Inspect Weak Curve Parameters
medium · 100 XP · machine with a lab · free · solves: 0
A toy service holds a private scalar d with 0 <= d < 100. You send it a curve point P and it returns R = dP. The curve is y^2 = x^3 + x + 1 mod 101. Its whole group has order 105 = 3 * 5 * 7, a smooth order. The service uses this whole group. It checks only that P is on the curve. It does not check which subgroup P is in.
Three points on the curve have small orders:
- (28, 8) has order 3.
- (46, 25) has order 5.
- (3, 43) has order 7.
Run python3 curve.py to verify these orders. It also has point addition, scalar multiplication and enumeration of multiples.
Start the lab. The service runs on host oracle, TCP port 9000.
Protocol. The service sends four banner lines when you connect. Points are JSON: [x, y] with integers from 0 to 100, and null for the point at infinity. Send one command per line:
mul [x, y]ormul null: the service replies with dP as[x, y], ornullwhen dP is the point at infinity.check <d>: send your answer as a decimal integer. The service repliescorrect: <flag>orwrong, then closes the connection. You get one answer per connection.- Each connection allows 20 mul queries. After the reply to the last one, the service sends
error: query limit reachedand closes the connection. - A bad command, or a point that is not on the curve, gets one reply line that starts with
error:. It uses no query.
client.py gives you Oracle.mul(point) and Oracle.check(d) for your scripts.
Your task.
- Send each small-order point P and get R = dP.
- Find j with jP = R. This gives d mod 3, d mod 5 and d mod 7.
- Combine the three residues with the CRT. 3 * 5 * 7 = 105 is larger than the bound 100, so the result is d.
- Validate d with another mul query: compare the reply with your own dP.
- Send
check <d>to get the flag.
Why this fails. Real systems use a curve group of prime order or a prime-order subgroup with a small cofactor. They validate every received point: it is on the curve, it is not the point at infinity, and it is in the prime-order subgroup.
Tags: learn
Try next
- Read the Vault's Timing (medium)
- Recover the Hidden Suffix (medium)
- Recover Plaintext with a Padding Oracle (medium)