cardano-addresses
Copyright2020 Input Output (Hong Kong) Ltd. 2021-2022 Input Output Global Inc. (IOG) 2023-2025 Intersect
LicenseApache-2.0
Safe HaskellNone
LanguageHaskell2010

Cardano.Address.Crypto

Description

Cryptographic primitives used by cardano-addresses.

This module centralises all cryptographic dependencies so that alternative backends (e.g. libsodium, pure-Haskell, WebCrypto) can be provided by replacing this single module.

Hashing a public key into a credential

Cardano Shelley addresses contain a 28-byte Blake2b-224 hash of the verification key (or script). This is the credential that appears on-chain.

>>> import Cardano.Address.Crypto
>>> import qualified Data.ByteString as BS
>>> let pubKeyBytes = BS.replicate 32 0
>>> BS.length (blake2b224 pubKeyBytes)
28
>>> credentialHashSize
28

Generating a root key from a seed

Byron uses ccGenerate (derivation scheme 1), Icarus and Shelley use ccGenerateNew (derivation scheme 2 with PBKDF2).

>>> import Cardano.Address.Crypto
>>> import Data.ByteArray (ScrubbedBytes, convert)
>>> import qualified Data.ByteString as BS
>>> let seed = convert ("this is a seed that is at least 32 bytes long!!" :: BS.ByteString) :: ScrubbedBytes
>>> let xprv = ccGenerate seed (mempty :: ScrubbedBytes)
>>> let xpub = ccToXPub xprv
>>> BS.length (ccUnXPrv xprv)
128

Deriving child keys

Hardened derivation (index >= 0x80000000) requires the private key. Soft derivation can be done from the public key alone.

>>> import Cardano.Address.Crypto
>>> import Data.ByteArray (ScrubbedBytes, convert)
>>> import qualified Data.ByteString as BS
>>> let seed = convert ("this is a seed that is at least 32 bytes long!!" :: BS.ByteString) :: ScrubbedBytes
>>> let rootKey = ccGenerate seed (mempty :: ScrubbedBytes)
>>> let childKey = ccDeriveXPrv DerivationScheme2 (mempty :: ScrubbedBytes) rootKey 0x80000000
>>> let childPub = ccToXPub childKey
>>> BS.length (ccUnXPrv childKey)
128

Signing and verifying

>>> import Cardano.Address.Crypto
>>> import Data.ByteArray (ScrubbedBytes, convert)
>>> import qualified Data.ByteString as BS
>>> let seed = convert ("this is a seed that is at least 32 bytes long!!" :: BS.ByteString) :: ScrubbedBytes
>>> let xprv = ccGenerate seed (mempty :: ScrubbedBytes)
>>> let xpub = ccToXPub xprv
>>> let sig = ccSign (mempty :: ScrubbedBytes) xprv ("hello" :: BS.ByteString)
>>> ccVerify xpub ("hello" :: BS.ByteString) sig
True
Synopsis

Hashing

blake2b160 :: ByteArrayAccess a => a -> ByteString #

Blake2b-160 hash (20 bytes). Used for wallet ID computation from an extended root or account key.

blake2b224 :: ByteArrayAccess a => a -> ByteString #

Blake2b-224 hash (28 bytes), used for credential hashing.

blake2b256 :: ByteArrayAccess a => a -> ByteString #

Blake2b-256 hash (32 bytes). Used for Byron seed hashing (double CBOR-serialized entropy).

sha3_256 :: ByteArrayAccess a => a -> ByteString #

SHA3-256 hash. Used together with blake2b224 to compute Byron address roots: blake2b224 . sha3_256.

credentialHashSize :: Int #

Size in bytes of a Blake2b-224 credential hash (28).

Key derivation functions

pbkdf2HmacSha512 #

Arguments

:: (ByteArrayAccess password, ByteArrayAccess salt) 
=> Int

Number of iterations

-> Int

Desired output length in bytes

-> password 
-> salt 
-> ScrubbedBytes 

PBKDF2 with HMAC-SHA512. Used for:

  • Byron HD passphrase derivation (500 iterations, 32 bytes)
  • Icarus/Shelley mnemonic-to-seed (4096 iterations, 96 bytes)
  • Ledger hardware wallet BIP39 seed (2048 iterations, 64 bytes)

HMAC

hmacSha256 :: (ByteArrayAccess key, ByteArrayAccess msg) => key -> msg -> ByteString #

HMAC-SHA256. Used in Ledger hardware wallet key derivation for computing the chain code from the initial seed.

