All Projects → lukechampine → lthash

lukechampine / lthash

Licence: MIT license
A homomorphic hash function

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to lthash

bromberg sl2
Cayley hashing as in "Navigating in the Cayley Graph of SL₂(𝔽ₚ)"
Stars: ✭ 32 (-47.54%)
Mutual labels:  hash, homomorphic
phpass-starter
A starter project for Phpass.
Stars: ✭ 24 (-60.66%)
Mutual labels:  hash
pufferfish
An efficient index for the colored, compacted, de Bruijn graph
Stars: ✭ 94 (+54.1%)
Mutual labels:  hash
cdnupload
Upload your site's static files to a directory or CDN, using content-based hashing
Stars: ✭ 41 (-32.79%)
Mutual labels:  hash
ds
🔗 Common Data Structures and Algorithms
Stars: ✭ 40 (-34.43%)
Mutual labels:  hash
pymerkletools
Python tools for creating Merkle trees, generating Merkle proofs, and verification of Merkle proofs
Stars: ✭ 128 (+109.84%)
Mutual labels:  hash
Fog
Pharo Ethereum Driver
Stars: ✭ 19 (-68.85%)
Mutual labels:  hash
komihash
Very fast, high-quality hash function (non-cryptographic, C) + PRNG
Stars: ✭ 68 (+11.48%)
Mutual labels:  hash
laravel-hashid
HashId Implementation on Laravel Eloquent ORM
Stars: ✭ 23 (-62.3%)
Mutual labels:  hash
agent
hashtopolis.org
Stars: ✭ 19 (-68.85%)
Mutual labels:  hash
DelphiEncryptionCompendium
Cryptographic library for Embarcadero Delphi and potentially for FPC as well
Stars: ✭ 181 (+196.72%)
Mutual labels:  hash
simple-sha256
Generate SHA-256 hashes (in Node and the Browser)
Stars: ✭ 42 (-31.15%)
Mutual labels:  hash
Valour
An open source chat client for freedom
Stars: ✭ 52 (-14.75%)
Mutual labels:  hash
JSum
Consistent checksum calculation of JSON objects.
Stars: ✭ 64 (+4.92%)
Mutual labels:  hash
harsh
Hashids implementation in Rust
Stars: ✭ 48 (-21.31%)
Mutual labels:  hash
expand-hash
Recursively expands property keys with dot-notation into objects.
Stars: ✭ 25 (-59.02%)
Mutual labels:  hash
hash
Data management, integration and modeling with blocks #
Stars: ✭ 400 (+555.74%)
Mutual labels:  hash
crypthash-net
CryptHash.NET is a .NET multi-target library to encrypt/decrypt/hash/encode/decode strings and files, with an optional .NET Core multiplatform console utility.
Stars: ✭ 33 (-45.9%)
Mutual labels:  hash
pthash
Fast and compact minimal perfect hash functions in C++.
Stars: ✭ 62 (+1.64%)
Mutual labels:  hash
jscrypto
Crypto library for Node/ES6/Typescript/Browser.
Stars: ✭ 20 (-67.21%)
Mutual labels:  hash

lthash

GoDoc Go Report Card

go get lukechampine.com/lthash

This repo contains an implementation of LtHash, as defined by Bellare and Micciancio and later specified more concretely by researchers at Facebook.

LtHash is a homomorphic hash function based on BLAKE2x. A homomorphic hash function provides a solution to the following problem: Given the hash of an input, along with a small update to the input, how can we compute the hash of the new input with its update applied, without having to recompute the entire hash from scratch?

For example, say you have a database that contains three items: "Apple", "Banana", and "Orange". We compute the LtHash of this set by summing the hashes of the individual elements. Later, we replace "Banana" with "Grape". To compute the new hash, we take our original hash, subtract the hash of "Banana", and add the hash of "Grape". The resulting hash is the same as if the database originally contained "Grape" instead of "Banana".

This repo currently contains an implementation of lthash16. Facebook's paper further specifies lthash20 and lthash32; these may be added in the future.

Be aware that LtHash is vulnerable to multiset input collisions. A multiset is a set containing more than one instance of a particular element. In particular, it is trivial to produce a collision in lthash16 by adding the same input to the hash 2^16 times. One way to prevent this is to concatenate each input with a unique piece of metadata, such as an index.

Usage

h := lthash.New16()

// compute the combined hash of "Apple", "Banana", and "Orange"
h.Add([]byte("Apple"))
h.Add([]byte("Banana"))
h.Add([]byte("Orange"))
oldSum := h.Sum(nil)

// replace "Banana" with "Grape"; the resulting hash is the same
// as the combined hash of "Apple", "Grape", and "Orange".
h.Remove([]byte("Banana"))
h.Add([]byte("Grape"))
newSum := h.Sum(nil)

Benchmarks

Tested on an i5-7600K @ 3.80GHz. Results will likely be slower on non-amd64 architectures.

BenchmarkLtHash/16-4    200000    9651 ns/op    424.38 MB/s    0 allocs/op
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].