{"version":3,"sources":["../src/index.ts","../src/drivers/ed25519.ts","../src/types.ts","../src/drivers/bls12381g2.ts","../src/drivers/secp256k1.ts","../src/drivers/secp256r1.ts","../src/drivers/secp384r1.ts","../src/drivers/secp521r1.ts","../src/drivers/jwk.jcs.ts"],"sourcesContent":["import varint from 'varint'\nconst { decode } = varint\n// @ts-ignore\nimport { base58btc } from 'multiformats/bases/base58'\nimport ed25519 from './drivers/ed25519'\nimport bls12381g2 from './drivers/bls12381g2'\nimport secp256k1 from './drivers/secp256k1'\nimport secp256r1 from './drivers/secp256r1'\nimport secp384r1 from './drivers/secp384r1'\nimport secp521r1 from './drivers/secp521r1'\nimport { DIDResolutionResult, ParsedDID, Resolvable, ResolverRegistry } from 'did-resolver'\nimport jwkJcs from './drivers/jwk.jcs'\nimport { DID_JSON, DID_LD_JSON, DIDKeyResolutionOptions, KeyToDidDocArgs } from './types'\n\nexport * from './types'\n\nconst prefixToDriverMap: any = {\n  0xe7: secp256k1,\n  0xed: ed25519,\n  0x1200: secp256r1,\n  0x1201: secp384r1,\n  0x1202: secp521r1,\n  0xeb: bls12381g2,\n  0xeb51: jwkJcs,\n}\n\nexport const getResolver = (): ResolverRegistry => {\n  return {\n    key: async (did: string, parsed: ParsedDID, r: Resolvable, options: DIDKeyResolutionOptions) => {\n      const contentType = options.accept || DID_LD_JSON\n      const response: DIDResolutionResult = {\n        didResolutionMetadata: { contentType },\n        didDocument: null,\n        didDocumentMetadata: {},\n      }\n      try {\n        const multicodecPubKey = base58btc.decode(parsed.id)\n        const keyType = decode(multicodecPubKey)\n        const pubKeyBytes = multicodecPubKey.slice(decode.bytes)\n        const args: KeyToDidDocArgs = { pubKeyBytes, fingerprint: parsed.id, contentType, options }\n        const doc = await prefixToDriverMap[keyType].keyToDidDoc(args)\n        if (contentType === DID_LD_JSON) {\n          if (!doc['@context']) {\n            doc['@context'] = 'https://w3id.org/did/v1'\n          } else if (\n            Array.isArray(doc['@context']) &&\n            !doc['@context'].includes('https://w3id.org/did/v1') &&\n            !doc['@context'].includes('https://www.w3.org/ns/did/v1')\n          ) {\n            doc['@context'].push('https://w3id.org/did/v1')\n          }\n          response.didDocument = doc\n        } else if (contentType === DID_JSON) {\n          response.didDocument = doc\n        } else {\n          delete response.didResolutionMetadata.contentType\n          response.didResolutionMetadata.error = 'representationNotSupported'\n        }\n      } catch (e: any) {\n        response.didResolutionMetadata.error = 'invalidDid'\n        response.didResolutionMetadata.message = e.toString()\n      }\n      return response\n    },\n  }\n}\nexport default { getResolver }\n","// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { toString } = u8a\nimport { DIDDocument } from 'did-resolver'\n// import { edwardsToMontgomery } from '@noble/curves/ed25519'\nimport { convertPublicKeyToX25519 } from '@stablelib/ed25519'\nimport { DID_LD_JSON, KeyToDidDocArgs } from '../types'\n\nfunction encodeKey(key: Uint8Array, encodeKey?: number) {\n  const bytes = new Uint8Array(key.length + 2)\n  bytes[0] = encodeKey ?? 0xec\n  // The multicodec is encoded as a varint so we need to add this.\n  // See js-multicodec for a general implementation\n  bytes[1] = 0x01\n  bytes.set(key, 2)\n  return `z${toString(bytes, 'base58btc')}`\n}\n\nexport const keyToDidDoc = (args: KeyToDidDocArgs) => {\n  const { options } = args\n  if (!options?.publicKeyFormat) {\n    return keyToDidDoc2020(args)\n  }\n  switch (options.publicKeyFormat) {\n    case 'Ed25519VerificationKey2018':\n    case 'X25519KeyAgreementKey2019':\n      return keyToDidDoc2018_2019(args)\n    case 'Ed25519VerificationKey2020':\n    case 'X25519KeyAgreementKey2020':\n    case 'Multikey':\n      return keyToDidDoc2020(args)\n    default:\n      throw Error(`${options.publicKeyFormat} not supported yet for the ed25519 driver`)\n  }\n}\nconst keyToDidDoc2018_2019 = ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs): DIDDocument => {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n\n  //todo: Move to noble lib. x25519 values differ between below methods. Current implementation is correct according to DID:key spec\n  // const pubKeyHex = toString(pubKeyBytes, 'base16')\n  // const x25519PubBytes = edwardsToMontgomery(pubKeyHex)\n  const x25519PubBytes = convertPublicKeyToX25519(pubKeyBytes)\n\n  const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`\n  return {\n    ...(contentType === DID_LD_JSON && {\n      '@context': [\n        'https://www.w3.org/ns/did/v1',\n        'https://w3id.org/security/suites/ed25519-2018/v1',\n        'https://w3id.org/security/suites/x25519-2019/v1',\n      ],\n    }),\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'Ed25519VerificationKey2018',\n        controller: did,\n        publicKeyBase58: toString(pubKeyBytes, 'base58btc'),\n      },\n      {\n        id: x25519KeyId,\n        type: 'X25519KeyAgreementKey2019',\n        controller: did,\n        publicKeyBase58: toString(x25519PubBytes, 'base58btc'),\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n    keyAgreement: [x25519KeyId],\n  }\n}\n\nconst keyToDidDoc2020 = ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs): DIDDocument => {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n  //todo: Move to noble lib. x25519 values differ between below methods. Current implementation is correct according to DID:key spec\n  // const pubKeyHex = u8a.toString(pubKeyBytes, 'base16')\n  // const x25519PubBytes = edwardsToMontgomery(pubKeyBytes)\n  const x25519PubBytes = convertPublicKeyToX25519(pubKeyBytes)\n\n  const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`\n  return {\n    ...(contentType === DID_LD_JSON && {\n      '@context': [\n        'https://www.w3.org/ns/did/v1',\n        'https://w3id.org/security/suites/ed25519-2020/v1',\n        'https://w3id.org/security/suites/x25519-2020/v1',\n      ],\n    }),\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'Ed25519VerificationKey2020',\n        controller: did,\n        publicKeyMultibase: encodeKey(pubKeyBytes, 0xed),\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n    keyAgreement: [\n      {\n        id: x25519KeyId,\n        type: 'X25519KeyAgreementKey2020',\n        controller: did,\n        publicKeyMultibase: encodeKey(x25519PubBytes, 0xec),\n      },\n    ],\n  }\n}\nexport default { keyToDidDoc }\n","import { DIDResolutionOptions } from 'did-resolver'\n\nexport const DID_LD_JSON = 'application/did+ld+json'\nexport const DID_JSON = 'application/did+json'\n\nexport type PublicKeyFormat =\n  | 'JsonWebKey2020'\n  | 'Ed25519VerificationKey2018'\n  | 'X25519KeyAgreementKey2019'\n  | 'Ed25519VerificationKey2020'\n  | 'X25519KeyAgreementKey2020'\n  | 'Multikey'\nexport interface KeyToDidDocArgs {\n  pubKeyBytes: Uint8Array\n  fingerprint: string\n  contentType?: string\n  options?: DIDKeyResolutionOptions\n}\n\nexport interface DIDKeyResolutionOptions extends DIDResolutionOptions {\n  publicKeyFormat?: PublicKeyFormat\n}\n","import { DIDDocument } from 'did-resolver'\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { toString } = u8a\nimport { KeyToDidDocArgs } from '../index'\n\nexport const keyToDidDoc = ({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): DIDDocument => {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n  return {\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'Bls12381G2Key2020',\n        controller: did,\n        publicKeyBase58: toString(pubKeyBytes, 'base58btc'),\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n  }\n}\nexport default { keyToDidDoc }\n","// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { toString } = u8a\nimport { DIDDocument } from 'did-resolver'\nimport { KeyToDidDocArgs } from '../types'\n\nexport const keyToDidDoc = ({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): DIDDocument => {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n  return {\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'Secp256k1VerificationKey2018',\n        controller: did,\n        publicKeyBase58: toString(pubKeyBytes, 'base58btc'),\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n  }\n}\n\nexport default { keyToDidDoc }\n","// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.\n\nimport * as nist_weierstrauss from 'nist-weierstrauss'\nimport { base64urlPoint } from 'nist-weierstrauss'\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { fromString } = u8a\nimport { KeyToDidDocArgs } from '../types'\n\n/**\n * Constructs the document based on the method key\n */\nexport function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n  const key = pubKeyBytesToXY(pubKeyBytes)\n  return {\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'JsonWebKey2020',\n        controller: did,\n        publicKeyJwk: {\n          kty: 'EC',\n          crv: 'P-256',\n          x: key.xm,\n          y: key.ym,\n        },\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n  }\n}\n\n/**\n *\n * @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),\n *  uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.\n * @returns point x,y with coordinates as multibase encoded base64urls\n *\n * See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-256.\n * At present only raw p-256 keys are covered in the specification.\n * @throws TypeError: input cannot be null or undefined.\n * @throws Error: Unexpected pubKeyBytes\n * @internal\n */\nexport function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint {\n  if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {\n    throw new TypeError('input must be a Uint8Array')\n  }\n  const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes)\n  const bytesCount = publicKeyHex.length / 2\n\n  // raw p-256 key\n  if (bytesCount == 64) {\n    return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKeyHex)\n  }\n\n  // uncompressed p-256 key, SEC format\n  if (bytesCount == 65) {\n    if (publicKeyHex.slice(0, 2) == '04') {\n      const publicKey = publicKeyHex.slice(2)\n      return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKey)\n    }\n  }\n\n  // compressed p-256 key, SEC format\n  if (bytesCount == 33) {\n    if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {\n      const publicKey = fromString(publicKeyHex, 'base16')\n      const point = nist_weierstrauss.secp256r1.ECPointDecompress(publicKey)\n      return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point)\n    }\n  }\n\n  throw new Error('Unexpected pubKeyBytes')\n}\n\nexport default { keyToDidDoc }\n","// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.\n\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { fromString } = u8a\n\nimport * as nist_weierstrauss from 'nist-weierstrauss'\nimport { base64urlPoint } from 'nist-weierstrauss'\nimport { KeyToDidDocArgs } from '../types'\n\n/**\n * Constructs the document based on the method key\n */\nexport function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n  const key = pubKeyBytesToXY(pubKeyBytes)\n  return {\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'JsonWebKey2020',\n        controller: did,\n        publicKeyJwk: {\n          kty: 'EC',\n          crv: 'P-384',\n          x: key.xm,\n          y: key.ym,\n        },\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n  }\n}\n\n/**\n *\n * @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),\n *  uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.\n * @returns point x,y with coordinates as multibase encoded base64urls\n *\n * See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-384.\n * At present only raw p-384 keys are covered in the specification.\n * @throws TypeError: input cannot be null or undefined.\n * @throws Error: Unexpected pubKeyBytes\n * @internal\n */\nexport function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint {\n  if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {\n    throw new TypeError('input must be a Uint8Array')\n  }\n  const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes)\n  const bytesCount = publicKeyHex.length / 2\n\n  // raw p-384 key\n  if (bytesCount == 96) {\n    return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKeyHex)\n  }\n\n  // uncompressed p-384 key, SEC format\n  if (bytesCount == 97) {\n    if (publicKeyHex.slice(0, 2) == '04') {\n      const publicKey = publicKeyHex.slice(2)\n      return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKey)\n    }\n  }\n\n  // compressed p-384 key, SEC format\n  if (bytesCount == 49) {\n    if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {\n      const publicKey = fromString(publicKeyHex, 'base16')\n      const point = nist_weierstrauss.secp384r1.ECPointDecompress(publicKey)\n      return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point)\n    }\n  }\n\n  throw new Error('Unexpected pubKeyBytes')\n}\n\nexport default { keyToDidDoc }\n","// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.\n\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { fromString } = u8a\n\nimport * as nist_weierstrauss from 'nist-weierstrauss'\nimport { base64urlPoint } from 'nist-weierstrauss'\nimport { KeyToDidDocArgs } from '../types'\n\n/**\n * Constructs the document based on the method key\n */\nexport function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n  const key = pubKeyBytesToXY(pubKeyBytes)\n  return {\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'JsonWebKey2020',\n        controller: did,\n        publicKeyJwk: {\n          kty: 'EC',\n          crv: 'P-521',\n          x: key.xm,\n          y: key.ym,\n        },\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n  }\n}\n\n/**\n *\n * @param pubKeyBytes - public key as compressed with 0x02 prefix if even and 0x03 prefix if odd.\n * @returns point x,y with coordinates as multibase encoded base64urls\n *\n * See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-521.\n * For compression see: https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#rfc.section.3\n * @throws TypeError: input cannot be null or undefined.\n * @throws Error: Unexpected pubKeyBytes\n * @internal\n */\nexport function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint {\n  if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {\n    throw new TypeError('input must be a Uint8Array')\n  }\n  const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes)\n\n  // compressed p-521 key, SEC format\n  // publicKeyHex.length / 2.0 = 67.0 bytes\n  if (132 <= publicKeyHex.length && publicKeyHex.length <= 134) {\n    if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {\n      const publicKey = fromString(publicKeyHex, 'base16')\n      const point = nist_weierstrauss.secp521r1.ECPointDecompress(publicKey)\n      return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point)\n    }\n  }\n\n  throw new Error('Unexpected pubKeyBytes')\n}\n\nexport default { keyToDidDoc }\n","import { DIDDocument, JsonWebKey as DIFJWK } from 'did-resolver'\nimport { DID_LD_JSON, KeyToDidDocArgs } from '../index'\nimport { jwkJcsDecode } from '@sphereon/ssi-sdk-ext.key-utils'\n\nexport const keyToDidDoc = ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs): DIDDocument => {\n  const did = `did:key:${fingerprint}`\n  const keyId = `${did}#${fingerprint}`\n  const publicKeyJwk = jwkJcsDecode(pubKeyBytes) as DIFJWK\n  return {\n    ...(contentType === DID_LD_JSON && {\n      '@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/jws-2020/v1'],\n    }),\n    id: did,\n    verificationMethod: [\n      {\n        id: keyId,\n        type: 'JsonWebKey2020',\n        controller: did,\n        publicKeyJwk,\n      },\n    ],\n    authentication: [keyId],\n    assertionMethod: [keyId],\n    capabilityDelegation: [keyId],\n    capabilityInvocation: [keyId],\n  }\n}\nexport default { keyToDidDoc }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAAA,oBAAmB;AAGnB,oBAA0B;;;ACF1B,UAAqB;AAIrB,qBAAyC;;;ACHlC,IAAMA,cAAc;AACpB,IAAMC,WAAW;;;ADDxB,IAAM,EAAEC,SAAQ,IAAKC;AAMrB,SAASC,UAAUC,KAAiBD,YAAkB;AACpD,QAAME,QAAQ,IAAIC,WAAWF,IAAIG,SAAS,CAAA;AAC1CF,QAAM,CAAA,IAAKF,cAAa;AAGxBE,QAAM,CAAA,IAAK;AACXA,QAAMG,IAAIJ,KAAK,CAAA;AACf,SAAO,IAAIH,SAASI,OAAO,WAAA,CAAA;AAC7B;AARSF;AAUF,IAAMM,cAAc,wBAACC,SAAAA;AAC1B,QAAM,EAAEC,QAAO,IAAKD;AACpB,MAAI,CAACC,SAASC,iBAAiB;AAC7B,WAAOC,gBAAgBH,IAAAA;EACzB;AACA,UAAQC,QAAQC,iBAAe;IAC7B,KAAK;IACL,KAAK;AACH,aAAOE,qB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AAOY;UAAIT;UAAaD;QAAQ;AAC1F,cAAMiB,MAAM,MAAM9B,kBAAkBwB,OAAAA,EAASO,YAAYH,IAAAA;AACzD,YAAId,gBAAgBE,aAAa;AAC/B,cAAI,CAACc,IAAI,UAAA,GAAa;AACpBA,gBAAI,UAAA,IAAc;UACpB,WACEE,MAAMC,QAAQH,IAAI,UAAA,CAAW,KAC7B,CAACA,IAAI,UAAA,EAAYI,SAAS,yBAAA,KAC1B,CAACJ,IAAI,UAAA,EAAYI,SAAS,8BAAA,GAC1B;AACAJ,gBAAI,UAAA,EAAYK,KAAK,yBAAA;UACvB;AACAlB,mBAASE,cAAcW;QACzB,WAAWhB,gBAAgBsB,UAAU;AACnCnB,mBAASE,cAAcW;QACzB,OAAO;AACL,iBAAOb,SAASC,sBAAsBJ;AACtCG,mBAASC,sBAAsBmB,QAAQ;QACzC;MACF,SAASC,GAAQ;AACfrB,iBAASC,sBAAsBmB,QAAQ;AACvCpB,iBAASC,sBAAsBqB,UAAUD,EAAEE,SAAQ;MACrD;AACA,aAAOvB;IACT,GAnCK;EAoCP;AACF,GAvC2B;AAwC3B,IAAA,gBAAe;EAAET;AAAY;","names":["DID_LD_JSON","DID_JSON","toString","u8a","encodeKey","key","bytes","Uint8Array","length","set","keyToDidDoc","args","options","publicKeyFormat","keyToDidDoc2020","keyToDidDoc2018_2019","Error","pubKeyBytes","fingerprint","contentType","did","keyId","x25519PubBytes","convertPublicKeyToX25519","x25519KeyId","DID_LD_JSON","id","verificationMethod","type","controller","publicKeyBase58","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","keyAgreement","publicKeyMultibase","u8a","toString","u8a","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","id","verificationMethod","type","controller","publicKeyBase58","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","u8a","toString","u8a","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","id","verificationMethod","type","controller","publicKeyBase58","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","u8a","fromString","u8a","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","key","pubKeyBytesToXY","id","verificationMethod","type","controller","publicKeyJwk","kty","crv","x","xm","y","ym","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","nist_weierstrauss_common","testUint8Array","TypeError","publicKeyHex","pubKeyBytesToHex","bytesCount","length","publicKeyToXY","slice","publicKey","point","secp256r1","ECPointDecompress","publicKeyIntToXY","Error","u8a","nist_weierstrauss","fromString","u8a","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","key","pubKeyBytesToXY","id","verificationMethod","type","controller","publicKeyJwk","kty","crv","x","xm","y","ym","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","nist_weierstrauss_common","testUint8Array","TypeError","publicKeyHex","pubKeyBytesToHex","bytesCount","length","publicKeyToXY","slice","publicKey","point","secp384r1","ECPointDecompress","publicKeyIntToXY","Error","u8a","nist_weierstrauss","fromString","u8a","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","key","pubKeyBytesToXY","id","verificationMethod","type","controller","publicKeyJwk","kty","crv","x","xm","y","ym","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","nist_weierstrauss_common","testUint8Array","TypeError","publicKeyHex","pubKeyBytesToHex","length","slice","publicKey","point","secp521r1","ECPointDecompress","publicKeyIntToXY","Error","keyToDidDoc","pubKeyBytes","fingerprint","contentType","did","keyId","publicKeyJwk","jwkJcsDecode","DID_LD_JSON","id","verificationMethod","type","controller","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","decode","varint","prefixToDriverMap","secp256k1","ed25519","secp256r1","secp384r1","secp521r1","bls12381g2","jwkJcs","getResolver","key","did","parsed","r","options","contentType","accept","DID_LD_JSON","response","didResolutionMetadata","didDocument","didDocumentMetadata","multicodecPubKey","base58btc","id","keyType","pubKeyBytes","slice","bytes","args","fingerprint","doc","keyToDidDoc","Array","isArray","includes","push","DID_JSON","error","e","message","toString"]}