Skip to content

Commit

Permalink
didtest: complete the set of function, finish removing the dependency…
Browse files Browse the repository at this point in the history
… on testing.T
  • Loading branch information
MichaelMure committed Dec 12, 2024
1 parent 8bb3a4f commit 042d6dc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions did/didtest/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ package didtest

import (
"fmt"
"testing"

"github.com/libp2p/go-libp2p/core/crypto"
"github.com/stretchr/testify/require"

"github.com/ucan-wg/go-ucan/did"
)
Expand Down Expand Up @@ -92,17 +90,26 @@ func (p Persona) PrivKey() crypto.PrivKey {
return res
}

func (p Persona) PrivKeyConfig() string {
res, ok := privKeyB64()[p]
if !ok {
panic(fmt.Sprintf("Unknown persona: %v", p))
}
return res
}

// PubKey returns the Ed25519 public key for the Persona.
func (p Persona) PubKey() crypto.PubKey {
return p.PrivKey().GetPublic()
}

// PubKeyConfig returns the marshaled and encoded Ed25519 public key
// for the Persona.
func (p Persona) PubKeyConfig(t *testing.T) string {
func (p Persona) PubKeyConfig() string {
pubKeyMar, err := crypto.MarshalPublicKey(p.PrivKey().GetPublic())
require.NoError(t, err)

if err != nil {
panic(err)
}
return crypto.ConfigEncodeKey(pubKeyMar)
}

Expand Down

0 comments on commit 042d6dc

Please sign in to comment.