bitcoin-hs-0.0.1: Partial implementation of the Bitcoin protocol (as of 2013)

Safe HaskellNone




Using (weighted) projective coordinates on the curve we can maybe avoid the division bottleneck.

Based on: Chae Hoon Lim, Hyo Sun Hwang: Fast implementation of Elliptic Curve arithmetic in GF(p^n).

We will use (2,3,1) weighting, and a constant factor of 2 in Y:

x = X/Z^2 
y = Y/(2*Z^3)
z = 1

Thus the curve equation y^2 = x^3 + 7 becomes

Y^2/4 = X^3 + 7*Z^6

and then the infinity point on the curve is (1,2,0).



data ECProj Source #

Note: the Eq instance is equality of all coordinates, not equality on the projective plane (for that, use "(=~=)" instead)


ECProj !Fp !Fp !Fp 

Num/Eq instances

(=~=) :: ECProj -> ECProj -> Bool infix 4 Source #

hs_addECP :: ECProj -> ECProj -> ECProj Source #

Addition in the elliptic curve (or multiplication if you prefer to think it as a multiplicative group)

hs_dblECP :: ECProj -> ECProj Source #

Doubling a point in the elliptic curve (multiplication by the integer 2)

invECP :: ECProj -> ECProj Source #

Inverse (negation) in the elliptic curve

hs_mulECP :: ECProj -> Integer -> ECProj Source #

Multiplication by a positive integer (or exponentiation, if you think multiplicatively)