From 1ae621593a9e5cde50b08d2119ca0859cd80d7e8 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Mon, 20 Nov 2023 14:52:16 +0100 Subject: [PATCH] Add golden test. Checked with previous version, it is working fine. Signed-off-by: Antonio Navarro Perez --- tm2/pkg/crypto/ed25519/ed25519_test.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tm2/pkg/crypto/ed25519/ed25519_test.go b/tm2/pkg/crypto/ed25519/ed25519_test.go index fdf269018c0..d7e2b86e2a9 100644 --- a/tm2/pkg/crypto/ed25519/ed25519_test.go +++ b/tm2/pkg/crypto/ed25519/ed25519_test.go @@ -1,12 +1,14 @@ package ed25519_test import ( + "encoding/hex" "testing" - "github.com/gnolang/gno/tm2/pkg/crypto" - "github.com/gnolang/gno/tm2/pkg/crypto/ed25519" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/gnolang/gno/tm2/pkg/crypto" + "github.com/gnolang/gno/tm2/pkg/crypto/ed25519" ) func TestSignAndValidateEd25519(t *testing.T) { @@ -28,3 +30,17 @@ func TestSignAndValidateEd25519(t *testing.T) { assert.False(t, pubKey.VerifyBytes(msg, sig)) } + +const privKeySecretGolden = "secret_golden" +const msgGolden = "msg_golden" +const signedGolden = "f9d4e6a665dfb6cd7e2fedf0d46a1725472e640a5e93d654ce4caa986e5defd23c8b3af76aa6e39c24c582f0ebee860f66254b29cf6d034ce461ae2773133703" + +func TestSignAndVerifyGolden(t *testing.T) { + privKey := ed25519.GenPrivKeyFromSecret([]byte(privKeySecretGolden)) + // pubKey := privKey.PubKey() + out, err := privKey.Sign([]byte(msgGolden)) + require.NoError(t, err) + + hexOut := hex.EncodeToString(out) + require.Equal(t, signedGolden, hexOut) +}