tz: initialize digest in Sum

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-07-06 17:59:52 +03:00 committed by fyrchik
parent 3de3046074
commit 85abb43253
2 changed files with 2 additions and 0 deletions

View file

@ -29,6 +29,7 @@ func New() *digest {
// Sum returns Tillich-Zémor checksum of data.
func Sum(data []byte) [Size]byte {
d := new(digest)
d.Reset()
_, _ = d.Write(data) // no errors
return d.checkSum()
}

View file

@ -151,6 +151,7 @@ func TestHomomorphism(t *testing.T) {
// Test if our hashing is really homomorphic
h = Sum(b)
require.NotEqual(t, [64]byte{}, h)
h1 = Sum(b[:32])
h2 = Sum(b[32:])