import { MerkleTreeInclusionProof , newInMemoryDB , SparseMerkleTreeImpl , } from '@pigi/core-db' ; import { Decider , Decision } from '../../types' ; export interface MerkleInclusionProofDeciderInput { merkleProof : MerkleTreeInclusionProof ; } /**
 * Decider that determines whether or not a Merkle Inclusion Proof is valid.
 */ export class MerkleInclusionProofDecider implements Decider { public async decide ( input , _noCache ? ) { const tree = await SparseMerkleTreeImpl . create ( newInMemoryDB ( 256 ) , input . merkleProof . rootHash , input . merkleProof . siblings . length + 1 ) ; const outcome = await tree . verifyAndStore ( input . merkleProof ) ; return { outcome , justification : [ { implication : { decider : this , input , } , implicationWitness : undefined , } , ] , } ; } }