Importing a "raw" private key into the subtle crypto js library

139 views Asked by At

I have a private key that is just a simple 32 byte private key that was generated somewhere else entirely outside of javascript. I want to import this private key into javascript using the subtle crypto library.

From my experimentation and research, it seems there is no way to import a raw private key. It has to be in either pkcs8 format, or in jwk format.

First, I tried to convert my 32 byte private key into jwk format. I ran into a dead end when I realized that jwk requires the "x" and "y" parameters, which are basically the public key. I don't have the public key, all I have is the private key. I know you can generate the public key from the private key, but I assume that first requires you to import the private key first, which is what I'm trying to do.

Then I tried to convert it to pkcs8, but that also requires the x and y public points, which, again, I do not have.

Is this even possible? I know other crypto libraries let you import raw private keys, but for some reason subtle crypto doesn't let you?

0

There are 0 answers