morley-1.7.0: Developer tools for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Tezos.Crypto.Util

Contents

Description

Utilities shared by multiple cryptographic primitives.

Synopsis

Documentation

encodeBase58Check :: ByteString -> Text Source #

Encode a bytestring in Base58Check format.

decodeBase58Check :: Text -> Maybe ByteString Source #

Decode a bytestring from Base58Check format.

decodeBase58CheckWithPrefix :: ByteString -> Text -> Either B58CheckWithPrefixError ByteString Source #

Parse a base58check encoded value expecting some prefix. If the actual prefix matches the expected one, it's stripped of and the resulting payload is returned.

formatImpl :: ByteArrayAccess x => ByteString -> x -> Text Source #

Template for 'format*' functions.

parseImpl :: ByteString -> (ByteString -> Either CryptoParseError res) -> Text -> Either CryptoParseError res Source #

Template for 'parse*' functions.

firstRight :: NonEmpty (Either e a) -> Either e a Source #

Returns first encountered Right in a list. If there are none, returns arbitrary Left. It is useful to implement parsing.

deterministic :: ByteString -> MonadPseudoRandom ChaChaDRG a -> a Source #

Do randomized action using specified seed.

ECDSA Utils

mkSignature_ :: ByteArray ba => Curve -> ba -> Either CryptoParseError Signature Source #

Make a Signature from raw bytes.

mkSecretKey_ :: ByteArray ba => Curve -> ba -> KeyPair Source #

Make a SecretKey from raw bytes.

secretKeyToBytes_ :: ByteArray ba => KeyPair -> ba Source #

Convert a PublicKey to raw bytes.

signatureToBytes_ :: ByteArray ba => Curve -> Signature -> ba Source #

Convert a PublicKey to raw bytes.

mkPublicKey_ :: ByteArrayAccess ba => Curve -> ba -> Either CryptoParseError PublicKey Source #

Make a PublicKey from raw bytes.

Raw bytes are in the format of Compressed SEC Format. Refer to this article on how this is parsed: https://www.oreilly.com/library/view/programming-bitcoin/9781492031482/ch04.html

publicKeyToBytes_ :: forall ba. (ByteArray ba, HasCallStack) => Curve -> PublicKey -> ba Source #

Convert a PublicKey to raw bytes.