Skip to content

Commit

Permalink
Merge pull request #89 from Fantom-foundation/rapol/refactor/remove-k…
Browse files Browse the repository at this point in the history
…eccak256

Remove Keccak256
  • Loading branch information
rpl-ffl authored Oct 2, 2024
2 parents 220a4fa + ba26973 commit 8ee452d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
2 changes: 1 addition & 1 deletion protobuf/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions types/hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8ee452d

Please sign in to comment.