-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | BLAKE3 hashing algorithm -- -- Bindings to the official fast BLAKE3 implementations in assembly and -- C, with support for AVX-512, AVX2, SSE 2, and SSE 4.1. @package blake3 @version 0.3 -- | IO and low level tools. module BLAKE3.IO -- | BLAKE3 hashing. hash :: forall len digest bin. (ByteArrayN len digest, ByteArrayAccess bin) => Maybe Key -> [bin] -> IO digest -- | Initialize a Hasher. init :: Ptr Hasher -> Maybe Key -> IO () -- | Update Hasher state with new data. update :: forall bin. ByteArrayAccess bin => Ptr Hasher -> [bin] -> IO () -- | Finalize incremental hashing and obtain a the BLAKE3 output of the -- specified length. finalize :: forall len output. ByteArrayN len output => Ptr Hasher -> IO output -- | Finalize incremental hashing and obtain the specified length -- of BLAKE3 output starting at the specified offset. -- --
-- finalize h = finalizeSeek h 0 --finalizeSeek :: forall len output. ByteArrayN len output => Ptr Hasher -> Word64 -> IO output -- | Output from BLAKE3 algorithm, of len bytes. -- -- The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN. newtype Digest (len :: Nat) Digest :: SizedByteArray len ScrubbedBytes -> Digest (len :: Nat) -- | Key used for keyed hashing mode. -- -- Obtain with key. -- -- See hashKeyed. data Key -- | Obtain a Key for use in BLAKE3 keyed hashing. -- -- See hashKeyed. key :: ByteArrayAccess bin => bin -> Maybe Key -- | Initialize a Hasher in derivation mode. -- -- The input key material must be provided afterwards, using -- update. initDerive :: forall context. ByteArrayAccess context => Ptr Hasher -> context -> IO () -- | BLAKE3 internal state. -- -- Obtain with hasher, hasherKeyed. data Hasher -- | Obtain a Ptr Hasher to use with functions like -- initDerive, etc. modifyHasher :: Hasher -> (Ptr Hasher -> IO a) -> IO a type HASHER_ALIGNMENT = 8 -- | In bytes. type HASHER_SIZE = 1912 -- | In bytes. type KEY_LEN = 32 -- | In bytes. type BLOCK_SIZE = 64 -- | In bytes. type DEFAULT_DIGEST_LEN = 32 type CHUNK_LEN = 1024 type MAX_DEPTH = 54 type MAX_SIMD_DEGREE = 16 -- |
-- void blake3_hasher_init(blake3_hasher *self) --c_init :: Ptr Hasher -> IO () -- |
-- void blake3_hasher_init_keyed(blake3_hasher *self, const uint8_t key[KEY_LEN]) --c_init_keyed :: Ptr Hasher -> Ptr Word8 -> IO () -- |
-- void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, size_t context_len) --c_init_derive_key_raw :: Ptr Hasher -> Ptr Word8 -> CSize -> IO () -- |
-- void blake3_hasher_update(blake3_hasher *self, const void *input, size_t input_len) --c_update :: Ptr Hasher -> Ptr Word8 -> CSize -> IO () -- |
-- void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, size_t out_len) --c_finalize :: Ptr Hasher -> Ptr Word8 -> CSize -> IO () -- |
-- void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, uint8_t *out, size_t out_len) --c_finalize_seek :: Ptr Hasher -> Word64 -> Ptr Word8 -> CSize -> IO () instance GHC.TypeNats.KnownNat len => Data.ByteArray.Sized.ByteArrayN len (BLAKE3.IO.Digest len) instance GHC.TypeNats.KnownNat len => Data.ByteArray.Types.ByteArrayAccess (BLAKE3.IO.Digest len) instance GHC.Classes.Ord (BLAKE3.IO.Digest len) instance GHC.Classes.Eq (BLAKE3.IO.Digest len) instance Data.ByteArray.Sized.ByteArrayN BLAKE3.IO.HASHER_SIZE BLAKE3.IO.Hasher instance Data.ByteArray.Types.ByteArrayAccess BLAKE3.IO.Hasher instance GHC.Classes.Eq BLAKE3.IO.Hasher instance GHC.Show.Show BLAKE3.IO.Hasher instance Foreign.Storable.Storable BLAKE3.IO.Hasher instance Data.ByteArray.Sized.ByteArrayN BLAKE3.IO.KEY_LEN BLAKE3.IO.Key instance GHC.Classes.Eq BLAKE3.IO.Key instance GHC.Show.Show BLAKE3.IO.Key instance Data.ByteArray.Types.ByteArrayAccess BLAKE3.IO.Key instance Foreign.Storable.Storable BLAKE3.IO.Key instance GHC.Show.Show (BLAKE3.IO.Digest len) instance GHC.TypeNats.KnownNat len => Foreign.Storable.Storable (BLAKE3.IO.Digest len) -- | Haskell bindings to the fast official BLAKE3 hashing implementation -- in assembly and C. With support for AVX-512, AVX2, SSE 2, and SSE -- 4.1. -- -- The original assembly and C implementation is released into the public -- domain with CC0 1.0. Alternatively, it is licensed under the Apache -- License 2.0, copyright of Jack O'Connor and Samuel Neves. See its -- LICENSE for details. -- -- This Haskell library is the copyright of Renzo Carbonara, licensed -- under the terms of the Apache License 2.0. module BLAKE3 -- | BLAKE3 hashing. -- -- For incremental hashing, see init, update and -- finalize: -- --
-- hash yk = finalize . update (init yk) --hash :: forall len digest bin. (ByteArrayN len digest, ByteArrayAccess bin) => Maybe Key -> [bin] -> digest -- | Output from BLAKE3 algorithm, of len bytes. -- -- The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN. newtype Digest (len :: Nat) Digest :: SizedByteArray len ScrubbedBytes -> Digest (len :: Nat) -- | Key used for keyed hashing mode. -- -- Obtain with key. -- -- See hashKeyed. data Key -- | Obtain a Key for use in BLAKE3 keyed hashing. -- -- See hashKeyed. key :: ByteArrayAccess bin => bin -> Maybe Key -- | BLAKE3 key derivation. -- -- This can be used for KDF (key derivation function) purposes. -- -- The key derivation context should be hardcoded, globally -- unique, application-specific well-known string. -- -- A good format for the context string is: -- --
-- [application] [commit timestamp] [purpose] ---- -- For example: -- --
-- example.com 2019-12-25 16:18:03 session tokens v1 --derive :: forall len okm ikm context. (ByteArrayN len okm, ByteArrayAccess ikm, ByteArrayAccess context) => context -> [ikm] -> okm -- | BLAKE3 internal state. -- -- Obtain with hasher, hasherKeyed. data Hasher -- | Initial Hasher for incremental hashing. init :: Maybe Key -> Hasher -- | Update Hasher with new data. update :: forall bin. ByteArrayAccess bin => Hasher -> [bin] -> Hasher -- | Finalize incremental hashing and obtain a the BLAKE3 output of the -- specified length. finalize :: forall len output. ByteArrayN len output => Hasher -> output -- | Finalize incremental hashing and obtain the specified length -- of BLAKE3 output starting at the specified offset. -- --
-- finalize h = finalizeSeek h 0 --finalizeSeek :: forall len output. ByteArrayN len output => Hasher -> Word64 -> output -- | In bytes. type KEY_LEN = 32 -- | In bytes. type BLOCK_SIZE = 64 -- | In bytes. type DEFAULT_DIGEST_LEN = 32