tzhash/README.md

79 lines
2.3 KiB
Markdown
Raw Normal View History

2018-12-29 13:04:17 +00:00
# Demo
[![asciicast](https://asciinema.org/a/IArEDLTrQyabI3agSSpINoqNu.svg)](https://asciinema.org/a/IArEDLTrQyabI3agSSpINoqNu)
**In project root:**
```bash
$ make
...
$ ./demo.sh
2018-12-29 13:04:17 +00:00
```
# Homomorphic hashing in golang
Package `tz` contains pure-Go (with some Assembly) implementation of hashing
function described by [Tillich and
Zémor](https://link.springer.com/content/pdf/10.1007/3-540-48658-5_5.pdf).
2018-12-29 13:04:17 +00:00
There are [existing implementations](https://github.com/srijs/hwsl2-core)
already, however they are written in C.
2018-12-29 13:04:17 +00:00
Package `gf127` contains arithmetic in `GF(2^127)` with `x^127+x^63+1` as reduction polynomial.
2018-12-29 13:04:17 +00:00
# Description
TZ Hash 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.
2018-12-29 13:04:17 +00:00
The example of how it works can be seen in tests and demo.
2018-12-29 13:04:17 +00:00
2019-06-24 07:33:00 +00:00
# Benchmarks
## go vs AVX vs AVX2 version
2019-06-24 07:33:00 +00:00
```
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
2019-06-24 07:33:00 +00:00
```
2018-12-29 13:04:17 +00:00
# Makefile
``` bash
2018-12-29 13:04:17 +00:00
Usage:
make <target>
Targets:
all Just `make` will build all possible binaries
clean Print version
dep Pull go dependencies
help Show this help prompt
test Run Unit Test with go test
version Print version
2018-12-29 13:04:17 +00:00
```
# Contributing
Feel free to contribute to this project after reading the [contributing
guidelines](CONTRIBUTING.md).
Before starting to work on a certain topic, create a new issue first, describing
the feature/topic you are going to implement.
# License
This project is licensed under the Apache 2.0 License -
see the [LICENSE](LICENSE) file for details
# References
2018-12-29 13:04:17 +00:00
- [https://link.springer.com/content/pdf/10.1007/3-540-48658-5_5.pdf](https://link.springer.com/content/pdf/10.1007/3-540-48658-5_5.pdf)
- [https://github.com/srijs/hwsl2-core](https://github.com/srijs/hwsl2-core)