Skip to content
pwnsy
cryptographyintermediate#ecc#elliptic-curve#public-key#ecdsa#ecdh

How Elliptic Curve Cryptography Works

A plain guide to ECC: why a 256-bit curve matches 3072-bit RSA, the discrete log trapdoor, and how ECDH and ECDSA are used.

RSA works, but it pays for its security with large keys, and large keys are expensive on phones, embedded devices, and busy servers doing thousands of handshakes a second. Elliptic curve cryptography reaches the same security level with keys roughly a tenth the size. That efficiency is why the modern web has quietly shifted to ECC, and why your browser's TLS connections now lean on curve-based key exchange and signatures.

ECC is public-key cryptography, same family as RSA, with the same public/private keypair structure. What changes is the underlying math problem. Instead of factoring large numbers, ECC leans on the geometry and algebra of an elliptic curve.

The curve, in plain terms

An elliptic curve is the set of points satisfying an equation of the form y^2 = x^3 + ax + b. Picture a smooth, symmetric curve. The useful fact is that you can define an addition operation on its points: take two points on the curve, draw a line through them, and where that line meets the curve again (reflected across the x-axis) gives you a third point. This "point addition" obeys clean algebraic rules.

Add a point to itself repeatedly and you get point multiplication: computing k * G, which means adding a base point G to itself k times. In real cryptography the curve is defined over a finite field, so the points are a large but finite set of integer coordinates, and the geometry becomes pure modular arithmetic. The picture is just an aid; the security comes from the number theory.

The trapdoor: point multiplication is a one-way street

Here is the operation that makes ECC work as a trapdoor:

  • Forward (easy): given a base point G and a secret number k, computing the point k * G is fast, even for enormous k.
  • Backward (hard): given G and the result point k * G, recovering the secret k is infeasible.

That backward problem is the elliptic curve discrete logarithm problem (ECDLP). Your private key is the secret number k. Your public key is the resulting point k * G. You publish the point, and no one can work back to your secret.

The reason ECC keys can be small is that the best known algorithms for the ECDLP are much less efficient than the best algorithms for factoring. Factoring has clever sub-exponential methods, so RSA needs big keys to stay ahead of them. The ECDLP has no such shortcut on well-chosen curves, so a much smaller key delivers the same resistance.

Why smaller keys match bigger RSA keys

Security is measured in "bits of security", the effective work an attacker must do. ECC packs far more security per key bit than RSA. The rough equivalences NIST publishes look like this.

Security levelECC key sizeRSA key size
112-bit224-bit curve2048-bit
128-bit256-bit curve3072-bit
192-bit384-bit curve7680-bit
256-bit521-bit curve15360-bit

A 256-bit elliptic curve key gives about 128 bits of security, the same as an RSA key twelve times longer. Smaller keys ripple into real advantages: faster key generation, faster signing and key agreement, smaller certificates and handshake messages, and lower power draw. On a battery-powered sensor or a phone, those savings are not cosmetic.

Bits of security, briefly

"128-bit security" means an attacker faces roughly 2^128 operations to break the key, which is comfortably out of reach for any foreseeable classical computer. Both RSA-3072 and a 256-bit curve hit this target. ECC just gets there with a much shorter key.

The two jobs: ECDH and ECDSA

ECC is used through a handful of named protocols. Two do most of the work.

ECDH: agreeing on a shared secret

ECDH (Elliptic Curve Diffie-Hellman) lets two parties who have never met derive a shared secret over a fully public channel. Each side has a keypair. Alice sends her public point to Bob, Bob sends his to Alice. Alice multiplies Bob's public point by her private key; Bob multiplies Alice's public point by his. The point-multiplication rules mean they both land on the exact same secret point, which an eavesdropper who saw only the two public points cannot compute. That shared value becomes the symmetric key for the session. The X25519 function (from Curve25519) is the modern standard for this. See How Diffie-Hellman Works.

ECDSA and EdDSA: signing

