Skip to content

A C# implementation of LtHASH (Lattice Hash), a homomorphic hashing algorithm based on lattice cryptography

License

Notifications You must be signed in to change notification settings

cypher-network/lthash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lthash

This is not production quality code. It is full of bugs and not complete.

A C# implementation of LtHASH (Lattice Hash), a homomorphic hashing algorithm based on lattice cryptography introduced by Mihir Bellare and Daniele Micciancio in this paper. This is a simplified C# porting of the Facebook Folly C++ Library implementation of the algorithm introduced here.

Homomorphic Hashing

A homomorphic hash can simplistically be defined as a hash function such that one can compute the hash of a composite block from the hashes of the individual blocks or rather being f1 and f2 two hash functions and op1, op2 two operations it is true that:

$$f1(a op1 b) = f2(a) op2 f2(b)$$

One of the main building blocks of a homomorphic hashing function is therefore an underlying hash function (our f2). This project depends on this C# implementation of the BLAKE3 cryptographic hash function.

Example

var ltHash = new Lthash32();

// Create an initial checksum of two inputs
ltHash.Add(System.Text.Encoding.UTF8.GetBytes("apple"), System.Text.Encoding.UTF8.GetBytes("orange"));
var checksum = ltHash.GetChecksum();

// Remove the hash of "apple" from the checksum and check
// if the two checksums are equals
ltHash.Remove(System.Text.Encoding.UTF8.GetBytes("apple"));
var isEqual = ltHash.ChecksumEquals(checksum);

// Update the hash of "orange" with the new value "apple"
// and check if the two checksums are equals
ltHash.Update(System.Text.Encoding.UTF8.GetBytes("orange"), System.Text.Encoding.UTF8.GetBytes("apple"));
isEqual = ltHash.ChecksumEquals(checksum);

// Adding again the missing "orange" and check if the
// checksum is equal to the initial checksum
ltHash.Add(System.Text.Encoding.UTF8.GetBytes("orange"));
isEqual = ltHash.ChecksumEquals(checksum);

About

A C# implementation of LtHASH (Lattice Hash), a homomorphic hashing algorithm based on lattice cryptography

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages