Asymmetric Encryption & Digital Signatures
Generate keypairs, sign/verify messages with separate public/private keys, perform key agreement, and compare RSA, ECDSA, and Ed25519 workflows. ECC-specific enrichment stays available when the selected algorithm supports it.
Key Pair Generation
Digital Signature Workflow
Key Agreement (ECDH)
Generate a shared secret using elliptic-curve Diffie–Hellman (ECDH). Real world: TLS, P2P handshakes, and wallets derive AEAD keys from ECDH via a KDF.
How ECDH Works: The Magic Math
Alice
Bob
Elliptic Curve: One Picture, Full Story
This graph is an intuition aid drawn over the real numbers. Real deployed curves such as P-256 work over finite fields, so the canvas illustrates point-addition ideas without claiming to be the literal production curve.
Curve + Keys
The formula y² = x³ + a·x + b creates a special curve because:
- For each x, you solve for y → get y = ±√(x³ + a·x + b)
- If the stuff under the square root is positive, you get two possible y values (one positive, one negative)
- Plotting all these (x, y) points forms a smooth, symmetric curve that loops
Why not just a line or circle? The curve's special shape gives us a mathematical "group" — meaning we can add points on the curve together using geometric rules, and the result is always another point on the same curve. This addition is what powers all the cryptography.
If you don't follow the math correctly, things break:
- Bad curve parameters (a, b): If chosen wrong → curve has sharp corners or self-intersects → point addition doesn't work → can't do cryptography
- G not on the curve: The generator point must be on the curve → if it's not → adding it doesn't follow the rules → public keys are invalid
- d = 0 or too big: Private key must be in valid range → if d = 0 → Q = 0·G = nothing → can't create signatures
- Predictable or reused randomness: If you use the same random number twice → attacker solves equations → private key gets stolen
Bottom line: Math has rules. Break them and the security disappears.
Generator G: Picked once by standards organizations. It's a specific point on the curve that, when you add it to itself repeatedly, cycles through a huge number of different points before repeating. Everyone uses the same G so we're all doing math on the same curve.
Private key d: You pick a completely random number between 1 and (curve order - 1). This randomness is critical:
- If d is predictable (like always using "12345") → attacker guesses it → your crypto is broken
- If d is biased (favors certain numbers) → attacker exploits the pattern → your crypto is broken
- If multiple people reuse the same d → their public keys are identical → easy to track/attack
Public key Q: Computed from d and G using point addition: Q = d·G. Because d is random, Q appears random too — but it's mathematically linked to d through the curve.
- The curve exists because y² = x³ + a·x + b creates a special mathematical structure where points can be added together, and the result is always on the curve.
- G (generator) is a fixed starting point that everyone agrees on — it's part of the standard.
- d (private key) must be truly random — if it's predictable, reused, or biased, attackers can break your crypto.
- Q (public key) = d·G — computed by "multiplying" the generator point by your private key using curve point addition.
- Breaking any rule → contradictions → security fails. Math has to be done exactly right, or it doesn't work.
ECDSA Nonce Reuse Concept Demo
ECDSA requires a unique random nonce per signature. If two signatures from the same key reuse the nonce (same r), the private key can be recovered. This section is a conceptual math walkthrough: WebCrypto does not let the browser force a real reused nonce with your live key, so the same-r failure is simulated to show why it is dangerous.
Address Derivation
In blockchain systems, addresses are derived from public keys via hashing + encoding (e.g., base58check). Real world: Bitcoin (base58check), Ethereum (EIP‑55 checksum). Addresses are shorter identifiers and avoid exposing the raw public key until first spend.