Post
Topic
Board Development & Technical Discussion
Re: openssl making private/public keys for ethereum
by
starmyc
on 23/03/2018, 13:31:21 UTC
Hmm. I need to take a deeper look, may be I missed a thing. Let me a few hours and I'll do some experiments. I'll let you know!

Ok, I guess it was incomplete.

Code:
$ openssl ec -check -inform DER -in private_key.der  -noout
read EC key
EC Key Invalid!
140074609043200:error:1010207B:elliptic curve routines:ec_key_simple_check_key:invalid private key:crypto/ec/ec_key.c:373:

That's because I imported the private key in the file, but the public key is still in there and openssl won't regenerate it (I thinked so, but well, it doesn't).

Let's make a valid file:

Code:
$ openssl ec -inform DER -in private_key.der -no_public 2>/dev/null | openssl ec -inform PEM -outform DER -out private_key_fixed.der 2>/dev/null
$ openssl ec -check -inform DER -in private_key_fixed.der -noout -text
read EC key
Private-Key: (256 bit)
priv:
    a1:14:da:d0:00:00:00:00:00:fa:ce:d0:00:00:00:
    00:00:ba:d0:00:00:00:00:de:ca:f0:0c:02:ba:d0:
    2b:ad
pub:
    04:9f:7d:cb:14:14:21:77:d7:b9:48:78:c4:59:b6:
    3a:16:f4:12:80:84:49:b7:8f:a1:7b:e6:4c:d3:7f:
    ed:57:a6:42:12:07:e6:ca:95:e0:c5:15:c3:5f:d5:
    8c:af:ac:a8:b0:e7:d6:07:a3:3a:2c:5c:b1:6a:de:
    28:af:83:15:f7
ASN1 OID: secp256k1
EC Key valid.

This said, my initial steps are just taking a long way. I could sum up the stuff, I guess.