-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathhasher.go
More file actions
34 lines (29 loc) · 892 Bytes
/
hasher.go
File metadata and controls
34 lines (29 loc) · 892 Bytes
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
34
package utils
import (
"fmt"
"github.com/onflow/flow-go/crypto/hash"
"github.com/onflow/flow-go/module/signature"
)
// NewExecutionReceiptHasher generates and returns a hasher for signing
// and verification of execution receipts
func NewExecutionReceiptHasher() hash.Hasher {
h := signature.NewBLSHasher(signature.ExecutionReceiptTag)
return h
}
// NewSPOCKHasher generates and returns a hasher for signing
// and verification of SPoCKs
func NewSPOCKHasher() hash.Hasher {
h := signature.NewBLSHasher(signature.SPOCKTag)
return h
}
// NewHasher returns one of the hashers supported by Flow transactions.
func NewHasher(algo hash.HashingAlgorithm) (hash.Hasher, error) {
switch algo {
case hash.SHA2_256:
return hash.NewSHA2_256(), nil
case hash.SHA3_256:
return hash.NewSHA3_256(), nil
default:
return nil, fmt.Errorf("not supported hashing algorithms: %d", algo)
}
}