Bitcoin Forum
May 11, 2024, 02:57:33 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: generating public key from private key on the command line  (Read 1445 times)
cyberguy (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 4


View Profile WWW
May 25, 2016, 02:54:49 PM
 #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 ?
1715396253
Hero Member
*
Offline Offline

Posts: 1715396253

View Profile Personal Message (Offline)

Ignore
1715396253
Reply with quote  #2

1715396253
Report to moderator
1715396253
Hero Member
*
Offline Offline

Posts: 1715396253

View Profile Personal Message (Offline)

Ignore
1715396253
Reply with quote  #2

1715396253
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
May 25, 2016, 06:42:51 PM
 #2

you can use gocoin for that - the lib or the wallet app

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
cyberguy (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 4


View Profile WWW
May 25, 2016, 10:39:11 PM
 #3

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
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
May 26, 2016, 07:15:20 AM
Last edit: May 26, 2016, 09:18:40 AM by piotr_n
 #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
It does. You only need the wallet tool, which has tiny requirements. It even runs on Raspberry Pi.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
May 26, 2016, 09:11:30 AM
 #5

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

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
cyberguy (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 4


View Profile WWW
May 26, 2016, 09:33:45 AM
 #6

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
unknown9387
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
May 27, 2016, 05:03:58 PM
 #7

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.
YarkoL
Legendary
*
Offline Offline

Activity: 996
Merit: 1013


View Profile
May 27, 2016, 08:45:17 PM
 #8


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.

“God does not play dice"
bit22gen
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
June 02, 2016, 09:07:37 PM
 #9

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
cyberguy (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 4


View Profile WWW
June 04, 2016, 03:38:58 PM
 #10

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!