diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-11-18 02:39:42 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-11-18 02:39:42 +0800 |
commit | 10475f444c9ef0f5f800ccdb03d2ba34b5bf4026 (patch) | |
tree | 6514c6d074076ba65f134bcfce453c6e7185793c /crypto/secp256k1/secp256_test.go | |
parent | 9422eec55460aaca300cabd52124ed0cbd8dedd3 (diff) | |
parent | e344e1d4903f47d525258305d986f4aa0dd0ab52 (diff) | |
download | dexon-10475f444c9ef0f5f800ccdb03d2ba34b5bf4026.tar dexon-10475f444c9ef0f5f800ccdb03d2ba34b5bf4026.tar.gz dexon-10475f444c9ef0f5f800ccdb03d2ba34b5bf4026.tar.bz2 dexon-10475f444c9ef0f5f800ccdb03d2ba34b5bf4026.tar.lz dexon-10475f444c9ef0f5f800ccdb03d2ba34b5bf4026.tar.xz dexon-10475f444c9ef0f5f800ccdb03d2ba34b5bf4026.tar.zst dexon-10475f444c9ef0f5f800ccdb03d2ba34b5bf4026.zip |
Merge pull request #1984 from fjl/secp256k1-recover-id-verify
crypto/secp256k1: verify recovery ID before calling libsecp256k1
Diffstat (limited to 'crypto/secp256k1/secp256_test.go')
-rw-r--r-- | crypto/secp256k1/secp256_test.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/crypto/secp256k1/secp256_test.go b/crypto/secp256k1/secp256_test.go index 45c448f3c..cb71ea5e7 100644 --- a/crypto/secp256k1/secp256_test.go +++ b/crypto/secp256k1/secp256_test.go @@ -56,6 +56,17 @@ func TestSignatureValidity(t *testing.T) { } } +func TestInvalidRecoveryID(t *testing.T) { + _, seckey := GenerateKeyPair() + msg := randentropy.GetEntropyCSPRNG(32) + sig, _ := Sign(msg, seckey) + sig[64] = 99 + _, err := RecoverPubkey(msg, sig) + if err != ErrInvalidRecoveryID { + t.Fatalf("got %q, want %q", err, ErrInvalidRecoveryID) + } +} + func TestSignAndRecover(t *testing.T) { pubkey1, seckey := GenerateKeyPair() msg := randentropy.GetEntropyCSPRNG(32) @@ -70,10 +81,6 @@ func TestSignAndRecover(t *testing.T) { if !bytes.Equal(pubkey1, pubkey2) { t.Errorf("pubkey mismatch: want: %x have: %x", pubkey1, pubkey2) } - err = VerifySignature(msg, sig, pubkey1) - if err != nil { - t.Errorf("signature verification error: %s", err) - } } func TestRandomMessagesWithSameKey(t *testing.T) { |