Overview

7 Public Key Encryption and Digital Signatures: Using ECC

This chapter transitions from the RSA mindset to elliptic curve cryptography (ECC), explaining why ECC has become the practical default for modern systems. It highlights ECC’s central advantage—equivalent security with far smaller keys and better performance—making it ideal for smartphones, cloud workloads, and high-throughput services. The security foundation is the elliptic curve discrete logarithm problem, which is currently intractable; the text cautions that a breakthrough algorithm or sufficiently powerful quantum computers would endanger ECC, but neither poses an immediate, real-world threat today.

Readers are guided through how ECC is configured and used in practice. Only vetted, named curves should be selected, and both parties must use the same curve; the chapter discusses trade-offs such as security level, computational efficiency, implementation safety, and trust in the curve’s provenance, citing options like Curve25519, P-256, Curve448, and secp256k1. For confidentiality, ECC is applied in hybrid schemes where ECDH establishes a shared secret that feeds symmetric encryption (e.g., AES). Developers typically rely on protocols like TLS/SSH rather than implementing key agreement themselves. Concrete Java examples show key generation for a chosen curve, ECIES-based encryption/decryption via a provider, and ECDSA for signatures with SHA-256. The chapter stresses operational hygiene: use separate key pairs for encryption and signing, verify signatures before decryption, and expect tampering to be detected.

The comparison between RSA and ECC underscores that both remain viable, but ECC generally delivers superior performance and smaller keys (for example, ~256-bit ECC is comparable to 3072-bit RSA), a key reason adoption surged alongside mobile devices and remains attractive on servers. It notes the distinct failure modes—fast factoring would break RSA; a fast elliptic-curve discrete log algorithm would break ECC—and acknowledges future quantum risks while pointing toward emerging post-quantum cryptography. The practical takeaway is to prefer ECC for new applications—commonly Curve25519—use well-reviewed configurations, and adhere to organizational security standards when making final selections.

An example of an elliptic curve. This curve named Curve25519 is one of the most used with ECC algorithm.
ACME Inc. staff inspect returned merchandise and approve refunds using the warehouse management service. Once a day the payment service requests to the warehouse management service to return a JSON array containing the credit cards and amount to refunds. The payment service issues refund to customer credit card accounts.
Diffie-Helman algorithm computes the same result from the (payment private key, warehouse public key) and (warehouse private key, payment public key) key combinations.

Summary

  • Elliptic Curve Cryptography (ECC) is a modern alternative to RSA that provides the same level of security with smaller keys and better performance.
  • ECC is based on the elliptic curve discrete logarithm problem, which is very hard to solve with today’s computers.
  • Just like RSA, ECC will be broken by powerful quantum computers, but those are not yet a practical threat.
  • Different elliptic curves offer different levels of security, efficiency, and trust. Widely used safe curves include Curve25519, P-256, and secp256k1.
  • Elliptic Curve Diffie-Hellman (ECDH) is used to securely generate shared symmetric keys over insecure networks, and is the variant used in modern TLS.
  • Java supports ECC directly, and libraries like Bouncy Castle make it easier to encrypt and decrypt content using ECC.
  • ECC is also used for digital signatures through the Elliptic Curve Digital Signature Algorithm (ECDSA). Signing and encryption must use separate key pairs to avoid weakening security.
  • Digital signatures with ECC provide authenticity, integrity, and non-repudiation, while remaining more efficient than RSA for mobile devices and high-scale systems.
  • Today, most cryptographers recommend ECC over RSA for new applications because of its performance and security trade-offs.

FAQ

What is Elliptic Curve Cryptography (ECC) and why use it over RSA?ECC is a modern public-key cryptosystem that delivers comparable security to RSA with much smaller keys, leading to faster operations and lower CPU/battery use—especially important for mobile devices and high-throughput servers.
What mathematical problem makes ECC secure?The elliptic curve discrete logarithm problem (ECDLP). No efficient classical algorithm is known to solve it, which underpins ECC’s security.
Are all elliptic curves safe for cryptography? How do I choose one?No. Only use well-studied, standardized curves. Consider security level, computational efficiency, implementation safety, and trust in the curve designer. Common choices include Curve25519, Curve448, P-256, and secp256k1. Both sides must use the same curve.
How does ECDH relate to AES in real systems?Systems use a hybrid scheme: ECDH securely derives a shared secret, which is fed through a key-derivation function to produce an AES key; AES then encrypts the actual data. Protocols like TLS and SSH do this under the hood.
What’s the difference between classic Diffie-Hellman (DH) and Elliptic Curve Diffie-Hellman (ECDH)?DH works over large integers and needs very long keys; ECDH uses elliptic curves to achieve the same security with much shorter keys and better performance. Modern protocols (e.g., TLS 1.3) use ECDH.
How do I encrypt and decrypt with ECC in Java?Generate an EC key pair (KeyPairGenerator with ECGenParameterSpec for the chosen curve), then use an ECIES cipher (commonly via the Bouncy Castle provider) to encrypt with the recipient’s public key and decrypt with the corresponding private key.
How do I create and verify ECC digital signatures in Java?Use ECDSA: create a Signature instance like “SHA256withECDSA”, initSign with a private key to sign, and initVerify with the public key to verify. Keep a separate key pair for signing, distinct from encryption keys.
What ECC key size is roughly equivalent to a 3072-bit RSA key?About 256 bits of ECC security is commonly considered comparable to 3072-bit RSA.
Will quantum computers break ECC and RSA?Yes—sufficiently powerful quantum computers would break both. They are not yet an immediate practical threat, and post-quantum cryptography is being developed to replace them when needed.
Which curve should I prefer today?Curve25519 is a widely recommended default for new applications due to its security, efficiency, and robust scrutiny. Always follow your organization’s security standards and ensure both parties use the same curve.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Software Security for Developers ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Software Security for Developers ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Software Security for Developers ebook for free