hash - How can we prove that a bitcoin block is always solvable? -



hash - How can we prove that a bitcoin block is always solvable? -

i'm trying implement simple cryptocurrency similar bitcoin, understand downwards code level.

i understand bitcoin block contains hash of previous block, many transactions , reward transaction solver.

the miner runs sha256 on candidate block combined random number. long first digits of hash result zeros, block solved, , broadcast result entire network claim reward.

but have never seen proving block solvable @ all. guess guaranteed sha256? because solution size fixed, after trying plenty inputs, guaranteed nail every hash result? how can prove solution distribution of block (uniform), can indeed cover hash results?

now, suppose block indeed solvable, can assume using 64bit random integer plenty solve it? how 32bit? or have utilize infinite bit integer?

for example, in basiccoin project:

the code proof of work following:

def pow(block, hashes): halfhash = tools.det_hash(block) block[u'nonce'] = random.randint(0, 10000000000000000000000000000000000000000) count = 0 while tools.det_hash({u'nonce': block['nonce'], u'halfhash': halfhash}) > block['target']: count += 1 block[u'nonce'] += 1 if count > hashes: homecoming {'error': false} if restart_signal.is_set(): restart_signal.clear() homecoming {'solution_found': true} ''' testing sudden loss in hashpower miners. if block[u'length']>150: else: time.sleep(0.01) ''' homecoming block

this code randoms number between [0, 10000000000000000000000000000000000000000] start point, , increases value 1 one:

block[u'nonce'] += 1

i'm not python programmer, don't know how python handles type of integer. there no handling of integer overflow.

i'm trying implement similar thing c++, don't know kind of integer can guarantee solution.

but how can prove solution distribution of block (uniform), can indeed cover hash results?

sha256 deterministic if rehash txns provide same 256 hash. client nodes maintain txn , hashes in merkle tree network clients propagate , verify longest possible block chain.

the merkle tree essential info construction recording hashes of previous blocks. there chain of hash confirmations can tracked from origin (genesis) block.

hash bitcoin sha256

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -