Safe Haskell | None |
---|---|
Language | Haskell2010 |
Haskell bindings to the official BLAKE3 hashing implementation in C.
The original 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.
Synopsis
- hash :: forall len bin. (KnownNat len, ByteArrayAccess bin) => [bin] -> Digest len
- data Digest (len :: Nat)
- hashKeyed :: forall len bin. (KnownNat len, ByteArrayAccess bin) => Key -> [bin] -> Digest len
- data Key
- key :: ByteArrayAccess bin => bin -> Maybe Key
- derive :: forall len ikm. (KnownNat len, ByteArrayAccess ikm) => Context -> [ikm] -> Digest len
- data Context
- context :: ByteArrayAccess bin => bin -> Maybe Context
- data Hasher
- hasher :: Hasher
- hasherKeyed :: Key -> Hasher
- update :: forall bin. ByteArrayAccess bin => Hasher -> [bin] -> Hasher
- finalize :: forall len. KnownNat len => Hasher -> Digest len
- type KEY_LEN = 32
- type BLOCK_SIZE = 64
- type DEFAULT_DIGEST_LEN = 32
Hashing
:: (KnownNat len, ByteArrayAccess bin) | |
=> [bin] | Data to hash. |
-> Digest len | Default digest length is |
data Digest (len :: Nat) Source #
Output from BLAKE3 algorithm, of len
bytes.
The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN
.
Keyed hashing
:: (KnownNat len, ByteArrayAccess bin) | |
=> Key | |
-> [bin] | Data to hash. |
-> Digest len | Default digest length is |
BLAKE3 hashing with a Key
.
For incremental hashing, see hasherKeyed
, update
and finalize
:
hashKeyed
key =finalize
.
update
(hasherKeyed
key)
:: ByteArrayAccess bin | |
=> bin | Key bytes. Must have length |
-> Maybe Key |
Key derivation
:: (KnownNat len, ByteArrayAccess ikm) | |
=> Context | |
-> [ikm] | Input key material. |
-> Digest len | Default digest length is |
BLAKE3 key derivation.
Context for BLAKE3 key derivation. Obtain with context
.
:: ByteArrayAccess bin | |
=> bin | If |
-> Maybe Context |
Obtain a Context
for BLAKE3 key derivation.
The context should be hardcoded, globally unique, and application-specific.
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
Incremental hashing
Immutable BLAKE3 hashing state.
Obtain with hasher
or hasherKeyed
.
update :: forall bin. ByteArrayAccess bin => Hasher -> [bin] -> Hasher Source #
Update Hasher
with new data.
Constants
type BLOCK_SIZE = 64 Source #
In bytes.
type DEFAULT_DIGEST_LEN = 32 Source #
In bytes.