-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Typeclass-based interface to cryptoids
--
-- Typeclass-based interface to cryptoids
@package cryptoids-class
@version 0.0.0
-- | Polymorphic functions to perform cryptographic operations on
-- CryptoIDs in a monadic context
module Data.CryptoID.Class
-- | 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.
class MonadThrow m => MonadCrypto (m :: * -> *) where {
type family MonadCryptoKey m :: *;
}
cryptoIDKey :: MonadCrypto m => (MonadCryptoKey m -> m a) -> m a
-- | Multiparameter typeclass of (namespace, ciphertext, plaintext,
-- monad) tuples which allow for cryptographic operations on
-- CryptoIDs with appropriate namespace,
-- plaintext, and ciphertext, utilising the state of
-- monad
--
-- Instances of this typeclass are usually universally quantified over
-- (at least) namespace, and m
class MonadCrypto m => HasCryptoID (namespace :: Symbol) (ciphertext :: *) (plaintext :: *) (m :: * -> *)
-- | Encrypt a plaintext in a fashion dependent on the
-- namespace and desired ciphertext-type retrieving the
-- key from and throwing errors into m
encrypt :: HasCryptoID namespace ciphertext plaintext m => plaintext -> m (CryptoID namespace ciphertext)
-- | Encrypt a ciphertext in a fashion dependent on the
-- namespace and desired plaintext-type retrieving the
-- key from and throwing errors into m
decrypt :: HasCryptoID namespace ciphertext plaintext m => CryptoID namespace ciphertext -> m plaintext
-- | 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.
module Data.CryptoID.Class.ImplicitNamespace
-- | 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.
class MonadThrow m => MonadCrypto (m :: * -> *) where {
type family MonadCryptoKey m :: *;
}
cryptoIDKey :: MonadCrypto m => (MonadCryptoKey m -> m a) -> m a
-- | Type family of namespaces associated to certain
-- plaintext-types (parameterized over ciphertext for
-- completeness)
-- | HasCryptoID reformulated to utilize CryptoIDNamespace
type HasCryptoID ciphertext plaintext = HasCryptoID (CryptoIDNamespace ciphertext plaintext) ciphertext plaintext
-- | CryptoID reformulated to utilize CryptoIDNamespace
type CryptoID ciphertext plaintext = CryptoID (CryptoIDNamespace ciphertext plaintext) ciphertext
CryptoID :: () => a -> CryptoID namespace a
ciphertext :: () => CryptoID namespace a -> a
-- | Specialised version of encrypt for when (plaintext,
-- ciphertext) uniquely determines the namespace
encrypt :: HasCryptoID ciphertext plaintext m => plaintext -> m (CryptoID ciphertext plaintext)
-- | Specialised version of decrypt for when (plaintext,
-- ciphertext) uniquely determines the namespace
decrypt :: HasCryptoID ciphertext plaintext m => CryptoID ciphertext plaintext -> m plaintext