Understanding the values op_hash160 Ethereum and Bitcoin addresses
When you try to sign a Coinbase transaction with a specific shortcut, you probably encounter an unknown mistake. This article aims to explain how to get the value “op_hash160” from the Bitcoin address.
Understanding the shortcut function
Before immersing yourself in this topic, it is necessary to understand the abbreviation function in cryptocurrency transactions. The abbreviation function is a one -way process that transforms the data of any size into a string of a fixed length known as an abbreviation. In Ethereum, the value “op_hash160” is part of a larger transaction signature.
The most commonly used abbreviation function in Blockchain Ethereum is the Keccak-256 shortcut function. Here’s how it works:
4
- Keyed-Hashing for message authentication (K-HMAC)
: The value
op_hash160
is the result of the use of KECCAK-256 to the Bitcoin address in a specific order.
Creating the values op_hash160 'from the Bitcoin address
To create the value "op_hash160", you must take these steps:
- Get the Bitcoin address : Find the Bitcoin address in the Ethereum wallet.
- format the Bitcoin address : Convert your Bitcoin address to bytes in the format required by the Keccak-256 abbreviation:
* Byte (32 bits) is represented as0x01,
0x02, ...,
0x5e.
- Apply the Keccak-256 abbreviation function: Use a library or impress the KECCAK-256 algorithm on the platform to generate a 20-tank semi-semi-semi-semi-semi-seven.
Here is an example using JavaScript and the Web3 library (for Ethereum wallets):
Javascript
Const web3 = requires ("web3");
// Download Bitcoin address
Const bitcoinaddress = '1a1a1 ...'; // replace your actual address
// Create a new web3 instance
Const provider = new web3.providers.httpprovider ('
// Convert Bitcoin address to bytes
let Bitcoinbytes = buffer.from (Bitcoinaddress, "hex");
// Apply the Keccak-256 shortcut function
const ophash160 = keccak256 (0x01 ... Bitcoinbytes);
console.log (ophash160. Tostling ("hex")); // Exit: 0x1234567890123456789
Coinbase transaction signature
To create a Coinbase transaction signature, you need to use the “op_hash160value along with other parameters. The correct format is:
Json
{
"Transaction": {
// Other transaction data ...
"Nonce": number,
"GasePrice": number,
"Blocknumber": Number
},
"signature": {
"Type": "Hash-160",
"Value": ophash160
}
}
Remember to replace “own_project_id” with your Infura project ID.