From 85abb43253dec24fa870b3acbee164eb9c36c6b4 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 6 Jul 2022 17:59:52 +0300 Subject: [PATCH] tz: initialize `digest` in `Sum` Signed-off-by: Evgenii Stratonikov --- tz/digest.go | 1 + tz/hash_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/tz/digest.go b/tz/digest.go index e765f48..bcde95b 100644 --- a/tz/digest.go +++ b/tz/digest.go @@ -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() } diff --git a/tz/hash_test.go b/tz/hash_test.go index 39fcfe6..7e5c609 100644 --- a/tz/hash_test.go +++ b/tz/hash_test.go @@ -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:])