Skip to content

Commit

Permalink
Fix erroneous DID for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Apr 23, 2024
1 parent 1f8ffeb commit ff1d800
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
8 changes: 0 additions & 8 deletions did/doc/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,3 @@ func compareSlices(a []string, b []string) bool {

return slices.Compare(a, b) == 0
}

// func (d *Document) Path() path.Path {
// return d.immutablePath
// }

// func (d *Document) DID() did.DID {
// return d.did
// }
4 changes: 2 additions & 2 deletions key/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func NewEncryptionKey(d did.DID) (EncryptionKey, error) {
return EncryptionKey{}, fmt.Errorf("NewEncryptionKey: %w", err)
}

// We just mangle the base DID as this is not a pointer to a DID.
d.Fragment = name
// Create a unique identifier for the key
d = did.New(d.IPNSName(), name)

// Generate a random private key
var privKey [curve25519.ScalarSize]byte
Expand Down
7 changes: 5 additions & 2 deletions key/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
mf "github.com/bahner/go-ma/utils"
nanoid "github.com/matoous/go-nanoid/v2"
"github.com/multiformats/go-multicodec"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -41,8 +42,10 @@ func NewSigningKey(d did.DID) (SigningKey, error) {
if err != nil {
return SigningKey{}, fmt.Errorf("NewSigningKey: %w", err)
}
// We just mangle the base DID as this is not a pointer to a DID.
d.Fragment = name

// Create a unique identifier for the key
d = did.New(d.IPNSName(), name)
log.Info("Created new DID: ", d)

publicKey, privKey, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
Expand Down

0 comments on commit ff1d800

Please sign in to comment.