Skip to main content

MerkleMap

o1js / Modules / MerkleMap

Class: MerkleMap

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new MerkleMap()

Creates a new, empty Merkle Map.

Defined in

lib/merkle-map.ts:19

Properties

tree

tree: MerkleTree

Defined in

lib/merkle-map.ts:11

Methods

_keyToIndex

_keyToIndex(key): bigint

Parameters

NameType
keyField

Returns

bigint

Defined in

lib/merkle-map.ts:34


get

get(key): Field

Returns a value given a key. Values are by default Field(0).

Parameters

NameTypeDescription
keyFieldThe key to get the value from.

Returns

Field

The value stored at the key.

Defined in

lib/merkle-map.ts:70


getRoot

getRoot(): Field

Returns the root of the Merkle Map.

Returns

Field

The root of the Merkle Map.

Defined in

lib/merkle-map.ts:81


getWitness

getWitness(key): MerkleMapWitness

Returns a circuit-compatible witness (also known as Merkle Proof or Merkle Witness) for the given key.

Parameters

NameTypeDescription
keyFieldThe key to make a witness for.

Returns

MerkleMapWitness

A MerkleMapWitness, which can be used to assert changes to the MerkleMap, and the witness's key.

Defined in

lib/merkle-map.ts:90


set

set(key, value): void

Sets a key of the merkle map to a given value.

Parameters

NameTypeDescription
keyFieldThe key to set in the map.
valueField-

Returns

void

Defined in

lib/merkle-map.ts:58