morley-1.20.0: Developer tools for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Morley.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

publicKeyLengthBytes_ :: (Integral n, CheckIntSubType Int n) => Curve -> n Source #

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

Make a KeyPair from raw bytes representing a secret key.

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.

signatureLengthBytes_ :: (Integral n, CheckIntSubType Int n) => Curve -> n Source #