VB accumulator that supports both membership proofs and non-membership proofs. For guarding against forgery of non-membership proofs (details in the paper), during initialization, it should generate several accumulator members and never remove them from accumulator, nor it should allow duplicates of them to be added. Thus, several methods accept an optional persistent database IInitialElementsStore which stores those initial elements.

Hierarchy (view full)

Constructors

Properties

params: undefined | AccumulatorParams
secretKey: undefined | AccumulatorSecretKey
value: {
    f_V: Uint8Array;
    maxSize: number;
    V: Uint8Array;
}

f_V is supposed to kept private by the accumulator manager. V is the accumulated value.

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.

    • OptionalinitialElementsStore: IInitialElementsStore

      if provided, check that the element is not part of the initial elements, throws error if it is.

    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.

    • OptionalinitialElementsStore: IInitialElementsStore

    Returns Promise<void>

  • Throws an error if the element is part of the initial elements given that the initial element store is provided

    Parameters

    Returns Promise<void>

  • Throws an error if any element of the batch is part of the initial elements given that the initial element store is provided

    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.

    • OptionalinitialElementsStore: IInitialElementsStore

      if provided, check that the element is not part of the initial elements, throws error if it is.

    Returns Promise<void>

  • Parameters

    • nonMembers: Uint8Array[]
    • members: Uint8Array[]

    Returns Uint8Array[]

  • Parameters

    • nonMember: Uint8Array
    • members: Uint8Array[]

    Returns Uint8Array

  • 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

  • The first few members of a universal accumulator are fixed for each curve. These should be added to the curve before creating any witness and must never be removed.

    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

  • Initialize a universal accumulator of the given maxSize. The function takes time proportional to maxSize as it generates about the same number of elements as the maxSize and takes their product in the end. These "initial elements" should not be added or removed from the accumulator.

    Parameters

    • maxSize: number

      Maximum members the accumulator can have at any instant.

    • params: AccumulatorParams
    • secretKey: AccumulatorSecretKey
    • OptionalinitialElementsStore: IInitialElementsStore

      Optional, stores "initial elements" generated during initialization.

    • batchSize: number = 100

      Breaks down this large computation in batches of size batchSize.

    Returns Promise<UniversalAccumulator>