ECCHacks |
A gentle introduction to elliptic-curve cryptography |
|
The real clockThe 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[0]**2 + P[1]**2 == 1 # output: True This function (like your smartwatch) isn't perfectly accurate: the correct answer for P[1] would have been exactly 0.5, and the correct answer for P[0] 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. |