crypto-multihash-0.2.0.0: Multihash library on top of cryptonite crypto library

LicenseBSD3
MaintainerMarcello Seri <marcello.seri@gmail.com>
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Crypto.Multihash

Contents

Description

Multihash library built on top of haskell cryptonite crypto package Multihash is a protocol for encoding the hash algorithm and digest length at the start of the digest, see the official multihash poroposal github repo.

The library re-exports the needed types and typclasses from Algorithms namely HashAlgorithm, SHA1, SHA256, SHA512, SHA3_512, SHA3_384, SHA3_256, SHA3_224, Blake2b_512, Blake2s_256.

For additional informations refer to the README.md or the gihub repository.

Synopsis

Multihash Types

data Base Source #

Base usable to encode the digest

Constructors

Base2

Binary form

Base16

Hex encoding

Base32

Not yet implemented. Waiting for this issue to resolve

Base58

Bitcoin base58 encoding

Base64

Base64 encoding

Instances

Eq Base Source # 

Methods

(==) :: Base -> Base -> Bool #

(/=) :: Base -> Base -> Bool #

Show Base Source # 

Methods

showsPrec :: Int -> Base -> ShowS #

show :: Base -> String #

showList :: [Base] -> ShowS #

class Codable a where Source #

Codable hash algorithms are the algorithms supported for multihashing

Minimal complete definition

toCode

Methods

toCode :: a -> Int Source #

Returns the first byte for the head of the multihash digest

Multihash helpers

encode' :: (HashAlgorithm a, Codable a, Show a) => Base -> MultihashDigest a -> String Source #

Encoder for MultihashDigest. Throws an error if the MultihashDigest length field does not match the Digest length.

multihash :: (HashAlgorithm a, Codable a, ByteArrayAccess bs) => a -> bs -> MultihashDigest a Source #

Helper to multihash a ByteArrayAccess (e.g. a ByteString) using a supported hash algorithm.

multihashlazy :: (HashAlgorithm a, Codable a) => a -> ByteString -> MultihashDigest a Source #

Helper to multihash a lazy ByteString using a supported hash algorithm.

checkMultihash :: ByteArrayAccess bs => ByteString -> bs -> Either String Bool Source #

Check the correctness of an encoded MultihashDigest against the data it is supposed to have hashed, passed as a ByteArrayAccess (e.g. a BinaryString).

Re-exported types

class HashAlgorithm a #

Class representing hashing algorithms.

The interface presented here is update in place and lowlevel. the Hash module takes care of hidding the mutable interface properly.

Instances

HashAlgorithm SHA3_224 
HashAlgorithm SHA3_256 
HashAlgorithm SHA3_384 
HashAlgorithm SHA3_512 
HashAlgorithm SHA512 
HashAlgorithm SHA256 
HashAlgorithm SHA1 
HashAlgorithm Blake2b_512 
HashAlgorithm Blake2s_224 
HashAlgorithm Blake2s_256 

data SHA1 :: * #

SHA1 cryptographic hash algorithm

Constructors

SHA1