bitcoin-keys-0.1: Bitcoin keys
Safe HaskellNone
LanguageHaskell2010

Bitcoin.Keys

Description

This module exports tools for working with Bitcoin keys.

Synopsis

Private

data Prv Source #

Private key.

Construct with parsePrv.

Instances

Instances details
Eq Prv Source # 
Instance details

Defined in Bitcoin.Keys.GHC

Methods

(==) :: Prv -> Prv -> Bool #

(/=) :: Prv -> Prv -> Bool #

Ord Prv Source # 
Instance details

Defined in Bitcoin.Keys.GHC

Methods

compare :: Prv -> Prv -> Ordering #

(<) :: Prv -> Prv -> Bool #

(<=) :: Prv -> Prv -> Bool #

(>) :: Prv -> Prv -> Bool #

(>=) :: Prv -> Prv -> Bool #

max :: Prv -> Prv -> Prv #

min :: Prv -> Prv -> Prv #

Show Prv Source #

Big-endian base-16.

Instance details

Defined in Bitcoin.Keys.GHC

Methods

showsPrec :: Int -> Prv -> ShowS #

show :: Prv -> String #

showList :: [Prv] -> ShowS #

parsePrv :: ByteString -> Maybe Prv Source #

Construct a Prv key from its raw 32 bytes (big-endian).

Returns Nothing if something is not satisfied.

Just == parsePrv . prvRaw

prvRaw :: Prv -> ByteString Source #

Obtain the 32 raw bytes inside a Prv (big-endian).

Just == parsePrv . prvRaw

prvToPub :: Prv -> Pub Source #

Obtain the Pub key for Prv.

Public

data Pub Source #

Public key.

Construct with parsePub.

Instances

Instances details
Eq Pub Source # 
Instance details

Defined in Bitcoin.Keys.GHC

Methods

(==) :: Pub -> Pub -> Bool #

(/=) :: Pub -> Pub -> Bool #

Ord Pub Source # 
Instance details

Defined in Bitcoin.Keys.GHC

Methods

compare :: Pub -> Pub -> Ordering #

(<) :: Pub -> Pub -> Bool #

(<=) :: Pub -> Pub -> Bool #

(>) :: Pub -> Pub -> Bool #

(>=) :: Pub -> Pub -> Bool #

max :: Pub -> Pub -> Pub #

min :: Pub -> Pub -> Pub #

Show Pub Source #

SEC compressed base-16.

Instance details

Defined in Bitcoin.Keys.GHC

Methods

showsPrec :: Int -> Pub -> ShowS #

show :: Pub -> String #

showList :: [Pub] -> ShowS #

parsePub :: ByteString -> Maybe Pub Source #

Construct a Pub key from either its compressed or uncompressed SEC-encoded bytes.

  • Compressed keys are 33 bytes. The leftmost byte is 0x02 if the y coordinate is even, or 0x03 if odd. The remaining 32 bytes are the big-endian encoded x coordinate.
  • Uncompressed keys are 65 bytes. The leftmost byte is 0x04. The next 32 bytes are the big-endian encoded x cordinate. The next 32 bytes are the big-endian encoded y coordinate.

Returns Nothing if something is not satisfied.

pubCompressed :: Pub -> ByteString Source #

Obtain the 33-bytes contatining the SEC compressed Public key.

Just == parsePub . pubCompressed

pubUncompressed :: Pub -> ByteString Source #

Obtain the 65-bytes contatining the SEC uncompressed Public key.

Just == parsePub . pubUncompressed

Tweak

data Tweak Source #

A 32-byte number used to modify a Pub or Prv using prvAddTweak or pubAddTweak.

Instances

Instances details
Eq Tweak Source # 
Instance details

Defined in Bitcoin.Keys.GHC

Methods

(==) :: Tweak -> Tweak -> Bool #

(/=) :: Tweak -> Tweak -> Bool #

Ord Tweak Source # 
Instance details

Defined in Bitcoin.Keys.GHC

Methods

compare :: Tweak -> Tweak -> Ordering #

(<) :: Tweak -> Tweak -> Bool #

(<=) :: Tweak -> Tweak -> Bool #

(>) :: Tweak -> Tweak -> Bool #

(>=) :: Tweak -> Tweak -> Bool #

max :: Tweak -> Tweak -> Tweak #

min :: Tweak -> Tweak -> Tweak #

Show Tweak Source #

Big-endian base-16.

Instance details

Defined in Bitcoin.Keys.GHC

Methods

showsPrec :: Int -> Tweak -> ShowS #

show :: Tweak -> String #

showList :: [Tweak] -> ShowS #

parseTweak :: ByteString -> Maybe Tweak Source #

Construct a Tweak from its raw 32 bytes (big-endian).

Returns Nothing if something is not satisfied.

pubAddTweak :: Tweak -> Pub -> Maybe Pub Source #

Tweak a Public key by adding Tweak times the generator to it.

Returns Nothing if the resulting Pub would be invalid.

pubAddTweak t . prvToPub == fmap prvToPub . prvAddTweak t

prvAddTweak :: Tweak -> Prv -> Maybe Prv Source #

Tweak a Prvate key by adding Tweak times the generator to it.

Returns Nothing if the resulting Prv would be invalid.

pubAddTweak t . prvToPub == fmap prvToPub . prvAddTweak t