Public Key Hash
Introduction to public key hash and its relationship with addresses.
Introduction to Public Key Hash
As the name implies, a public key hash is the hash value of a public key. In Bitcoin, a public key hash is a commonly used way to represent addresses for receiving Bitcoin.
Hashing the public key serves two purposes: fixing the length of the public key and protecting its security. A public key hash is a fixed-length string, usually 160 bits, and can be represented in various formats, such as Base58 encoding or Base64 encoding.
The public key hash is the core part of a Bitcoin address. It is a short and secure representation generated through multiple hashing operations. The public key hash avoids exposing the public key directly, enhancing security and privacy. A Bitcoin address is essentially a public key hash processed through additional encoding steps.
Hash160
The process of calculating a public key hash typically involves hashing the public key and then hashing the result again. This calculation method, called Hash160, is a commonly used hashing algorithm in Bitcoin.
Calculating a Public Key Hash from a Public Key
The process of calculating a public key hash includes the following steps:
- Compute SHA-256 Hash: First, perform a SHA-256 hash on the public key to obtain a 256-bit hash value.
- Compute RIPEMD-160 Hash: Then, perform a RIPEMD-160 hash on the output of the SHA-256 hash to obtain a 160-bit hash value.
This process is called Hash160 because it combines two different hash functions.
Detailed Explanation of the Hash160 Process
Assume the public key is denoted as ( K ). The specific steps to calculate Hash160 are as follows:
-
Compute SHA-256 Hash:
-
Compute RIPEMD-160 Hash:
Formula for the Hash160 Process
Using KaTeX notation:
-
Compute the SHA-256 hash:
-
Compute the RIPEMD-160 hash:
Example
Assume the public key ( K ) is: [ K = 04b0bd634234abbb1ba1e986e8841855dd45b2a4f7cd9b4c8e0ec6ccf97c71548520b2a6d03cfcc92d5a4a3ac2e4ab7c1b3b9d0b4d43fb2314cd2fce6b81f8d2a ]
The steps are as follows:
-
Compute the SHA-256 hash: Suppose the result is:
-
Compute the RIPEMD-160 hash: Suppose the result is:
This 160-bit hash value ( H_160 ) is the public key hash.
Through this process, the public key is converted into a shorter hash value, making it easier to store and use while enhancing security.