ECDSA (Elliptic Curve Digital Signature Algorithm) produces digital signatures. You sign a message hash with your private key, and anyone verifies it with your public key, proving authenticity and integrity. EdDSA (specifically Ed25519) is a newer signature scheme on a twisted Edwards curve that is faster, simpler, and more resistant to certain implementation mistakes. Modern systems increasingly prefer Ed25519. See How Digital Signatures Work.

ECDSA needs unique randomness per signature

ECDSA requires a fresh, unpredictable random value (the nonce) for every signature. Reusing that value across two signatures, or using a predictable one, leaks the private key outright. This exact mistake has broken real systems. Ed25519 avoids the trap by deriving the value deterministically, which is one reason to prefer it.

How to use ECC safely

As with RSA, you consume ECC through libraries. The decisions that matter are curve choice and key handling.

  1. Choose a vetted curve. X25519 and Ed25519 (Curve25519 family) are excellent modern defaults. The NIST P-256 and P-384 curves are widely supported and fine for interoperability. Never invent your own curve.
  2. Prefer 256-bit curves for general use, 384-bit for higher assurance. These map to 128-bit and 192-bit security respectively.
  3. Prefer Ed25519 for signatures where you can. It sidesteps the nonce-reuse landmine that has broken careless ECDSA deployments.
  4. Protect the private key. A private scalar in the wrong hands is a full compromise. Use hardware modules or a secrets manager.
  5. Use ECDH to establish a symmetric key, then let AES or ChaCha20 carry the data. ECC handles key agreement; a symmetric cipher does bulk encryption.

Curve mistakes, weak randomness, and side-channel leaks all surface as real vulnerabilities. You can see how elliptic-curve implementation flaws become tracked CVEs on our Exploit Intelligence dashboard, a reminder that the danger is usually in the implementation, not the curve.

The quantum caveat

ECC, like RSA, is vulnerable to a large fault-tolerant quantum computer. Shor's algorithm solves the discrete logarithm problem as well as factoring, so a working quantum machine would break ECDH and ECDSA together. Such a machine does not exist yet, and timelines are genuinely uncertain, so avoid confident predictions. The sensible move is to know where you depend on ECC and follow NIST's post-quantum standards as they roll out. See Post-Quantum Cryptography Explained.

For classical security today, ECC is the efficient choice. It gives you RSA-grade protection with keys small enough to run comfortably on the smallest devices, which is exactly why it now sits under most of your encrypted traffic.

Point addition, worked through slowly

The single operation that everything rests on is point addition, so it repays a slow walk. Take two distinct points on the curve, call them P and Q. Draw the straight line through them. Because the curve equation is a cubic, that line meets the curve in exactly one more place, a third point. Reflect that third point across the x-axis, and the reflection is defined to be the sum, written P + Q. The reflection step is what makes the operation behave like proper addition, giving it an identity element and inverses.

Two special cases complete the rules. When you add a point to itself, P + P, there is no second point to draw a line through, so instead you use the tangent line at P, find where that tangent meets the curve again, and reflect. This is point doubling, and it is the workhorse of fast multiplication. The other special case is the point at infinity, a single extra point that acts as zero: adding it to any point leaves that point unchanged, and a point plus its own reflection sums to it. With these rules the points of the curve form a clean algebraic structure, a group, which is exactly the setting number theory needs.

Over a finite field the picture of lines and curves disappears and the same rules become formulas in modular arithmetic. The coordinates are integers reduced modulo a large prime, and point addition becomes a fixed sequence of modular multiplications, additions, and one modular inversion. The geometry is only scaffolding for intuition. The security lives in the arithmetic over the field.

Scalar multiplication and why it is fast one way

Computing k * G means adding G to itself k times, and if you did it by literally adding G repeatedly it would take k steps, which is hopeless for a 256-bit k. The reason the forward direction is fast is an old trick called double-and-add. Write k in binary. Then walk the bits from the top, doubling the running point at every bit and adding G whenever the bit is one. A 256-bit k needs about 256 doublings and at most 256 additions, a few hundred operations rather than an astronomical number. That is why signing and key agreement are quick even though k is enormous.

The reverse direction has no such shortcut on a well-chosen curve. Given G and the point k * G, recovering k is the elliptic curve discrete logarithm problem, and the best known general algorithms take work on the order of the square root of the group size. For a 256-bit curve that is roughly 2 to the 128 operations, which is the same wall that makes 128-bit security meaningful. The gap between an easy forward path and an infeasible reverse path is the entire trapdoor.

Why square-root, and why it sets the key size

The strongest generic attacks on the discrete logarithm, such as the rho method, run in time roughly the square root of the number of points on the curve. So a curve with about 2 to the 256 points gives about 2 to the 128 work to break, which is why a 256-bit curve targets 128-bit security. Doubling the security level means doubling the curve size, a much gentler growth than RSA, where key sizes balloon because factoring has faster-than-square-root methods.

A worked example of ECDH, step by step

Following a key agreement through concrete steps shows why both sides land on the same secret and why an eavesdropper cannot.

Both parties agree in advance on the curve and a base point G, which are public and shared by everyone using the system. Alice picks a secret integer a, her private key, and computes the point a * G, her public key. Bob picks a secret integer b and computes b * G. They exchange the two public points over an open channel, so an eavesdropper now knows G, a * G, and b * G.

Now each side combines its own private key with the other's public key. Alice computes a * (b * G). Bob computes b * (a * G). Because scalar multiplication is associative and commutative in this group, both expressions equal (a * b) * G, the same point. That shared point, or a hash of its x-coordinate, becomes the symmetric key for the session.

The eavesdropper is stuck. To reach (a * b) * G they would need either a or b, but recovering a from a * G, or b from b * G, is the discrete logarithm problem, which is infeasible. Knowing the two public points is not enough to combine them into the shared secret without one of the private scalars. This is the same idea as classic Diffie-Hellman, moved from exponentiation modulo a prime onto point multiplication on a curve, which is why the smaller keys buy the same security.

Named curves and what sets them apart

In practice you never invent a curve; you pick a vetted, standardised one. Knowing the main families helps you read a configuration and choose sensibly.

CurveSecurity levelTypical usesNotes
Curve25519 (X25519)About 128-bitKey exchange in modern TLS, SSH, VPNsDesigned for speed and safe implementation
Ed25519About 128-bitSignatures in SSH, package signing, tokensDeterministic nonces, resists a common ECDSA flaw
NIST P-256About 128-bitTLS, general interoperabilityVery widely supported, required by many standards
NIST P-384About 192-bitHigher-assurance systemsCommon where policy demands more than 128-bit
NIST P-521About 256-bitHighest assuranceRare in practice, larger and slower

The split between the Curve25519 family and the NIST P-curves is the one to understand. The Curve25519 designs, X25519 for key exchange and Ed25519 for signatures, were built specifically to make fast, constant-time implementations easy and to remove sharp edges that have tripped up earlier code. The NIST P-curves are older, are mandated by many standards and compliance regimes, and are correct when implemented carefully, which is why they remain everywhere. For a new system with a free choice, X25519 and Ed25519 are the low-risk defaults; for interoperability with existing standards, the P-curves are the pragmatic pick.

How to detect and avoid ECC implementation mistakes

The math is sound, so real-world ECC failures come from implementation, and the recurring mistakes have concrete signatures worth recognising.

  • Reused or predictable ECDSA nonces. If the per-signature random value repeats across two signatures, or is even partially predictable, the private key can be recovered algebraically. The signal is any signing path that does not use a vetted deterministic or high-quality random nonce.
  • Missing point validation. Accepting a public point without checking that it actually lies on the intended curve invites invalid-curve attacks, where a crafted point drags the computation onto a weaker curve and leaks the private key. The signal is key-agreement code that never validates incoming points.
  • Non-constant-time operations. If scalar multiplication branches or does memory lookups that depend on secret bits, timing or cache measurements can recover the key. The signal is a hand-rolled implementation rather than a library written for constant-time behaviour.
  • Weak randomness for key generation. A private scalar drawn from a poor random source can be guessable. The signal is key generation that does not draw from a cryptographically secure generator.
  • Homegrown or exotic curves. A custom curve, or an obscure one chosen without scrutiny, may have structure that makes the discrete logarithm easier. The signal is any curve outside the small set of vetted standards.
