-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wrapper for ethereum private/pub key Add is ethereum check When no option given, default as no applyHash Add option for sign: applyHash sign the raw mesaage or sign the hash of the msg Change pubkey to pointer type Update signature_test Add hasher input test When sign input is already a hash, don't hash again Add signature for keccak256 Add eth keccak256ecdsa
- Loading branch information
Showing
9 changed files
with
277 additions
and
7 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
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
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,24 @@ | ||
package signature | ||
|
||
import ( | ||
"encoding/hex" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestScheme(t *testing.T) { | ||
a := require.New(t) | ||
a.Equal(KECCAK256WithECDSA, SignatureScheme(0x0b), "fail") | ||
s := KECCAK256WithECDSA | ||
a.Equal(s.Name(), "KECCAK256WithECDSA", "fail") | ||
} | ||
|
||
func TestGetHash(t *testing.T) { | ||
a := require.New(t) | ||
|
||
hasher := GetHash(KECCAK256WithECDSA) | ||
h := hasher.Sum(nil) | ||
// empty hash of keccak256 is value below: https://www.oreilly.com/library/view/mastering-ethereum/9781491971932/ch04.html | ||
a.Equal("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", hex.EncodeToString(h), "fail") | ||
} |
Oops, something went wrong.