cryptonite-0.29: Cryptography Primitives sink
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Crypto.ECC

Description

Elliptic Curve Cryptography

Synopsis

Documentation

data Curve_P256R1 #

P256 Curve

also known as P256

Constructors

Curve_P256R1 

Instances

Instances details
Data Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Curve_P256R1 -> c Curve_P256R1 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Curve_P256R1 #

toConstr :: Curve_P256R1 -> Constr #

dataTypeOf :: Curve_P256R1 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Curve_P256R1) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_P256R1) #

gmapT :: (forall b. Data b => b -> b) -> Curve_P256R1 -> Curve_P256R1 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Curve_P256R1 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_P256R1 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1 #

Show Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveBasepointArith Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveArith Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveDH Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurve Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_P256R1 #

type Scalar Curve_P256R1 #

EllipticCurveECDSA Curve_P256R1 # 
Instance details

Defined in Crypto.PubKey.ECDSA

type Point Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

type Scalar Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

data Curve_P384R1 #

Constructors

Curve_P384R1 

Instances

Instances details
Data Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Curve_P384R1 -> c Curve_P384R1 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Curve_P384R1 #

toConstr :: Curve_P384R1 -> Constr #

dataTypeOf :: Curve_P384R1 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Curve_P384R1) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_P384R1) #

gmapT :: (forall b. Data b => b -> b) -> Curve_P384R1 -> Curve_P384R1 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Curve_P384R1 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_P384R1 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1 #

Show Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveBasepointArith Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveArith Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveDH Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurve Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_P384R1 #

type Scalar Curve_P384R1 #

EllipticCurveECDSA Curve_P384R1 # 
Instance details

Defined in Crypto.PubKey.ECDSA

type Point Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

type Scalar Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

data Curve_P521R1 #

Constructors

Curve_P521R1 

Instances

Instances details
Data Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Curve_P521R1 -> c Curve_P521R1 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Curve_P521R1 #

toConstr :: Curve_P521R1 -> Constr #

dataTypeOf :: Curve_P521R1 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Curve_P521R1) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_P521R1) #

gmapT :: (forall b. Data b => b -> b) -> Curve_P521R1 -> Curve_P521R1 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Curve_P521R1 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_P521R1 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1 #

Show Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveBasepointArith Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveArith Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveDH Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurve Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_P521R1 #

type Scalar Curve_P521R1 #

EllipticCurveECDSA Curve_P521R1 # 
Instance details

Defined in Crypto.PubKey.ECDSA

type Point Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

type Scalar Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

data Curve_X25519 #

Constructors

Curve_X25519 

Instances

Instances details
Data Curve_X25519 # 
Instance details

Defined in Crypto.ECC

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Curve_X25519 -> c Curve_X25519 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Curve_X25519 #

toConstr :: Curve_X25519 -> Constr #

dataTypeOf :: Curve_X25519 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Curve_X25519) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_X25519) #

gmapT :: (forall b. Data b => b -> b) -> Curve_X25519 -> Curve_X25519 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Curve_X25519 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_X25519 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519 #

Show Curve_X25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurveDH Curve_X25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurve Curve_X25519 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_X25519 #

type Scalar Curve_X25519 #

type Point Curve_X25519 # 
Instance details

Defined in Crypto.ECC

type Scalar Curve_X25519 # 
Instance details

Defined in Crypto.ECC

data Curve_X448 #

Constructors

Curve_X448 

Instances

Instances details
Data Curve_X448 # 
Instance details

Defined in Crypto.ECC

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Curve_X448 -> c Curve_X448 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Curve_X448 #

toConstr :: Curve_X448 -> Constr #

dataTypeOf :: Curve_X448 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Curve_X448) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_X448) #

gmapT :: (forall b. Data b => b -> b) -> Curve_X448 -> Curve_X448 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Curve_X448 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_X448 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448 #

Show Curve_X448 # 
Instance details

Defined in Crypto.ECC

EllipticCurveDH Curve_X448 # 
Instance details

Defined in Crypto.ECC

EllipticCurve Curve_X448 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_X448 #

type Scalar Curve_X448 #

type Point Curve_X448 # 
Instance details

Defined in Crypto.ECC

type Scalar Curve_X448 # 
Instance details

Defined in Crypto.ECC

data Curve_Edwards25519 #

Constructors

Curve_Edwards25519 

Instances

Instances details
Data Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Curve_Edwards25519 -> c Curve_Edwards25519 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Curve_Edwards25519 #

toConstr :: Curve_Edwards25519 -> Constr #

dataTypeOf :: Curve_Edwards25519 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Curve_Edwards25519) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_Edwards25519) #

gmapT :: (forall b. Data b => b -> b) -> Curve_Edwards25519 -> Curve_Edwards25519 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Curve_Edwards25519 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_Edwards25519 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Curve_Edwards25519 -> m Curve_Edwards25519 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_Edwards25519 -> m Curve_Edwards25519 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Curve_Edwards25519 -> m Curve_Edwards25519 #

Show Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurveBasepointArith Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurveArith Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurve Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurveEdDSA Curve_Edwards25519 # 
Instance details

