Class SparseMerkleProof

Merkle proof CircuitValue for an element in a SparseMerkleTree.

SparseMerkleProof

Hierarchy

  • {
        root: Field;
        sideNodes: Field[];
    }
    • SparseMerkleProof

Constructors

  • Parameters

    • value: {
          root: Field;
          sideNodes: Field[];
      }
      • root: Field
      • sideNodes: Field[]

    Returns SparseMerkleProof

Properties

root: Field = Field
sideNodes: Field[] = ...
_isStruct: true
check: ((value) => void)

Add assertions to the proof to check if value is a valid member of type T. This function does not return anything, instead it creates any number of assertions to prove that value is a valid member of the type T.

For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.

Type declaration

    • (value): void
    • Parameters

      • value: {
            root: Field;
            sideNodes: Field[];
        }

        the element of type T to put assertions on.

        • root: Field
        • sideNodes: Field[]

      Returns void

empty: (() => {
    root: Field;
    sideNodes: Field[];
})

Type declaration

    • (): {
          root: Field;
          sideNodes: Field[];
      }
    • Returns {
          root: Field;
          sideNodes: Field[];
      }

      • root: Field
      • sideNodes: Field[]
fromFields: ((fields) => {
    root: Field;
    sideNodes: Field[];
})

Type declaration

    • (fields): {
          root: Field;
          sideNodes: Field[];
      }
    • Parameters

      • fields: Field[]

      Returns {
          root: Field;
          sideNodes: Field[];
      }

      • root: Field
      • sideNodes: Field[]
fromJSON: ((x) => {
    root: Field;
    sideNodes: Field[];
})

Type declaration

    • (x): {
          root: Field;
          sideNodes: Field[];
      }
    • Parameters

      • x: {
            root: string;
            sideNodes: string[];
        }
        • root: string
        • sideNodes: string[]

      Returns {
          root: Field;
          sideNodes: Field[];
      }

      • root: Field
      • sideNodes: Field[]
fromValue: ((x) => {
    root: Field;
    sideNodes: Field[];
}) & ((value) => {
    root: Field;
    sideNodes: Field[];
})

Convert provable type from a normal JS type.

Type declaration

    • (x): {
          root: Field;
          sideNodes: Field[];
      }
    • Parameters

      • x: {
            root: Field;
            sideNodes: Field[];
        } | {
            root: bigint;
            sideNodes: bigint[];
        }

      Returns {
          root: Field;
          sideNodes: Field[];
      }

      • root: Field
      • sideNodes: Field[]

Type declaration

    • (value): {
          root: Field;
          sideNodes: Field[];
      }
    • Parameters

      • value: {
            root: string | number | bigint | Field;
            sideNodes: Field[] | bigint[];
        }
        • root: string | number | bigint | Field
        • sideNodes: Field[] | bigint[]

      Returns {
          root: Field;
          sideNodes: Field[];
      }

      • root: Field
      • sideNodes: Field[]
toAuxiliary: ((value?) => any[])

A function that takes value (optional), an element of type T, as argument and returns an array of any type that make up the "auxiliary" (non-provable) data of value.

Type declaration

    • (value?): any[]
    • Parameters

      • Optional value: {
            root: Field;
            sideNodes: Field[];
        }

        the element of type T to generate the auxiliary data array from, optional. If not provided, a default value for auxiliary data is returned.

        • root: Field
        • sideNodes: Field[]

      Returns any[]

Returns

An array of any type describing how this T element is made up of "auxiliary" (non-provable) data.

toFields: ((value) => Field[])

A function that takes value, an element of type T, as argument and returns an array of Field elements that make up the provable data of value.

Type declaration

    • (value): Field[]
    • Parameters

      • value: {
            root: Field;
            sideNodes: Field[];
        }

        the element of type T to generate the Field array from.

        • root: Field
        • sideNodes: Field[]

      Returns Field[]

Returns

A Field array describing how this T element is made up of Field elements.

toInput: ((x) => {
    fields?: Field[];
    packed?: [Field, number][];
})

Type declaration

    • (x): {
          fields?: Field[];
          packed?: [Field, number][];
      }
    • Parameters

      • x: {
            root: Field;
            sideNodes: Field[];
        }
        • root: Field
        • sideNodes: Field[]

      Returns {
          fields?: Field[];
          packed?: [Field, number][];
      }

      • Optional fields?: Field[]
      • Optional packed?: [Field, number][]
toJSON: ((x) => {
    root: string;
    sideNodes: string[];
})

Type declaration

    • (x): {
          root: string;
          sideNodes: string[];
      }
    • Parameters

      • x: {
            root: Field;
            sideNodes: Field[];
        }
        • root: Field
        • sideNodes: Field[]

      Returns {
          root: string;
          sideNodes: string[];
      }

      • root: string
      • sideNodes: string[]
toValue: ((x) => {
    root: bigint;
    sideNodes: bigint[];
})

Convert provable type to a normal JS type.

Type declaration

    • (x): {
          root: bigint;
          sideNodes: bigint[];
      }
    • Parameters

      • x: {
            root: Field;
            sideNodes: Field[];
        }
        • root: Field
        • sideNodes: Field[]

      Returns {
          root: bigint;
          sideNodes: bigint[];
      }

      • root: bigint
      • sideNodes: bigint[]

Methods

  • Return the size of the T type in terms of Field type, as Field is the primitive type.

    Returns number

    A number representing the size of the T type in terms of Field type.