morley-0.7.0: Developer tools for the Michelson Language

Safe HaskellNone
LanguageHaskell2010

Tezos.Crypto.Secp256k1

Contents

Description

Secp256k1 cryptographic primitives.

Synopsis

Cryptographic primitive types

data PublicKey Source #

Secp256k1 public cryptographic key.

Constructors

PublicKey 

Fields

  • unPublicKey :: PublicKey
     
  • pkBytes :: Maybe ByteString

    This is the hack we use to make serialization correct. Decoding is currently not implemented, so when we have to decode bytes we remember these bytes and produce some random public key.

    TODO (#18) remove it.

Instances
Eq PublicKey Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Show PublicKey Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Arbitrary PublicKey Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Buildable PublicKey Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Methods

build :: PublicKey -> Builder #

data SecretKey Source #

Secp256k1 secret cryptographic key.

Instances
Eq SecretKey Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Show SecretKey Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Arbitrary SecretKey Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

newtype Signature Source #

Secp256k1 cryptographic signature.

Constructors

Signature 
Instances
Eq Signature Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Show Signature Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Arbitrary Signature Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Buildable Signature Source # 
Instance details

Defined in Tezos.Crypto.Secp256k1

Methods

build :: Signature -> Builder #

detSecretKey :: ByteString -> SecretKey Source #

Deterministicaly generate a secret key from seed.

toPublic :: SecretKey -> PublicKey Source #

Create a public key from a secret key.

Raw bytes (no checksums, tags or anything)

publicKeyToBytes :: forall ba. ByteArray ba => PublicKey -> ba Source #

Convert a PublicKey to raw bytes.

TODO (#18): apparently it uses compressed SEC format as described in https://www.oreilly.com/library/view/programming-bitcoin/9781492031482/ch04.html However, it is not tested yet.

mkPublicKey :: ByteArrayAccess ba => ba -> Either CryptoParseError PublicKey Source #

Make a PublicKey from raw bytes.

TODO (#18): it should decode from compressed SEC format, but it's left for a future task, so for now we return a constant.

signatureToBytes :: ByteArray ba => Signature -> ba Source #

Convert a PublicKey to raw bytes.

TODO (#18): apparently a signature always has 64 bytes, so this format might be correct, but it is not tested.

mkSignature :: ByteArray ba => ba -> Either CryptoParseError Signature Source #

Make a Signature from raw bytes.

TODO (#18): apparently a signature always has 64 bytes, so this format might be correct, but it is not tested.

Formatting and parsing

Signing

sign :: MonadRandom m => SecretKey -> ByteString -> m Signature Source #

Sign a message using the secret key.

checkSignature :: PublicKey -> Signature -> ByteString -> Bool Source #

Check that a sequence of bytes has been signed with a given key.