From 0fe703afd132fb4f442883366d7b0cbedcd1044b Mon Sep 17 00:00:00 2001 From: antonis19 Date: Wed, 15 Jan 2025 16:10:01 +0100 Subject: [PATCH] remove legacy function --- erigon-lib/commitment/utils.go | 35 +--------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/erigon-lib/commitment/utils.go b/erigon-lib/commitment/utils.go index 75c75799a36..cf7fe8291da 100644 --- a/erigon-lib/commitment/utils.go +++ b/erigon-lib/commitment/utils.go @@ -16,13 +16,11 @@ package commitment import ( - "bytes" "errors" "fmt" "github.com/erigontech/erigon-lib/common/length" "github.com/erigontech/erigon-lib/crypto" - "golang.org/x/crypto/sha3" ) // nibblize a key : e.g. [0xab] => [0x0a, 0x0b] @@ -35,32 +33,6 @@ func Nibblize(key []byte) []byte { // nolint:unused return nibblized } -func legacyHashAndNibblizeKey(key []byte) []byte { - hashedKey := make([]byte, length.Hash) - keccak := sha3.NewLegacyKeccak256().(keccakState) - keccak.Reset() - fp := length.Addr - if len(key) < length.Addr { - fp = len(key) - } - keccak.Write(key[:fp]) - keccak.Read(hashedKey[:length.Hash]) - - if len(key[fp:]) > 0 { - hashedKey = append(hashedKey, make([]byte, length.Hash)...) - keccak.Reset() - keccak.Write(key[fp:]) - keccak.Read(hashedKey[length.Hash:]) - } - - nibblized := make([]byte, len(hashedKey)*2) - for i, b := range hashedKey { - nibblized[i*2] = (b >> 4) & 0xf - nibblized[i*2+1] = b & 0xf - } - return nibblized -} - // Hash the account or storage key and return the resulting hashed key in the nibblized form func HashAndNibblizeKey(key []byte) []byte { keyLen := length.Addr @@ -72,12 +44,7 @@ func HashAndNibblizeKey(key []byte) []byte { storageKeyHash := crypto.Keccak256(key[length.Addr:]) compactedHashKey = append(compactedHashKey, storageKeyHash...) } - result := Nibblize(compactedHashKey) - legacyResult := legacyHashAndNibblizeKey(key) - if !bytes.Equal(result, legacyResult) { - panic("result not equal with legacy function") - } - return result + return Nibblize(compactedHashKey) } func CompactedKeyToHex(compact []byte) []byte {