How to use the merkle-patricia-tree.verifyProof function in merkle-patricia-tree

To help you get started, we’ve selected a few merkle-patricia-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zmitton / eth-proof / verify.js View on Github external
static branchContains(path, branch){
    // console.log(path, branch)
    let complete, error, response = false
    let encodedBranch = []
    for (let i = 0; i < branch.length; i++) {
      encodedBranch.push(toHex(encode(branch[i])))
    }

    Trie.verifyProof(toHex(this.branchRootOf(branch)) , path, encodedBranch, (e,r)=>{
      error = e
      response = r
      complete = true
    })

    while(!complete){/*wait*/}

    if(error){
      throw Error(error)
    }else{
      return response
    }
  }
}
github zmitton / eth-proof / verifyProof.js View on Github external
return new Promise((accept, reject) => {
      let encodedProof = []
      for (let i = 0; i < proof.length; i++) {
        encodedProof.push(encode(proof[i]))
      }

      Tree.verifyProof(toBuffer(this.getRootFromProof(proof)) , path, encodedProof, (e,r)=>{
        if(e){
          return reject(e)
        }else{
          return accept(r)
        }
      })
    })
  }