tz: initialize digest
in Sum
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
3de3046074
commit
85abb43253
2 changed files with 2 additions and 0 deletions
|
@ -29,6 +29,7 @@ func New() *digest {
|
||||||
// Sum returns Tillich-Zémor checksum of data.
|
// Sum returns Tillich-Zémor checksum of data.
|
||||||
func Sum(data []byte) [Size]byte {
|
func Sum(data []byte) [Size]byte {
|
||||||
d := new(digest)
|
d := new(digest)
|
||||||
|
d.Reset()
|
||||||
_, _ = d.Write(data) // no errors
|
_, _ = d.Write(data) // no errors
|
||||||
return d.checkSum()
|
return d.checkSum()
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,7 @@ func TestHomomorphism(t *testing.T) {
|
||||||
|
|
||||||
// Test if our hashing is really homomorphic
|
// Test if our hashing is really homomorphic
|
||||||
h = Sum(b)
|
h = Sum(b)
|
||||||
|
require.NotEqual(t, [64]byte{}, h)
|
||||||
h1 = Sum(b[:32])
|
h1 = Sum(b[:32])
|
||||||
h2 = Sum(b[32:])
|
h2 = Sum(b[32:])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue