github.com/onflow/flow-go@v0.33.17/engine/execution/utils/hasher.go (about) 1 package utils 2 3 import ( 4 "fmt" 5 6 "github.com/onflow/flow-go/crypto/hash" 7 "github.com/onflow/flow-go/module/signature" 8 ) 9 10 // NewExecutionReceiptHasher generates and returns a hasher for signing 11 // and verification of execution receipts 12 func NewExecutionReceiptHasher() hash.Hasher { 13 h := signature.NewBLSHasher(signature.ExecutionReceiptTag) 14 return h 15 } 16 17 // NewSPOCKHasher generates and returns a hasher for signing 18 // and verification of SPoCKs 19 func NewSPOCKHasher() hash.Hasher { 20 h := signature.NewBLSHasher(signature.SPOCKTag) 21 return h 22 } 23 24 // NewHasher returns one of the hashers supported by Flow transactions. 25 func NewHasher(algo hash.HashingAlgorithm) (hash.Hasher, error) { 26 switch algo { 27 case hash.SHA2_256: 28 return hash.NewSHA2_256(), nil 29 case hash.SHA3_256: 30 return hash.NewSHA3_256(), nil 31 default: 32 return nil, fmt.Errorf("not supported hashing algorithms: %d", algo) 33 } 34 }