Bitcoin Forum
December 07, 2016, 12:55:13 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Minimal Python address generator  (Read 4966 times)
weex
Legendary
*
Offline Offline

Activity: 1062


Give me your tired, your poor, your huddled...


View Profile
June 06, 2012, 10:45:20 PM
 #1

For a project I'm working on I wanted a tool that would create a new address and print it out with a private key. The goals are:

* Minimal so it's as easy (as such a thing can be) to read and audit
* Runs on any machine with minimal setup
* Runs locally, not web-based.

Obviously bitaddress.org does much more but as I intend to recommend this for the most secure storage scenarios, I prefer a simpler script rather than a full interface.

Joric in #bitcoin-dev was kind enough to throw something together and I've made a couple minor tweaks to simplify it.

It is hosted at my github at https://github.com/weex/addrgen

My hope is that for simple generation of random/non-vanity addresses in secure scenarios that this can be used and recommended.

Please recommend ways that this script or any process that used it can reduce the chance of the private key being stolen.

Thanks,

weex

1481115313
Hero Member
*
Offline Offline

Posts: 1481115313

View Profile Personal Message (Offline)

Ignore
1481115313
Reply with quote  #2

1481115313
Report to moderator
1481115313
Hero Member
*
Offline Offline

Posts: 1481115313

View Profile Personal Message (Offline)

Ignore
1481115313
Reply with quote  #2

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

Activity: 1134


View Profile
June 13, 2012, 09:46:25 AM
 #2

It is not python but have you considered using my bitcoin bash tools?

Code:
$ . bitcoin.sh
$ newBitcoinKey
---
WIF: 5KFtidLNEgFicv1QWGjMUECprKEQdLEqDGA7V5F8PJDZxaazRG7
bitcoin address: 1NZunrMgUVoe7H46GZW3x1NUxGPSyJUCSL
public key: 048EB823CBA7A29B9E8DE312E1F7516333D2754C2A7C480218C4E16E0CAB0E782EFFA715E5AB89426C948827A384CF32ECE0E8DE8625F2B124F40630CCA720997A

It only requires openssl and dc.
weex
Legendary
*
Offline Offline

Activity: 1062


Give me your tired, your poor, your huddled...


View Profile
June 13, 2012, 08:47:05 PM
 #3

I did not consider that as I couldn't find it when I searched. As mentioned in my second feature, I would like windows users to be able to run it fairly easily. Python is a bit easier to install than bash(using cygwin is what comes to mind) on Windows.

dunand
Hero Member
*****
Offline Offline

Activity: 625



View Profile
June 14, 2012, 12:20:29 AM
 #4

Nice tool Grondilu.
weex
Legendary
*
Offline Offline

Activity: 1062


Give me your tired, your poor, your huddled...


View Profile
June 14, 2012, 12:21:50 AM
 #5

I get that all the time. Wink You should thank Joric though as he's the one that really put it together.

Stardust
Full Member
***
Offline Offline

Activity: 190


View Profile
June 14, 2012, 04:55:45 AM
 #6

Great tool Grondilu. Well I was a fan before this addition of the bitcoin bash tools.
smokeyrd
Newbie
*
Offline Offline

Activity: 8


View Profile
September 12, 2014, 12:29:31 PM
 #7

Im more than a bit late to this thread but... I am just starting out on python and see where the script defines the functions but for whatever reason I do not see where the functions are actually called I know there's some way to trace the program and will look into that but wanted to post here to see if anyone is able to assist my nubness.
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1526

Reverse engineer from time to time


View Profile
September 12, 2014, 04:56:46 PM
 #8

Im more than a bit late to this thread but... I am just starting out on python and see where the script defines the functions but for whatever reason I do not see where the functions are actually called I know there's some way to trace the program and will look into that but wanted to post here to see if anyone is able to assist my nubness.
Which functions arent called?

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
andytoshi
Full Member
***
Offline Offline

Activity: 167

-


View Profile
September 12, 2014, 11:03:31 PM
 #9

The majority of the python code is "classic Joric" address-from-user-passphrase generation, defaulting to a single round of SHA256 to coerce a passphrase into a key. It looks like the program itself wisely ignores all this and simply uses OpenSSL's random keygen functionality. So for example the function `generate` is 14 lines long but only the very last one is actually ever used, the rest is just there to compromise your security in case you call the function wrong.
weex
Legendary
*
Offline Offline

Activity: 1062


Give me your tired, your poor, your huddled...


View Profile
September 15, 2014, 04:34:11 PM
 #10

The majority of the python code is "classic Joric" address-from-user-passphrase generation, defaulting to a single round of SHA256 to coerce a passphrase into a key. It looks like the program itself wisely ignores all this and simply uses OpenSSL's random keygen functionality. So for example the function `generate` is 14 lines long but only the very last one is actually ever used, the rest is just there to compromise your security in case you call the function wrong.
Are you saying you wouldn't consider this safe to use if you modify it to use the passphrase AND the passphrase has 160+ bits of entropy?

deepceleron
Legendary
*
Offline Offline

Activity: 1470



View Profile WWW
September 16, 2014, 10:23:45 AM
 #11

It looks like the program itself wisely ignores all this and simply uses OpenSSL's random keygen functionality. So for example the function `generate` is 14 lines long but only the very last one is actually ever used, the rest is just there to compromise your security in case you call the function wrong.

I hadn't seen this before, but I am agreed. What's on the repo just uses "EC_KEY_new_by_curve_name" to have whatever ssl library happens to be on the system generate a random number for the curve. There's lots of functions that are never reached. Hopefully the system library still gives back a secp256k1 curve for NID 714. Even if you trust a 10 year old Microsoft library to do what it's supposed to without NSA backdoors in the RNG, it could have been altered or replaced by a virus or rootkit.

Since this thread got a bump, I'll refer people to https://bitcointalk.org/index.php?topic=361092.0 for making strong random addresses, or https://github.com/vbuterin/pybitcointools for Python functions that include all the EC math that Bitcoin needs.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!