You are correct that effectively Bitcoin PoW involves computing the Merkle root every now and then in addition to the hash grinding.
However, this is negligable. Even ignoring nTime rolling, the Merkke root computation is just a dozen or so hashes every 232. It's so little because not the entire Merkle tree needs recomputation; just the coinbase transaction ...
Secp256k1 was designed to be a 256-bit size elliptic curve without cofactor and admitting an efficient endomorphism for optimization purposes. The choices of the relevant parameters are derived from these criteria.
P is selected allow a more efficient implementation on general purpose computers. See Solinas' paper on Generalized Mersenne Numbers. We don't ...
Let's disect this function call:
void sha256(struct sha256 *sha, const void *p, size_t size)
First we realize that the return value is void which means the function does not return the sha256 of the data. However we see that the first argument struct sha256 *sha is a pointer to a sha256 struct with the name sha. This suggests that the pointer that we pass ...
sha256.h has the exported (visible from outside) methods and functions. To compute SHA256, you should #include that.
contain SHA256 transform functions (used in SHA256.Write), each specialized for different processors with different instruction sets. Above is the list in order, most of the ...
As the protocol is upgraded with soft-forks changing script interpreter behaviour, the script-machine is extended with additional runs. Each new upgrade brings a new script run with new rules, whilst previous script runs continue to be evaluated according to older rules. Arguments need to be supplied to determine whether the newer script runs are to be ...
The P2WPKH actually uses the HASH160 hashing algorithm, which is just RIPEMD160(SHA256(pubkey)).
The reason for using SHA256 is mentioned in BIP141:
The increased size improves security against possible collision
attacks, as 2^80 work is not infeasible anymore (By the end of 2015,
2^84 hashes have been calculated in Bitcoin mining since the creation
A few things to check:
Make sure you are computing the HASH256 on the decoded byte values of the string. In other words, HASH256(0x73656e646572)
Make sure you are doing 2 rounds of SHA256
Using secp256k1 to generate a compressed public key
This is a P2PKH address (prefix is 1) so the steps to generate the address from the public key are:
pubkeyhash = ...
A Bitcoin block is a container data structure that aggregates all the transactions. The block is made of a header (containing metadata), followed by a long list of transactions that are included in the block. The block header consists of merkle tree root, previous block header hash, timestamp amongst other metadata.
The Merkle tree root in simpler terms ...
The SHA256 function that you are using in the excel sheet is hashing the binary as a text rather than using the bits from it. This results in the output of your excel function being different from the desired one. Below is a simple python script that will illustrate it to you.
string1 = '...
CSHA256 itself mimics OpenSSL's SHA256_CTX, and its constructor mimics the Init function. The Write method corresponds to the Update function. The Finalize method matches the Final function.
In short: you construct a CSHA256 object, call Write any number of times to feed it bytes to hash, and then call Finalize to compute the resulting hash.
The problem is that you are hashing the string of the hexadecimal representation of the bytes of the block header, not the bytes of the block header itself. You need to hash the bytes of the block header itself.
You need to set everything as a byte array, not a string. So you would have something like this for the entire block header all together:
A very short layman's answer (not mathematically correct) is the normalization of the the private key needs to be a very large prime number less than 2^256-1 to ensure the cyclic modulo operation does not easily repeat predictably to compute the associated public key. If someone was able to discover a larger prime number than p = 2^256 - 2^32 - 2^9 -2^8 - 2^...
let address = BitcoinAddress.Create("1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1",
let sha = NBitcoin.Crypto.Hashes.SHA256(address.ScriptPubKey.ToBytes())
let reversedSha = sha.Reverse().ToArray() // add `open System.Linq` at the top