Class Accumulator<T>Abstract

Interface implemented by both Positive and Universal accumulator. Contains implementations for parameter and key generation. Note:

  • The secret key and params are optional in functions like add, remove, etc. as they can be stored in the accumulator object. If exposure to the secret key needs to be minimized, don't pass it to the constructor but only to functions that need it.
  • Methods to update the accumulator optionally accept a state, i.e. an object implementing IAccumulatorState which should be updated when the new elements are added or old elements are removed from the accumulator. An additional purpose of passing the state object is to check if duplicate elements are not added or already absent elements are not removed or membership witness for absent elements is not created. If checks in the state fail, they throw errors.

Type Parameters

  • T

Hierarchy (view full)

Constructors

Properties

params: undefined | AccumulatorParams
secretKey: undefined | AccumulatorSecretKey
value: object | Uint8Array

Accessors

Methods

  • Add a single element to the accumulator

    Parameters

    • element: Uint8Array

      The element to add.

    • OptionalsecretKey: AccumulatorSecretKey

      If secret key is not provided, its expected to find the secret key on the object.

    • Optionalstate: IAccumulatorState

      If state is provided it is checked before computing the new accumulator and updated with new element after computing the new accumulator. Throws error if element present.

    Returns void

  • Add a batch of elements to the accumulator.

    Parameters

    • elements: Uint8Array[]
    • OptionalsecretKey: AccumulatorSecretKey
    • Optionalstate: IAccumulatorState

      If state is provided it is checked before computing the new accumulator and updated with new elements after computing the new accumulator

    Returns void

  • Protected

    If state is provided, add the batch of elements to the state

    Parameters

    Returns Promise<void>

  • Add and remove batches of elements.

    Parameters

    • additions: Uint8Array[]

      The batch to be added

    • removals: Uint8Array[]

      The batch to be removed.

    • OptionalsecretKey: AccumulatorSecretKey
    • Optionalstate: IAccumulatorState

      If state is provided it is checked before computing the new accumulator and updated by adding and removing given elements after computing the new accumulator.

    Returns void

  • Protected

    Check if element is absent in the state and throws an error if its present. Only checks if the state is passed

    Parameters

    Returns Promise<void>

  • Protected

    Check if a batch of elements is absent in the state and throws an error any of them is present. Only checks if the state is passed

    Parameters

    Returns Promise<void>

  • Protected

    Check if element is present in the state and throws an error if its absent. Only checks if the state is passed

    Parameters

    Returns Promise<void>

  • Protected

    Check if a batch of elements is present in the state and throws an error any of them is absent. Only checks if the state is passed

    Parameters

    Returns Promise<void>

  • Remove a single element from the accumulator

    Parameters

    • element: Uint8Array
    • OptionalsecretKey: AccumulatorSecretKey
    • Optionalstate: IAccumulatorState

      If state is provided it is checked before computing the new accumulator and element is removed from it after computing the new accumulator. Throws error if element is not present.

    Returns void

  • Remove a batch of elements from the accumulator.

    Parameters

    • elements: Uint8Array[]
    • OptionalsecretKey: AccumulatorSecretKey
    • Optionalstate: IAccumulatorState

      If state is provided it is checked before computing the new accumulator and updated by removing those elements after computing the new accumulator

    Returns void

  • Protected

    If state is provided, remove the batch of elements from the state

    Parameters

    Returns Promise<void>

  • Protected

    If state is provided, remove the element from the state

    Parameters

    Returns Promise<void>

  • To add arbitrary bytes like byte representation of UUID or some other user id or something else as an accumulator member, encode it first using this. This is an irreversible encoding as a hash function is used to convert a message of arbitrary length to a fixed length encoding.

    Parameters

    • bytes: Uint8Array

    Returns Uint8Array

  • To add a positive number as an accumulator member, encode it first using this. Encodes a positive safe integer, i.e. of 53 bits

    Parameters

    • num: number

      should be a positive integer

    Returns Uint8Array

  • Generate proving key for proving membership in an accumulator in zero knowledge. Proving key is public data that must be known to both the prover and verifier. Any prover and verifier pair can mutually agree on a proving key and the manager does not need to be aware of any proving key.

    Parameters

    • Optionallabel: Uint8Array

      The bytearray that is hashed to deterministically generate the proving key.

    Returns MembershipProvingKey