Author

Topic: how many addresses from a single private key (Read 1167 times)

legendary
Activity: 3514
Merit: 4895
April 14, 2017, 12:13:29 PM
#9
If we look at the first transaction of the bitcoin history (it should be a Pay2PubKey transaction)  this is the script:

Code:
0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG

and this is the abstraction-address: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX

That depends on where you look.

There is no standard way of converting a Pay2PubKey script into an address.  Some block explorers choose to treat it like a Pay2PubKeyHash address.

They hash the pubkey, put a 0x00 byte in front of it, and use bease58check encoding.  This is just a choice they've made in how they want to display the script to you on their website.

If you were to try to send to that address (12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX) it would NOT be a Pay2PubKey output.  Any Bitcoin wallet would convert that address into a Pay2PubKeyHash output script when it built the transaction.


How can I distinguish between this address and an address that is related to a Pay2PubKeyHash?

That address IS a Pay2PubKeyHash.  The block explorers that you are using are just misrepresenting the output script to you.

How do the wallets know if the address 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX should be converted in a Pay2PubKey script or in a Pay2PubKeyHash script?

They don't.  They will always convert that address into the associated Pay2PubKeyHash script.
staff
Activity: 3458
Merit: 6793
Just writing some code
If we look at the first transaction of the bitcoin history (it should be a Pay2PubKey transaction)  this is the script:

Code:
0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG

and this is the abstraction-address: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX

How can I distinguish between this address and an address that is related to a Pay2PubKeyHash?

The wallets convert those addresses into scripts.

How do the wallets know if the address 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX should be converted in a Pay2PubKey script or in a Pay2PubKeyHash script?

There are no addresses for P2PK. Most wallets and block explorers will just show them as a normal P2PKH address because it is easy to make that address and sending to that address will still allow the owner of that public key to spend their Bitcoin. Since the address is based on the hash of the public key, you can't make a P2PK script with just an address, you need the full public key.
legendary
Activity: 1948
Merit: 2097
The point here is that there are NO ADDRESSES in the blockchain or in transactions.  Addresses are an abstraction that wallets use to make it easier for us humans to talk about exchanging control over value.  The wallets convert those addresses into scripts.  If we want another script type, we can just create a new "address" representation of that script.  As far as I'm aware, we currently have 3 "standard" script types:

  • Pay2PubKeyHash
  • Pay2PubKey
  • Pay2ScriptHash


If we look at the first transaction of the bitcoin history (it should be a Pay2PubKey transaction)  this is the script:

Code:
0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG

and this is the abstraction-address: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX

How can I distinguish between this address and an address that is related to a Pay2PubKeyHash?

The wallets convert those addresses into scripts.

How do the wallets know if the address 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX should be converted in a Pay2PubKey script or in a Pay2PubKeyHash script?
legendary
Activity: 3514
Merit: 4895
The point here is that there are NO ADDRESSES in the blockchain or in transactions.  Addresses are an abstraction that wallets use to make it easier for us humans to talk about exchanging control over value.  The wallets convert those addresses into scripts.  If we want another script type, we can just create a new "address" representation of that script.  As far as I'm aware, we currently have 3 "standard" script types:

  • Pay2PubKeyHash
  • Pay2PubKey
  • Pay2ScriptHash


A given private key will have 2 Pay2PubKeyHash scripts (one compressed and one uncompressed).

I'm not certain if the Pay2PubKey script supports compressed keys, but I think it does. In that case, A given private key will also have 2 Pay2PubKey scripts (one compressed and one uncompressed).

Pay2ScriptHash scripts don't need a private key at all (although it is generally best to use one if you don't want the bitcoins taken by anyone that knows the script).  I'm not certain, but I think the hash portion of the Pay2ScriptHash is RIPEMD160.  As such, while there are practically an unlimited number of scripts that you could create, you are limited to no more than 2160 Pay2ScriptHash "addresses".

You could also create a nonstandard, but valid, scripts that are none of the above. There is no standard way to represent such scripts as "addresses".
legendary
Activity: 2053
Merit: 1356
aka tonikt
However this is not a very elegant solution, as it wastes precious block chain space.

I'd rather go for a smaller nonce  

Something like:

Code:
0x04 <4 random bytes> OP_DROP OP_CHECKSIGVERIFY
legendary
Activity: 2053
Merit: 1356
aka tonikt
Quote
In other words: from a single private key k, how many different addresses can we get?

You can get virtually unlimited number of P2SH addresses for a single private key.
You just need to hash a script with some kind of nonce.
For instance, it could be 1 of 2 mulitisig, where the second key is a random number.

Then in this script:
Code:

{1 [pubkey1] [pubkey2] 2 OP_CHECKMULTISIG}

instead of pubkey2 I can put any string with any lenght?


No. Put something that has a format of a public key; starts from 2 or 3 and is followed by 32 bytes. The 32 bytes can be anything. As long as they aren't any known public key Smiley
legendary
Activity: 1948
Merit: 2097
Quote
In other words: from a single private key k, how many different addresses can we get?

You can get virtually unlimited number of P2SH addresses for a single private key.
You just need to hash a script with some kind of nonce.
For instance, it could be 1 of 2 mulitisig, where the second key is a random number.

Then in this script:
Code:

{1 [pubkey1] [pubkey2] 2 OP_CHECKMULTISIG}

instead of pubkey2 I can put any string with any lenght?
legendary
Activity: 2053
Merit: 1356
aka tonikt
Quote
My question is: if i made a Base58 encoding of "05+s" instead of "00+s" and I got the address  3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX, I could spend the bitcoin of that address?
No, you couldn't spend from that address.
You need hash of a script, not of a public key.


Quote
In other words: from a single private key k, how many different addresses can we get?

You can get virtually unlimited number of P2SH addresses for a single private key.
You just need to hash a script with some kind of nonce.
For instance, it could be 1 of 2 mulitisig, where the second key is a random number.
legendary
Activity: 1948
Merit: 2097
I have a doubt about the use of:

Quote
Pay to Pubkey Hash address (P2PKH):  17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem

Pay to script hash address (P2SH) : 3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX  

I know that the starting "1" and "3" are added after sha256 + ripemd160, to get "1" I have to add a "00" prefix and to get "3" a "05" prefix before the Base58 encoding.


So, let's imagine I have a private key k, then I compute the public key kG : (x,y), then I perform
 sha256(ripemd160(x,y)). Now I have a 160bit string s.

My question is: if i made a Base58 encoding of "05+s" instead of "00+s" and I got the address  3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX, I could spend the bitcoin of that address?

In other words: from a single private key k, how many different addresses can we get?

Surely there are at least 2 pubkey hash addresses (compressed and uncompressed public key), but in theory is it possible to get a pay to script address too from a single private key?

Jump to: