-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace Sha3 RLP Hash with NewLegacyKeccak256
- Loading branch information
bglmmz
committed
Aug 25, 2022
1 parent
7516f99
commit ba58b8f
Showing
8 changed files
with
39 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package crypto | ||
|
||
import ( | ||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"golang.org/x/crypto/sha3" | ||
"io" | ||
) | ||
|
||
// LegacyKeccak256SHA3Hex returns a hex string with 0x prefix | ||
func LegacyKeccak256SHA3Hex(data string) string { | ||
h := LegacyKeccak256SHA3(data) | ||
return h.Hex() | ||
} | ||
|
||
func LegacyKeccak256SHA3(data string) (h ethcommon.Hash) { | ||
w := sha3.NewLegacyKeccak256() | ||
io.WriteString(w, data) | ||
w.Sum(h[:0]) | ||
return h | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package crypto | ||
|
||
import "testing" | ||
|
||
func Test_LegacyKeccak256SHA3Hex(t *testing.T) { | ||
t.Log(LegacyKeccak256SHA3Hex("test")) | ||
} | ||
|
||
func Test_LegacyKeccak256SHA3(t *testing.T) { | ||
t.Log(LegacyKeccak256SHA3("test")) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters