Convert ECDSA private hex key to public key

送分小仙女□ 提交于 2020-01-15 04:52:04

问题


I'm using the below two lines to generate a hex of an ECDSA private key:

openssl ecparam -genkey -name secp256k1 -out data.pem

openssl ec -in data.pem -outform DER|tail -c +8|head -c 32|xxd -p -c 32

Those output something like this:

059f2c8f5b1978bcc02d4b41e75c3aae99f3194fb06b53ffd256178e1367a2a6

How can I then use that hex key to generate a public ECDSA key, something like this?

043d6fa62769c10ceb28d3c13ae1e2329888e99d9c8bf854cc5bdcea0b7cd3002a0f5d244e35eec297c8eb4098b75295328cdeebe7e39a5ac7539f0fc146fa3c99

Any help is appreciated.


回答1:


Try this one

openssl ec -in data.pem -pubout -out pubkey.pem



回答2:


You can take the last 65 bytes of your private key you got from

openssl ecparam -genkey -name secp256k1 -out data.pem
openssl ec -in data.pem -outform DER

That's your public key too.



来源:https://stackoverflow.com/questions/20086121/convert-ecdsa-private-hex-key-to-public-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!