Safe Haskell | None |
---|---|
Language | Haskell2010 |
Secp256k1 cryptographic primitives.
Synopsis
- data PublicKey = PublicKey {}
- data SecretKey
- newtype Signature = Signature {}
- detSecretKey :: ByteString -> SecretKey
- toPublic :: SecretKey -> PublicKey
- publicKeyToBytes :: forall ba. ByteArray ba => PublicKey -> ba
- mkPublicKey :: ByteArrayAccess ba => ba -> Either CryptoParseError PublicKey
- publicKeyLengthBytes :: Integral n => n
- signatureToBytes :: ByteArray ba => Signature -> ba
- mkSignature :: ByteArray ba => ba -> Either CryptoParseError Signature
- signatureLengthBytes :: Integral n => n
- formatPublicKey :: PublicKey -> Text
- mformatPublicKey :: PublicKey -> MText
- parsePublicKey :: Text -> Either CryptoParseError PublicKey
- formatSignature :: Signature -> Text
- mformatSignature :: Signature -> MText
- parseSignature :: Text -> Either CryptoParseError Signature
- sign :: MonadRandom m => SecretKey -> ByteString -> m Signature
- checkSignature :: PublicKey -> Signature -> ByteString -> Bool
Cryptographic primitive types
Secp256k1 public cryptographic key.
PublicKey | |
|
Instances
Eq PublicKey Source # | |
Show PublicKey Source # | |
Generic PublicKey Source # | |
Arbitrary PublicKey Source # | |
NFData PublicKey Source # | |
Defined in Tezos.Crypto.Secp256k1 | |
Buildable PublicKey Source # | |
Defined in Tezos.Crypto.Secp256k1 | |
type Rep PublicKey Source # | |
Defined in Tezos.Crypto.Secp256k1 type Rep PublicKey = D1 ('MetaData "PublicKey" "Tezos.Crypto.Secp256k1" "morley-1.2.0-GFTR6HhJxtXGRHqcKAr6TU" 'False) (C1 ('MetaCons "PublicKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPublicKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 PublicKey) :*: S1 ('MetaSel ('Just "pkBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ByteString)))) |
Secp256k1 secret cryptographic key.
Secp256k1 cryptographic signature.
detSecretKey :: ByteString -> SecretKey Source #
Deterministicaly generate a secret key from seed.
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.
publicKeyLengthBytes :: Integral n => n Source #
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.
signatureLengthBytes :: Integral n => n Source #
Formatting and parsing
formatPublicKey :: PublicKey -> Text Source #
mformatPublicKey :: PublicKey -> MText Source #
formatSignature :: Signature -> Text Source #
mformatSignature :: Signature -> MText Source #
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.