Skip to content

Commit

Permalink
crypto: export GetSignedData function
Browse files Browse the repository at this point in the history
It's needed for tests and further custom verification script build.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed May 2, 2024
1 parent dfca14f commit 984bcfb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/crypto/hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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()
Expand All @@ -28,7 +31,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
Expand Down

0 comments on commit 984bcfb

Please sign in to comment.