cryptonite-0.10: 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 Source

Represent a ECDSA signature namely R and S.

Constructors

Signature |

Fields

sign_r :: Integer

  ECDSA r

sign_s :: Integer

  ECDSA s

Instances

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

type PublicPoint = Point Source

ECC Public Point

data PublicKey Source

ECDSA Public Key.

Constructors

PublicKey |

Fields

public_curve :: Curve
public_q :: PublicPoint

Instances

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

type PrivateNumber = Integer Source

ECC Private Number

data PrivateKey Source

ECDSA Private Key.

Constructors

PrivateKey |

Fields

private_curve :: Curve
private_d :: PrivateNumber

Instances

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

data KeyPair Source

ECDSA Key Pair.

Constructors

KeyPair Curve PublicPoint PrivateNumber |

Instances

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

toPublicKey :: KeyPair -> PublicKey Source

Public key of a ECDSA Key pair.

toPrivateKey :: KeyPair -> PrivateKey Source

Private key of a ECDSA Key pair.

signWith Source

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 Source

Sign message using the private key.

WARNING: Vulnerable to timing attacks.

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

Verify a bytestring using the public key.