From d3b244ccc9216b58eccbed693702c1d92366c8ff Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 2 May 2024 14:06:37 +0300 Subject: [PATCH] crypto: export GetSignedData function It's needed for tests and further custom verification script build. Signed-off-by: Anna Shaleva --- pkg/crypto/hash/hash.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/crypto/hash/hash.go b/pkg/crypto/hash/hash.go index a997a3514..999b291da 100644 --- a/pkg/crypto/hash/hash.go +++ b/pkg/crypto/hash/hash.go @@ -16,7 +16,10 @@ type Hashable interface { Hash() util.Uint256 } -func getSignedData(net uint32, hh Hashable) []byte { +// GetSignedData returns the concatenated byte slice containing of the network +// magic in constant-length 4-bytes LE representation and hashable item hash in BE +// representation. +func GetSignedData(net uint32, hh Hashable) []byte { var b = make([]byte, 4+util.Uint256Size) binary.LittleEndian.PutUint32(b, net) h := hh.Hash() @@ -27,7 +30,7 @@ func getSignedData(net uint32, hh Hashable) []byte { // NetSha256 calculates a network-specific hash of the Hashable item that can then // be signed/verified. func NetSha256(net uint32, hh Hashable) util.Uint256 { - return Sha256(getSignedData(net, hh)) + return Sha256(GetSignedData(net, hh)) } // Sha256 hashes the incoming byte slice