Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: casascius on December 06, 2012, 07:22:45 AM



Title: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 07:22:45 AM
I just released some of the magic that goes into physical bitcoins: a generator for those little round key circles I put in my coins.

How it works:
1 - download latest Casascius Bitcoin Address Utility (either on github, or https://casascius.com/btcaddress-alpha.zip)
2 - generate some keys
3 - print physical bitcoin inserts!

I made it so you can generate key circles with Minikeys, regular keys, or two-factor Encrypted Private Keys.  Minikeys are 30 characters and fit in a single circle.  Regular keys are 51 characters and two-factor encrypted ones are 58 characters, these print on a two-circle shape that you fold in half.

Each sheet gives you 8 keys, and gives you a QR code for the bitcoin address.

I added one more thing, and that's something called "confirmation codes".  A confirmation code lets someone who ordered a two-factor passphrase physical bitcoin verify that the address they were given is really protected by their passphrase, without giving them access to the funds.  So... I can sell a two-factor physical bitcoin with YOUR passphrase, and also give you back a "confirmation code" that allows you to independently calculate the bitcoin address that went inside your product.  It allows you to prove that I didn't just give you an address of my own.

Of course, with this generator, the genie is out of the bottle, and you could create your own physical bitcoins yourself.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: Uglux on December 06, 2012, 07:27:48 AM
Nice. Thank you.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: BoardGameCoin on December 06, 2012, 07:31:35 AM
Yay! Your roll-your-own coins just got a bit more valuable... Not that I don't trust you, but I prefer not needing to ;)



Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: Yuhfhrh on December 06, 2012, 07:36:02 AM
Mike, this is perfect. I'm speechless about the impact you have had on bitcoin. So many more people are learning about bitcoin from the coins I have been buying from you. The light just turns on for them when I whip one of them out!

Thank you for releasing this, now I feel silly for asking for more of the private key circles.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 07:37:31 AM
Important thing I should add: for cutting out circles you really want is a hole punch meant for train tickets that punches the right diameter of holes (about 10mm)

I searched high and low in the US and a company called M C Mieth Manufacturing had one.  That was long ago before I gained access to a laser machine that I now use to just bulk cut keys by the thousands.  If you are just doing a few for fun, then scissors will work fine.

EDIT: here is a link: http://ticketpunch.net/index.php/vmchk/Large-Die-Punch/Large-Round-Holes-up-to-1/2.html - I bought the 3/8" version and it fits all of my coins and bars.  You do NOT want the reservoir option - it will get in the way of aiming the tool at the text on the key.

http://ticketpunch.net/components/com_virtuemart/shop_image/product/Large_Round_Hole_4dec93060fcbf.gif

Mike, this is perfect. I'm speechless about the impact you have had on bitcoin. So many more people are learning about bitcoin from the coins I have been buying from you. The light just turns on for them when I whip one of them out!

Thank you for releasing this, now I feel silly for asking for more of the private key circles.

No problem!  The key circle you print yourself is inherently a better one anyway.

Now I will have to make a report that prints more than 8 of them to a page, but that'll come later, it's my bed time.

I will probably up my minimum order quantity of the roll-your-owns and decrease the price...


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 07:45:50 AM
Just pushed a couple quick bug fixes, including fixing an inability to print more than 1 page worth of keys at a time


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: smoothie on December 06, 2012, 07:52:05 AM
Downloaded, Unzipped, Clicked "wallet generator" and it crashed...



Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 07:54:15 AM
Downloaded, Unzipped, Clicked "wallet generator" and it crashed...



What's the error you get?  Does it say?

Also what version of Windows, and what country and language edition (if not English)?  I have seen instances where the Microsoft crypto routines refuse to run because they don't like what country you're in or what edition of Windows you're running.  I have removed many references from Microsoft crypto in favor of Bouncy Castle to prevent this nanny sitting, but there are plenty of spots that still refer to the MS crypto.

Also, where is "Wallet Generator"? this is something I had on a much earlier version of this utility, but currently I don't believe I expose access to the screen named that, since I made a better one.  What do you see when it runs?  One big white empty box, or a bunch of little text boxes and arrow buttons?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: Yuhfhrh on December 06, 2012, 08:59:33 AM
Its working fine for me. Windows 7 64-bit.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: DobZombie on December 06, 2012, 02:13:37 PM
Cheers casascius, you the man :)


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 02:24:20 PM
Quote
Downloaded, Unzipped, Clicked "wallet generator" and it crashed...
The same for me - Win Vista
The file to download seems to be the "old" address generator. Could it just be a mistake?

