Skip to content
sjnamPublic

About

Exploring Elliptic Curves

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

A Field Trip through Elliptic Curves

A literate program in GWEB, written to teach myself elliptic curves and their cryptography. A single .gw source yields both the Go package elliptic and a typeset document (PDF, in Korean).

The trip has two destinations. One is Schoof's algorithm, which counts the points on a curve; the other is elliptic curve cryptography (ECDSA), which puts such curves to work. Along the way we pass through finite fields, polynomials and fast multiplication by NTT, division polynomials, and three attacks on the discrete logarithm.

Layers

Chapter (.gw) Contents
fp.gw Arithmetic in the finite field $F_p$ on uint64 ($p<2^{63}$)
poly.gw Polynomials in $F_p[x]$, with fast multiplication by three-prime NTT + CRT
curve.gw The group law on big.Int (with MetaPost figures)
divpoly.gw Division polynomials $\psi_n$, which capture the torsion points
schoof.gw Counting points with the characteristic equation of Frobenius
dlp.gw Shanks, Pollard $\rho$, Pohlig–Hellman
ecdsa.gw Signing and verification on secp256k1

The lower layers (finite fields, polynomials) live or die by speed, so they use uint64 and stay off the heap. The upper layers (curves, cryptography) must handle 256-bit numbers, so they use big.Int. Schoof bridges the two worlds, solving a problem about a large curve with fast arithmetic in a small field. That is what cut the time for a 60-bit curve from days, in an older big.Int-only implementation, to seconds.

Building

make          # tangle + typeset the document (PDF)
make tangle   # elliptic.gw -> elliptic.go, elliptic_test.go
make test     # go test ./...
make doc      # elliptic.pdf (luatex, for the Korean text; figures in MetaPost)
make twill    # elliptic-twill.pdf, a book-style edition with mini-indexes on each page, via gtwill
make clean    # remove generated files (the .gw sources stay)

Typesetting the document requires gweave/gtangle, luatex, and the luamplib package, which draws the MetaPost figures during the TeX run. The GWEB macros (kotexgweb.tex, gwebmac.tex) are found automatically in the installed texmf tree.

About

Exploring Elliptic Curves

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages