Author

Topic: generating public key from private key on the command line (Read 1445 times)

jr. member
Activity: 34
Merit: 4
is there any command line utility that can be used to do the secp256k1 calculation on a given hexadecimal number (private key) and print the result (public key) to stdout in compressed and/or uncompressed form. can this be done using openssl ?

bitgen can be used:
http://bitcoin-gen.org/

Currently it will require two commands to get the information, but modifying the source to give all information at once is trivial.
It can run on a 32-bit machine and has low memory requirements.

For example:
$ bitgen hex 12312381273918273128937128912c3b1293cb712938cb12983cb192cb1289b3 info

Would give:
Wif    : 5HxJGdttiqC6hd4wXyExr8Jmv6WugaCtZtteoT8MCj74fhanXrQ

Next:
$ bitgen info 5HxJGdttiqC6hd4wXyExr8Jmv6WugaCtZtteoT8MCj74fhanXrQ

Gives:
Public point  :(6B4D16EF98953A36752D7A2776B5989ED8700B8F80ECAA1818F15E3EF31D1532
              : E9B6F7C6BE1017AC8D0A733DD099CBBB3A0DAEC89514F50F57A4B0259ACC0F10)
Public key    : 046B4D16EF98953A36752D7A2776B5989ED8700B8F80ECAA1818F15E3EF31D1532E9B6F7C6BE101 7AC8D0A733DD099CBBB3A0DAEC89514F50F57A4B0259ACC0F10


THIS is exactly what I wanted. In fact it is more than what I wanted. Thanks a lot.

To all those who posted above. Thanks for your replies. But I will only be considering bitgen, since the features I need are present in it.
jr. member
Activity: 45
Merit: 1
is there any command line utility that can be used to do the secp256k1 calculation on a given hexadecimal number (private key) and print the result (public key) to stdout in compressed and/or uncompressed form. can this be done using openssl ?

bitgen can be used:
http://bitcoin-gen.org/

Currently it will require two commands to get the information, but modifying the source to give all information at once is trivial.
It can run on a 32-bit machine and has low memory requirements.

For example:
$ bitgen hex 12312381273918273128937128912c3b1293cb712938cb12983cb192cb1289b3 info

Would give:
Wif    : 5HxJGdttiqC6hd4wXyExr8Jmv6WugaCtZtteoT8MCj74fhanXrQ

Next:
$ bitgen info 5HxJGdttiqC6hd4wXyExr8Jmv6WugaCtZtteoT8MCj74fhanXrQ

Gives:
Public point  :(6B4D16EF98953A36752D7A2776B5989ED8700B8F80ECAA1818F15E3EF31D1532
              : E9B6F7C6BE1017AC8D0A733DD099CBBB3A0DAEC89514F50F57A4B0259ACC0F10)
Public key    : 046B4D16EF98953A36752D7A2776B5989ED8700B8F80ECAA1818F15E3EF31D1532E9B6F7C6BE101 7AC8D0A733DD099CBBB3A0DAEC89514F50F57A4B0259ACC0F10
legendary
Activity: 996
Merit: 1013

Yes gocoin works just fine.

You can also do this very simply with
pybittools

https://github.com/vbuterin/pybitcointools

right at the start of the readme is an example.
newbie
Activity: 2
Merit: 0
First question, did the previous suggestion work.  2, if you don't mind telling us, would you be willing to explain what you're trying to do?  I have a simple python program that could easily be modded to just spit out public keys.  Though I don't think I have one that will allow you to input (on the command line, as opposed to actually putting it into the python program itself).  I also think the one(s) I have would require a decimal input.  Just asking.
jr. member
Activity: 34
Merit: 4
Try this:

Code:
package main

import (
"fmt"
"encoding/hex"
"github.com/piotrnar/gocoin/lib/btc"
)

const PRV_KEY_HEX = "AB9EA551E262A87A13BB90591BE7B545CDF3FD0E1234567890ABCDEF12345678"
const COMPRESSED = false

func main() {
private_key, _ := hex.DecodeString(PRV_KEY_HEX)
fmt.Println(hex.EncodeToString(btc.PublicFromPrivate(private_key, COMPRESSED)))
}


You will just need to fetch gocoin package first (having go and git installed):
Code:
go get -d github.com/piotrnar/gocoin

thanks, will give it a try
legendary
Activity: 2053
Merit: 1354
aka tonikt
Try this:

Code:
package main

import (
"fmt"
"encoding/hex"
"github.com/piotrnar/gocoin/lib/btc"
)

const PRV_KEY_HEX = "AB9EA551E262A87A13BB90591BE7B545CDF3FD0E1234567890ABCDEF12345678"
const COMPRESSED = false

func main() {
private_key, _ := hex.DecodeString(PRV_KEY_HEX)
fmt.Println(hex.EncodeToString(btc.PublicFromPrivate(private_key, COMPRESSED)))
}


You will just need to fetch gocoin package first (having go and git installed):
Code:
go get -d github.com/piotrnar/gocoin
legendary
Activity: 2053
Merit: 1354
aka tonikt
you can use gocoin for that - the lib or the wallet app

I need something that can run on a 32-bit machine with low memory requirements
It does. You only need the wallet tool, which has tiny requirements. It even runs on Raspberry Pi.
jr. member
Activity: 34
Merit: 4
you can use gocoin for that - the lib or the wallet app

I need something that can run on a 32-bit machine with low memory requirements
legendary
Activity: 2053
Merit: 1354
aka tonikt
you can use gocoin for that - the lib or the wallet app
jr. member
Activity: 34
Merit: 4
is there any command line utility that can be used to do the secp256k1 calculation on a given hexadecimal number (private key) and print the result (public key) to stdout in compressed and/or uncompressed form. can this be done using openssl ?
Jump to: