Title: Playing with Public Keys Post by: wyager on July 24, 2012, 03:26:13 AM I wrote a small/dirty python script that allows me to use an arbitrary value (like a string) as a "public key" in order to create a Bitcoin address.
This is the script: Code: #Wyager's quick and dirty arbitrary public key hasher I don't use python very often, so forgive my bad form. My intention here was to make a simple system that allowed for proof of copyright or whatever. You treat your secret string/document as a "public key", and send money to the corresponding address, so it shows up on the blockchain. If you ever need to prove that you knew the string/document at some point, you can simply point to the transaction that has that address on the blockchain. This gives you a strong hash+timestamp. This is obviously not the only way to do this, this was just for fun. Anyway, what I noticed was that someone else obviously had the same idea. I ran this script using "hello" as the public key, and that produces an address of 1HeqNjAst5TCQ63F7xhjg6bcTbDKrRk7sH. According to http://blockexplorer.com/address/1HeqNjAst5TCQ63F7xhjg6bcTbDKrRk7sH (http://blockexplorer.com/address/1HeqNjAst5TCQ63F7xhjg6bcTbDKrRk7sH), someone has already sent money to "hello". I wonder what other addresses out there like this exist? :P Title: Re: Playing with Public Keys Post by: foo on July 24, 2012, 03:39:36 AM This concept is usually known as "brain wallets".
I recently played around with this myself and found that SHA-256("test") has been used: http://blockchain.info/address/1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE BTW, the variable you named "sha_pubkey" actually contains the Bitcoin private key, so you should rename that one. :) Title: Re: Playing with Public Keys Post by: wyager on July 24, 2012, 03:49:38 AM This concept is usually known as "brain wallets". I recently played around with this myself and found that SHA-256("test") has been used: http://blockchain.info/address/1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE BTW, the variable you named "sha_pubkey" actually contains the Bitcoin private key, so you should rename that one. :) Interesting. I had heard the term before, but didn't realize that's what they were implying. I'm also pretty sure that "sha_pubkey" is the public key. I based my code off of https://en.bitcoin.it/w/images/en/9/9b/PubKeyToAddr.png (https://en.bitcoin.it/w/images/en/9/9b/PubKeyToAddr.png) Title: Re: Playing with Public Keys Post by: Meni Rosenfeld on July 24, 2012, 03:51:49 AM This concept is usually known as "brain wallets". It's only a brain wallet if it's a private key/seed and it's memorized. The OP didn't say anything about private keys or memorization.BTW, the variable you named "sha_pubkey" actually contains the Bitcoin private key, so you should rename that one. :) No, according to my understanding of the code sha_pubkey is (the hash of) the public key, the private key is nowhere to be found. If there was a conversion from private to public, we'd see a mention of ECDSA.Title: Re: Playing with Public Keys Post by: wyager on July 24, 2012, 03:52:40 AM This concept is usually known as "brain wallets". It's only a brain wallet if it's a private key/seed and it's memorized. The OP didn't say anything about private keys or memorization.BTW, the variable you named "sha_pubkey" actually contains the Bitcoin private key, so you should rename that one. :) No, according to my understanding of the code sha_pubkey is (the hash of) the public key, the private key is nowhere to be found. If there was a conversion from private to public, we'd see a mention of ECDSA.That is my understanding. Title: Re: Playing with Public Keys Post by: foo on July 24, 2012, 03:53:44 AM Ah, I think you're missing a step in your code, namely the one that makes the public key out of the private key. This explains why I was not able to verify your calculation for "hello". :)
I used this site for the hash: http://www.xorbin.com/tools/sha256-hash-calculator and then plugged the hex string as a private key into https://www.bitaddress.org/ which gives the Bitcoin address. Title: Re: Playing with Public Keys Post by: wyager on July 24, 2012, 03:54:43 AM Ah, I think you're missing a step in your code, namely the one that makes the public key out of the private key. This explains why I was not able to verify your calculation for "hello". :) I used this site for the hash: http://www.xorbin.com/tools/sha256-hash-calculator and then plugged the hex string as a private key into https://www.bitaddress.org/ which gives the Bitcoin address. Nope, it works fine for me... This code is public key only. You are not able to spend the money at the address, only generate the address itself. Title: Re: Playing with Public Keys Post by: foo on July 24, 2012, 03:58:52 AM Ah, I think you're missing a step in your code, namely the one that makes the public key out of the private key. This explains why I was not able to verify your calculation for "hello". :) I used this site for the hash: http://www.xorbin.com/tools/sha256-hash-calculator and then plugged the hex string as a private key into https://www.bitaddress.org/ which gives the Bitcoin address. Nope, it works fine for me... This code is public key only. You are not able to spend the money at the address, only generate the address itself. Title: Re: Playing with Public Keys Post by: wyager on July 24, 2012, 04:02:22 AM Ah, I think you're missing a step in your code, namely the one that makes the public key out of the private key. This explains why I was not able to verify your calculation for "hello". :) I used this site for the hash: http://www.xorbin.com/tools/sha256-hash-calculator and then plugged the hex string as a private key into https://www.bitaddress.org/ which gives the Bitcoin address. Nope, it works fine for me... This code is public key only. You are not able to spend the money at the address, only generate the address itself. If you just wanted proof-of-knowledge OR if you wanted to create a "black hole" that people could send BTC to, knowing those BTC could never be recovered until ECDSA was broken. Title: Re: Playing with Public Keys Post by: foo on July 24, 2012, 04:06:14 AM What would be the point of doing that instead of hashing the document to a private key? As you say, you'll destroy any coins sent there if you hash it to a public key. If you just wanted proof-of-knowledge OR if you wanted to create a "black hole" that people could send BTC to, knowing those BTC could never be recovered until ECDSA was broken. Hashing to a private key gives the same proof-of-knowledge, plus you can take your coin back. Title: Re: Playing with Public Keys Post by: wyager on July 24, 2012, 05:04:26 AM What would be the point of doing that instead of hashing the document to a private key? As you say, you'll destroy any coins sent there if you hash it to a public key. If you just wanted proof-of-knowledge OR if you wanted to create a "black hole" that people could send BTC to, knowing those BTC could never be recovered until ECDSA was broken. Hashing to a private key gives the same proof-of-knowledge, plus you can take your coin back. I know... Read my OP: Quote This is obviously not the only way to do this, this was just for fun. |