anvilresearch / webcrypto

W3C Web Cryptography API for Node.js
MIT License
82 stars 14 forks source link

ECDSA Notes #10

Closed EternalDeiwos closed 7 years ago

EternalDeiwos commented 7 years ago

Regarding taking a look at ECDSA stuff with @thelunararmy

JWA curve names to OpenSSL curve names:

P-256 => prime256v1
P-384 => secp384r1
P-512 => secp521r1

All of these are currently supported by OpenSSL/Node and the use of which is featured in their docs

OpenSSL: openssl ecparam --name prime256v1 -genkey -noout -out privateKey.pem openssl ec -in privateKey.pem -pubout -out publicKey.pem

EternalDeiwos commented 7 years ago

Further notes regarding ECDSA for bitcoin: Bitcoin uses the secp256k1 curve and RIPEMD-160 and SHA-256 for hashes.

According to SafeCurves this is also broken like the NIST curves. The general feeling is to use ED25519 (which is supposedly safe)

EternalDeiwos commented 7 years ago

We can now get x and y coords from a ECDSA key

https://gist.github.com/EternalDeiwos/f06faadca0894f32d023e6511bd2a935

EternalDeiwos commented 7 years ago

Regarding conversion between PKCS1 and PKCS8 PEM encoded private keys:

For all purposes, PKCS1 and PKCS8 private keys are exactly equivalent. The only difference is that PKCS8 private keys include algorithm and parameter metadata and must therefore be parsed differently.

This command will accept a PKCS1 private key and produce a PKCS8 private key:

openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in pkcs1.pem -out pkcs8.pem
OR
cat pkcs1.pem | openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -out pkcs8.pem
EternalDeiwos commented 7 years ago

13 Merged and closed. Closing this.