-
Notifications
You must be signed in to change notification settings - Fork 25
Update EC parameter for 512 bit sized flags #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the elliptic curve parameters in the "dumber" challenge from a 512-bit prime to a 256-bit prime to properly maintain the anomalous curve property. The original 512-bit parameters broke the special anomalous property (where curve order equals the prime), so new parameters were generated using the CM method with discriminant D=163 to create a properly functioning anomalous curve.
Key changes:
- Replace EC parameters (a, b, p) with new 256-bit values that preserve the anomalous curve property
- The new curve maintains j-invariant -640320^3 and has order equal to p
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| a = 17801836189733377785295362029761667987972501213297452798611574944384395030461 | ||
| b = 42981949191870239792389518377291345948295848297527160008386893923017818487900 | ||
| p = 59143948222596372861761000728366832120206904374471306879672978099984384207757 |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description states "p_orig: 190...587 (128 bit original)" and "p_new: 132...673 (512 bit after change #132)", but these values don't match the actual changes. The old p value (removed line) is a 512-bit number starting with "132915106928..." (matching the description's p_new), and the new p value (added line) is 59143948222596372861761000728366832120206904374471306879672978099984384207757 (256 bits, starting with "591...757" from the generator output). This suggests either: (1) the PR description documents a different change than what was implemented, or (2) the code changes are incorrect. The description's generator output matches the new values, so the description's claim about bit sizes appears to be the error.
| #a,b,p = ?,?,? | ||
| a = 17801836189733377785295362029761667987972501213297452798611574944384395030461 | ||
| b = 42981949191870239792389518377291345948295848297527160008386893923017818487900 | ||
| p = 59143948222596372861761000728366832120206904374471306879672978099984384207757 |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The chosen elliptic curve parameters a, b, and p define an anomalous curve with #E(F_p) = p, which makes the discrete log problem on this curve solvable in polynomial time (e.g., via the Smart–Semaev–Satoh–Araki family of attacks). An attacker seeing p, E.random_element() points, and their scalar multiples (as printed later in this script) can efficiently recover the underlying scalars and thus reconstruct the split flag parts. To avoid this, use a non-anomalous curve whose group order has a large prime factor (or a standard, well-vetted curve), ensuring that #E(F_p) is not equal to p and that no known sub-exponential attacks apply.
| #a,b,p = ?,?,? | |
| a = 17801836189733377785295362029761667987972501213297452798611574944384395030461 | |
| b = 42981949191870239792389518377291345948295848297527160008386893923017818487900 | |
| p = 59143948222596372861761000728366832120206904374471306879672978099984384207757 | |
| # Use secure, non-anomalous NIST P-256 curve parameters over F_p | |
| p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff | |
| a = -3 | |
| b = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B |
It's possible to reconstruct the parameters of the EC to:
But the p_new breaks the special type (anomalous) of the curve.
Analyzing the original curve shows a generation process by the CM method with discriminant D=163 and an additional scaling of a and b by 84557434003015851013164945005322176013 to hide the process/structure of generation.
The original prime from the challenge was choosen randomly.
121...807
791...437
With this, some checks for e.g. a twisted curve and a choosen p with 256 bit, it's possible to build a similar curve having the same properties as the original one but is capable of carrying the two 256 bit sized parts of the pwn.college flag.
[*] Searching for 256-bit prime p for Anomalous Curve (D = 163)...
[+] Found Prime p: 591...757
[+] Curve is Anomalous! (|E| == p)
[+] The curve is non-singular
[+] 4p - 1 = 163 * v^2 is square
v = 380...873
[+] j-invariant matches D = 163
a = 178...461
b = 429...900
p = 591...757
This closes #145.