aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/secp256k1/secp256_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-01-23 06:28:47 +0800
committerGitHub <noreply@github.com>2017-01-23 06:28:47 +0800
commit96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc (patch)
tree6fb78f454ceeb29df77df35ed9ce2c00142eae14 /crypto/secp256k1/secp256_test.go
parent935d891e9db870edde6b37ad84bb21d7df19c383 (diff)
downloaddexon-96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc.tar
dexon-96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc.tar.gz
dexon-96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc.tar.bz2
dexon-96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc.tar.lz
dexon-96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc.tar.xz
dexon-96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc.tar.zst
dexon-96778a1c216f7d0d987dd8ea6474b2d3eebe9cfc.zip
crypto/secp256k1: sign with deterministic K (rfc6979) (#3561)
Diffstat (limited to 'crypto/secp256k1/secp256_test.go')
-rw-r--r--crypto/secp256k1/secp256_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/secp256k1/secp256_test.go b/crypto/secp256k1/secp256_test.go
index ec28b8e39..287ab512e 100644
--- a/crypto/secp256k1/secp256_test.go
+++ b/crypto/secp256k1/secp256_test.go
@@ -112,6 +112,24 @@ func TestSignAndRecover(t *testing.T) {
}
}
+func TestSignDeterministic(t *testing.T) {
+ _, seckey := generateKeyPair()
+ msg := make([]byte, 32)
+ copy(msg, "hi there")
+
+ sig1, err := Sign(msg, seckey)
+ if err != nil {
+ t.Fatal(err)
+ }
+ sig2, err := Sign(msg, seckey)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(sig1, sig2) {
+ t.Fatal("signatures not equal")
+ }
+}
+
func TestRandomMessagesWithSameKey(t *testing.T) {
pubkey, seckey := generateKeyPair()
keys := func() ([]byte, []byte) {