Bitcoin Internals: Verifying Merkle Roots using Merkle Proofs in JavaScript

Поделиться
HTML-код
  • Опубликовано: 9 ноя 2017
  • In this video we expand on the previous one where we computed a given list of transactions Merkle root using Merkle trees. We will now compute a Merkle proof for a given transaction, allowing clients to validate that a transaction exists in a block without having to download it's entire contents.
    This technique is used widely in light-weight Bitcoin clients (using Simplified Payment Verification).
    We codify a JavaScript solution which will create a Merkle proof for a transaction and then do the inverse and validate that proofs claim based on the blocks Merkle root.
    Discussed in the video:
    - bitcoin.org/en/glossary/simpl...
    - www.bitcoinbook.info/
    The source-code for this video can be found here:
    gist.github.com/eddmann/6b8d0...
  • НаукаНаука

Комментарии • 16

  • @sarenodev
    @sarenodev 2 года назад

    I've been surfing the internet this past few days just for the specific information about verification in Merkle Tree and this video is the best as it explains everything thoroughly and clearly. Big 👍.

  • @shinsatori184
    @shinsatori184 3 года назад

    Finally someone really explained how Merkle Tree works to verify transactions inside. Most video just doesn't. Thanks really!

  • @itakpeemmanuel5863
    @itakpeemmanuel5863 2 года назад

    This is really indepth and i greatly appreciate it.

  • @rajakumarjanga9273
    @rajakumarjanga9273 День назад

    Thanks!

  • @Latesttechs
    @Latesttechs 2 года назад

    Great stuff mate

  • @nadirlaskar
    @nadirlaskar 6 лет назад

    What if the hash Hij is tempered with over network and thus we get different root hash and we wrongly conclude the transaction Hk is invalid or doesn't exist?

  • @0xcoder542
    @0xcoder542 3 года назад +3

    Absolutely, a great example of Merkle Tree video. Quick one, wondering if you could share me any similar solution in Python? That would be much appreciated.

  • @arvind30
    @arvind30 4 года назад

    when a node(or wallet) is doing the SPV, does it need to download all of the transactions for a block and recreate the merkel tree in order to do the proof that you have described? Or will the full node that is being queried for this information return the Merkel root and necessary merkel branches?

    • @arjunkhandkar
      @arjunkhandkar 4 года назад

      The SPV node doesn't need to download all the transactions or recreate the Merkle tree -- it only needs the Merkle root for that block. The full node being queried provides the Merkle branch(es) which the SPV node can use in conjunction with the Txn hash to create a Merkle root and verify if it matches with the root included in the block header.

    • @jackpitts5561
      @jackpitts5561 3 года назад

      @@arjunkhandkar Even better if the sending wallet includes the hash pairs needed to generate the merkleRoot for the block which the recieving wallet will have a copy. Then the recieving wallet can just use the transaction hash plus the hash-pairs of the branches for the full merkelproof and run a function to check if it gets the merkle root for the block header it stores in its private datbase.

  • @joemesserman4278
    @joemesserman4278 6 лет назад

    great video thanks!

  • @Box-9393
    @Box-9393 5 лет назад +2

    Nice presentation. But I have still a question and hope you can help me. When I want to find out, if transaction HK is included in the merkle tree or not, then I have to know first of all the pairnode or neighbour node of HK. Does this make sence? I mean, when a neigbour node really exist and can be found, why we should check if HK is included? When a par node exist, it would mean that HK is included automatically or not?

    • @itakpeemmanuel5863
      @itakpeemmanuel5863 2 года назад

      The proof is for nodes(SPVs) that don't have all the transactions. These SPVs want to know if a tx is in a block, but they don't have all the txs so they can't simply check, they have to rely on another node(full node) that contains all the txs in every block.
      Now SPVs can simply ask a full node if a tx is in the list of it's txs. The full node however can provide a dishonest answer, and the SPV has no system to validate that answer.
      To ensure a trustless system with valid answers, full nodes can provide a proof from the merkle tree using the provided tx and send it to the SPVs. SPVs can then perform the validation to be certain if the tx is indeed contained in the block.
      It is computationally infeasible for a node to generate a faux proof that also validates the tx.

  • @saimafa5579
    @saimafa5579 6 лет назад

    Can you give me the codes used in the vid?thanks

    • @eddmann4644
      @eddmann4644  6 лет назад

      Source can be found at: gist.github.com/eddmann/6b8d0ddd3123c37f296b7680b8fa198a