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

Safe HaskellNone
LanguageHaskell98

Bitcoin.Crypto.EC.DSA

Contents

Description

Synopsis

Documentation

data Signature Source #

An ECDSA signature

Constructors

Signature 

newtype SignBits Source #

Two extra bits of information, used to recover the public key from the signatures.

Constructors

SignBits Word8 

signing, verifying, recovering

hashInteger :: Hash256 -> Integer Source #

The integer representation of a hash. We should take the left log2[secp256k1_n] bits, but both the hash and n has 256 bits, so we take the whole hash.

signMessageHashIO :: PrivKey -> Hash256 -> IO (SignBits, Signature) Source #

Signs the hash of a message (using the defaul random source - this probably shouldn't be used!)

signMessageHash :: RandomGen gen => PrivKey -> Hash256 -> gen -> ((SignBits, Signature), gen) Source #

Signs the hash of a message (given a random number source)

signMessageHashRFC6979 :: PrivKey -> Hash256 -> (SignBits, Signature) Source #

Deterministic signature as specified by RFC 6979: http://tools.ietf.org/html/rfc6979, in particular section 3.2

recoverPubKeyFromHash :: (PubKeyFormat, SignBits, Signature) -> Hash256 -> Maybe PubKey Source #

Recovers the public key from the (extended) signature and the hash of the message.

On the Word8 paramter: Bit 0 encodes whether the curve point R (which has x coordinate r from the signature) has even or odd y coordinate; and bit 1 encodes how to reconstruct the x coordinate from r.

some tests