transmute-industries / did-key.js

A DID Key Implementation in TypeScript
https://did.key.transmute.industries/
Apache License 2.0
53 stars 15 forks source link

Error: KeyUtils is not exported #145

Open lemoustachiste opened 2 years ago

lemoustachiste commented 2 years ago

Similarly to this error: https://github.com/transmute-industries/verifiable-data/issues/73, I am also encountering a build issue with did-key-secp256k1:

[!] Error: 'keyUtils' is not exported by node_modules/@transmute/did-key-secp256k1/dist/did-key-secp256k1.esm.js, imported by src/inspectors/confirmDidSignature.ts
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src/inspectors/confirmDidSignature.ts (4:9)
2: import { IDidDocument } from '../models/DidDocument';
3: import { IDidDocumentPublicKey } from '@decentralized-identity/did-common-typescript';
4: import { keyUtils } from '@transmute/did-key-secp256k1';
            ^
lemoustachiste commented 2 years ago

Actually it looks like it's not available at all. In a former version of the package I was using keyUtils as follows:

function retrieveIssuingAddress (verificationMethodPublicKey: IDidDocumentPublicKey, chain: IBlockchainObject): string {
  const publicKey = keyUtils.publicKeyUInt8ArrayFromJwk(verificationMethodPublicKey.publicKeyJwk as keyUtils.ISecp256k1PublicKeyJwk);
  const address = bitcoin.payments.p2pkh({ pubkey: publicKey, network: bitcoin.networks[chain.code] }).address;
  return address;
}

And on my issuing side:

function jwkFrom (key: Buffer, isPrivate: boolean = false): any /* @trust/keyto */ {
  const keyToHexString = key.toString('hex');
  if (isPrivate) {
    return keyUtils.privateKeyJwkFromPrivateKeyHex(keyToHexString);
  }

  return keyUtils.publicKeyJwkFromPublicKeyHex(keyToHexString);
}

Are those still available for consumption?