Safe Haskell | None |
---|---|
Language | Haskell98 |
Elliptic Curve cryptography keys
- newtype PrivKey = PrivKey {}
- data PubKey
- = FullPubKey !Integer !Integer
- | ComprPubKey !Word8 !Integer
- data PubKeyFormat
- generatePrivKeyIO :: IO PrivKey
- generatePrivKey :: RandomGen gen => gen -> (PrivKey, gen)
- pubKeyFormat :: PubKey -> PubKeyFormat
- computePubKey :: PubKeyFormat -> PrivKey -> PubKey
- computeFullPubKey :: PrivKey -> PubKey
- isValidPubKey :: PubKey -> Bool
- formatPubKey :: PubKeyFormat -> PubKey -> PubKey
- uncompressPubKey :: PubKey -> Maybe PubKey
- compressPubKey :: PubKey -> PubKey
private and public keys.
The private key is a random number in the interval [1,n-1] (n being secp256k1_n)
The public key (which is the point priv*G
on the curve, G
being the generator), either in long format (both coordinates)
or short format (x coordinate plus parity of y)
FullPubKey !Integer !Integer | |
ComprPubKey !Word8 !Integer | only x; the single byte encodes the parity of |
data PubKeyFormat Source #
Unfortunately there is this mess with compressed/uncompressed formats :(
generatePrivKeyIO :: IO PrivKey Source #
Generates a private key with the built-in random generator.
WARNING: this probably doesn't have enough entropy, use only for testing!
generatePrivKey :: RandomGen gen => gen -> (PrivKey, gen) Source #
Generates a private key using the supplied random generator.
WARNING! You are responsible for the random generator having enough entropy! (be careful not to have a constant seed, for example...)
pubKeyFormat :: PubKey -> PubKeyFormat Source #
computePubKey :: PubKeyFormat -> PrivKey -> PubKey Source #
Computes the public key in the given format
computeFullPubKey :: PrivKey -> PubKey Source #
isValidPubKey :: PubKey -> Bool Source #
formatPubKey :: PubKeyFormat -> PubKey -> PubKey Source #
Changes a pubkey to the given format
uncompressPubKey :: PubKey -> Maybe PubKey Source #
Uncompresses a public key. This may actually fail if there is no point (x,y) on the curve for any y.
compressPubKey :: PubKey -> PubKey Source #
Compresses a public key