From ba26973aee5da89d3efa6fee58d575a8c7c7eba3 Mon Sep 17 00:00:00 2001 From: RT Date: Tue, 1 Oct 2024 12:08:45 +0000 Subject: [PATCH] remove keccak256 --- protobuf/decode.go | 2 +- types/hash/hash.go | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/protobuf/decode.go b/protobuf/decode.go index edfff38..c52f039 100644 --- a/protobuf/decode.go +++ b/protobuf/decode.go @@ -224,7 +224,7 @@ func (msg *Substate_TxMessage) getContractAddress() types.Address { // mimics crypto.CreateAddress, to avoid cyclical dependency. func createAddress(addr types.Address, nonce uint64) types.Address { data, _ := trlp.EncodeToBytes([]interface{}{addr, nonce}) - return types.BytesToAddress(hash.Keccak256(data)[12:]) + return types.BytesToAddress(hash.Keccak256Hash(data).Bytes()[12:]) } // decode converts protobuf-encoded Substate_Result into aida-comprehensible Result diff --git a/types/hash/hash.go b/types/hash/hash.go index 45d3647..0dd2511 100644 --- a/types/hash/hash.go +++ b/types/hash/hash.go @@ -37,17 +37,6 @@ func NewKeccakState() KeccakState { return sha3.NewLegacyKeccak256().(KeccakState) } -// Keccak256 calculates and returns the Keccak256 hash of the input data. -func Keccak256(data ...[]byte) []byte { - b := make([]byte, 32) - d := NewKeccakState() - for _, b := range data { - d.Write(b) - } - d.Read(b) - return b -} - // Keccak256Hash calculates and returns the Keccak256 hash of the input data, // converting it to an internal Hash data structure. func Keccak256Hash(data ...[]byte) (h types.Hash) {