| License | BSD-style | 
|---|---|
| Maintainer | Vincent Hanquez <[email protected]> | 
| Stability | experimental | 
| Portability | unknown | 
| Safe Haskell | Safe-Inferred | 
| Language | Haskell2010 | 
Crypto.ECC
Description
Elliptic Curve Cryptography
Synopsis
- data Curve_P256R1 = Curve_P256R1
 - data Curve_P384R1 = Curve_P384R1
 - data Curve_P521R1 = Curve_P521R1
 - data Curve_X25519 = Curve_X25519
 - data Curve_X448 = Curve_X448
 - data Curve_Edwards25519 = Curve_Edwards25519
 - class EllipticCurve curve where
- type Point curve :: Type
 - type Scalar curve :: Type
 - curveGenerateScalar :: MonadRandom randomly => proxy curve -> randomly (Scalar curve)
 - curveGenerateKeyPair :: MonadRandom randomly => proxy curve -> randomly (KeyPair curve)
 - curveSizeBits :: proxy curve -> Int
 - encodePoint :: ByteArray bs => proxy curve -> Point curve -> bs
 - decodePoint :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Point curve)
 
 - class EllipticCurve curve => EllipticCurveDH curve where
- ecdhRaw :: proxy curve -> Scalar curve -> Point curve -> SharedSecret
 - ecdh :: proxy curve -> Scalar curve -> Point curve -> CryptoFailable SharedSecret
 
 - class (EllipticCurve curve, Eq (Point curve)) => EllipticCurveArith curve where
 - class (EllipticCurveArith curve, Eq (Scalar curve)) => EllipticCurveBasepointArith curve where
- curveOrderBits :: proxy curve -> Int
 - pointBaseSmul :: proxy curve -> Scalar curve -> Point curve
 - pointsSmulVarTime :: proxy curve -> Scalar curve -> Scalar curve -> Point curve -> Point curve
 - encodeScalar :: ByteArray bs => proxy curve -> Scalar curve -> bs
 - decodeScalar :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Scalar curve)
 - scalarToInteger :: proxy curve -> Scalar curve -> Integer
 - scalarFromInteger :: proxy curve -> Integer -> CryptoFailable (Scalar curve)
 - scalarAdd :: proxy curve -> Scalar curve -> Scalar curve -> Scalar curve
 - scalarMul :: proxy curve -> Scalar curve -> Scalar curve -> Scalar curve
 
 - data KeyPair curve = KeyPair {
- keypairGetPublic :: !(Point curve)
 - keypairGetPrivate :: !(Scalar curve)
 
 - newtype SharedSecret = SharedSecret ScrubbedBytes
 
Documentation
data Curve_P256R1 Source #
P256 Curve
also known as P256
Constructors
| Curve_P256R1 | 
Instances
data Curve_P384R1 Source #
Constructors
| Curve_P384R1 | 
Instances
data Curve_P521R1 Source #
Constructors
| Curve_P521R1 | 
Instances
data Curve_X25519 Source #
Constructors
| Curve_X25519 | 
Instances
data Curve_X448 Source #
Constructors
| Curve_X448 | 
Instances
data Curve_Edwards25519 Source #
Constructors
| Curve_Edwards25519 | 
Instances
class EllipticCurve curve where Source #
Associated Types
type Point curve :: Type Source #
Point on an Elliptic Curve
type Scalar curve :: Type Source #
Scalar in the Elliptic Curve domain
Methods
curveGenerateScalar :: MonadRandom randomly => proxy curve -> randomly (Scalar curve) Source #
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) Source #
Generate a new random keypair
curveSizeBits :: proxy curve -> Int Source #
Get the curve size in bits
encodePoint :: ByteArray bs => proxy curve -> Point curve -> bs Source #
Encode a elliptic curve point into binary form
decodePoint :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Point curve) Source #
Try to decode the binary form of an elliptic curve point
Instances
class EllipticCurve curve => EllipticCurveDH curve where Source #
Minimal complete definition
Methods
ecdhRaw :: proxy curve -> Scalar curve -> Point curve -> SharedSecret Source #
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 Source #
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.
Instances
class (EllipticCurve curve, Eq (Point curve)) => EllipticCurveArith curve where Source #
Methods
pointAdd :: proxy curve -> Point curve -> Point curve -> Point curve Source #
Add points on a curve
pointNegate :: proxy curve -> Point curve -> Point curve Source #
Negate a curve point
pointSmul :: proxy curve -> Scalar curve -> Point curve -> Point curve Source #
Scalar Multiplication on a curve
Instances
class (EllipticCurveArith curve, Eq (Scalar curve)) => EllipticCurveBasepointArith curve where Source #
Minimal complete definition
curveOrderBits, pointBaseSmul, encodeScalar, decodeScalar, scalarToInteger, scalarFromInteger, scalarAdd, scalarMul
Methods
curveOrderBits :: proxy curve -> Int Source #
Get the curve order size in bits
pointBaseSmul :: proxy curve -> Scalar curve -> Point curve Source #
Multiply a scalar with the curve base point
pointsSmulVarTime :: proxy curve -> Scalar curve -> Scalar curve -> Point curve -> Point curve Source #
Multiply the point p with s2 and add a lifted to curve value s1
encodeScalar :: ByteArray bs => proxy curve -> Scalar curve -> bs Source #
Encode an elliptic curve scalar into big-endian form
decodeScalar :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Scalar curve) Source #
Try to decode the big-endian form of an elliptic curve scalar
scalarToInteger :: proxy curve -> Scalar curve -> Integer Source #
Convert an elliptic curve scalar to an integer
scalarFromInteger :: proxy curve -> Integer -> CryptoFailable (Scalar curve) Source #
Try to create an elliptic curve scalar from an integer
scalarAdd :: proxy curve -> Scalar curve -> Scalar curve -> Scalar curve Source #
Add two scalars and reduce modulo the curve order
scalarMul :: proxy curve -> Scalar curve -> Scalar curve -> Scalar curve Source #
Multiply two scalars and reduce modulo the curve order
Instances
An elliptic curve key pair composed of the private part (a scalar), and the associated point.
Constructors
| KeyPair | |
Fields 
  | |