Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module exports tools for working with Bitcoin keys.
Synopsis
- data Prv
- parsePrv :: ByteString -> Maybe Prv
- prvRaw :: Prv -> ByteString
- prvToPub :: Prv -> Pub
- data Pub
- parsePub :: ByteString -> Maybe Pub
- pubCompressed :: Pub -> ByteString
- pubUncompressed :: Pub -> ByteString
- data Tweak
- parseTweak :: ByteString -> Maybe Tweak
- pubAddTweak :: Tweak -> Pub -> Maybe Pub
- prvAddTweak :: Tweak -> Prv -> Maybe Prv
Private
Private key.
Construct with parsePrv
.
prvRaw :: Prv -> ByteString Source #
Public
Public key.
Construct with parsePub
.
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 they
coordinate is even, or0x03
if odd. The remaining 32 bytes are the big-endian encodedx
coordinate. - Uncompressed keys are 65 bytes. The leftmost byte is
0x04
. The next 32 bytes are the big-endian encodedx
cordinate. The next 32 bytes are the big-endian encodedy
coordinate.
Returns Nothing
if something is not satisfied.
pubCompressed :: Pub -> ByteString Source #
Obtain the 33-bytes contatining the SEC compressed Pub
lic key.
Just
==parsePub
.pubCompressed
pubUncompressed :: Pub -> ByteString Source #
Obtain the 65-bytes contatining the SEC uncompressed Pub
lic key.
Just
==parsePub
.pubUncompressed
Tweak
A 32-byte number used to modify a Pub
or Prv
using prvAddTweak
or pubAddTweak
.
parseTweak :: ByteString -> Maybe Tweak Source #
pubAddTweak :: Tweak -> Pub -> Maybe Pub Source #
Tweak a Pub
lic key by adding Tweak
times the generator to it.
Returns Nothing
if the resulting Pub
would be invalid.
pubAddTweak
t .prvToPub
== fmapprvToPub
.prvAddTweak
t
prvAddTweak :: Tweak -> Prv -> Maybe Prv Source #
Tweak a Prv
ate key by adding Tweak
times the generator to it.
Returns Nothing
if the resulting Prv
would be invalid.
pubAddTweak
t .prvToPub
== fmapprvToPub
.prvAddTweak
t