From 03a55025dbf745da01f67464739011a45d69c3a7 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Sat, 18 Oct 2025 17:22:38 +0800 Subject: [PATCH] accounts: use hash pool in TextHash --- accounts/accounts.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/accounts/accounts.go b/accounts/accounts.go index 7bd911577a1..98ccb02da44 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -20,12 +20,13 @@ package accounts import ( "fmt" "math/big" + "unsafe" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" - "golang.org/x/crypto/sha3" ) // Account represents an Ethereum account located at a specific location defined @@ -196,9 +197,8 @@ func TextHash(data []byte) []byte { // This gives context to the signed message and prevents signing of transactions. func TextAndHash(data []byte) ([]byte, string) { msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), data) - hasher := sha3.NewLegacyKeccak256() - hasher.Write([]byte(msg)) - return hasher.Sum(nil), msg + hash := crypto.Keccak256(unsafe.Slice(unsafe.StringData(msg), len(msg))) + return hash, msg } // WalletEventType represents the different event types that can be fired by