Let a vetted library make these choices

Almost every serious ECC vulnerability traces to hand-written arithmetic, missing point checks, or bad randomness, not to a weakness in the curve. Use a well-reviewed cryptographic library, prefer X25519 and Ed25519 where you have a free choice, and never implement point arithmetic yourself. The safest ECC code is the code you did not write.

Common misconceptions

A few beliefs about ECC lead people astray.

"A 256-bit ECC key is weaker than a 2048-bit RSA key because it has fewer bits." The bit counts measure different things. RSA bits count the size of the modulus; ECC bits count the size of the curve. A 256-bit curve gives about 128-bit security, comparable to RSA-3072, because the discrete logarithm on a good curve has no sub-exponential shortcut. Comparing the raw key lengths across the two systems is meaningless.

"ECC is newer and therefore less trustworthy than RSA." Elliptic curve cryptography has been studied since the 1980s and standardised and deployed for decades. It underpins a large share of TLS, SSH, and modern messaging. It is mature, not experimental.

"Bigger curves are always better." Past your target security level, a larger curve mostly costs performance for protection you do not need. A 256-bit curve at 128-bit security is the general-purpose default; reach for 384-bit only when a policy or threat model calls for 192-bit security.

"ECC encrypts data directly." In practice ECC establishes a shared symmetric key through ECDH or proves authenticity through a signature. A symmetric cipher such as AES or ChaCha20 does the bulk encryption. ECC is used for key agreement and signatures, with the fast symmetric cipher carrying the payload.

Frequently asked questions

Why can ECC keys be so much smaller than RSA keys?

Because the problem underneath ECC, the elliptic curve discrete logarithm, has no known sub-exponential attack on a good curve, while factoring, which RSA relies on, does. The best generic attacks on ECC take roughly the square root of the group size, so a 256-bit curve reaches about 128-bit security, matching an RSA key many times longer.

Is ECC more secure than RSA?

At the same security level they are comparable for classical attackers. ECC reaches that level with smaller keys and faster operations, which is why modern systems favour it. Both fall to a large quantum computer, so neither is post-quantum.

What is the difference between ECDH and ECDSA?

ECDH is key agreement: two parties derive a shared secret over a public channel, which becomes a symmetric key. ECDSA is a signature scheme: you sign with a private key and anyone verifies with the public key, proving authenticity and integrity. One establishes a secret, the other proves origin.

Should I use Curve25519 or the NIST P-curves?

For a new system with a free choice, X25519 for key exchange and Ed25519 for signatures are excellent low-risk defaults, designed for speed and safe implementation. Where you must interoperate with standards that require them, the NIST P-256 and P-384 curves are widely supported and sound when implemented carefully.

Why is the ECDSA nonce so dangerous?

ECDSA needs a fresh, unpredictable random value for every signature. If that value repeats, or is predictable, the private key can be recovered from the signatures algebraically. Ed25519 avoids the trap by deriving the value deterministically from the key and message, which is one reason to prefer it.

Does a quantum computer break ECC?

A large, fault-tolerant quantum computer running Shor's algorithm would break both ECDH and ECDSA, because Shor solves the discrete logarithm as well as factoring. No such machine exists yet and timelines are uncertain, so the sensible step is to know where you depend on ECC and adopt NIST's post-quantum standards as they roll out.

Can I just make my own curve for extra safety through obscurity?

No. A homegrown curve may contain structure that makes the discrete logarithm easy, and you have no way to know without the scrutiny that standard curves have received. Obscurity is not security here. Use vetted curves only.

Does ECC handle bulk encryption of large files?

Not directly. In practice ECC agrees a shared symmetric key through ECDH, or proves authenticity with a signature, and a fast symmetric cipher such as AES or ChaCha20 encrypts the actual data. This split plays to each tool's strength: ECC for compact key agreement and signatures, symmetric ciphers for high-throughput encryption of the payload.

Sources & further reading

Sharetwitterlinkedin

Related guides