hwsl2-0.1.1.3: Hashing with SL2

LicenseMIT
MaintainerSam Rijs <srijs@airpost.net>
Safe HaskellNone
LanguageHaskell2010

Data.Hash.SL2

Description

An algebraic hash function, inspired by the paper "Hashing with SL2" by Tillich and Zemor.

The hash function is based on matrix multiplication in the special linear group of degree 2, over a Galois field of order 2^127, with all computations modulo the polynomial x^127 + x^63 + 1.

This construction gives some nice properties, which traditional "bit-scambling" hash functions don't possess, including it being composable. It holds:

hash (m1 <> m2) == hash m1 <> hash m2

All operations in this package are implemented in a very efficient manner using SSE instructions.

Synopsis

Documentation

data Hash Source

Opaque representation of a 512 bit hash.

Instances

hash :: ByteString -> Hash Source

O(n) Calculate the hash of the ByteString. Alias for (mempty <+).

(<+) :: Hash -> ByteString -> Hash infixl 7 Source

O(n) Append the hash of the ByteString to the existing Hash. A significantly faster equivalent of (flip (<>) . hash).

(+>) :: ByteString -> Hash -> Hash infixr 7 Source

O(n) Prepend the hash of the ByteString to the existing Hash. A significantly faster equivalent of ((<>) . hash).

(<|) :: Foldable t => Hash -> t ByteString -> Hash infixl 7 Source

O(n) Append the hash of every ByteString to the existing Hash, from left to right. A significantly faster equivalent of (foldl (<+)).

(|>) :: Foldable t => t ByteString -> Hash -> Hash infixr 7 Source

O(n) Prepend the hash of every ByteString to the existing Hash, from right to left. A significantly faster equivalent of (foldr (+>)).

parse :: String -> Maybe Hash Source

O(1) Parse the representation generated by show.