import { Proof } from './types' ; import { calculatePathNodes , ROOT_INDEX } from './utils' ; export const verifyProof = ( queryHashes , proof , rootHash ) : boolean => { const { idxs , siblingHashes , size } = proof ; if ( size === 0 ) { return false ; } let calculatedTree ; try { calculatedTree = calculatePathNodes ( queryHashes , size , idxs , siblingHashes ) ; } catch ( error ) { return false ; } const calculatedRoot = calculatedTree . get ( ROOT_INDEX ) ; if ( ! calculatedRoot ) { return false ; } return calculatedRoot . equals ( rootHash ) ; } ;