Live data from Hacker News

A peek under Bitcoin’s hood: Writing a client that can create a transaction

samlewis.me

31–40 of 67 posts

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#31

Earlier quoted context omitted.

Bitcoin addresses are basically a public key, so you can generate them offline the same way you can generate pgp keys, openssl keys, SSH keys you use to access GitHub etc. The chances of a collision are so astronomically low that our sun will probably run out of fuel and explode before two identical keys are generated.

With the comfort of a public blockchain at hand why not eliminate this case at address-creation time?

Blockchain's function is only to prevent double spend. Note that addresses are just a virtual term, in reality when you send money to an address you are setting up a "lock" (predicate) that can be unlocked only by a private key associated with public key that hashes to this address.

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#32
post #18

I am actually really surprised it took a month for someone to swipe the BTC he sent to an address with a private key of 0xfacebeef. That could be found via an incremental search in under an hour of CPU search time on one computer. I note that compressed public keys are not being used in these examples - it's highly recommended to use them, since they reduce transaction size and cost. Regarding weak keys - there have…

Just a warning for people, I was playing around with BTC the other day and not generating random entropy from urandom, just putting in a short string. I found my BTC was stolen immediately when I did this. It wasn't a lot of coins, since I was just testing, but it certainly cost me some debugging time as I wondered how the extra transaction had occurred. Basically, someone out there has already generated the keys cor…

There are multiple parties doing this, at least tens of billions of keys in their databases.

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#33

Earlier quoted context omitted.

Bitcoin addresses are basically a public key, so you can generate them offline the same way you can generate pgp keys, openssl keys, SSH keys you use to access GitHub etc. The chances of a collision are so astronomically low that our sun will probably run out of fuel and explode before two identical keys are generated.

With the comfort of a public blockchain at hand why not eliminate this case at address-creation time?

Let's do some back-of-the-envelope calculations.

Let's say the probability of someone cloning a Velociraptor within the next 20 years is 1 in 1 trillion. Let's say that given a Velociraptor has been cloned, it has a probability of 1 in 1 million of escaping. Let's say that given a Velociraptor is on the lam, it has a 1 in 100 billion chance of breaking into your house. Let's say that if there's a Velociraptor in your house, checking for it increases your chance of survival by 1%.

Let's assume there are 1 quadrillion Bitcoin addresses created.

Under the assumption of correct implementation, checking for velociraptors in your closet is literally more rational than checking for duplicate addresses.

Now, there is some value in checking for duplicate keys as a safeguard against implementation bugs, but that's best covered by generating a billion addresses on your own and checking for duplicates within your personal set.

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#34
post #21

Looks like there was bitcoin left in the address he published the private key for until about 30 minutes ago. I hope that was a deliberate giveaway. https://blockchain.info/tx/2685ff794de17cebdf94eb0f111e8b8c0...

As of the time of publishing, roughly ~8.58 USD.

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#35
post #33

Earlier quoted context omitted.

With the comfort of a public blockchain at hand why not eliminate this case at address-creation time?

Let's do some back-of-the-envelope calculations. Let's say the probability of someone cloning a Velociraptor within the next 20 years is 1 in 1 trillion. Let's say that given a Velociraptor has been cloned, it has a probability of 1 in 1 million of escaping. Let's say that given a Velociraptor is on the lam, it has a 1 in 100 billion chance of breaking into your house. Let's say that if there's a Velociraptor in your…

A very succinct way of explaining it, thanks!

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#36
post #21

Looks like there was bitcoin left in the address he published the private key for until about 30 minutes ago. I hope that was a deliberate giveaway. https://blockchain.info/tx/2685ff794de17cebdf94eb0f111e8b8c0...

I did deliberately leave that there in the hope someone might take it using what they'd learnt from the article. there's a short note about this in the conclusion to the article. From the "non whole" fee amount it looks as though someone might have just used some sort of wallet software to take it though, which is a shame.

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#37
post #3

Article says > This is also why address reuse in Bitcoin is encouraged as to sign a transaction you need to reveal your public key. If you don't reuse an address after sending a transaction from the address, you don't need worry about the private key of that address being exposed. Shouldn't that say "address reuse in Bitcoin is discouraged "? Otherwise I don't think I understand what he's trying to say.

Oops, you are correct. Good pick up, I'll get to changing that!

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#38
post #2

Very cool. This could be used to implement offline wallet with minimal amount of third party code. One issue I'd like to point is I wish the author used proper random generated private key. Examples on the internet have a nasty habits of being copy pasted and reused verbatim :(

My intention in using "hand crafted"/memorable private keys was just to make the article and what I was doing easier to follow.

I don't think there's any harm in people copying and pasting examples, it only becomes an issue if they start depositing money to either of the addresses that I listed the private keys for. I hope that's an obvious enough mistake not to make! Thanks for the feedback anyway, I'll keep an eye on those addresses and if they start getting mysterious deposits change the article to include more cryptographically secure keys.

Re: A peek under Bitcoin’s hood: Writing a client that can create a transaction

#39
post #24
post #19

Earlier quoted context omitted.

FWIW, I was looking at eth code in the weekend and it's pretty accessible (I was looking at go -- I've read that eth python should be even more readable). The address part is very similar, even simpler, than bitcoin. It's the same elliptic curve, same way to build private/public keys. For the address, it uses a different hash function, Keccak256, and then it's just serialized in hex. Code here [1]. Pointers to key ge…

Keccak256? Isn't that just SHA3 with a digest of 256 bits?

No, it's slightly different from SHA3-256. There was a tweak for standardization.
Post reply on HN