Bitcoin Forum

Other => Beginners & Help => Topic started by: Jet Cash on July 02, 2018, 08:20:03 AM



Title: The Merkle and the Nonce
Post by: Jet Cash on July 02, 2018, 08:20:03 AM
It sounds like the title of a film about the EU dark angel and a sex offender (British prison slang for nonce ), but these are specific terms used in the construction of the blockchain. I'll award merits to posters providing a simple description of either or both words.

Describe a Merkle tree or Merkle root, or the Nonce in a Bitcoin blockchain

As always, no plagiarism or cut and paste answers. Also you are free to correct any posted misconceptions.


Title: Re: The Merkle and the Nonce
Post by: RAMSHIVDEEPAK on July 02, 2018, 09:37:39 AM
    It sounds like the title of a film about the EU dark angel and a sex offender (British prison slang for nonce ), but these are specific terms used in the construction of the blockchain. I'll award merits to posters providing a simple description of either or both words.

    Describe a Merkle tree or Merkle root, or the Nonce in a Bitcoin blockchain

    As always, no plagiarism or cut and paste answers. Also you are free to correct any posted misconceptions.

    first we have to know about the HASH FUNCTION- ON WAY FUNCTION THAT TAKES THE INPUT AND GENERATE FIX LENGTH UNIQUE OUTPUT

    pairing hash transaction output using the HASH function  and  pair the output again using the hash function and continue this process till you get one unique out put,that out put is merkle root and whole procees is called merkle tree.

    t1   HASH --- H1
                                         HASH    ---  A
    t2   HASH --- H2                                                HASH  ---- m
                                         HASH    ---  B                                      HASH  --- K
    t3    HASH --- H2                                               HASH   --- n                       HASH ---- F
                                         HASH    ---  C                                      HASH  ---L              HASH -----I (merkle ROOT)                    
    t4    HASH --- H2                                               HASH   --- o                        HASH ----G
                                         HASH    ---  D                                     HASH  ---M
    t5    HASH --- H2                                                HASH   --- p
                                        HASH    ---  E
    t6    HASH --- H2  

    {WHOLE SYSTEM -merkle tree}


    Title: Re: The Merkle and the Nonce
    Post by: sunriseme on July 02, 2018, 10:52:33 AM
    My understanding is that nonce was added to the scrypt as the unique number that miners are trying to reach while solving the blocks.
    The block height has details about next wanted hash, time, block version, hash of the merckle root, timestamp and the nonce.
    Going through solutions until the right nonce is found is known as 'proof of work'.
    The reward for guessing the nonce is adding new block to the chain.
    I read that the extra-nonce field was introduced as a safety (maybe) and to keep up with the increased difficulty.


    Title: Re: The Merkle and the Nonce
    Post by: nngella on July 02, 2018, 11:20:18 AM
    Before answering the question, I think it is necessary to explain first how the blockchain technology works.

    Blockchain is just like a database shared throughout the network of users and these users regularly make changes/update the network and continually being reconciled between the users.

    The best analogy that I read is a google spreadsheet available to everyone.  As one user make a change, everyone will see that change and everyone's copy will be updated(everyone has his own copy which makes it decentralized).

    What is a Merkle Tree?

    Going with the document analogy of bitcoin.  Let us say that there are 4 users who make changes to the document (blockchain) and they are W, X, Y, and Z.

    Blockchain will consolidate the changes in the manner just like below:

    Level 3                                        Change WXYZ
    Level 2          Change WX ---------------------------------Change YZ
    Level 1  Change X ----- Change W                   Change Z ----- Change Y

    Level 1 - Users W, X, Y, and Z make changes to the document
    Level 2 - blockchain consolidated the changes pairing change X and change W making an updated document with change WX.  Another pair with change Z and change Y made another updated document having a change YZ.
    Level 3 - the 2 documents (1 - change WX and 1- change ZY) are reconciled to make a single updated document having change WXYZ.  Change WXYZ contains all the changes made by the 4 users.

    The diagram above looks like a triangle or a tree hence it is called Merkle Tree.  The final document (change WXYZ) is called Merkle Root.


    Title: Re: The Merkle and the Nonce
    Post by: vphasitha01 on July 02, 2018, 04:11:22 PM
    Before I explaining the "Merkle tree" or Merkle root" it is better to explaining what is "hash".Every block in a block chain has a hash. It's like a finger print. It identify the block and all it's content and it's always unique just as like fingerprint. Once a block is created it's hash is calculated. Changing something(data) inside the block will cause hash to change, in other other words we can say hashes are very useful when you want to detect changes in the block

    So let's now move to the "Merkle tree" and Merkle root". Say we have 1600 transactions in a block( normally we can get avarage[1] as around 1600 transaction per block, however it's depend on the size of the transactions). First we put each transaction through a hash function[2] to get a transaction hash or transaction ID which is used itself to identify a transaction.

    Then we put them all into pairs and perform a hash of that pair of hashes. We do put up them again and hash them again and keep doing this until all of the transactions in a block meets at a single hash. This single hash called as " Merkle root" and the cascade network called as " Markle tree".

    That produced Markle root put in to a block header which is the part of a Bitcoin block that gets hash in process of mining. Having a Markle root in the block header, basically makes transactions temper proof. If you want to change value of it that would be reflected in the hash of that transaction or transaction ID. That change would cascade up the Markle tree to the Markle root, ultimately changing the value of Markle root. In thus in validating the block, everybody would be able to see that your transaction is not valid. It's not in a valid block since you're tempered with some how.

    So if you're want to verify a perticular transaction, you only need to look at the branches that the transaction on the Markle tree. You don't need to look at the entire Markle tree just only the branches.

    I think I have explained what i understood about "Markle tree" and "Markle root".



    [1]-Link>>>https://www.blockchain.com/charts/n-transactions-per-block
    [2]-Link>>>https://en.m.wikipedia.org/wiki/Cryptographic_hash_function