A P256 scalar
Modulecrypton-2.1.7Haskell2010
Crypto.PubKey.ECC.P256
P256 support
- 2 types
- 30 values
- Packagecrypton-2.1.7
- Exports32
- LanguageHaskell2010
- LicenceBSD-3-Clause AND MIT AND ISC
- SourceP256.hs
A P256 point
Point arithmetic
15 declarationsGet the base point for the P256 Curve
Add a point to another point
Negate a point
Multiply a point by a scalar
warning: variable time
Similar to pointMul, serializing the x coordinate as binary. When scalar is multiple of point order the result is all zero.
multiply the point p with n2 and add a lifted to curve value @n1
n1 * G + n2 * pwarning: variable time
Check if a Point is valid
Check if a Point is the point at infinity
Lift to curve a scalar
Using the curve generator as base point compute:
scalar * GReturn the x coordinate as a Scalar if the point is not at infinity
Convert a point to (x,y) Integers
Convert from (x,y) Integers to a point
Convert a point to a binary representation
Convert from binary to a valid point
Convert from binary to a point, possibly invalid
Scalar arithmetic
15 declarationsGenerate a randomly generated new scalar
The scalar representing 0
The scalar representing the curve order
Check if the scalar is 0
Bring a scalar below the order of the curve
scalarFromInteger and scalarFromBinary take any 256 bits, so a scalar can arrive above the order; the arithmetic below wants it brought down first. Twice the order is more than 256 bits hold, so this is a single subtraction, taken or not through a mask rather than a branch.
Perform addition between two scalars
a + bPerform subtraction between two scalars
a - bPerform multiplication between two scalars
a * bGive the inverse of the scalar
1 / awarning: variable time
Give the inverse of the scalar using safe exponentiation
1 / aCompare 2 Scalar
convert a scalar from binary
convert a scalar to binary
Convert from an Integer to a P256 Scalar
Convert from a P256 Scalar to an Integer