merkletreejs 方法 getHexProof 不起作用?

merkletreejs method getHexProof doesn't work?

我正在尝试使用 merkletreejs 库测试 merkle 证明,但我不明白为什么会这样

const tree = new MerkleTree(leaves, SHA256)
const root = tree.getHexRoot()
const leaf = SHA256('a')
const proof = tree.getProof(leaf) // РАБОТАЕТ
console.log(tree.verify(proof, leaf, root)) // true

但这不是吗?

const tree = new MerkleTree(leaves, SHA256)
const root = tree.getHexRoot()
const leaf = SHA256('a')
const proof = tree.getHexProof(leaf)
console.log(tree.verify(proof, leaf, root)) // false

它似乎需要一些额外的代码才能工作。 这 code 有效:

const { MerkleTree } = require('merkletreejs')
const sha1 = require('crypto-js/sha1')

const leaves = [
    'd89f84d948796605a413e196f40bce1d6294175d',
    '32f04c7f572bf75a266268c6f4d8c92731dc3b7f',
    'b80b52d80f5fe940ac2c987044bc439e4218ac94',
    '1553c75a1d637961827f4904a0955e57915d8310'
  ]

  const tree = new MerkleTree(leaves, sha1, {
    sortLeaves: true,
    sortPairs: true
  })

  const root = tree.getHexRoot()
  const leaf = 'b80b52d80f5fe940ac2c987044bc439e4218ac94'
  const proof = tree.getHexProof(leaf)

  

  console.log(tree.verify(proof, leaf, root))