cryptonite-0.9: Cryptography Primitives sink

Safe Haskell | None
Language | Haskell2010

Crypto.PubKey.ECC.ECDSA

Description

WARNING: Signature operations may leak the private key. Signature verification should be safe.

Synopsis

- data Signature = Signature {
  - sign_r :: Integer
  - sign_s :: Integer
  }
- type PublicPoint = Point
- data PublicKey = PublicKey {
  - public_curve :: Curve
  - public_q :: PublicPoint
  }
- type PrivateNumber = Integer
- data PrivateKey = PrivateKey {
  - private_curve :: Curve
  - private_d :: PrivateNumber
  }
- data KeyPair = KeyPair Curve PublicPoint PrivateNumber
- toPublicKey :: KeyPair -> PublicKey
- toPrivateKey :: KeyPair -> PrivateKey
- signWith :: (ByteArrayAccess msg, HashAlgorithm hash) => Integer -> PrivateKey -> hash -> msg -> Maybe Signature
- sign :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m) => PrivateKey -> hash -> msg -> m Signature
- verify :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> PublicKey -> Signature -> msg -> Bool

# Documentation

data Signature

Represent a ECDSA signature namely R and S.

Constructors

Signature |
Fields sign_r :: Integer ECDSA r sign_s :: Integer ECDSA s

Instances

Eq Signature |
Data Signature |
Read Signature |
Show Signature |

type PublicPoint = Point

ECC Public Point

data PublicKey

ECDSA Public Key.

Constructors

PublicKey |
Fields public_curve :: Curve public_q :: PublicPoint

Instances

Eq PublicKey |
Data PublicKey |
Read PublicKey |
Show PublicKey |

type PrivateNumber = Integer

ECC Private Number

data PrivateKey

ECDSA Private Key.

Constructors

PrivateKey |
Fields private_curve :: Curve private_d :: PrivateNumber

Instances

Eq PrivateKey |
Data PrivateKey |
Read PrivateKey |
Show PrivateKey |

data KeyPair

ECDSA Key Pair.

Constructors

KeyPair Curve PublicPoint PrivateNumber |

Instances

Eq KeyPair |
Data KeyPair |
Read KeyPair |
Show KeyPair |

toPublicKey :: KeyPair -> PublicKey

Public key of a ECDSA Key pair.

toPrivateKey :: KeyPair -> PrivateKey

Private key of a ECDSA Key pair.

signWith

Arguments

:: (ByteArrayAccess msg, HashAlgorithm hash) |
=> Integer | k random number
-> PrivateKey | private key
-> hash | hash function
-> msg | message to sign
-> Maybe Signature |

Sign message using the private key and an explicit k number.

WARNING: Vulnerable to timing attacks.

sign :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m) => PrivateKey -> hash -> msg -> m Signature

Sign message using the private key.

WARNING: Vulnerable to timing attacks.

verify :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> PublicKey -> Signature -> msg -> Bool

Verify a bytestring using the public key.