Private
constructorOptional
merkleTree: LeanIMT<bigint>Private
_mapPrivate
Optional
_merkleThe content ID (root hash) of this POD.
Private
merkleThe depth of the Merkle tree representation of this POD. The proofs generated by this POD will be no longer than this, but may be shorter due to the optimizations of the Lean-IMT datastructure (see @zk-kit/imt).
The number of entries in this POD.
Private
_getthe contents of this POD as a PODEntries object. Mutating
this object will not change this PODContent
instance.
Generates all necessary info about a single POD entry needed to populate a proof circuit. This includes a membership proof, as well name hash, value hash, and optionally the value itself. Note that name strings never appear in circuits directly. Values only appear in circuits if they are numeric values which fit in a single circuit signal.
the entry name to look up
an object containing info for circuit inputs
if the entry name is not found
Creates a new proof of membership for an entry by the given name.
the entry name to look up
a membership proof for the given entry
if the entry name is not found
Gets an entry value by name, without its type tag. Mutating the returned
value will not change this PODContent
instance.
the entry name to look up
the value, or undefined if there is no value by that name
Converts the entries to a JSON-compatible format which can be safely
serialized using JSON.stringify
without any loss of information. To
reconstitute a PODContent object from JSON, see fromJSON.
a JSON-compatible representation of this POD.
Static
deserializeDeserializes POD entries from JSON.
a string previously created by #serialize.
a new PODContent instance
if the string isn't valid JSON, or represents entries which aren't legal for inclusion in a POD
Static
fromFactory for creating a new POD from entries. The entries do not need
to be in sorted order, but will be sorted in the resulting PODContent
.
the POD entries to include
a new PODContent
if any of the entries aren't legal for inclusion in a POD
Static
fromJSONRebuilds a PODContent object from entries in the JSON-compatible format
produced by toJSON. The input can be taken directly from
JSON.parse
and will be fully validated by this function.
the JSON-encoded entries.
a new POD object
if the input is malformed
Static
verifyChecks the validity of a POD membership proof by recomputing hashes.
Validity depends only on the name hash and value hash included in the membership proof. This method doesn't check (and has no access to) the hash pre-image name or value.
the membership proof of a POD entry
true
if the proof is valid.
Generated using TypeDoc
Class encapsulating an unsigned POD with functions for common use cases. PODContent instances are immutable (within the limits of TypeScript), but derived data (such as the Merkle tree of entries) is calculated lazily as it is needed.
A POD is made up of
PODEntries
, built into a Merkle tree (in sorted order) to produce a root hash called the Content ID, which is then signed. To create a POD, use one of the static factory methods of this class.PODContent
instances are usually contained in a signedPOD
instance.