cryptonite-0.9: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | Experimental
Portability | Excellent
Safe Haskell | None
Language | Haskell2010

Crypto.PubKey.ECC.Types

Contents

- recommended curves definition

Description

references: https://tools.ietf.org/html/rfc5915

Synopsis

- data Curve
  - = CurveF2m CurveBinary
  - | CurveFP CurvePrime
- data Point
  - = Point Integer Integer
  - | PointO
- type PublicPoint = Point
- type PrivateNumber = Integer
- data CurveBinary = CurveBinary Integer CurveCommon
- data CurvePrime = CurvePrime Integer CurveCommon
- common_curve :: Curve -> CurveCommon
- curveSizeBits :: Curve -> Int
- ecc_fx :: CurveBinary -> Integer
- ecc_p :: CurvePrime -> Integer
- data CurveCommon = CurveCommon {
  - ecc_a :: Integer
  - ecc_b :: Integer
  - ecc_g :: Point
  - ecc_n :: Integer
  - ecc_h :: Integer
  }
- data CurveName
  - = SEC_p112r1
  - | SEC_p112r2
  - | SEC_p128r1
  - | SEC_p128r2
  - | SEC_p160k1
  - | SEC_p160r1
  - | SEC_p160r2
  - | SEC_p192k1
  - | SEC_p192r1
  - | SEC_p224k1
  - | SEC_p224r1
  - | SEC_p256k1
  - | SEC_p256r1
  - | SEC_p384r1
  - | SEC_p521r1
  - | SEC_t113r1
  - | SEC_t113r2
  - | SEC_t131r1
  - | SEC_t131r2
  - | SEC_t163k1
  - | SEC_t163r1
  - | SEC_t163r2
  - | SEC_t193r1
  - | SEC_t193r2
  - | SEC_t233k1
  - | SEC_t233r1
  - | SEC_t239k1
  - | SEC_t283k1
  - | SEC_t283r1
  - | SEC_t409k1
  - | SEC_t409r1
  - | SEC_t571k1
  - | SEC_t571r1
- getCurveByName :: CurveName -> Curve

# Documentation

data Curve

Define either a binary curve or a prime curve.

Constructors

CurveF2m CurveBinary | 𝔽(2^m)
CurveFP CurvePrime | 𝔽p

Instances

Eq Curve |
Data Curve |
Read Curve |
Show Curve |

data Point

Define a point on a curve.

Constructors

Point Integer Integer |
PointO | Point at Infinity

Instances

Eq Point |
Data Point |
Read Point |
Show Point |
NFData Point |

type PublicPoint = Point

ECC Public Point

type PrivateNumber = Integer

ECC Private Number

data CurveBinary

Define an elliptic curve in 𝔽(2^m). The firt parameter is the Integer representatioin of the irreducible polynomial f(x).

Constructors

CurveBinary Integer CurveCommon |

Instances

Eq CurveBinary |
Data CurveBinary |
Read CurveBinary |
Show CurveBinary |
NFData CurveBinary |

data CurvePrime

Define an elliptic curve in 𝔽p. The first parameter is the Prime Number.

Constructors

CurvePrime Integer CurveCommon |

Instances

Eq CurvePrime |
Data CurvePrime |
Read CurvePrime |
Show CurvePrime |

common_curve :: Curve -> CurveCommon

Parameters in common between binary and prime curves.

curveSizeBits :: Curve -> Int

get the size of the curve in bits

ecc_fx :: CurveBinary -> Integer

Irreducible polynomial representing the characteristic of a CurveBinary.

ecc_p :: CurvePrime -> Integer

Prime number representing the characteristic of a CurvePrime.

data CurveCommon

Define common parameters in a curve definition of the form: y^2 = x^3 + ax + b.

Constructors

CurveCommon |
Fields ecc_a :: Integer curve parameter a ecc_b :: Integer curve parameter b ecc_g :: Point base point ecc_n :: Integer order of G ecc_h :: Integer cofactor

Instances

Eq CurveCommon |
Data CurveCommon |
Read CurveCommon |
Show CurveCommon |

# recommended curves definition

data CurveName

Define names for known recommended curves.

Constructors

SEC_p112r1 |
SEC_p112r2 |
SEC_p128r1 |
SEC_p128r2 |
SEC_p160k1 |
SEC_p160r1 |
SEC_p160r2 |
SEC_p192k1 |
SEC_p192r1 |
SEC_p224k1 |
SEC_p224r1 |
SEC_p256k1 |
SEC_p256r1 |
SEC_p384r1 |
SEC_p521r1 |
SEC_t113r1 |
SEC_t113r2 |
SEC_t131r1 |
SEC_t131r2 |
SEC_t163k1 |
SEC_t163r1 |
SEC_t163r2 |
SEC_t193r1 |
SEC_t193r2 |
SEC_t233k1 |
SEC_t233r1 |
SEC_t239k1 |
SEC_t283k1 |
SEC_t283r1 |
SEC_t409k1 |
SEC_t409r1 |
SEC_t571k1 |
SEC_t571r1 |

Instances

Enum CurveName |
Eq CurveName |
Data CurveName |
Ord CurveName |
Read CurveName |
Show CurveName |

getCurveByName :: CurveName -> Curve

Get the curve definition associated with a recommended known curve name.