revert error from verification of multiproof flags
This commit is contained in:
parent
dda5c23cbc
commit
35f512bdb3
|
@ -906,12 +906,12 @@ export class MerkleTree extends Base {
|
|||
throw new Error('Invalid Inputs!')
|
||||
}
|
||||
|
||||
let ids : number[]
|
||||
if (leaves.every(Number.isInteger)) {
|
||||
leaves = leaves
|
||||
ids = leaves.sort((a, b) => a === b ? 0 : a > b ? 1 : -1) // Indices where passed
|
||||
} else {
|
||||
leaves = leaves.map((el) => this._bufferIndexOf(this.leaves, el))
|
||||
ids = leaves.map((el) => this._bufferIndexOf(this.leaves, el)).sort((a, b) => a === b ? 0 : a > b ? 1 : -1)
|
||||
}
|
||||
let ids : number[] = [...leaves].sort((a, b) => a === b ? 0 : a > b ? 1 : -1)
|
||||
|
||||
if (!ids.every((idx: number) => idx !== -1)) {
|
||||
throw new Error('Element does not exist in Merkle tree')
|
||||
|
@ -937,11 +937,6 @@ export class MerkleTree extends Base {
|
|||
}, [])
|
||||
}
|
||||
|
||||
const leafValues = leaves.map(i => this.leaves[i]);
|
||||
if (!this.verifyMultiProofWithFlags(this.getRoot(), leafValues, proofs, flags)) {
|
||||
throw new Error('cannot generate multiProof flags for parameters')
|
||||
}
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
|
|
|
@ -1185,16 +1185,3 @@ test('complete option with incompatible options', t => {
|
|||
/option "complete" is incompatible with "duplicateOdd"/,
|
||||
)
|
||||
})
|
||||
|
||||
test('bad multiproof', t => {
|
||||
t.plan(1);
|
||||
const leaves = 'abcdefghi'.split('').map(keccak256).sort(Buffer.compare);
|
||||
const merkleTree = new MerkleTree(leaves, keccak256, { complete: true });
|
||||
const reqLeaves = leaves;
|
||||
const root = merkleTree.getHexRoot();
|
||||
const proof = merkleTree.getMultiProof(reqLeaves);
|
||||
t.throws(
|
||||
() => merkleTree.getProofFlags(reqLeaves, proof),
|
||||
/cannot generate multiProof flags for parameters/,
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue