/
interface.go
33 lines (25 loc) · 1.07 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2021 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bmt
import (
"hash"
)
const (
SpanSize = 8
)
// Hash provides the necessary extension of the hash interface to add the length-prefix of the BMT hash.
//
// Any implementation should make it possible to generate a BMT hash using the hash.Hash interface only.
// However, the limitation will be that the Span of the BMT hash always must be limited to the amount of bytes actually written.
type Hash interface {
hash.Hash
// SetHeaderInt64 sets the header bytes of BMT hash to the little endian binary representation of the int64 argument.
SetHeaderInt64(int64)
// SetHeader sets the header bytes of BMT hash by copying the first 8 bytes of the argument.
SetHeader([]byte)
// Hash calculates the BMT hash of the buffer written so far and appends it to the argument
Hash([]byte) ([]byte, error)
// Capacity returns the maximum amount of bytes that will be processed by the implementation.
Capacity() int
}