From 798f6073c395a21edab6c8b966c2e5f1197f607d Mon Sep 17 00:00:00 2001 From: gabe Date: Wed, 22 May 2024 21:58:21 -0700 Subject: [PATCH] fix test --- impl/internal/did/did.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/impl/internal/did/did.go b/impl/internal/did/did.go index c9731ab0..8654b5fb 100644 --- a/impl/internal/did/did.go +++ b/impl/internal/did/did.go @@ -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 { @@ -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) }