Tillich-Zémor hashing golang implementation
Find a file
Evgenii Stratonikov c8a32b25ec Optimize AVX2 implementation
We use 6 instructions only to calculate mask based on single bit value.
Use only 3 now and calculate multiple masks in parallel.

Also `VPSUB*` is faster than VPBROADCAST*,
see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html .

```
name                     old time/op    new time/op    delta
Sum/AVX2Inline_digest-8    1.83ms ± 0%    1.62ms ± 1%  -11.23%  (p=0.000 n=46+42)

name                     old speed      new speed      delta
Sum/AVX2Inline_digest-8  54.7MB/s ± 0%  61.6MB/s ± 1%  +12.65%  (p=0.000 n=46+42)
```

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-12-29 13:23:05 +03:00
.circleci Enable CircleCI (#2) 2019-01-03 13:26:32 +03:00
cmd Add pure Go hash implementation 2019-07-19 18:59:43 +03:00
gf127 gf127: remove branch in pure Go operations 2021-12-29 11:00:27 +03:00
tz Optimize AVX2 implementation 2021-12-29 13:23:05 +03:00
.gitignore Ignore vendor and binary 2020-01-16 11:30:45 +03:00
auto.sh Initial 2018-12-29 16:04:17 +03:00
benchmark Update alpine image, fixup for Makefile, fixup for benchmark 2020-01-16 11:30:46 +03:00
Dockerfile Update alpine image, fixup for Makefile, fixup for benchmark 2020-01-16 11:30:46 +03:00
go.mod Use golang.org/x/sys instead of self-implemented detector 2020-01-16 11:30:46 +03:00
go.sum Use golang.org/x/sys instead of self-implemented detector 2020-01-16 11:30:46 +03:00
LICENSE Initial 2018-12-29 16:04:17 +03:00
Makefile Update alpine image, fixup for Makefile, fixup for benchmark 2020-01-16 11:30:46 +03:00
README.md Update benchmark result in README.md 2019-10-16 15:11:57 +03:00

Demo

asciicast

In project root:

# show help
make
# run auto demo
make auto

Homomorphic hashing in golang

Package tz containts pure-Go implementation of hashing function described by Tillich and Źemor in [1] .

There are existing implementations already (e.g. [2]), however they are written in C.

Package gf127 contains arithmetic in GF(2^127) with x^127+x^63+1 as reduction polynomial.

Description

It can be used instead of Merkle-tree for data-validation, because homomorphic hashes are concatenable: hash sum of data can be calculated based on hashes of chunks.

The example of how it works can be seen in tests.

Benchmarks

go vs AVX vs AVX2 version

BenchmarkSum/AVX_digest-8             308       3889484 ns/op          25.71 MB/s         5 allocs/op
BenchmarkSum/AVXInline_digest-8       457       2455437 ns/op          40.73 MB/s         5 allocs/op
BenchmarkSum/AVX2_digest-8            399       3031102 ns/op          32.99 MB/s         3 allocs/op
BenchmarkSum/AVX2Inline_digest-8      602       2077719 ns/op          48.13 MB/s         3 allocs/op
BenchmarkSum/PureGo_digest-8           68       17795480 ns/op          5.62 MB/s         5 allocs/op

Contributing

At this moment, we do not accept contributions. Follow us.

Makefile

→ make
  Usage:

    make <target>

  Targets:

    attach   Attach to existing container
    auto     Auto Tillich-Zémor hasher demo
    down     Stop demo container
    help     Show this help prompt
    up       Run Tillich-Zémor hasher demo

Links

[1] https://link.springer.com/content/pdf/10.1007/3-540-48658-5_5.pdf

[2] https://github.com/srijs/hwsl2-core