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

Converting from JWK format: Public Key could not be parsed #201

Open
lemoustachiste opened this issue Sep 7, 2023 · 0 comments
Open

Converting from JWK format: Public Key could not be parsed #201

lemoustachiste opened this issue Sep 7, 2023 · 0 comments

Comments

@lemoustachiste
Copy link

Hi,

so I eventually have a private key handed to me as PEM. For my tests, I generated a key as follows:

openssl ecparam -name secp256k1 -genkey -noout -out priv_k.pem

I am then converting it to JWK, and generating a public key (both openssl and publicKeyJWKToPEM yield the same result, so I am confident this works).

Then I am trying to convert to secp256k1 key pair to use as DID document, so I'm using this method from @transmute: https://github.com/transmute-industries/verifiable-data/blob/main/packages/secp256k1-key-pair/src/getPublicKeyFromPublicKeyJwk.ts#L3, which uses secp256k1-node under the hood

but this fails with the following error:

Public Key could not be parsed

as this check fails: https://github.com/cryptocoinjs/secp256k1-node/blob/master/lib/elliptic.js#L39. I am not a cryptographer so I don't off the bat understand what it's supposed to check.

Here is my private key as JWK:

{
  "kty": "EC",
  "crv": "K-256",
  "d": "r-MRT1Jq7PgvtmMtiEr_lFgE6iPGkl9pW2kU10F88q4",
  "x": "O4bF2wCslKVW0adio9s4fhSrq4h4_tw9IGNmc93oBas",
  "y": "O9hHmm9rRFWHv3vI4TWsqPxMXKp570_MU71XCLtjkEs"
}

Can you guide me towards the light here? Where is the data wrong?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant