Hot answers tagged

8

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


7

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


7

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


3

sha256.h has the exported (visible from outside) methods and functions. To compute SHA256, you should #include that. sha256_sse4.cpp sha256_sse41.cpp sha256_avx2.cpp sha256_shani.cpp 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 ...


2

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


2

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


2

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


2

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


2

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. import hashlib string1 = '...


1

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.


1

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: Byte[] ...


1

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^...


1

% echo -n "sender" | bx base16-encode | bx sha256 | bx sha256 | bx ec-to-public | bx ec-to-address -v 0 18aMGf2AxQ3YXyNv9sKxiHYCXcBJeJv9d1 % echo -n "sender" | bx base16-encode | bx sha256 | bx ec-to-public | bx ec-to-address -v 0 1DcTtaa37w971TmoafPpE9Pk16xc42YA87


1

static void test ( ) { const MyByteArray x ( QByteArray ( "sender" ) ); _trace ( x.sha256 ( ).getAddressHashCompressed ( ).toString ( ) ); _trace ( x.sha256d ( ).getAddressHashCompressed ( ).toString ( ) ); } the output is: 1DcTtaa37w971TmoafPpE9Pk16xc42YA87 18aMGf2AxQ3YXyNv9sKxiHYCXcBJeJv9d1 So, your code runs sha256 only once, but not twice


1

In F#: let address = BitcoinAddress.Create("1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1", NBitcoin.Network.Main) let sha = NBitcoin.Crypto.Hashes.SHA256(address.ScriptPubKey.ToBytes()) let reversedSha = sha.Reverse().ToArray() // add `open System.Linq` at the top NBitcoin.DataEncoders.Encoders.Hex.EncodeData reversedSha


Only top voted, non community-wiki answers of a minimum length are eligible