From c1e43f87272ef72d9970631465617a9a5b3111c0 Mon Sep 17 00:00:00 2001 From: alexvanin Date: Sun, 1 Mar 2020 16:57:24 +0300 Subject: [PATCH] rfc6979: Add tests for short `r` and `s` coordinates --- rfc6979_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rfc6979_test.go b/rfc6979_test.go index 5791bfd..c42b037 100644 --- a/rfc6979_test.go +++ b/rfc6979_test.go @@ -4,6 +4,7 @@ import ( "encoding/hex" "testing" + "github.com/nspcc-dev/neofs-crypto/test" "github.com/stretchr/testify/require" ) @@ -83,3 +84,23 @@ func TestRFC6979(t *testing.T) { } } } + +func TestRFC6979_ShortDecodePoints(t *testing.T) { + key := test.DecodeKey(1) + + msgs := []string{ + "6341922933e156ea5a53b8ea3fa4a80c", // this msg has 31 byte `s` point + "61b863d81f72e0e0d0353b1cb90d62ce", // this msg has 31 byte 'r' point + } + + for i := range msgs { + msg, err := hex.DecodeString(msgs[i]) + require.NoError(t, err) + + signature, err := SignRFC6979(key, msg) + require.NoError(t, err, msgs[i]) + + err = VerifyRFC6979(&key.PublicKey, msg, signature) + require.NoError(t, err, msgs[i]) + } +}