Completed event and key libraries.

This commit is contained in:
Jay
2025-10-20 11:00:44 -04:00
parent 0ab4edb45d
commit 2c893f9619
12 changed files with 824 additions and 0 deletions

29
keys_test.go Normal file
View File

@@ -0,0 +1,29 @@
package roots
import (
"regexp"
"testing"
)
var hexPattern = regexp.MustCompile("^[a-f0-9]{64}$")
func TestGeneratePrivateKey(t *testing.T) {
sk, err := GeneratePrivateKey()
expectOk(t, err)
if !hexPattern.MatchString(sk) {
t.Errorf("invalid private key format: %s", sk)
}
}
func TestGetPublicKey(t *testing.T) {
pk, err := GetPublicKey(testSK)
expectOk(t, err)
expectEqualStrings(t, pk, testPK)
}
func TestGetPublicKeyInvalidPrivateKey(t *testing.T) {
_, err := GetPublicKey("abc123")
expectErrorSubstring(t, err, "private key must be 64 hex characters")
}