bitcoin-hs-0.0.1: Partial implementation of the Bitcoin protocol (as of 2013)

Safe HaskellNone
LanguageHaskell98

Bitcoin.Crypto.EC.Key

Contents

Description

Elliptic Curve cryptography keys

Synopsis

private and public keys.

newtype PrivKey Source #

The private key is a random number in the interval [1,n-1] (n being secp256k1_n)

Constructors

PrivKey 

Fields

data PubKey Source #

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)

Constructors

FullPubKey !Integer !Integer

x y

ComprPubKey !Word8 !Integer

only x; the single byte encodes the parity of y (then we have the curve equation)

Instances

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...)

computePubKey :: PubKeyFormat -> PrivKey -> PubKey Source #

Computes the public key in the given format

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