Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

secp256k1: Missing publicKeyJwkFromPublicKeyBase58 method #64

Open
alexkravets opened this issue Feb 5, 2021 · 1 comment
Open

secp256k1: Missing publicKeyJwkFromPublicKeyBase58 method #64

alexkravets opened this issue Feb 5, 2021 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@alexkravets
Copy link

publicKeyJwkFromPublicKeyBase58 method is present for Ed25519 suite but is missing for secp256k1 .

Suggested method:

const publicKeyJwkFromPublicKeyBase58 = value => {
  const publicKeyHex = publicKeyUInt8ArrayFromPublicKeyBase58(value).toString('hex')
  const publicKeyJwk = publicKeyJwkFromPublicKeyHex(publicKeyHex)

  return publicKeyJwk
}
@alexkravets alexkravets changed the title secp256k1: missing publicKeyJwkFromPublicKeyBase58 method secp256k1: Missing publicKeyJwkFromPublicKeyBase58 method Feb 5, 2021
@OR13
Copy link
Member

OR13 commented Feb 5, 2021

thanks! PRs welcome, I know these helper methods are useful, you can convert base58 to hex and then use:

https://github.com/transmute-industries/did-key.js/blob/master/packages/secp256k1/src/keyUtils.ts#L93

const publicKeyJwkFromPublicKeyBase58 = (base58Encoded: string) => {
  const publicKeyHex = Buffer.from(bs58.decode(base58Encoded)).toString('hex')
  const publicKeyJwk = publicKeyJwkFromPublicKeyHex(publicKeyHex)

  return publicKeyJwk
}

@OR13 OR13 added enhancement New feature or request good first issue Good for newcomers labels Feb 5, 2021
@OR13 OR13 mentioned this issue Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants