레이블이 nonce인 게시물을 표시합니다. 모든 게시물 표시
레이블이 nonce인 게시물을 표시합니다. 모든 게시물 표시

2014년 1월 24일 금요일

proof of work of bitcoin : satoshi paper


1.2) Proof-of-Work of bitcoin
    1). Scanning for a value that when hashed, the hash begins with number of zero bits.
   
    2). increment a nonce in the block until a value is found,  that gives the blocks hash the required zero bits

    3). As later blocks are chained after it,

          * the work to change the block would include redoing all the blocks  after it.
 
        * Every block contains a hash of the previous block.

             - Creating a chain of blocks from the genesis block to the current block.

            - By these properties, double-spending of bitcoins very difficult.


    4) Proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour.
    

v* Problem of majority decision in bitcoin
    
     1) Proof-of work is one-CPU-one-vote, not one-IP-one-vote.

     2) Majority decision is represented by the longest chain.

         è To modify a past block, an attacker redo the proof-of-work of the block and all blocks after it.

         è Probability of attack reduces exponentially as next blocks are added.
 



* Block of bitcoin 

  
  * There are multiple valid solutions for any given block

    - only one of the solutions needs to be found for the block to be solved.
  * Coinbase transaction:  known as a generation transaction.

      - appearing the first transaction in every block.
  * The number of generated Bitcoins per block: starts at 50.

      - halved every 210,000 blocks (about four years).
  * Bitcoin transactions are broadcast to the network,

      - all peers trying to solve blocks collect the transaction records.

      - add the transaction records to the block.
  * The difficulty of bitcoin is automatically adjusted by the network,

      - solving an average of 6 blocks per hour.

      - every 2016 blocks (about two weeks).
  * This increases (or decreases) the difficulty of generating blocks.


  * Hash of block:  SHA-256 hash of a block's header.

     - between 0the maximum value of a 256-bit number.

     - bitcoin uses: SHA256(SHA256(Block_Header))
  * If your hash is below the target, then you win.

     - If not, you increment the nonce and try again.

How to get the hash of block header in bitcoin

This is example of how to get the hash of block header in bitcoin.




* Calculation of the hash of block header

How to produce the different block hashes for each other in bitcoin


Most of block header will be the same for all users.

There might be some minor variation in the timestamps.

The nonce will usually be different, but it increases in a strictly linear way.

"Nonce" starts at 0 and is incremented for each hash.

Whenever Nonce overflows (which it does frequently),

the extraNonce portion of the generation transaction is incremented,

which changes the Merkle root.

Given block header, people generate the exact same sequence of hashes

as each other and the fastest CPU would almost always win.

However, it is (nearly) impossible for two people to have the same Merkle root

because the first transaction in your block is a generation "sent"

to one of your unique Bitcoin addresses.

Thus, your block is different from everyone else's blocks.



https://en.bitcoin.it/wiki/Block_hashing_algorithm