Bitcoin Forum
April 23, 2024, 07:26:14 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 2 3 4 [5]  All
  Print  
Author Topic: Prize for importing private key [WON]  (Read 18050 times)
mgiuca
Newbie
*
Offline Offline

Activity: 25
Merit: 7


View Profile
February 24, 2011, 10:57:51 AM
 #81

Thanks for your help mike. Actually I just spent ... fricking ... too many hours to admit ... trawling through OpenSSL to figure out how to do it.

My code is online here:
https://code.launchpad.net/~mgiuca/+junk/bitcoin-import

It depends on OpenSSL and BitcoinTools, and is otherwise fairly automatic. It takes a 32-bit private key in base58 and automatically inserts it into your Bitcoin wallet. Yay!
1713857174
Hero Member
*
Offline Offline

Posts: 1713857174

View Profile Personal Message (Offline)

Ignore
1713857174
Reply with quote  #2

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

Activity: 40
Merit: 0


View Profile
February 24, 2011, 01:10:07 PM
 #82

Little late to this party...

...I was also working on the challenge, and I found that Crypto++ worked really well for this. What I found was a nice surprise was that the ECDSA classes were nice enough to generate public keys from a private one if you had the data:

http://www.cryptopp.com/wiki/Elliptic_Curve_Digital_Signature_Algorithm

Found it much, MUCH easier to use than OpenSSL. Downside is, well, you gotta know C++.
JollyGreen
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
February 24, 2011, 05:52:26 PM
 #83

Little late to this party...

...I was also working on the challenge, and I found that Crypto++ worked really well for this. What I found was a nice surprise was that the ECDSA classes were nice enough to generate public keys from a private one if you had the data:

http://www.cryptopp.com/wiki/Elliptic_Curve_Digital_Signature_Algorithm

Found it much, MUCH easier to use than OpenSSL. Downside is, well, you gotta know C++.

I looked into this library and I couldn't find that it supported ecdsa 256k1.  Maybe it's just a matter of adding the curve constants to their library....
JollyGreen
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
February 24, 2011, 05:56:02 PM
 #84

Thanks for your help mike. Actually I just spent ... fricking ... too many hours to admit ... trawling through OpenSSL to figure out how to do it.

My code is online here:
https://code.launchpad.net/~mgiuca/+junk/bitcoin-import

It depends on OpenSSL and BitcoinTools, and is otherwise fairly automatic. It takes a 32-bit private key in base58 and automatically inserts it into your Bitcoin wallet. Yay!

Nice work again, python just seems so much easier to deal with than these other libraries, I guess just preference though Smiley
chromicant
Newbie
*
Offline Offline

Activity: 40
Merit: 0


View Profile
February 24, 2011, 07:37:28 PM
 #85

I looked into this library and I couldn't find that it supported ecdsa 256k1.  Maybe it's just a matter of adding the curve constants to their library....

It's in there. My code looked a little something like this (from memory, so it may very well be WRONG):

AutoSeededRandomPool prng;
Integer pkey("TheHexStringOfTheKeyUnhashed");
ECDSA<ECP, SHA256>::PrivateKey privateKey;
ECDSA<ECP, SHA256>::PublicKey publicKey;

privateKey.Initialize(prng, ASN1::secp256k1());
privateKey.SetPrivateExponent(pkey);
privateKey.MakePublicKey(publicKey);


And volia, a public key from a private key.

mgiuca
Newbie
*
Offline Offline

Activity: 25
Merit: 7


View Profile
February 25, 2011, 05:11:53 AM
 #86

Nice work again, python just seems so much easier to deal with than these other libraries, I guess just preference though Smiley
I agree. I always choose Python if I can Smiley In this case, I chose a mixture of Python and C. I am glad I stuck with C/OpenSSL when other people are using Java/Bouncy Castle or other approaches. My code can be integrated into the main Bitcoin codebase without introducing any new dependencies. I am interested to see if I can extend it to deal with this .bitkey format people are talking about.

I have stated elsewhere that I wanted to replace the Wallet format (which I regard as an ugly black box with way too much unnecessary data in it -- data like transactions and public keys are redundant and are not necessary for restoring precious coins from a backup) with a new one. I see now (having worked with the wallet) that it's quite integral to Bitcoin and it isn't going to be replaced any time soon.

Therefore, I am thinking that Bitcoin should be reading and writing two formats simultaneously. It keeps a wallet.bitkey file in the home directory. Whenever it writes a new private key to the wallet.dat, it also appends it to wallet.bitkey in human-readable format. When it starts up, it scans wallet.bitkey and if it sees any private keys which aren't in the wallet, it loads them in. That way, you can always check your wallet.bitkey file to see what keys you have in human readable format. And you can import/merge such files manually, and Bitcoin will slurp them in at startup.

In this case, my code would be useful because it uses OpenSSL to read in a private key and make a full DER key which is required by wallet.dat. The code to read wallet.bitkey and insert keys into wallet.dat would need this mechanism.
netrin
Sr. Member
****
Offline Offline

Activity: 322
Merit: 251


FirstBits: 168Bc


View Profile
May 28, 2011, 12:32:46 PM
 #87

I think the advantages of base58 (unambigous 1lLiI for humans) is lost in a QR encoded message. Base93 (x21-x7E) is more data dense. Base10 (decimal) is almost as dense due to the four encoding types (numeric, alpha, pseudo-binary, and kanji). Data Matrix (as opposed to QR) has the advantage of a true binary format.

Greenlandic tupilak. Hand carved, traditional cursed bone figures. Sorry, polar bear, walrus and human remains not available for export.
Pages: « 1 2 3 4 [5]  All
  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!