Bitcoin Forum
July 12, 2025, 07:25:50 PM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Wallet software / Zsh/OpenSSL Shell Script Key Generator on: December 25, 2012, 03:01:55 AM
I've been intrigued for a while by the use of bitaddress.org and Bitcoin off-the-grid (BOTG) to generate keys for secure storage (and gift-certificate-like paper keys). I particularly liked how BOTG just used basic things that were part of most linux-like systems and straight OpenSSL to generate the keys. (While I think bitaddress.org's code is probably fine, I'm a little paranoid about using Javascript to generate the random numbers, and OpenSSL is basically the standard.) Also, I wanted to play around with learning zsh scripting. I used a lot of the code from BOTG, but adapted it in several ways: (1) Zsh is a little different than most shells, and so I had to make a couple tweaks (like 1-indexing arrays), (2) I'm on a Mac, and a couple of the utilities it used weren't available. (Though for all I know, this won't work on a linux system now), (3) I wanted to support the full range of keys that OpenSSL generated, rather than just most of them (I think that BOTG eliminated about a bit of private key availability, not that it [em]really[/em] matters), (4) I'm not convinced that the BOTG address-generating code worked for addresses that were less than 34 characters, and though I might have I redid it anyway.

I very much appreciate the BOTG base, and it handles a lot more things than this code does. This is just a way to generate a key with OpenSSL and find its address, so that one can send coins there and then later import the key into a wallet. Any contributions here which are mine I put into the public domain. (And as usual, no warranty, while I've tested it for my purposes and it seems good to me and I plan to use it, there's of course the chance of a subtle bug that will mean you can't get your coins or something.)

To run, just put the code in a file and mark it executable. Pass an argument of "1" if you'd like to see all the details of the OpenSSL key to check everything.

Code:
#!/bin/zsh
debug=$1
base58=(1 2 3 4 5 6 7 8 9 A B C D E F G H J K L M N P Q R S T U V W X Y Z a b c d e f g h i j k m n o p q r s t u v w x y z)

capitalizeHex() {
    tr "[a-f]" "[A-F]"
}

encodeBase58() {                                 
    initialones=$(sed -e 's/\(\(00\)*\).*/\1/' -e 's/00/1/g' <<<$1)
    echo -n $initialones
    bc <<<"ibase=16; n=$1; while(n>0) { n%3A ; n/=3A }" |
    tail -r |
    while read n
        do echo -n ${base58[n+1]}
    done
}

checksum() {
    xxd -p -r <<<"$1" |
    openssl dgst -sha256 -binary |
    openssl dgst -sha256 -binary |
    xxd -p -c 80 |
    head -c 8 |
    capitalizeHex
}

hexToAddress() {
    echo "$(encodeBase58 "$2$1$(checksum "$2$1")")"
}

privatekey=$(openssl ecparam -genkey -name secp256k1 -noout)
openssldescription=$(openssl ec -text <<<$privatekey 2>/dev/null)
privatekeyhex=$(head -5 <<<$openssldescription | tail -3 | fmt -120 | sed -e 's/[: ]//g' -e 's/^00//' | awk '{printf "%064s\n", $0}' | capitalizeHex)
publickeyhashhex=$(openssl ec -pubout -outform DER <<<$privatekey 2>/dev/null | tail -c 65 | openssl dgst -sha256 -binary | openssl dgst -rmd160 -binary | xxd -p -c 80 | capitalizeHex)
address=$(hexToAddress $publickeyhashhex "00")
privatekeywif=$(hexToAddress $privatekeyhex "80")

(( $debug )) && echo $openssldescription
echo "Private Key Hex:" $privatekeyhex
echo "Private Key WIF:" $privatekeywif
(( $debug )) && echo "Public Key Hash:" $publickeyhashhex
echo "Address:" $address
2  Economy / Goods / Selling Magic: the Gathering (MTG) Return to Ravnica (RTR) Booster Box on: November 28, 2012, 08:30:14 PM
I have a sealed booster box (containing 36 packs) of the new Return to Ravnica expansion for Magic: the Gathering. Looking to sell it for about US$85 or so worth of bitcoins, including shipping to US. Please PM if you're interested.
3  Economy / Currency exchange / Selling US $50 via BiddingPond on: October 06, 2011, 12:39:44 AM
I've put up an auction at BiddingPond for $50 USD, via any of several delivery methods.

https://www.biddingpond.com/item.php?id=1022
4  Economy / Goods / FS: Magic: the Gathering New Phyrexia Booster Box on: October 01, 2011, 01:12:51 AM
I have one sealed display booster box (36 booster packs) of the Magic: the Gathering expansion New Phyrexia for sale. I'm asking 13 BTC for it, which includes shipping within the US via Priority Mail with Delivery Confirmation. Full retail would be like US$144, although a full box often goes for just under US$100. I often judge Magic: the Gathering events, and sometimes I get paid in booster boxes, and I don't go through them myself nearly as quickly as they seem to accumulate. So, I'm hoping to get rid of an extra booster box lying around my house and accumulate some bitcoins while I'm at it.

Everything's negotiable. Pictures available upon request. Offer may change if the USD/BTC price changes significantly from the $5-ish range it's been in lately.

Please ask if you have any questions. Thank you.
5  Economy / Currency exchange / [Closed] Want to buy 50 BTC for USD $250 on: September 30, 2011, 04:28:36 PM
I'd like to spend USD $250 to get 50 BTC from someone. I've been around for a while, and have done a dozen or so good transactions on BiddingPond, but haven't done much on the forums. I'm certainly willing to send first to someone with a good reputation, and am amenable to doing the transaction in several smaller chunks. Maybe using a trusted escrow service here could work too.

I am willing to send the USD via your choice of the following:
  • Paypal
  • Cash discretely mailed to your US Address via Priority Mail with Delivery Confirmation.
  • Emailing you a gift card (Visa, American Express, Amazon, other major retailer)
  • Physically mailing you a gift card (as above) to your US Address via Priority Mail with Delivery Confirmation.
  • Some other way that's easy to do, please feel free to ask.

I'm pretty flexible, and everything is negotiable. Please feel free to PM or post in this thread. Thanks.
6  Economy / Goods / [CLOSED] Selling Magic: the Gathering Judge Promo Card: Dark Confidant on: July 23, 2011, 06:41:08 PM
I received a promotional Dark Confidant card today as thanks for being a judge for Magic: the Gathering, and I am listing it on BiddingPond:

https://www.biddingpond.com/item.php?id=958

It's a good card, and can be hard to find, so I wanted to make sure anyone interested would see it and bid. Thank you!

7  Economy / Currency exchange / Selling USD $50 in Dollar Coins via BiddingPond on: July 15, 2011, 12:32:59 PM
Just wanted to point people here to my auction on BiddingPond for 50 dollar coins, mailed to you anywhere in the US:

https://www.biddingpond.com/item.php?id=931

Thank you!
8  Economy / Goods / 3 Magic: the Gathering booster boxes on BiddingPond on: July 06, 2011, 06:15:42 PM
I know I've seen some Magic interest on these boards before, so I figured I'd try selling a few boxes I received from working a Grand Prix that I'll probably not be using. One box each of Scars of Mirrodin, Mirrodin Besieged, and New Phyrexia, for a total of 108 booster packs. I just lowered the starting bid to 12 BTC.

https://www.biddingpond.com/item.php?id=894
9  Bitcoin / Development & Technical Discussion / Download over SSL? on: June 17, 2011, 11:54:34 AM
I'm rather confused as to why the download links on the bitcoin.org home page aren't downloading the client over SSL? Especially with known trojans out there, it seems like needing to trust the ISPs between you and the download server (or your tor exit node if downloading over tor) is a piece of trust that shouldn't be needed. I understand that people could (and should) check the checksum with that posted on this forum, but if enabling SSL for the download is easy, it seems like it would help give users confidence that they have the official client, particularly users that are less technical.

And if it's not easy to set up with SourceForge, perhaps the downloads should be mirrored somewhere where it is easy?
10  Bitcoin / Bitcoin Technical Support / Confused by automatic addition of tx fees by sendmany on: May 04, 2011, 01:31:46 AM
So, now that the Mac version of 0.3.21 came out, I decided to play around with the new "sendmany" feature, and I was rather surprised.

First, I did Transaction 1, although all the addresses were addresses from the same wallet, and it seemed to work fine, and did not add a fee.

Then, I did Transaction 2, to 5 outside addresses, and it added a 0.01 transaction fee without any prompting. The transaction is hardly any bigger, so I'm rather confused.

I don't necessarily object to the fee itself, but the fact that it was deducted from my balance without me realizing it or being asked about it. I thought the point of "sendmany" was that bundling transactions saved resources, so I'm confused that I'm paying a fee now, whereas I never needed a pay a fee just sending to a single address before. And I don't see what's different about my two transactions to the network that would cause them to be treated differently.

Perhaps it's something to do with my unfamiliarity with using bitcoin via the command line, as I usually have been using the GUI.

I'd appreciate any enlightenment that somebody could give me. Thank you.
11  Economy / Marketplace / Domain name "easyfail.com" for sale for BTC on: April 15, 2011, 11:46:11 AM
I've put up for auction the domain name "easyfail.com" up at BiddingPond:

http://www.biddingpond.com/item.php?id=479

I thought it sounded like a cool name, that somebody could do something interesting with, but I don't have the time to try to figure out what to do with it myself.
12  Economy / Marketplace / Selling Magic: the Gathering Online Packs for BTC on: December 07, 2010, 01:35:15 AM
For sale on Magic: the Gathering Online:

  • 3 packs of Magic 2011: 55 BTC
  • 3 packs of Rise of the Eldrazi: 55 BTC
  • Up to 4 Event Tickets: 5 BTC each

I've got some other random cards and stuff, too, but that's the only recent stuff that I think someone might be interested in without digging through my whole collection. But if you're interested in something else, it couldn't hurt to ask. Prices may change depending on the BTC/USD market, and are definitely negotiable.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!