UNPKG

snarky-smt

Version:

Sparse Merkle Tree for SnarkyJS

46 lines (45 loc) 1.76 kB
import { Field, Provable } from 'snarkyjs'; import { Hasher } from '../model'; import { Store } from '../store/store'; import { CompactSparseMerkleProof } from './proofs'; import { CompactSparseMerkleTree } from './csmt'; export { CompactDeepSparseMerkleSubTree }; /** * This is used to compute new roots for state transitions based on sideNodes. * * @class CompactSparseMerkleTree * @extends {CompactDeepSparseMerkleSubTree<K, V>} * @template K * @template V */ declare class CompactDeepSparseMerkleSubTree<K, V> extends CompactSparseMerkleTree<K, V> { /** * Creates an instance of CompactDeepSparseMerkleSubTree. * @param {Store<V>} store * @param {Field} root * @param {Provable<K>} keyType * @param {Provable<V>} valueType * @param {{ hasher?: Hasher; hashKey?: boolean; hashValue?: boolean }} [options={ * hasher: Poseidon.hash, * hashKey: true, * hashValue: true, * }] hasher: The hash function to use, defaults to Poseidon.hash; hashKey: * whether to hash the key, the default is true; hashValue: whether to hash the value, * the default is true. * @memberof CompactDeepSparseMerkleSubTree */ constructor(store: Store<V>, root: Field, keyType: Provable<K>, valueType: Provable<V>, options?: { hasher?: Hasher; hashKey?: boolean; hashValue?: boolean; }); /** * Add a branch to the tree, a branch is generated by smt.prove. * * @param {CompactSparseMerkleProof} proof * @param {K} key * @param {V} [value] * @memberof CompactDeepSparseMerkleSubTree */ addBranch(proof: CompactSparseMerkleProof, key: K, value?: V): Promise<void>; }