Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
duyuefeng0708
GitHub Repository: duyuefeng0708/Cryptography-From-First-Principle
Path: blob/main/foundations/06-elliptic-curves/README.md
483 views
unlisted

Module 06: Elliptic Curves

View on nbviewer

The same group theory, a different (and better) group. These curves power modern crypto.

Prerequisites

Learning Objectives

After completing this module you will:

  1. Understand the elliptic curve group law geometrically (over the reals) and algebraically (over finite fields)

  2. Implement point addition and scalar multiplication from scratch

  3. Apply ECDH for key exchange and ECDSA for digital signatures

  4. See why the EC discrete log problem is harder than the DLP in Z_p*, enabling shorter keys

Explore (SageMath Notebooks)

Work through these notebooks in order:

#NotebookWhat You'll Learn
aCurves over the RealsThe geometry of elliptic curves and the chord and tangent rule
bPoint Addition GeometryVisualizing the group operation step by step
cCurves over Finite FieldsMoving from continuous curves to discrete point sets
dGroup Structure and OrderHasse's theorem, point counting, and group structure
eScalar MultiplicationDouble and add algorithm for efficient scalar multiplication
fECDH and ECDSAKey exchange and signatures on elliptic curves

Implement (Rust)

Build these from scratch in rust/src/lib.rs:

#FunctionDescription
1point_addAdd two points on an elliptic curve over a prime field
2point_doubleDouble a point (tangent line case of the group law)
3scalar_mulScalar multiplication via double and add
4ecdh_shared_secretCompute an ECDH shared secret from a private key and public point
5ecdsa_verifyVerify an ECDSA signature given a message, signature, and public key

Run: cargo test -p elliptic-curves

Break

Try these attacks in the break/ folder:

  • ECDSA nonce reuse (the PlayStation 3 hack): recover the private key when the same nonce is used twice

  • Invalid curve attack: send a point not on the curve to extract bits of the secret

  • Small subgroup on the twist: exploit points on the quadratic twist to leak secret key information

Connect

See where this shows up in practice (in the connect/ folder):

  • ECDH (X25519) in TLS 1.3 is the default key exchange in modern HTTPS connections

  • ECDSA in Bitcoin/Ethereum, where every transaction is authorized by an ECDSA signature on secp256k1

  • Ed25519 in SSH is the recommended signing algorithm for SSH keys


Next: Module 07: Pairings