secp256k1-node
secp256k1-node copied to clipboard
Converting from JWK format: Public Key could not be parsed
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