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

2014년 1월 24일 금요일

Merkle tree structure of transaction in bitcoin




https://en.bitcoin.it/wiki/Protocol_specification#block



Merkle tree is to make sure that data blocks (transactions) received
from other peers in a peer-to-peer network are received undamaged and unaltered,
and even to check that the other peers do not lie and send fake blocks.
Merkle tree can be used to verify any kind of data stored.

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

How to calculate the difficulty and target from the bit of bitcoin block header.


The method of obtainig the difficulty of bitcoin.


* Difficulty:  a measure of how difficult it is to find a new block.

    - changed by every 2016 blocks.

    - difficulty = maximum_target / current_target.

    - maximum target in bitcoin is constant.

         ==> 0x00000000FFFF0000000000000000000000000000000000000000000000000000

    - lower current target makes Bitcoin generation more difficult.

       the maximum target is the lowest possible difficulty.

* Difficulty 1 is defined as 0x1d00ffff,

    - maximum target : 0x00ffff * 2**(8*(0x1d - 3))

       = 0x00000000FFFF0000000000000000000000000000000000000000000000000000

* The maximum difficulty:  roughly maximum_target / 1, (about 2^224)