hmacSha512 :: (ByteArrayAccess key, ByteArrayAccess msg) => key -> msg -> ByteString #

HMAC-SHA512. Used in Ledger hardware wallet key derivation (SLIP-0010 master key generation with "ed25519 seed" as key).

Symmetric encryption

encryptChaChaPoly1305 #

Arguments

:: ByteArrayAccess key 
=> key 
-> ByteString

12-byte nonce

-> ByteString

Plaintext

-> CryptoFailable ByteString

Ciphertext with 16-byte authentication tag appended

ChaCha20-Poly1305 authenticated encryption. Used for encrypting Byron address derivation paths (account and address indices) with the HD passphrase.

The key must be 32 bytes, the nonce 12 bytes.

decryptChaChaPoly1305 #

Arguments

:: ByteArrayAccess key 
=> key 
-> ByteString

12-byte nonce

-> ByteString

Ciphertext with 16-byte authentication tag appended

-> CryptoFailable ByteString 

ChaCha20-Poly1305 authenticated decryption. Used for decrypting Byron address derivation paths when inspecting Byron addresses with a known root public key.

The key must be 32 bytes, the nonce 12 bytes.

Ed25519 curve operations

ed25519ScalarMult :: ByteString -> Maybe ByteString #

Ed25519 scalar multiplication: decode a scalar from a long bytestring and compute the corresponding public point. Used internally by xprvFromBytes to reconstruct the public key from a 96-byte extended private key.

Extended keys (re-exports from cardano-crypto)

ccXPrv :: ByteString -> Either String XPrv #

Construct an XPrv from raw bytes (128 bytes: 64 private + 32 public + 32 chain code).

ccXPub :: ByteString -> Either String XPub #

Construct an XPub from raw bytes (64 bytes: 32 public + 32 chain code).

ccUnXPrv :: XPrv -> ByteString #

Extract raw bytes from an XPrv (128 bytes: 64 prv + 32 pub + 32 cc).

ccToXPub :: XPrv -> XPub #

Derive the XPub from an XPrv.

ccSign :: ByteArrayAccess msg => ScrubbedBytes -> XPrv -> msg -> XSignature #

Sign a message with an XPrv.

ccVerify :: ByteArrayAccess msg => XPub -> msg -> XSignature -> Bool #

Verify a signature with an XPub.

ccGenerate :: ByteArrayAccess seed => seed -> ScrubbedBytes -> XPrv #

Generate an XPrv from a seed (legacy Byron method). The seed must be >= 32 bytes. Uses HMAC-SHA512 internally with repeated hashing until a valid Ed25519 extended key is found.

ccGenerateNew :: (ByteArrayAccess seed, ByteArrayAccess sndFactor) => seed -> sndFactor -> ScrubbedBytes -> XPrv #

Generate an XPrv from a seed with second factor (Icarus/Shelley method). Uses PBKDF2-HMAC-SHA512 (4096 iterations, 96 bytes) to stretch the mnemonic entropy. The second factor is an optional passphrase.

ccDeriveXPrv :: DerivationScheme -> ScrubbedBytes -> XPrv -> Word32 -> XPrv #

Derive a child XPrv from a parent XPrv. Supports both hardened (index >= 0x80000000) and soft derivation. DerivationScheme1 is used for Byron, DerivationScheme2 for Icarus/Shelley (BIP-44 compatible).

ccDeriveXPub :: DerivationScheme -> XPub -> Word32 -> Maybe XPub #

Derive a child XPub from a parent XPub. Only soft derivation is possible (index < 0x80000000). Returns Nothing if a hardened index is given.

Random

getEntropy :: Int -> IO ScrubbedBytes #

Obtain cryptographic entropy from the system. Used for BIP-39 entropy generation (genEntropy).

CRC32 (Byron address checksum)

crc32 :: CRC32 a => a -> Word32 #

Compute CRC32 checksum

Crypto error handling (re-exports from crypton)

data CryptoError #

Enumeration of all possible errors that can be found in this library

Instances

Instances details
Data CryptoError 
Instance details

Defined in Crypto.Error.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CryptoError -> c CryptoError #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CryptoError #

toConstr :: CryptoError -> Constr #

dataTypeOf :: CryptoError -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CryptoError) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CryptoError) #

gmapT :: (forall b. Data b => b -> b) -> CryptoError -> CryptoError #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CryptoError -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CryptoError -> r #

gmapQ :: (forall d. Data d => d -> u) -> CryptoError -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CryptoError -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError #

Enum CryptoError 
Instance details

Defined in Crypto.Error.Types

Exception CryptoError 
Instance details

Defined in Crypto.Error.Types

Show CryptoError 
Instance details

Defined in Crypto.Error.Types

Eq CryptoError 
Instance details

Defined in Crypto.Error.Types

data CryptoFailable a #

A simple Either like type to represent a computation that can fail

2 possibles values are:

  • CryptoPassed : The computation succeeded, and contains the result of the computation
  • CryptoFailed : The computation failed, and contains the cryptographic error associated

Instances

Instances details
MonadFailure CryptoFailable 
Instance details

Defined in Crypto.Error.Types

Associated Types

type Failure CryptoFailable 
Instance details

Defined in Crypto.Error.Types

Applicative CryptoFailable 
Instance details

Defined in Crypto.Error.Types

Functor CryptoFailable 
Instance details

Defined in Crypto.Error.Types

Methods

fmap :: (a -> b) -> CryptoFailable a -> CryptoFailable b #

(<$) :: a -> CryptoFailable b -> CryptoFailable a #

Monad CryptoFailable 
Instance details

Defined in Crypto.Error.Types

Show a => Show (CryptoFailable a) 
Instance details

Defined in Crypto.Error.Types

Eq a => Eq (CryptoFailable a) 
Instance details

Defined in Crypto.Error.Types

type Failure CryptoFailable 
Instance details

Defined in Crypto.Error.Types

eitherCryptoError :: CryptoFailable a -> Either CryptoError a #

Transform a CryptoFailable to an Either

Byte array utilities (re-exports from memory)

data ScrubbedBytes #

ScrubbedBytes is a memory chunk which have the properties of:

  • Being scrubbed after its goes out of scope.
  • A Show instance that doesn't actually show any content
  • A Eq instance that is constant time

Instances

Instances details
NormalForm ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Methods

toNormalForm :: ScrubbedBytes -> () #

NFData ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Methods

rnf :: ScrubbedBytes -> () #

Monoid ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Semigroup ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

IsString ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Show ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Eq ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Ord ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

ByteArray ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Methods

allocRet :: Int -> (Ptr p -> IO a) -> IO (a, ScrubbedBytes) #

ByteArrayAccess ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

class ByteArrayAccess ba #

Class to Access size properties and data of a ByteArray

Minimal complete definition

length, withByteArray

Instances

Instances details
ByteArrayAccess String 
Instance details

Defined in Data.ByteArray.Types

Methods

length :: String -> Int #

withByteArray :: String -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: String -> Ptr p -> IO () #

ByteArrayAccess ByteString 
Instance details

Defined in Data.ByteArray.Types

Methods

length :: ByteString -> Int #

withByteArray :: ByteString -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: ByteString -> Ptr p -> IO () #

ByteArrayAccess ScrambleIV 
Instance details

Defined in Cardano.Crypto.Encoding.Seed

Methods

length :: ScrambleIV -> Int #

withByteArray :: ScrambleIV -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: ScrambleIV -> Ptr p -> IO () #

ByteArrayAccess XPrv 
Instance details

Defined in Cardano.Crypto.Wallet

Methods

length :: XPrv -> Int #

withByteArray :: XPrv -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: XPrv -> Ptr p -> IO () #

ByteArrayAccess XSignature 
Instance details

Defined in Cardano.Crypto.Wallet

Methods

length :: XSignature -> Int #

withByteArray :: XSignature -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: XSignature -> Ptr p -> IO () #

ByteArrayAccess EncryptedKey 
Instance details

Defined in Cardano.Crypto.Wallet.Encrypted

ByteArrayAccess ChainCode 
Instance details

Defined in Cardano.Crypto.Wallet.Types

Methods

length :: ChainCode -> Int #

withByteArray :: ChainCode -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: ChainCode -> Ptr p -> IO () #

ByteArrayAccess PublicKey 
Instance details

Defined in Crypto.ECC.Ed25519Donna

Methods

length :: PublicKey -> Int #

withByteArray :: PublicKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: PublicKey -> Ptr p -> IO () #

ByteArrayAccess SecretKey 
Instance details

Defined in Crypto.ECC.Ed25519Donna

Methods

length :: SecretKey -> Int #

withByteArray :: SecretKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SecretKey -> Ptr p -> IO () #

ByteArrayAccess Signature 
Instance details

Defined in Crypto.ECC.Ed25519Donna

Methods

length :: Signature -> Int #

withByteArray :: Signature -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Signature -> Ptr p -> IO () #

ByteArrayAccess Seed 
Instance details

Defined in Crypto.Encoding.BIP39

Methods

length :: Seed -> Int #

