Author

Topic: Why there are so many formats of keys? (Read 232 times)

jr. member
Activity: 56
Merit: 3
September 11, 2019, 11:09:15 AM
#5
I was going to post a similar question then i saw this topic Roll Eyes

So not every bitcoin adres has the same composition of a private key?
Or did I understood it wrong?
Is that making bitcoin safer because when you have a private key you can't automatically spend those coins?

just made this example three bitcoin address are sharing the same private key Shocked  Shocked Shocked Shocked

Code:
HEX: d9ad33b207c07767317c6fcc8383b4af253ac561dc1d75723d35853574a55c3d

WIF: 5KU9qX4TXocazmzzGueHUGvKDnaAsjpojPNKRan7FvtrL1jKMZP
P2PKH: 1CqUpWkdhwXeyTRvVAAiYAD2ykiEpAV5Tj

WIFcomp: L4Wr19gG6xk541cwoDMZhPGKRS9Qax21G5j6KW66ctsriTzXoagc
P2PKH: 1BunhLhZzLDYbRhP8jstonwGnWZevHFpoy

WIFcomp: L4Wr19gG6xk541cwoDMZhPGKRS9Qax21G5j6KW66ctsriTzXoagc
P2SH: 3Lm5vqLtwJvEwfSaqKgNV3B7g6j4Tdvs6x

WIFcomp: L4Wr19gG6xk541cwoDMZhPGKRS9Qax21G5j6KW66ctsriTzXoagc
Bech32: bc1qw7kss494jjwfnh8k53ekvyjmsh75kuhr7ujpuz

as he said:
We have so many different types because we have so many different needs.


legendary
Activity: 1042
Merit: 2805
Bitcoin and C♯ Enthusiast
September 01, 2019, 01:28:04 PM
#4
So not every bitcoin adres has the same composition of a private key?
Or did I understood it wrong?
Is that making bitcoin safer because when you have a private key you can't automatically spend those coins?

Address is a concept created to make things user friendly so addresses represent the most common and straight forward scripts. As long as you don't go out of your way to create a script that is not common or you don't understand, there is no problem with spending coins as long as you have the private key.
newbie
Activity: 9
Merit: 0
September 01, 2019, 09:00:08 AM
#3
P2PKH and P2SH aren't keys, they are script types, and Hash160 is a hash function or rather combination of two (SHA256 and RIPEMD160).

In bitcoin when you send coins to someone else, you are lock those coins up by creating a "condition" that only when you fulfill requirements of that condition you could "unlock" or "spend" those coins. Some of these "common" conditions have special names.
For example P2PKH is one of the most common public scripts. The condition says that the owner must first provide a public key that when hashed using HASH160 function would produce a digest equal to the 20 bytes that is included inside the script and the signature alongside the public key provided would be a valid ECDSA signature for the provided transactions.

We have so many different types because we have so many different needs.
You might want to pay to one public key so you use P2PKH, you may want to add a specific time to the condition where coins could not be spent before that deadline is reached in which case you use CheckLockTimeVerify script type, you may want to create a complicated condition (such as paying multiple public keys aka multisig) and only reveal the hash of it so you use P2SH (of course P2SH isn't limited to multisig), and so on.
There is also new features such as Segregated Witness which defines new public script types. P2WPKH or P2WSH and some more are among them.

More on scripts: https://en.bitcoin.it/wiki/Script


So not every bitcoin adres has the same composition of a private key?
Or did I understood it wrong?
Is that making bitcoin safer because when you have a private key you can't automatically spend those coins?
legendary
Activity: 1042
Merit: 2805
Bitcoin and C♯ Enthusiast
August 30, 2019, 09:31:26 AM
#2
P2PKH and P2SH aren't keys, they are script types, and Hash160 is a hash function or rather combination of two (SHA256 and RIPEMD160).

In bitcoin when you send coins to someone else, you are lock those coins up by creating a "condition" that only when you fulfill requirements of that condition you could "unlock" or "spend" those coins. Some of these "common" conditions have special names.
For example P2PKH is one of the most common public scripts. The condition says that the owner must first provide a public key that when hashed using HASH160 function would produce a digest equal to the 20 bytes that is included inside the script and the signature alongside the public key provided would be a valid ECDSA signature for the provided transactions.

We have so many different types because we have so many different needs.
You might want to pay to one public key so you use P2PKH, you may want to add a specific time to the condition where coins could not be spent before that deadline is reached in which case you use CheckLockTimeVerify script type, you may want to create a complicated condition (such as paying multiple public keys aka multisig) and only reveal the hash of it so you use P2SH (of course P2SH isn't limited to multisig), and so on.
There is also new features such as Segregated Witness which defines new public script types. P2WPKH or P2WSH and some more are among them.

More on scripts: https://en.bitcoin.it/wiki/Script
jr. member
Activity: 56
Merit: 1
August 30, 2019, 09:08:23 AM
#1
I know there are P2PKH, Hash160, P2SH, and some others. I can't really understand the difference between them and why they were created. Why can't we just use one format? Please, help me understand the difference.

Maybe you can just point me to some relevant article.

Thanks!
Jump to: