| License | BSD3 |
|---|---|
| Maintainer | Marcello Seri <marcello.seri@gmail.com> |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.Multihash.Weak
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 Weak module contains a weaker implementation of the
MultihashDigest type that allows to deserialize multihashes and to work with
different algorithms at the same type. The API interface is almost identical
to the one exposed by Multihash. The notable differences are:
- the hash algorithms is no longer a type
- the type returned by the multihash constructors is an
Either(seeweakMultihashandweakMultihashlazy) - there is a function
toWeakMultihashto deserialise multihashes
For additional informations refer to the README.md or the gihub repository.
- data WeakMultihashDigest
- data Base
- class Encodable a where
- encode :: IsString s => Base -> a -> Either String s
- encode' :: IsString s => Base -> a -> s
- check :: (IsString s, ConvertibleStrings s ByteString) => s -> a -> Either String Bool
- check' :: (IsString s, ConvertibleStrings s ByteString) => s -> a -> Bool
- class Checkable b where
- checkPayload :: (IsString s, ConvertibleStrings s ByteString) => s -> b -> Either String Bool
- checkPayload' :: (IsString s, ConvertibleStrings s ByteString) => s -> b -> Bool
- newtype Payload bs = Payload bs
- weakMultihash :: ByteArrayAccess bs => ByteString -> bs -> Either String WeakMultihashDigest
- weakMultihash' :: ByteArrayAccess bs => ByteString -> bs -> WeakMultihashDigest
- weakMultihashlazy :: ByteString -> ByteString -> Either String WeakMultihashDigest
- weakMultihashlazy' :: ByteString -> ByteString -> WeakMultihashDigest
- toWeakMultihash :: ByteString -> Either String WeakMultihashDigest
- checkWeakMultihash :: (IsString s, ConvertibleStrings s ByteString, ByteArrayAccess bs) => s -> bs -> Either String Bool
- checkWeakMultihash' :: (IsString s, ConvertibleStrings s ByteString, ByteArrayAccess bs) => s -> bs -> Bool
Weak Multihash Types
data WeakMultihashDigest Source
Weak Multihash Digest container
Base usable to encode the digest
class Encodable a where Source
Methods
encode :: IsString s => Base -> a -> Either String s Source
Safe encoder for Encodable.
encode' :: IsString s => Base -> a -> s Source
Unsafe encoder for Encodable.
Throws an error if there are encoding issues.
check :: (IsString s, ConvertibleStrings s ByteString) => s -> a -> Either String Bool Source
check' :: (IsString s, ConvertibleStrings s ByteString) => s -> a -> Bool Source
Unsafe version of check. Throws on encoding/decoding errors instead of returning an Either type.
Instances
| Encodable WeakMultihashDigest Source | |
| (HashAlgorithm a, Codable a) => Encodable (MultihashDigest a) Source |
class Checkable b where Source
Minimal complete definition
Methods
checkPayload :: (IsString s, ConvertibleStrings s ByteString) => s -> b -> Either String Bool Source
Safely check the correctness of an encoded Encodable against the
corresponding data.
checkPayload' :: (IsString s, ConvertibleStrings s ByteString) => s -> b -> Bool Source
Unsafe version of checkPayload.
Throws on encoding/decoding errors instead of returning an Either type.
Instances
| ByteArrayAccess bs => Checkable (Payload bs) Source | |
| ByteArrayAccess bs => Checkable (Payload bs) Source |
Newtype to allow the creation of a Checkable typeclass for
all ByteArrayAccess without recurring to UndecidableInstances.
Constructors
| Payload bs |
Instances
| ByteArrayAccess bs => Checkable (Payload bs) Source |
Weak Multihash Helpers
weakMultihash :: ByteArrayAccess bs => ByteString -> bs -> Either String WeakMultihashDigest Source
Helper to multihash a ByteArrayAccess (e.g. a ByteString) using a
supported hash algorithm. Uses hash for hashing.
weakMultihash' :: ByteArrayAccess bs => ByteString -> bs -> WeakMultihashDigest Source
Unsafe equivalent of weakMultihash. Throws on creation errors.
weakMultihashlazy :: ByteString -> ByteString -> Either String WeakMultihashDigest Source
Helper to multihash a lazy ByteString using a supported hash algorithm.
Uses hashlazy for hashing.
weakMultihashlazy' :: ByteString -> ByteString -> WeakMultihashDigest Source
Unsafe equivalent of weakMultihashlazy. Throws on creation errors.
toWeakMultihash :: ByteString -> Either String WeakMultihashDigest Source
Imports a multihash into a WeahMultihashDigest if possible.
checkWeakMultihash :: (IsString s, ConvertibleStrings s ByteString, ByteArrayAccess bs) => s -> bs -> Either String Bool Source
checkPayload wrapper for API retro-compatibility.
checkWeakMultihash' :: (IsString s, ConvertibleStrings s ByteString, ByteArrayAccess bs) => s -> bs -> Bool Source
Unsafe checkPayload wrapper for API retro-compatibility.