Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
bunfield committed Jun 2, 2024
1 parent d74723f commit 9222c45
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions protocol/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package protocol_test

import (
"bytes"
"crypto/ecdsa"
"crypto/ed25519"
"crypto/elliptic"
Expand Down Expand Up @@ -454,16 +453,18 @@ func TestTypesFromCerts(t *testing.T) {
require.NoError(t, err)
switch k := privKey.(type) {
case *rsa.PrivateKey:
pk := address.FromPrivateKeyBytes(block.Bytes, SignatureTypeRsaSha256)
pk, err := address.FromPrivateKeyBytes(block.Bytes, SignatureTypeRsaSha256)
require.NoError(t, err)
pub = address.FromRSAPublicKey(&k.PublicKey)
require.Equal(t,pk.PublicKey.Key, pub.Key)
require.Equal(t, pk.PublicKey.Key, pub.Key)
priv := address.FromRSAPrivateKey(k)
s := new(RsaSha256Signature)
s.PublicKey = pub.Key
require.NoError(t, SignRsaSha256(s, priv.Key, nil, hash[:]))
sig = s
case *ecdsa.PrivateKey:
pk := address.FromPrivateKeyBytes(block.Bytes, SignatureTypeEcdsaSha256)
pk, err := address.FromPrivateKeyBytes(block.Bytes, SignatureTypeEcdsaSha256)
require.NoError(t, err)
pub = address.FromEcdsaPublicKeyAsPKIX(&k.PublicKey)
require.Equal(t, pk.PublicKey.Key, pub.Key)
priv := address.FromEcdsaPrivateKey(k)
Expand All @@ -472,7 +473,8 @@ func TestTypesFromCerts(t *testing.T) {
require.NoError(t, SignEcdsaSha256(s, priv.Key, nil, hash[:]))
sig = s
case ed25519.PrivateKey:
pk := address.FromPrivateKeyBytes(block.Bytes, SignatureTypeED25519)
pk, err := address.FromPrivateKeyBytes(block.Bytes, SignatureTypeED25519)
require.NoError(t, err)
pub = address.FromED25519PublicKey(k.Public().(ed25519.PublicKey))
require.Equal(t, pk.PublicKey.Key, pub.Key)
priv := address.FromED25519PrivateKey(k)
Expand Down

0 comments on commit 9222c45

Please sign in to comment.