arnaucube
arnaucube/go-dvotePublic Self-hosted repository
go-dvote/crypto/signature/signature_test.go
crypto/signature/signature_test.goRaw
 1package signature
 2
 3import "testing"
 4
 5func TestSignature(t *testing.T) {
 6	t.Log("Testing signature creation and verification")
 7	var s SignKeys
 8	s.Generate()
 9	pub, priv := s.HexString()
10	t.Logf("Generated pub:%s priv:%s\n", pub, priv)
11	message := "Hello, this is gonna be signed!"
12	t.Logf("Message to sign: %s\n", message)
13	msgSign, err := s.Sign(message)
14	if err != nil {
15		t.Errorf("Error while signing %s\n", err)
16	}
17	t.Logf("Signature of message: %s\n", msgSign)
18	v, err := s.Verify(message, msgSign, pub)
19	if err != nil {
20		t.Errorf("Verification error: %s\n", err)
21	}
22	if !v {
23		t.Error("Verification failed!")
24	}
25	t.Logf("Testing verification... %t\n", v)
26}