Skip to content

Commit

Permalink
Fix: Re define identifiers for the main controller set as default ver…
Browse files Browse the repository at this point in the history
…ification method

Signed-off-by: eum602 <[email protected]>
  • Loading branch information
eum602 committed Jun 26, 2024
1 parent 2f6562b commit f69bc6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/lac1/lac1resolverUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ export function wrapDidDocument(
mode
) {
const now = BigNumber.from(Math.floor(new Date().getTime() / 1000));
const valueInHex = caip10ControllerFormat.split(":")[2];
const defaultIdVerificationMethod = processVerificationMethodIdForAttribute(
did,
valueInHex
);
const defaultVerificationMethod = {
id: `${did}#controller`,
id: `${did}#${defaultIdVerificationMethod}`,
type: "EcdsaSecp256k1RecoveryMethod2020",
controller: `${did}`,
blockchainAccountId: caip10ControllerFormat,
Expand Down
9 changes: 7 additions & 2 deletions test/lac1/lac1Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getLac1didTestParams,
newLac1Did as newDid,
} from "../testInitializer.js";
import { processVerificationMethodIdForAttribute } from "../../lib/lac1/lac1resolverUtils.js";

const expect = chai.expect;
chai.use(chaiAsPromised);
Expand Down Expand Up @@ -45,9 +46,13 @@ describe("Lac1 DIDResolver", async () => {
const document = await resolver.lac1(did.id);
const d = document.verificationMethod[0];
expect(d["controller"]).to.eq(did.id);
expect(d["id"]).to.eq(`${did.id}#controller`);
expect(d["type"]).to.eq("EcdsaSecp256k1RecoveryMethod2020");
const currentController = await did.getController();
const defaultIdVerificationMethod = processVerificationMethodIdForAttribute(
did.id,
currentController
);
expect(d["id"]).to.eq(`${did.id}#${defaultIdVerificationMethod}`);
expect(d["type"]).to.eq("EcdsaSecp256k1RecoveryMethod2020");
const retrievedHexchainId =
did.chainId.length % 2 == 0 ? did.chainId : "0" + did.chainId;
const retrievedIntchainId = parseInt(retrievedHexchainId, 16);
Expand Down

0 comments on commit f69bc6a

Please sign in to comment.