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 ...
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 ...
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 ...
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 ...
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 = '...
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 = ...
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