cryptoids-class-0.0.0: Typeclass-based interface to cryptoids

Safe HaskellNone



When unambiguous it can be convenient to automatically infer the namespace based on the plaintext type.

Consider using newtype wrappers in order to do so.



class MonadThrow m => MonadCrypto (m :: * -> *) where Source #

Class of monads granting reader access to a key and allowing for failure during cryptographic operations

This formulation is weaker than MonadReader key (from mtl) in that it does not require local.

Minimal complete definition


Associated Types

type MonadCryptoKey m :: * Source #


cryptoIDKey :: (MonadCryptoKey m -> m a) -> m a Source #

type family CryptoIDNamespace (ciphertext :: *) (plaintext :: *) :: Symbol Source #

Type family of namespaces associated to certain plaintext-types (parameterized over ciphertext for completeness)

type HasCryptoID ciphertext plaintext = HasCryptoID (CryptoIDNamespace ciphertext plaintext) ciphertext plaintext Source #

HasCryptoID reformulated to utilize CryptoIDNamespace

type CryptoID ciphertext plaintext = CryptoID (CryptoIDNamespace ciphertext plaintext) ciphertext Source #

CryptoID reformulated to utilize CryptoIDNamespace

CryptoID :: a -> CryptoID namespace a #

ciphertext :: CryptoID namespace a -> a #

encrypt :: HasCryptoID ciphertext plaintext m => plaintext -> m (CryptoID ciphertext plaintext) Source #

Specialised version of encrypt for when (plaintext, ciphertext) uniquely determines the namespace

decrypt :: HasCryptoID ciphertext plaintext m => CryptoID ciphertext plaintext -> m plaintext Source #

Specialised version of decrypt for when (plaintext, ciphertext) uniquely determines the namespace