added uncompressed trust anchor pub key processing

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2024-05-10 14:44:11 +02:00
parent 066c1a7667
commit 0c52156406
No known key found for this signature in database
2 changed files with 18 additions and 0 deletions

View File

@ -35,6 +35,12 @@ func validatePublicKey(pubkey string) bool {
return false
}
//uncompressed key
if len(pubkeyBytes) == 64 {
return true
}
// compressed key
// Check if byte slice has correct length
if len(pubkeyBytes) != 33 {
return false

View File

@ -71,6 +71,18 @@ func TestMsgServerRegisterTrustAnchor(t *testing.T) {
}
}
func TestMsgServerRegisterTrustAnchorUncompressedKey(t *testing.T) {
t.Parallel()
pk := "6003d0ab9af4ec112629195a7266a244aecf1ac7691da0084be3e7ceea2ee71571b0963fffd9c80a640317509a681ac66c2ed70ecc9f317a0d2b1a9bff94ff74"
ta := moduleobject.TrustAnchor(pk)
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
msgServer, ctx := setupMsgServer(t)
res, err := msgServer.RegisterTrustAnchor(ctx, msg)
if assert.NoError(t, err) {
assert.Equal(t, &types.MsgRegisterTrustAnchorResponse{}, res)
}
}
func TestMsgServerRegisterTrustAnchorTwice(t *testing.T) {
t.Parallel()
_, pk := sample.KeyPair()