Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

6

Hash functions are unpredictable. You can't simply find an input to the hash function that produces such an output. The only way to accomplish that is by trying lots and lots of candidate blocks as input. If the target is 1000 times smaller, it requires 1000 times as many tries.


6

EDIT: For clarity, I mean this in the sense of what part of the technology requires me to use a hash function? As opposed, to just constructing something that looks like a valid hash. When determining whether or not a block is valid, each and every bitcoin node on the network will take the header of that block, and run it through a hashing algorithm to see ...


5

If you convert the difficulty bits to hex you will get: 0x1F00FFFF Coefficient = 0x00FFFF Exponent = 1F = 31 Target = Coefficient * 2**( 8 * ( exponent-3 ) ) Target = 0xFFFF with 31 - 3 = 28 trailing NULL (0x00) bytes Target: 0x0000FFFF00000000000000000000000000000000000000000000000000000000 Your Hash: ...


4

Sometimes these terms are used more or less interchangeably. Traditionally, a checksum is used to detect corruption and a hash is used to map large elements into slots randomly. In Bitcoin-land we're often concerned with "cryptographic hashes" which are hashes that have special security properties. Things called checksums are usually designed to have ...


3

Normally, one of the purposes of hashing a string (such as a transaction) is summarizing the data to save the size because of the space limitation. No, that would be a compression function. Hash functions are not compression functions, there is no reversing a hash. The point of a hash is to get a unique representation of the data that is the same size for ...


3

tx_hash and tx_hash_big_endian are the transaction id of the transaction that this output originated from in little endian and big endian (reversed). tx_output_n is the number of the output in the referenced transaction, i.e if a transaction has 5 outputs and you need to refer to the 5th you use a tx_output_n = 5. tx_index I believe is an internal unique ...


3

The Merkle tree structure is essential for section 7 (Reclaiming Disk Space) and section 8 (Simplified Payment Verification) in the whitepaper. With simple concatenation, the only way to be convinced that a transaction exists in a block is to have access to the hashes of all transactions, which requires a lot of storage space. With a Merkle tree you can: ...


3

You would duplicate the hash of the last two txs. The tree would "look" something like this: abcdefef / \ / \ / \ abcd efef / \ / \ / \ / \ ab cd ef ef / \ / \ / \ ...


3

A Bitcoin mining ASIC: does not attempt to complete a single hash, rather fragments of two SHA256 compression rounds which is then compared to a target, the result is never returned can not accept arbitrary information that is not in the form of a partial SHA256 compression round So in terms of competitiveness, a CPU can actually complete a SHA256 hash, ...


2

You have to byte-swap the hex values BEFORE concatenating them. You also have to byte-swap the double hashed hex string! import hashlib header_hex = "435fc2d898ebcd7821c6d407d8d915f9ef4f106057df089ddf3be7abbeef51a7435fc2d898ebcd7821c6d407d8d915f9ef4f106057df089ddf3be7abbeef51a7" header_bin = header_hex.decode('hex') ...


2

There are multiple things that you have done wrong. First, you hashed just the coinbase part of the coinbase transaction. You are supposed to hash the entire coinbase transaction. Second, you have hashed the transaction ids of the transactions, not the transactions themselves. Hashing the transaction themselves will result in the txid (ignoring segwit). So ...


2