Defined in Crypto.PubKey.EdDSA

Associated Types

type CurveDigestSize Curve_Edwards25519 :: Nat #

type Point Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

type Scalar Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

type CurveDigestSize Curve_Edwards25519 # 
Instance details

Defined in Crypto.PubKey.EdDSA

class EllipticCurve curve where #

Associated Types

type Point curve :: Type #

Point on an Elliptic Curve

type Scalar curve :: Type #

Scalar in the Elliptic Curve domain

Methods

curveGenerateScalar :: MonadRandom randomly => proxy curve -> randomly (Scalar curve) #

Generate a new random scalar on the curve. The scalar will represent a number between 1 and the order of the curve non included

curveGenerateKeyPair :: MonadRandom randomly => proxy curve -> randomly (KeyPair curve) #

Generate a new random keypair

curveSizeBits :: proxy curve -> Int #

Get the curve size in bits

encodePoint :: ByteArray bs => proxy curve -> Point curve -> bs #

Encode a elliptic curve point into binary form

decodePoint :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Point curve) #

Try to decode the binary form of an elliptic curve point

Instances

Instances details
EllipticCurve Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurve Curve_X448 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_X448 #

type Scalar Curve_X448 #

EllipticCurve Curve_X25519 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_X25519 #

type Scalar Curve_X25519 #

EllipticCurve Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_P521R1 #

type Scalar Curve_P521R1 #

EllipticCurve Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_P384R1 #

type Scalar Curve_P384R1 #

EllipticCurve Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

Associated Types

type Point Curve_P256R1 #

type Scalar Curve_P256R1 #

class EllipticCurve curve => EllipticCurveDH curve where #

Minimal complete definition

ecdh

Methods

ecdhRaw :: proxy curve -> Scalar curve -> Point curve -> SharedSecret #

Generate a Diffie hellman secret value.

This is generally just the .x coordinate of the resulting point, that is not hashed.

use pointSmul to keep the result in Point format.

WARNING: Curve implementations may return a special value or an exception when the public point lies in a subgroup of small order. This function is adequate when the scalar is in expected range and contributory behaviour is not needed. Otherwise use ecdh.

ecdh :: proxy curve -> Scalar curve -> Point curve -> CryptoFailable SharedSecret #

Generate a Diffie hellman secret value and verify that the result is not the point at infinity.

This additional test avoids risks existing with function ecdhRaw. Implementations always return a CryptoError instead of a special value or an exception.

class (EllipticCurve curve, Eq (Point curve)) => EllipticCurveArith curve where #

Methods

pointAdd :: proxy curve -> Point curve -> Point curve -> Point curve #

Add points on a curve

pointNegate :: proxy curve -> Point curve -> Point curve #

Negate a curve point

pointSmul :: proxy curve -> Scalar curve -> Point curve -> Point curve #

Scalar Multiplication on a curve

Instances

Instances details
EllipticCurveArith Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurveArith Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveArith Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveArith Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

class (EllipticCurveArith curve, Eq (Scalar curve)) => EllipticCurveBasepointArith curve where #

Methods

curveOrderBits :: proxy curve -> Int #

Get the curve order size in bits

pointBaseSmul :: proxy curve -> Scalar curve -> Point curve #

Multiply a scalar with the curve base point

pointsSmulVarTime :: proxy curve -> Scalar curve -> Scalar curve -> Point curve -> Point curve #

Multiply the point p with s2 and add a lifted to curve value s1

encodeScalar :: ByteArray bs => proxy curve -> Scalar curve -> bs #

Encode an elliptic curve scalar into big-endian form

decodeScalar :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Scalar curve) #

Try to decode the big-endian form of an elliptic curve scalar

scalarToInteger :: proxy curve -> Scalar curve -> Integer #

Convert an elliptic curve scalar to an integer

scalarFromInteger :: proxy curve -> Integer -> CryptoFailable (Scalar curve) #

Try to create an elliptic curve scalar from an integer

scalarAdd :: proxy curve -> Scalar curve -> Scalar curve -> Scalar curve #

Add two scalars and reduce modulo the curve order

scalarMul :: proxy curve -> Scalar curve -> Scalar curve -> Scalar curve #

Multiply two scalars and reduce modulo the curve order

Instances

Instances details
EllipticCurveBasepointArith Curve_Edwards25519 # 
Instance details

Defined in Crypto.ECC

EllipticCurveBasepointArith Curve_P521R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveBasepointArith Curve_P384R1 # 
Instance details

Defined in Crypto.ECC

EllipticCurveBasepointArith Curve_P256R1 # 
Instance details

Defined in Crypto.ECC

data KeyPair curve #

An elliptic curve key pair composed of the private part (a scalar), and the associated point.

Constructors

KeyPair 

Fields

newtype SharedSecret #

Instances

Instances details
Eq SharedSecret # 
Instance details

Defined in Crypto.ECC

NFData SharedSecret # 
Instance details

Defined in Crypto.ECC

Methods

rnf :: SharedSecret -> () #

ByteArrayAccess SharedSecret # 
Instance details

Defined in Crypto.ECC