ProofSpec defines what the expected parameters are for a given proof type. This can be stored in the client and used to validate any incoming proofs.

verify(ProofSpec, Proof) -> Proof | Error

As demonstrated in tests, if we don't fix the algorithm used to calculate the LeafHash for a given tree, there are many possible key-value pairs that can generate a given hash (by interpretting the preimage differently). We need this for proper security, requires client knows a priori what tree format server uses. But not in code, rather a configuration object.

interface ProofSpec {
    innerSpec?: InnerSpec;
    leafSpec?: LeafOp;
    maxDepth: number;
    minDepth: number;
}

Properties

innerSpec?: InnerSpec
leafSpec?: LeafOp

any field in the ExistenceProof must be the same as in this spec. except Prefix, which is just the first bytes of prefix (spec can be longer)

maxDepth: number

max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries)

minDepth: number

min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries)