You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
663 B

package signature
import "testing"
func TestSignature(t *testing.T) {
t.Log("Testing signature creation and verification")
var s SignKeys
s.Generate()
pub, priv := s.HexString()
t.Logf("Generated pub:%s priv:%s\n", pub, priv)
message := "Hello, this is gonna be signed!"
t.Logf("Message to sign: %s\n", message)
msgSign, err := s.Sign(message)
if err != nil {
t.Errorf("Error while signing %s\n", err)
}
t.Logf("Signature of message: %s\n", msgSign)
v, err := s.Verify(message, msgSign, pub)
if err != nil {
t.Errorf("Verification error: %s\n", err)
}
if !v {
t.Error("Verification failed!")
}
t.Logf("Testing verification... %t\n", v)
}