A cryptographic hash function projects an arbitrary amount of data to a limited image space. In the case of P2SH, the hash is a RIPEMD160 hash, projecting the redeem script to an hash digest of exactly 20 B (160 b) length. This is a trapdoor or one-way function that cannot be reverted (if it can be reverted, it's broken and therefore not a cryptographic ...


2

When a node receives a transaction, they perform the following steps at a high level. Inductively, they already have a set of validated transactions; these belong to the blockchain they have adopted as well as their current mempool. From this, the node has extracted a UTXO. Ensure that the inputs of the new transaction reference valid outpoints in the UTXO....


2

No, and this will not happen in the foreseeable future. Any given hash calculation will result in any one of 2^256 possible numbers. That means, the odds of finding any one exact number is 1/2^256. Even at today's hashrate of ~47000000 TH/s, it would take you 7.812×10^49 years to find a preimage for every one of those 2^256 numbers, assuming each hash you ...


2

Read the fine manual! $ ./src/bitcoin-cli help getblock getblock "blockhash" ( verbosity ) If verbosity is 0, returns a string that is serialized, hex-encoded data for ...


2

I guess that the script is the owner's address.I am not sure about this. According to https://en.bitcoin.it/wiki/Script Bitcoin uses a scripting system for transactions. Forth-like, Script is simple, stack-based, and processed from left to right. It is intentionally not Turing-complete, with no loops. A script is essentially a list of instructions ...


2


2

The original 50 BTC coinbase is not spendable since it was not included in the UTXO set. Any transaction trying to spend it would be invalid, since the previous output from the coinbase tx does not exist in the utxo set. The hex string is an encoding of The Times 03/Jan/2009 Chancellor on brink of second bailout for banks, along with the regular coinbase ...


2

Recall that in order to be a valid block, it has to have a valid proof of work: the hash of the header has to be below the current target value (i.e. start with a sufficient number of zeros). If you just alter something in the block (e.g. the destination of the coinbase transaction), its hash will change and almost certainly will no longer meet the proof-of-...


2

The speed of the hash is roughly linear in the number of bytes processed: SHA2 processes block of 64 bytes at a time, and the time taken is equal to the number of blocks processed. Computing a hashtree processes more blocks due to the intermediate levels but almost all the processing can be done in parallel unlike the linear hash which must be done ...


2

I can't say I'm familiar with all of the cryptocurrencies you mentioned, but the Bitcoin clones generally use elliptic curve (secp256k1) cryptography and the same address generation scheme. Keys A private key is any 256 bit number. However, for the EC used by Bitcoin, it must be between 0x1 and 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B ...


2

A checksum is an application of a hash function. From wikipedia - cryptographic hash function: A cryptographic hash... is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash) and is designed to be a one-way function, that is, a function which is infeasible to invert. From wikipedia - checksum: A checksum ...


2

It's possible, and this does happen (refered to as extraNonce), but this is orders of magnitude more resource intensive to do, as you need at least the left hand side of the merkle tree, rather than just 64 bytes of the header. In Bitcoin the nonce is only 32 bits, which means every 4.2 Billion hashes you need to either update the timestamp, or modify the ...


2

It doesn't matter which nonces you test or in what order that other than you need to avoid testing the exact same block header twice (since that would obviously be a waste of time). It's useful to test all the nonce values since if you don't test them all you will need to update extranonce more often, though not critical. Even though miners increment their ...


2

Where in the source code do we check whether hash(blockheader*nonce) < Difficulty The function you are looking for is in pow.cpp: bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params) { bool fNegative; bool fOverflow; arith_uint256 bnTarget; bnTarget.SetCompact(nBits, &fNegative, &...


2

The hash rate is literally how many distinct block header hashes you can try per second. Nothing more, nothing less. Note that I say "try" and not "compute". Determining whether a particular block header is interesting is somewhat faster than fully computing the hash: You can drop the last few rounds of the hash implementation, and only compute the first 32 ...


1

How am I suppose to get the txid of this transaction? The same way you get the txid of any other transaction, by hashing it (unless it is segwit). Note that the transaction you linked to is not a segwit transaction, so you can just take its hash. If the transaction is a segwit transaction (as indicated by the marker and flag bytes of 0x0001 following the ...


1

Bitcoin is a network that allows participants to hold and transfer value amongst each other. A journalist could use it to transact with sources, or perhaps to withhold their money from the grasp of an over-reaching government, but it will not protect a journalist that is publishing articles from an angry government. A journalist could publish anonymously, ...


1

The message that is signed is prepended with "\x18Bitcoin Signed Message:\n" + compactSizeEncoding( len(message) ) \x18 is Python syntax for unicode character 0x18. This new text string is then converted into a byte array by interpreting the string as UTF8. This will give you the correct hash preimage which is: SHA256(SHA256(utf8.to_bytes("\x18Bitcoin ...


1

When a node receives a transaction, what steps does it do to verify that transaction? This reference may be a bit obsolete (and even incorrect), but it is a good start: https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages I know that it verifies the block hash by calculating each hash of the contiguous blocks in order, but does it verify the ...


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