|A gentle introduction
to elliptic-curve cryptography
The real clock
The clock is a curve in the plane. Specifically, the points on the clock are the points (x,y) satisfying the equation x2+y2=1. Here are some examples of points on the clock:
The following Python function, oclock, returns a clock point given the time (12, 6, 3, 9, 1.5, etc.):
import math def oclock(time): radians = time * math.pi / 6 return math.sin(radians),math.cos(radians) # example: P = oclock(2) print P # output: (0.8660254037844386, 0.5000000000000001) # math people write ^ for exponentiation # in python, ^ is xor, and ** is exponentiation print P**2 + P**2 == 1 # output: True
This function (like your smartwatch) isn't perfectly accurate: the correct answer for P would have been exactly 0.5, and the correct answer for P would have had infinitely many digits. Try comparing oclock(3) to oclock(15). Python isn't performing exact computations on real numbers; it's performing limited-precision computations on "floating-point numbers". Don't worry that this imprecision will cause problems for cryptography: soon we'll replace real numbers with exact integers.
Version: This is version 2014.12.27 of the realclock.html web page.