Bitcoin Forum
April 28, 2024, 12:56:57 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Private keys, Public Keys and Bitcoin Addresses  (Read 2769 times)
cyberguy (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 4


View Profile WWW
May 16, 2016, 12:35:20 PM
Merited by ABCbits (2)
 #1

from what I have read,

a private key is a 256 bit binary number.

private key ----------elliptic curve multiplication-----> public key

public key -----------sha256 + ripemd160 -----------> public key hash

public key hash -------base58 check encoding------> bitcoin address

now according to the above,

2256 private keys are possible
since elliptic curve multiplication produces a unique public key from each private key, an equal number of corresponding public keys are also possible. But, since the public key goes through RIPEMD160, the public key hash has only 20 bytes or 160 bits. Hence only 2160 bitcoin addresses are possible. Does this mean that each bitcoin address may be associated with more than one private key? Since, if each of 2256 public keys produce only 2160 hashes this means more than one public key produces the same public key hash.

I would appreciate if an expert could clarify this matter ?

1714309017
Hero Member
*
Offline Offline

Posts: 1714309017

View Profile Personal Message (Offline)

Ignore
1714309017
Reply with quote  #2

1714309017
Report to moderator
1714309017
Hero Member
*
Offline Offline

Posts: 1714309017

View Profile Personal Message (Offline)

Ignore
1714309017
Reply with quote  #2

1714309017
Report to moderator
According to NIST and ECRYPT II, the cryptographic algorithms used in Bitcoin are expected to be strong until at least 2030. (After that, it will not be too difficult to transition to different algorithms.)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714309017
Hero Member
*
Offline Offline

Posts: 1714309017

View Profile Personal Message (Offline)

Ignore
1714309017
Reply with quote  #2

1714309017
Report to moderator
Syke
Legendary
*
Offline Offline

Activity: 3878
Merit: 1193


View Profile
May 16, 2016, 12:55:17 PM
Merited by ABCbits (1)
 #2

Since, if each of 2256 public keys produce only 2160 hashes this means more than one public key produces the same public key hash.

Yes, that is correct.

Buy & Hold
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1028



View Profile WWW
May 16, 2016, 02:44:29 PM
Last edit: May 16, 2016, 04:06:02 PM by deepceleron
Merited by ABCbits (3)
 #3

from what I have read,

a private key is a 256 bit binary number.

private key ----------elliptic curve multiplication-----> public key

public key -----------sha256 + ripemd160 -----------> public key hash

public key hash -------base58 check encoding------> bitcoin address

now according to the above,

2256 private keys are possible
since elliptic curve multiplication produces a unique public key from each private key, an equal number of corresponding public keys are also possible. But, since the public key goes through RIPEMD160, the public key hash has only 20 bytes or 160 bits. Hence only 2160 bitcoin addresses are possible. Does this mean that each bitcoin address may be associated with more than one private key? Since, if each of 2256 public keys produce only 2160 hashes this means more than one public key produces the same public key hash.

I would appreciate if an expert could clarify this matter ?



A valid private key is not 2**256, it is between 1 and FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141, which is the order n of G on the Koblitz curve secp256k1 used in Bitcoin.
The chance of a random 2**256 number not being on the curve is 1 in 267776665566007192515705986938822075895 or so, so pretty much the same thing as 2256 for casual discussion.

As you surmised, any given Bitcoin address is expected to have about 296 possible public/private keys.

There are probably 2160 Bitcoin addresses, but there is no proof that they all exist, and statistics about the chances they all exist aren't informed about how oracle-like ripemd160 might be when it is streamed 160+96 bits.

fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 266


View Profile
May 16, 2016, 03:06:54 PM
Merited by ABCbits (2)
 #4

I expect the hash test is first is to avoid unnecessary resource consumption. If the hash of the public key doesn't match, it won't even try to verify the signature.

If two public keys can share an address, a signature from the respective private key is still required to actually spend funds, no?

P2SH might be worse off because of HASH160. P2PKH still requires an OP_CHECKSIG, whereas if you find a script tailored to you that collides with a script-hash address, you could spend those funds using your version of the script. Either case still requires a SHA256 collision however, making this prospect unlikely.

Bitwasp Developer.
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1028



View Profile WWW
May 16, 2016, 03:43:34 PM
 #5

I expect the hash test is first is to avoid unnecessary resource consumption. If the hash of the public key doesn't match, it won't even try to verify the signature.

If two public keys can share an address, a signature from the respective private key is still required to actually spend funds, no?

P2SH might be worse off because of HASH160. P2PKH still requires an OP_CHECKSIG, whereas if you find a script tailored to you that collides with a script-hash address, you could spend those funds using your version of the script. Either case still requires a SHA256 collision however, making this prospect unlikely.

When I send you money, I am only sending it to a Bitcoin address; I don't know your public key. Any public key that hashes to that Bitcoin address can spend the money.

Of course, even if there were 21 trillion addresses each having one satoshi in them (more than the maximum number of bitcoins that will ever exist), the odds are impossible-1 that you will ever be able to spend money for a Bitcoin address and key you didn't generate yourself.
fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 266


View Profile
May 18, 2016, 01:38:35 AM
Merited by ABCbits (4)
 #6

When I send you money, I am only sending it to a Bitcoin address; I don't know your public key.

I know that.

Any public key that hashes to that Bitcoin address can spend the money.

But this is wrong. The public key is provided in the scriptSig, and that's what signatures are checked against. It's also how the hash is checked in the first place.

You can find a public key that collides with the hash, and pass the first part of a p2pkh script. If the hash passes, all that's left is <sig> <pub> OP_CHECKSIG, which still wouldn't pass with the dodgy key.

Bitwasp Developer.
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1028



View Profile WWW
May 18, 2016, 04:36:31 AM
 #7

When I send you money, I am only sending it to a Bitcoin address; I don't know your public key.

I know that.

Any public key that hashes to that Bitcoin address can spend the money.

But this is wrong. The public key is provided in the scriptSig, and that's what signatures are checked against. It's also how the hash is checked in the first place.

You can find a public key that collides with the hash, and pass the first part of a p2pkh script. If the hash passes, all that's left is <sig> <pub> OP_CHECKSIG, which still wouldn't pass with the dodgy key.

Bitcoin address balances are in the form of previous unspent transaction output (UXTO) payments they have received. A standard Bitcoin UXTO that would be in a wallet is a "pay to pubkey-hash", where money is sent to the RIPEMD160(SHA256()) hash of the public key (this pubKeyHash is the same thing as a Bitcoin address, without the Base58 encoding making it pretty). The output script in this UXTO defines the procedures that must be met to spend the money.

A pay to pubkey-hash output script has instructions that basically say: if you can provide a pubkey, and the hash of that pubkey is the Bitcoin address included in the script, then you can spend the bitcoins with a message signed by the keypair.

The output script doesn't care that you use a particular pubkey out of the many that might exist that create the same pubkey-hash, only that the hash (address) matches. The spender is the one that is sending the pubkey to the network, saying in effect with their transaction "this is bitcoins I am allowed to spend - here I'm signing a message with the instructions to spend it, and since you don't have the pubkey yet to cryptographically verify my signature, I'm providing the one I used to sign the message".

Of course the signature has to be valid and the pubkey has to match the bitcoin address, but that is assumed.

The original generation of 50 BTCs from mining was a pay-to-pubkey script. To spend those, you had to have the correct key.
kn_b_y
Newbie
*
Offline Offline

Activity: 26
Merit: 3


View Profile
May 18, 2016, 02:18:21 PM
Last edit: May 18, 2016, 04:16:34 PM by kn_b_y
 #8

Any public key that hashes to that Bitcoin address can spend the money.

But this is wrong. The public key is provided in the scriptSig, and that's what signatures are checked against. It's also how the hash is checked in the first place.

You can find a public key that collides with the hash, and pass the first part of a p2pkh script. If the hash passes, all that's left is <sig> <pub> OP_CHECKSIG, which still wouldn't pass with the dodgy key.

deepceleron is correct.

The public key is indeed provided in the scriptSig, but this is not what signatures are checked against.

The scriptSig (containing the signature and the public key in P2PKH) is provided by the spender. It is the scriptPubKey in the output of the transaction that is being spent from that does the checking.

In the case of P2PKH, the scriptPubKey makes no mention of the public key - just the address.
7788bitcoin
Legendary
*
Offline Offline

Activity: 2282
Merit: 1023


View Profile
May 28, 2016, 01:52:34 PM
 #9

Since, if each of 2256 public keys produce only 2160 hashes this means more than one public key produces the same public key hash.

Yes, that is correct.

Glad to know that.

I am not very good at math, but given a private key, is there any mathematical way to find other private keys that share the same public key?
cyberguy (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 4


View Profile WWW
May 28, 2016, 03:27:59 PM
 #10

Since, if each of 2256 public keys produce only 2160 hashes this means more than one public key produces the same public key hash.

Yes, that is correct.

Glad to know that.

I am not very good at math, but given a private key, is there any mathematical way to find other private keys that share the same public key?

two different private keys will never share the same public key. What is implied by the above quote is that many different private keys may share the same public key hash, which is not the same thing as the public key. I am not a cryptography expert, but I am 99% sure the answer to your question is no, if you actually meant public key hash.
Cryddit
Legendary
*
Offline Offline

Activity: 924
Merit: 1129


View Profile
May 31, 2016, 11:59:26 PM
 #11

I am a cryptography expert, and I AM 100% sure.

If the hash does what it's supposed to do, then having a privKey that hashes to a particular value will give you absolutely no advantage in finding another key that hashes to that value. 

That said, there are hashes like MD5, which don't do what they're supposed to do anymore because somebody figured out a way to attack it that gives hash collisions on demand.  Ripemd160 could eventually become such a hash if somebody figures out a good way to attack it.

The odds are against it though. 

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!