cryptonite-0.24: Cryptography Primitives sink

Crypto.PubKey.ECC.Prim

Description

Elliptic Curve Arithmetic.

WARNING: These functions are vulnerable to timing attacks.

Synopsis

# Documentation

scalarGenerate :: MonadRandom randomly => Curve -> randomly PrivateNumber Source #

Generate a valid scalar for a specific Curve

WARNING: Vulnerable to timing attacks.

Elliptic Curve point doubling.

WARNING: Vulnerable to timing attacks.

This perform the following calculation: > lambda = (3 * xp ^ 2 + a) / 2 yp > xr = lambda ^ 2 - 2 xp > yr = lambda (xp - xr) - yp

With binary curve: > xp == 0 => P = O > otherwise => > s = xp + (yp / xp) > xr = s ^ 2 + s + a > yr = xp ^ 2 + (s+1) * xr

Elliptic curve point multiplication using the base

WARNING: Vulnerable to timing attacks.

Elliptic curve point multiplication (double and add algorithm).

WARNING: Vulnerable to timing attacks.

Elliptic curve double-scalar multiplication (uses Shamir's trick).

pointAddTwoMuls c n1 p1 n2 p2 == pointAdd c (pointMul c n1 p1)
(pointMul c n2 p2)

WARNING: Vulnerable to timing attacks.

Check if a point is the point at infinity.

check if a point is on specific curve

This perform three checks:

• x is not out of range
• y is not out of range
• the equation y^2 = x^3 + a*x + b (mod p) holds