OK - I figured it out - largely with this helpful reply.  I had put "source.zip" at the download link instead of "btcaddress.zip"

"source.zip" is the inner zip file that contains the source code, but also apparently contains an older version of the binary and none of the dependencies.  It made it into the source directory as I was a while ago experimenting with compiling from the command line using the stripped down compiler that comes with the runtime, instead of the whole toolchain.  "btcaddress.zip" contains the binary, dependencies, and source.zip within it.

Try again.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 07:19:37 PM
Would it be possible to get a small user guide (howto), in particular for the 2-factor features?

In a nutshell:  Alice and Bob.  Alice wants a 2-factor physical bitcoin, and Bob is going to make it for her.  Alice doesn't want there to be a way for Bob to steal her money.

Alice picks a passphrase.  She uses the "Intermediate Code Generator", enters the passphrase, and generates an intermediate code.  An example of an intermediate code is: passphraseoRryVSRbiHXimnSbXSgh7fsq3u3tx1vgZPs9myhhuVUDftcLBVSGxGZY99JwbW (passphrase for this example was ''Fizzie Gullbits'')

She gives this to Bob.

Bob goes to the Generate Addresses screen, and generates some addresses using the intermediate code as the passphrase.  The utility automatically acknowledges this is an intermediate code (important!).  It generates some addresses and encrypted private keys.  Bob can see the Bitcoin address, but importantly, can't get the private keys or spend the funds without Alice's passphrase.

Bob prints key circles and confirmation codes (they come out on the same page).  Bob cuts out the key circles and inserts them into the physical bitcoin product.  He sends the product and the confirmation code to Alice.

Alice has the option of entering the confirmation code into the Confirmation Code Validator.  She doesn't have to, but if she does, she can confirm that the bitcoin address Bob gave her is really encumbered by her password.  (This prevents Bob from giving her his own bitcoin address and running with the money).  She has to trust that Bob really put the right private key inside the physical bitcoin product and didn't commit a "fail" in doing so, but at least she can be assured that there is no way Bob can take the money she sends to the physical bitcoin's address.

A confirmation code example is cfrm38V5qFs3BhUVjxeGnxwV3LH63oyaqRwm8Q9P8CsFchFKDaknBGyUMExvhNm4FCL9XJC8bsN - when verified with the password "Fizzie Gullbits", Alice can see a bitcoin address and know that, for all practical purposes, this bitcoin address could not have been generated without this passphrase.

In this example the combined bitcoin address was 1NKABYfNEDc7xXLYKyyWNYyYvdHuxKWEcd.  Alice and Bob can both independently verify it.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: Adrian-x on December 06, 2012, 07:49:04 PM
Thanks, I will give it a go.
I do have a question, it is not probably new, to Bitcoin, if 1000 people are generating addresses at the same time what stops the your system from making 2 identical addresses on alternate systems?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: DeathAndTaxes on December 06, 2012, 07:51:55 PM
Thanks, I will give it a go.
I do have a question, it is not probably new, to Bitcoin, if 1000 people are generating addresses at the same time what stops the your system from making 2 identical addresses on alternate systems?

Same thing which prevents 2 random bitcoin users on the planet from making the same address.

The simple version is 2^256 is much much much larger than you think.   A billion users, each generating a billion keys a year for a billion years has a ~0% chance of producing a duplicate.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: SlaveInDebt on December 06, 2012, 07:53:29 PM
Sharing is caring. Though I'll go ahead and order 50 from you for friends and family for buy random material things day.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: DannyHamilton on December 06, 2012, 09:09:17 PM
. . . what stops the your system from making 2 identical addresses on alternate systems?
. . . A billion users, each generating a billion keys a year for a billion years has a ~0% chance of producing a duplicate.
This assumes that all users are using a method that generates adequately random keys.  If they use some deterministic method and use the same starting point for their determination, then they will have a 100% change of producing duplicates. As an example, if I use

echo "Danny" |shasum -a 256

on my Mac to produce my private key, and someone else named Danny comes up with the same idea, we will both have access to the same bitcoins.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: Red Emerald on December 06, 2012, 09:15:51 PM
. . . what stops the your system from making 2 identical addresses on alternate systems?
. . . A billion users, each generating a billion keys a year for a billion years has a ~0% chance of producing a duplicate.
This assumes that all users are using a method that generates adequately random keys.  If they use some deterministic method and use the same starting point for their determination, then they will have a 100% change of producing duplicates. As an example, if I use

echo "Danny" |shasum -a 256

on my Mac to produce my private key, and someone else named Danny comes up with the same idea, we will both have access to the same bitcoins.
Well this program does the private key generation for you doesn't it?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: DannyHamilton on December 06, 2012, 09:39:53 PM
. . . what stops the your system from making 2 identical addresses on alternate systems?
. . . A billion users, each generating a billion keys a year for a billion years has a ~0% chance of producing a duplicate.
This assumes that all users are using a method that generates adequately random keys.  If they use some deterministic method and use the same starting point for their determination, then they will have a 100% change of producing duplicates. As an example, if I use

echo "Danny" |shasum -a 256

on my Mac to produce my private key, and someone else named Danny comes up with the same idea, we will both have access to the same bitcoins.
Well this program does the private key generation for you doesn't it?
True, as long as Casascius has used a reasonable source for randomness then using the Bitcoin Address Utility should have a ~0% chance of an address collision.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: BitcoinHoarder on December 06, 2012, 10:35:39 PM
Very cool, thanks man.

