Skip to main content

An implementation of multiset hashing

Project description

pymsh

PyPI PyPI - Python Version PyPI - Downloads PyPI - License

pymsh is an MIT-licensed implementation of the incremental multi-set hashing (MSH) scheme based on Clarke et al. [1] (ASIACRYPT '03).

Specifically, it supports XOR-based hashing for fast updates; BLAKE2B is used as the underlying hash function.

Usage

Simple: initialise the MSH() class and call hash(...) for hashing multisets directly, or update(...) for incremental updates.

Examples:

from pymsh import pymsh

msh = pymsh.MSH()
m1 = msh.hash([b'apple', b'apple', b'banana'])
print(m1.hex()) # => Returns the multiset hash value of m1
msh.reset()
m2 = msh.hash([b'banana', b'apple', b'apple'])
print(m2.hex()) # => m2 will == m1

An example of the update function:

from pymsh import pymsh

msh = pymsh.MSH()
new_lst = [b'apple']
m3 = msh.hash(new_lst)
print(m3.hex())
m3 = msh.update(b'banana')
print(m3.hex())
m3 = msh.update(b'apple')
print(m3.hex()) # => Equivalent to m2 or m1 above

References

  1. Clarke, D., Devadas, S., van Dijk, M., Gassend, B., Suh, G.E. (2003). "Incremental Multiset Hash Functions and Their Application to Memory Integrity Checking." In: Advances in Cryptology - ASIACRYPT. Lecture Notes in Computer Science, vol 2894. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-40061-5_12

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymsh-0.2.3.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

pymsh-0.2.3-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page