cryptonite-0.26: Cryptography Primitives sink

Crypto.PubKey.ECC.P256

Description

P256 support

Synopsis

# Documentation

data Scalar Source #

A P256 scalar

Instances
 Source # Instance detailsDefined in Crypto.PubKey.ECC.P256 Methods(==) :: Scalar -> Scalar -> Bool #(/=) :: Scalar -> Scalar -> Bool # Source # Instance detailsDefined in Crypto.PubKey.ECC.P256 MethodsshowsPrec :: Int -> Scalar -> ShowS #showList :: [Scalar] -> ShowS # Source # Instance detailsDefined in Crypto.PubKey.ECC.P256 Methodsrnf :: Scalar -> () # Source # Instance detailsDefined in Crypto.PubKey.ECC.P256 Methodslength :: Scalar -> Int #withByteArray :: Scalar -> (Ptr p -> IO a) -> IO a #copyByteArrayToPtr :: Scalar -> Ptr p -> IO () #

data Point Source #

A P256 point

Instances
 Source # Instance detailsDefined in Crypto.PubKey.ECC.P256 Methods(==) :: Point -> Point -> Bool #(/=) :: Point -> Point -> Bool # Source # Instance detailsDefined in Crypto.PubKey.ECC.P256 MethodsshowsPrec :: Int -> Point -> ShowS #show :: Point -> String #showList :: [Point] -> ShowS # Source # Instance detailsDefined in Crypto.PubKey.ECC.P256 Methodsrnf :: Point -> () #

# Point arithmetic

Get 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

pointDh :: ByteArray binary => Scalar -> Point -> binary Source #

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 * p

warning: variable time

Check if a Point is valid

Lift to curve a scalar

Using the curve generator as base point compute:

scalar * G

Convert a point to (x,y) Integers

Convert from (x,y) Integers to a point

pointToBinary :: ByteArray ba => Point -> ba Source #

Convert a point to a binary representation

Convert from binary to a valid point

Convert from binary to a point, possibly invalid

# Scalar arithmetic

scalarGenerate :: MonadRandom randomly => randomly Scalar Source #

Generate a randomly generated new scalar

The scalar representing 0

Check if the scalar is 0

a + b

Perform subtraction between two scalars

a - b

Give the inverse of the scalar

1 / a

warning: variable time

Compare 2 Scalar

convert a scalar from binary

scalarToBinary :: ByteArray ba => Scalar -> ba Source #

convert a scalar to binary

Convert from an Integer to a P256 Scalar

Convert from a P256 Scalar to an Integer