I will be using this to give away as gifts to people for the holidays.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: LoweryCBS on December 06, 2012, 11:05:00 PM
Not being much of a programmer, could someone explain it to me (like I'm 10 years old) the randomness of the algorithm?

How likely is it that someone can analyze the code and predict what keys will be generated?

I mean, are we looking at this:

http://imgs.xkcd.com/comics/random_number.png

(lifted from here http://xkcd.com/221/ (http://xkcd.com/221/))

. . . what stops the your system from making 2 identical addresses on alternate systems?
. . . A billion users, each generating a billion keys a year for a billion years has a ~0% chance of producing a duplicate.
This assumes that all users are using a method that generates adequately random keys.  If they use some deterministic method and use the same starting point for their determination, then they will have a 100% change of producing duplicates. As an example, if I use

echo "Danny" |shasum -a 256

on my Mac to produce my private key, and someone else named Danny comes up with the same idea, we will both have access to the same bitcoins.
Well this program does the private key generation for you doesn't it?
True, as long as Casascius has used a reasonable source for randomness then using the Bitcoin Address Utility should have a ~0% chance of an address collision.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: luv2drnkbr on December 06, 2012, 11:13:40 PM
Mike, you're awesome.  I've already used the two factor in your newest utility to do an escrow transaction with somebody.  This is awesome.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 11:18:38 PM
I have been doing a mix of the following (working on making it more consistent)

1 - Using SecureRandom from the BouncyCastle dependency
2 - Using SecureRandom from .NET's System.Security.Cryptography
3 - Doing both of the above while XORing the bytes with "extra entropy", formed mainly from hashing a buffer that grows when the app receives events (mouse moves, timer ticks, etc. cause the system tick count to be appended to the buffer) and gets chopped down when it gets too big, by being replaced with a hash of itself.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 06, 2012, 11:21:32 PM
Mike, you're awesome.  I've already used the two factor in your newest utility to do an escrow transaction with somebody.  This is awesome.

How did that work?  I am guessing you sent funds to an address neither of you had access to, until one of you ceded your key material to the other?

Just curious, did your deal involve checking the confirmation code to verify the address was indeed encumbered?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: enmaku on December 06, 2012, 11:24:12 PM
I have been doing a mix of the following (working on making it more consistent)

1 - Using SecureRandom from the BouncyCastle dependency
2 - Using SecureRandom from .NET's System.Security.Cryptography
3 - Doing both of the above while XORing the bytes with "extra entropy", formed mainly from hashing a buffer that grows when the app receives events (mouse moves, timer ticks, etc. cause the system tick count to be appended to the buffer) and gets chopped down when it gets too big, by being replaced with a hash of itself.


Started to post exactly this myself. You're too fast for me mike!

Code:
        private void Walletgen_Shown(object sender, EventArgs e) {
            const int phraselength = 80;

            RandomNumberGenerator rng = RandomNumberGenerator.Create();
            Byte[] byte8 = new byte[phraselength];
            rng.GetBytes(byte8);
            string randomphrase = "";
            string junk64 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz*#_%+!";
            for (int i = 0; i < phraselength; i++) {
                randomphrase += junk64.Substring(byte8[i] & 63, 1);
            }
            txtPassphrase.Text = randomphrase;
        }


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: MPOE-PR on December 07, 2012, 09:18:56 AM
Pretty cool.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: bitcats on December 07, 2012, 11:32:40 AM
There seems to be a bug, but im not sure:

I start the program, enter an (encrypted) key: 6PfRj9PLSPfGW9z5iKKyaVyKFvWScDhxvYjhtghhi9dVk8vAUngZD9RL6V
I click for details: the address utility opens.
I enter the passphrase "topsecret", and it calculates the hex/hash
Everything ok so far.
Now i click "Print Banknote" an i get an error message    
Code:
System.InvalidOperationException: Address is not available
    BtcAddress.EncryptedKeyPair.GetAddress()
    BtcAddress.KeyCollectionItem.GetAddressBase58()
    BtcAddress.QRPrint.OnPrintPage(PrintPageEventArgs e)
    System.Drawing.Printing.PrintDocument._OnPrintPage(PrintPageEventArgs e)
    System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
    System.Drawing.Printing.PrintController.Print(PrintDocument document)
    System.Drawing.Printing.PrintDocument.Print()
    BtcAddress.Forms.PrintVouchers.button1_Click(Object sender, EventArgs e)
    System.Windows.Forms.Control.OnClick(EventArgs e)
    System.Windows.Forms.Button.OnClick(EventArgs e)
    System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    System.Windows.Forms.Control.WndProc(Message& m)
    System.Windows.Forms.ButtonBase.WndProc(Message& m)
    System.Windows.Forms.Button.WndProc(Message& m)
    System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The same when i try to safe the "Address List" i get the message: Address not available


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: luv2drnkbr on December 07, 2012, 02:36:49 PM
Mike, you're awesome.  I've already used the two factor in your newest utility to do an escrow transaction with somebody.  This is awesome.

How did that work?  I am guessing you sent funds to an address neither of you had access to, until one of you ceded your key material to the other?

Just curious, did your deal involve checking the confirmation code to verify the address was indeed encumbered?

I don't know what the word "encumbered" means in this sense.  We both just verified that we did indeed got the same public address, then I sent funds to that address.  He performed agreed upon service.  Then I sent him the private key for my address (a throwaway created just for that transaction).

I still don't know the private key for the "escrow" address, but the money was moved out of it, so I know he got it.

Edit:  Oh, we used the Key Combiner, not the confirmation thingy.

Edit 2: oohhh I was using an old version.  this confirmation code thing is super awesome.

Edit 3:  Is there a way to get the confirmation code without printing the physical coin insert?  I can't find any other way.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 07, 2012, 03:10:25 PM
There seems to be a bug, but im not sure:

I start the program, enter an (encrypted) key: 6PfRj9PLSPfGW9z5iKKyaVyKFvWScDhxvYjhtghhi9dVk8vAUngZD9RL6V
I click for details: the address utility opens.

This is a bug in the sense that I'm mishandling what to do when this happens, but there's a fundamental problem: the key is encrypted and the program doesn't know the address.

Despite you decrypting it in the address utility, the program doesn't hold on to the password for the benefit of the printing part.  The print utility does not know the address of an encrypted private key unless you actually generated it within the program.  I would either have to add a prompt to collect that from you, or refuse to print at least the address.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 07, 2012, 03:16:48 PM
I don't know what the word "encumbered" means in this sense.

By this, I just mean that the funds themselves are unmovable until the restriction is satisfied.  I might have been more clear had I just said "restricted".

I suppose it's confidence building for the sending side to be able to have something tell him, in green bold print, "yes this address is safe and is half yours".  The "intermediate" and "confirmation" are little more than the same operations of the multiplying key combiner itself, wrapped in a pretty container with salt, some encryption, and some self-defense against typos. 


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: luv2drnkbr on December 07, 2012, 03:17:56 PM
Is there an easy way to get the confirmation code or do I just have to print the insert?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 07, 2012, 03:23:30 PM
Is there an easy way to get the confirmation code or do I just have to print the insert?

I will have to add one, now that I'm aware of this as a suitable application.  There isn't any way currently exposed other than that.

As a stop gap, if you're able to print to PDF, do that.  But I'm sure it'll get added soon enough.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: luv2drnkbr on December 07, 2012, 03:25:26 PM
Yeah, that's exactly what I did, PDF then just text copy.  Worked just fine, just a minor pain.  Still, friggin awesome!!!!!


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: bitcats on December 07, 2012, 04:48:56 PM
Despite you decrypting it in the address utility, the program doesn't hold on to the password for the benefit of the printing part.  The print utility does not know the address of an encrypted private key unless you actually generated it within the program.  I would either have to add a prompt to collect that from you, or refuse to print at least the address.
I'd like to import my (encrypted) keys and print them with the utility. Will you add this option to the next release?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: Tuxavant on December 07, 2012, 05:35:40 PM
This is ridiculously cool crypto! Some requests:

* help | about, version

* a viewable dir index showing all previous versions and a symlink from btcaddress.zip to the latest version.

* some way to automate notifications of all future updates: rss blog feed, official forum thread, etc.

* a bitcoin donation address 8D

Will there ever be support for these functions in linux, either gui or text?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: bitcats on December 08, 2012, 11:52:29 AM
The print utility does not know the address of an encrypted private key unless you actually generated it within the program.  I would either have to add a prompt to collect that from you, or refuse to print at least the address.
    I'd like to import my (encrypted) keys and print them with the utility. Will you add this option to the next release?

(Thanks a lot for that useful utility. Donation is coming)


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: John Kirk on December 08, 2012, 02:29:53 PM
This is very generous, Casascius.  Thanks!

I'm not seeing a license file anywhere. What license is the source code released under?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 08, 2012, 03:40:25 PM
This is very generous, Casascius.  Thanks!

I'm not seeing a license file anywhere. What license is the source code released under?


GPLv3


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on December 16, 2012, 07:54:32 PM
A version for Mac would be awesome

It will run with Mono or Parallels


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: phelix on February 03, 2013, 04:59:32 PM
Is it generally possible to generate the corresponding namecoin public key from a bitcoin public key?


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: casascius on February 03, 2013, 05:03:21 PM
Is it generally possible to generate the corresponding namecoin public key from a bitcoin public key?

I assume you mean namecoin address vs Bitcoin address (public keys are the same for both)

Use my Utility, the Address Utility screen

Put the Bitcoin address in the bottom box and hit the up arrow to get the Hash160

Then switch the selection dropdown from Bitcoin to Namecoin. Then hit the opposite arrow to go from hash160 to address and you will get the namecoin address.


Title: Re: Publicly released some of the magic potion that goes into physical bitcoins!
Post by: phelix on February 03, 2013, 07:20:16 PM
Is it generally possible to generate the corresponding namecoin public key from a bitcoin public key?

I assume you mean namecoin address vs Bitcoin address (public keys are the same for both)

Use my Utility, the Address Utility screen

Put the Bitcoin address in the bottom box and hit the up arrow to get the Hash160

Then switch the selection dropdown from Bitcoin to Namecoin. Then hit the opposite arrow to go from hash160 to address and you will get the namecoin address.

sweet! works like a charm. Had played with your tool just today but did not realize it was so easy.

The reason why I am asking is a sendbtctoname function for namecoin using a shared key. Should be easy to implement.
Found an alternative in the meantime, through sendbtctoalias: https://bitcointalk.org/index.php?topic=83793.msg1500895#msg1500895