Class: SMTProof ​
Defined in: smt-proof.ts:42
An optimized Sparse Merkle Tree proof.
Contains a converge bitmap indicating which levels of the 256-bit path have a non-empty sibling, and the sibling hashes at those levels. Levels without a sibling use depth-byte padding instead.
Constructors ​
Constructor ​
new SMTProof(
converge,hashes):SMTProof
Defined in: smt-proof.ts:46
Parameters ​
converge ​
bigint
hashes ​
readonly Uint8Array<ArrayBufferLike>[]
Returns ​
SMTProof
Accessors ​
converge ​
Get Signature ​
get converge():
bigint
Defined in: smt-proof.ts:52
Converge bitmap: bit i set means a sibling hash exists at depth 256 - i - 1.
Returns ​
bigint
hashes ​
Get Signature ​
get hashes(): readonly
Uint8Array<ArrayBufferLike>[]
Defined in: smt-proof.ts:55
Sibling hashes at converge points, ordered leaf-to-root.
Returns ​
readonly Uint8Array<ArrayBufferLike>[]
Methods ​
isValid() ​
isValid(
index,candidateHash,rootHash):boolean
Defined in: smt-proof.ts:65
Verify this proof for a single leaf.
Parameters ​
index ​
bigint
Leaf index in the 256-bit key space.
candidateHash ​
Uint8Array
Expected leaf hash.
rootHash ​
Uint8Array
Expected root hash.
Returns ​
boolean
true if the proof is valid.
toBinary() ​
toBinary():
Uint8Array
Defined in: smt-proof.ts:155
Export to compact binary format.
Layout: [convergeZeroCount : 1] [truncatedConverge : 32-zc] [hashCount : 1] [hashes : N*32]
Returns ​
Uint8Array
toJSON() ​
toJSON(
base64?,compact?):string
Defined in: smt-proof.ts:124
Export to JSON.
Parameters ​
base64? ​
boolean = false
Use base64 encoding instead of hex (default: false).
compact? ​
boolean = true
Omit whitespace (default: true).
Returns ​
string
fromBinary() ​
staticfromBinary(source):Promise<SMTProof>
Defined in: smt-proof.ts:180
Import from compact binary format. Accepts any sync or async byte iterable (e.g. Uint8Array, ReadableStream).
Parameters ​
source ​
Iterable<number, any, any> | AsyncIterable<number, any, any>
Returns ​
Promise<SMTProof>
fromJSON() ​
staticfromJSON(json,base64?):SMTProof
Defined in: smt-proof.ts:138
Import from JSON.
Parameters ​
json ​
string
JSON string.
base64? ​
boolean = false
Parse base64 instead of hex (default: false).
Returns ​
SMTProof
isValidBatch() ​
staticisValidBatch<TAdditional>(candidates,rootHash):Generator<SMTProofResult<TAdditional>>
Defined in: smt-proof.ts:77
Batch-validate multiple proofs against the same root hash.
Caches intermediate (partial) proofs so that subsequent candidates sharing an ancestor path can short-circuit once a cached match is found.
Type Parameters ​
TAdditional ​
TAdditional = unknown
Parameters ​
candidates ​
Iterable<SMTProofCandidate<TAdditional>>
rootHash ​
Uint8Array
Returns ​
Generator<SMTProofResult<TAdditional>>
Yields ​
One SMTProofResult per candidate.