withByteArray :: Seed -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Seed -> Ptr p -> IO () #

ByteArrayAccess Nonce 
Instance details

Defined in Crypto.Cipher.AESGCMSIV

Methods

length :: Nonce -> Int #

withByteArray :: Nonce -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Nonce -> Ptr p -> IO () #

ByteArrayAccess Nonce 
Instance details

Defined in Crypto.Cipher.ChaChaPoly1305

Methods

length :: Nonce -> Int #

withByteArray :: Nonce -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Nonce -> Ptr p -> IO () #

ByteArrayAccess XNonce 
Instance details

Defined in Crypto.Cipher.ChaChaPoly1305

Methods

length :: XNonce -> Int #

withByteArray :: XNonce -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: XNonce -> Ptr p -> IO () #

ByteArrayAccess State 
Instance details

Defined in Crypto.Cipher.RC4

Methods

length :: State -> Int #

withByteArray :: State -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: State -> Ptr p -> IO () #

ByteArrayAccess SharedSecret 
Instance details

Defined in Crypto.ECC

ByteArrayAccess Auth 
Instance details

Defined in Crypto.MAC.Poly1305

Methods

length :: Auth -> Int #

withByteArray :: Auth -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Auth -> Ptr p -> IO () #

ByteArrayAccess State 
Instance details

Defined in Crypto.MAC.Poly1305

Methods

length :: State -> Int #

withByteArray :: State -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: State -> Ptr p -> IO () #

ByteArrayAccess DhSecret 
Instance details

Defined in Crypto.PubKey.Curve25519

Methods

length :: DhSecret -> Int #

withByteArray :: DhSecret -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: DhSecret -> Ptr p -> IO () #

ByteArrayAccess PublicKey 
Instance details

Defined in Crypto.PubKey.Curve25519

Methods

length :: PublicKey -> Int #

withByteArray :: PublicKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: PublicKey -> Ptr p -> IO () #

ByteArrayAccess SecretKey 
Instance details

Defined in Crypto.PubKey.Curve25519

Methods

length :: SecretKey -> Int #

withByteArray :: SecretKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SecretKey -> Ptr p -> IO () #

ByteArrayAccess DhSecret 
Instance details

Defined in Crypto.PubKey.Curve448

Methods

length :: DhSecret -> Int #

withByteArray :: DhSecret -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: DhSecret -> Ptr p -> IO () #

ByteArrayAccess PublicKey 
Instance details

Defined in Crypto.PubKey.Curve448

Methods

length :: PublicKey -> Int #

withByteArray :: PublicKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: PublicKey -> Ptr p -> IO () #

ByteArrayAccess SecretKey 
Instance details

Defined in Crypto.PubKey.Curve448

Methods

length :: SecretKey -> Int #

withByteArray :: SecretKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SecretKey -> Ptr p -> IO () #

ByteArrayAccess SharedKey 
Instance details

Defined in Crypto.PubKey.DH

Methods

length :: SharedKey -> Int #

withByteArray :: SharedKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SharedKey -> Ptr p -> IO () #

ByteArrayAccess Scalar 
Instance details

Defined in Crypto.PubKey.ECC.P256

Methods

length :: Scalar -> Int #

withByteArray :: Scalar -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Scalar -> Ptr p -> IO () #

ByteArrayAccess PublicKey 
Instance details

Defined in Crypto.PubKey.Ed25519

Methods

length :: PublicKey -> Int #

withByteArray :: PublicKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: PublicKey -> Ptr p -> IO () #

ByteArrayAccess SecretKey 
Instance details

Defined in Crypto.PubKey.Ed25519

Methods

length :: SecretKey -> Int #

withByteArray :: SecretKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SecretKey -> Ptr p -> IO () #

ByteArrayAccess Signature 
Instance details

Defined in Crypto.PubKey.Ed25519

Methods

length :: Signature -> Int #

withByteArray :: Signature -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Signature -> Ptr p -> IO () #

ByteArrayAccess PublicKey 
Instance details

Defined in Crypto.PubKey.Ed448

Methods

length :: PublicKey -> Int #

withByteArray :: PublicKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: PublicKey -> Ptr p -> IO () #

ByteArrayAccess SecretKey 
Instance details

Defined in Crypto.PubKey.Ed448

Methods

length :: SecretKey -> Int #

withByteArray :: SecretKey -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SecretKey -> Ptr p -> IO () #

ByteArrayAccess Signature 
Instance details

Defined in Crypto.PubKey.Ed448

Methods

length :: Signature -> Int #

withByteArray :: Signature -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Signature -> Ptr p -> IO () #

ByteArrayAccess Seed 
Instance details

Defined in Crypto.Random

Methods

length :: Seed -> Int #

withByteArray :: Seed -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Seed -> Ptr p -> IO () #

ByteArrayAccess Bytes 
Instance details

Defined in Data.ByteArray.Bytes

Methods

length :: Bytes -> Int #

withByteArray :: Bytes -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Bytes -> Ptr p -> IO () #

ByteArrayAccess ScrubbedBytes 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

PrimType ty => ByteArrayAccess (Block ty) 
Instance details

Defined in Data.ByteArray.Types

Methods

length :: Block ty -> Int #

withByteArray :: Block ty -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Block ty -> Ptr p -> IO () #

PrimType ty => ByteArrayAccess (UArray ty) 
Instance details

Defined in Data.ByteArray.Types

Methods

length :: UArray ty -> Int #

withByteArray :: UArray ty -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: UArray ty -> Ptr p -> IO () #

ByteArrayAccess (MiyaguchiPreneel a) 
Instance details

Defined in Crypto.ConstructHash.MiyaguchiPreneel

ByteArrayAccess (MutableContext a) 
Instance details

Defined in Crypto.Hash.IO

Methods

length :: MutableContext a -> Int #

withByteArray :: MutableContext a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: MutableContext a -> Ptr p -> IO () #

ByteArrayAccess (Context a) 
Instance details

Defined in Crypto.Hash.Types

Methods

length :: Context a -> Int #

withByteArray :: Context a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: Context a -> Ptr p -> IO () #

ByteArrayAccess (Digest a) 
Instance details

Defined in Crypto.Hash.Types

Methods

length :: Digest a -> Int #

withByteArray :: Digest a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: Digest a -> Ptr p -> IO () #

ByteArrayAccess (PRK a) 
Instance details

Defined in Crypto.KDF.HKDF

Methods

length :: PRK a -> Int #

withByteArray :: PRK a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: PRK a -> Ptr p -> IO () #

ByteArrayAccess (CMAC a) 
Instance details

Defined in Crypto.MAC.CMAC

Methods

length :: CMAC a -> Int #

withByteArray :: CMAC a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: CMAC a -> Ptr p -> IO () #

ByteArrayAccess (HMAC a) 
Instance details

Defined in Crypto.MAC.HMAC

Methods

length :: HMAC a -> Int #

withByteArray :: HMAC a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: HMAC a -> Ptr p -> IO () #

ByteArrayAccess (KMAC a) 
Instance details

Defined in Crypto.MAC.KMAC

Methods

length :: KMAC a -> Int #

withByteArray :: KMAC a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: KMAC a -> Ptr p -> IO () #

ByteArrayAccess (KeyedBlake2 a) 
Instance details

Defined in Crypto.MAC.KeyedBlake2

Methods

length :: KeyedBlake2 a -> Int #

withByteArray :: KeyedBlake2 a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: KeyedBlake2 a -> Ptr p -> IO () #

ByteArrayAccess (SecretKey curve) 
Instance details

Defined in Crypto.PubKey.EdDSA

Methods

length :: SecretKey curve -> Int #

withByteArray :: SecretKey curve -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SecretKey curve -> Ptr p -> IO () #

(KnownNat n, PrimType ty, Countable ty n) => ByteArrayAccess (BlockN n ty) 
Instance details

Defined in Data.ByteArray.Types

Methods

length :: BlockN n ty -> Int #

withByteArray :: BlockN n ty -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: BlockN n ty -> Ptr p -> IO () #

ByteArrayAccess (PublicKey curve hash) 
Instance details

Defined in Crypto.PubKey.EdDSA

Methods

length :: PublicKey curve hash -> Int #

withByteArray :: PublicKey curve hash -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: PublicKey curve hash -> Ptr p -> IO () #

ByteArrayAccess (Signature curve hash) 
Instance details

Defined in Crypto.PubKey.EdDSA

Methods

length :: Signature curve hash -> Int #

withByteArray :: Signature curve hash -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: Signature curve hash -> Ptr p -> IO () #

(ByteArrayAccess ba, KnownNat n) => ByteArrayAccess (SizedByteArray n ba) 
Instance details

Defined in Data.ByteArray.Sized

Methods

length :: SizedByteArray n ba -> Int #

withByteArray :: SizedByteArray n ba -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: SizedByteArray n ba -> Ptr p -> IO () #

convert :: (ByteArrayAccess bin, ByteArray bout) => bin -> bout #

Convert a bytearray to another type of bytearray