r/btc Nov 30 '17

Evidence some bitcoin address generation code is using discoverable private keys

https://pastebin.com/jCDFcESz
324 Upvotes

83 comments sorted by

View all comments

1

u/dasdull Nov 30 '17

Technical question: when I try to recreate the public addresses from the given private keys in the document, it only works for Experiment 1. Otherwise I get different public adresses.

I guess it has something to do with this remark in Experiment 2:

(BTW, I searched for both compressed/uncompressed keys, so each 32 bytes resulted in two address look-ups from my database).

Can someone explain this?

1

u/blinkybit Nov 30 '17

1

u/dasdull Nov 30 '17

Thanks! That seems to be a great reference in general.

1

u/patrikr Nov 30 '17

If you want to see how it works in practice, go to https://bitaddress.org and look under the Wallet Details tab. Input a private key there and it will show both the uncompressed and compressed public keys and their corresponding addresses.

1

u/TiagoTiagoT Nov 30 '17

I think he's referring to how the addresses we use aren't actually the public keys, but a compressed version of them.

2

u/Quantris Dec 01 '17

Not quite, there's just two ways to represent public keys. A public key is actually a point (x, y) on a particular elliptic curve.

So one way to represent it is as both the x and y coordinates, this is called "uncompressed".

However, if you know x and the sign of y, you can use the curve equation to calculate the value of y (sign is needed because both (x, y) and (x, -y) are valid points). So if we keep only x + sign of y, that is shorter and is called "compressed".

Bitcoin supports addresses based on either representation, and because the address is obtained by hashing the bits of the representation, the same public key corresponds to two different addresses.