Path: blob/main/foundations/06-elliptic-curves/break/twist-subgroup-attack.ipynb
483 views
Break: Small Subgroup Attack on the Twist
Module 06 | Breaking Weak Parameters
Even with point validation, if the implementation does not fully check the curve equation, points on the quadratic twist can leak secret key information.
Why This Matters
Every elliptic curve over has a companion called the quadratic twist . An element either:
gives a point on (if is a square in ), or
gives a point on (if it is a non-square).
If a protocol uses only the -coordinate (as in X25519-style key exchange), and the implementation does not check which curve the -coordinate belongs to, an attacker can force computation on the twist.
The twist may have a different group order with small factors. Points of small order on the twist leak just as in the invalid curve attack.
This is why modern curves like Curve25519 are designed to be twist-secure: both the curve and its twist have near-prime order.
The Quadratic Twist
Given over , pick any non-square . The quadratic twist is:
By Hasse's theorem, for some . The twist order is:
Together: . If has near-prime order, the twist might not.
Step 1: Find Points of Small Order on the Twist
For each small prime factor of the twist order, we find a point on with by computing for a random point .
Step 2: Extract Secret Bits via Scalar Multiplication
In an -coordinate-only protocol (like X25519), the server receives an -coordinate and computes using only -coordinates. If the attacker sends an that corresponds to a twist point, the server unknowingly computes on the twist.
Since has order on the twist, depends only on . The attacker brute-forces the possibilities.
The Fix: Twist-Secure Curves
A curve is twist-secure if both and its quadratic twist have near-prime order (large prime factor in the group order).
Curve25519 (used in X25519 key exchange) was specifically designed for twist security:
| Order | Largest prime factor | |
|---|---|---|
| Curve25519 | is a 252-bit prime | |
| Twist of Curve25519 | is a 253-bit prime |
The cofactors (8 and 4) are tiny and harmless. The twist attack would require brute-forcing a 253-bit DLP, which is infeasible.
Other defenses:
Cofactor multiplication: Multiply received points by the cofactor to project into the prime-order subgroup, killing small-order components.
Full point validation: Check that lies on the correct curve , not the twist.
Exercises
secp256k1 twist: The Bitcoin curve secp256k1 has equation over a 256-bit prime field. Compute the twist order (you can use SageMath on a smaller analogue). Does secp256k1's twist have small factors? Is secp256k1 twist-secure?
Cofactor defense: If the server multiplies every received point by the cofactor before using it, explain why small-subgroup points are mapped to the identity.
Cost analysis: If the twist order has small factors , what is the total brute-force cost of the attack? Express it as and compare to a direct ECDLP attack of cost .
Summary
| Aspect | Detail |
|---|---|
| Vulnerability | Server processes points on the quadratic twist without validation |
| Root cause | -only protocols cannot distinguish curve points from twist points |
| Attack | Find small-order points on twist; extract per query; combine with CRT |
| Twist order | where is the trace of Frobenius |
| Twist-secure | Both and have near-prime order (e.g., Curve25519) |
| Fix | Use twist-secure curves; validate points; cofactor multiplication |
The twist attack teaches a subtle lesson: security depends not just on the curve you chose, but also on the curve you did not choose. The quadratic twist is an invisible companion that can undermine security if not accounted for in the curve selection and implementation.
Back to Module 06: Elliptic Curves