Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Digest = Digest {}
- toW64s :: Digest -> [Word64]
- snat2W64 :: SNat n -> Word64
- hash :: ByteString -> Digest
- hashStr :: String -> Digest
- digestConcat :: [Digest] -> Digest
- class Digestible (v :: *) where
- class DigestibleHO (f :: k -> *) where
- authPeel' :: forall sum ann i. (forall ix. ann ix -> Digest) -> Word64 -> Constr sum i -> NP ann (Lkup i sum) -> Digest
- authPeel :: forall codes ix ann i. IsNat ix => (forall iy. ann iy -> Digest) -> Proxy codes -> Proxy ix -> Constr (Lkup ix codes) i -> NP ann (Lkup i (Lkup ix codes)) -> Digest
Documentation
Our digests come from Blake2s_256
hash :: ByteString -> Digest Source #
Auxiliar hash function with the correct types instantiated.
digestConcat :: [Digest] -> Digest Source #
Concatenates digests together and hashes the result.
class Digestible (v :: *) where Source #
A Value is digestible if we know how to hash it.
Instances
Digestible Word64 Source # | A Word64 is digestible |
class DigestibleHO (f :: k -> *) where Source #
A functor is digestible if we can hash its value pointwise.
Instances
DigestibleHO Singl Source # | |
DigestibleHO W Source # | |
DigestibleHO (Const Void :: k -> Type) Source # | |
DigestibleHO ki => DigestibleHO (MetaVarIK ki :: Atom kon -> Type) Source # | |
authPeel' :: forall sum ann i. (forall ix. ann ix -> Digest) -> Word64 -> Constr sum i -> NP ann (Lkup i sum) -> Digest Source #
Authenticates a HPeel
without caring for the type
information. Only use this if you are sure of what you are
doing, as there can be colissions. For example:
data A = A1 B | A2 Int Int data B = B1 A | B2 Int Int
xA :: NP ann (Lkup 1 codesA) xB :: NP ann (Lkup 1 codesB) authPeel' f 0 (CS CZ) xA == authPeel' f 0 (CS CZ) xB
That's because A2
and B2
have the exact same signature
and are within the exact same position within the datatype.
We must use the salt to pass type information:
authPeel' f (snat2W64 IdxA) (CS CZ) xA =/ authPeel' f (snat2W64 IdxB) (CS CZ) xB
One should stick to authPeel
whenever in doubt.