Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe committed May 23, 2024
1 parent 6bba1a9 commit 798f607
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions impl/internal/did/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,22 +353,7 @@ func (d DHT) ToDNSPacket(doc did.Document, types []TypeIndex, gateways []Authori
var vmIDs []string
for i, vm := range doc.VerificationMethod {
recordIdentifier := fmt.Sprintf("k%d", i)

// calculate the JWK thumbprint
thumbprint, err := vm.PublicKeyJWK.Thumbprint()
if err != nil {
return nil, fmt.Errorf("failed to calculate JWK thumbprint: %v", err)
}

// check if the VM ID matches the JWK thumbprint
unqualifiedVMID := strings.TrimPrefix(vm.ID, doc.ID+"#")
if unqualifiedVMID == thumbprint {
// if the VM ID matches the thumbprint, use the thumbprint as the key in the keyLookup map
keyLookup[vm.ID] = thumbprint
} else {
// otherwise, use the unqualified VM ID
keyLookup[vm.ID] = unqualifiedVMID
}
keyLookup[vm.ID] = recordIdentifier

keyType := keyTypeForJWK(*vm.PublicKeyJWK)
if keyType < 0 {
Expand All @@ -389,7 +374,14 @@ func (d DHT) ToDNSPacket(doc did.Document, types []TypeIndex, gateways []Authori

txtRecord := ""

// calculate the JWK thumbprint
thumbprint, err := vm.PublicKeyJWK.Thumbprint()
if err != nil {
return nil, fmt.Errorf("failed to calculate JWK thumbprint: %v", err)
}

// only include the id if it's not the JWK thumbprint
unqualifiedVMID := strings.TrimPrefix(vm.ID, doc.ID+"#")
if unqualifiedVMID != thumbprint {
txtRecord += fmt.Sprintf("id=%s;", unqualifiedVMID)
}
Expand Down

0 comments on commit 798f607

Please sign in to comment.