Utility functions for the ProtoPODGPC family of circuits.

This can be factored out and generalized if/when there are multiple families and we're clear on what's common between them.

Constructors

Properties

ARTIFACTS_NPM_PACKAGE_NAME: string = ARTIFACTS_NPM_PACKAGE_NAME

Name of the package on NPM which contains published artifacts for this GPC family.

ARTIFACTS_NPM_VERSION: string = ARTIFACTS_NPM_VERSION

Version of the published artifacts on NPM which are compatible with this version of the GPC circuits.

CIRCUIT_FAMILY: ProtoPODGPCCircuitDesc[] = ...

List of pre-compiled circuits, sorted in order of increasing cost. These should match the declarations in circuits.json for circomkit, and each should correspond to an available set of precompiled artifacts.

CIRCUIT_PARAMETERS: [ProtoPODGPCCircuitParams, number][] = ...

Circuit parameters pulled from circuitParameters.json in the form of pairs consisting of the circuit parameters and the cost of the circuit in constraints.

Methods

  • Derives circuit descriptions from circuit parameters.

    Parameters

    • circuitParams: [ProtoPODGPCCircuitParams, number][]

      an array of pairs of circuit parameters and circuit sizes (constraint counts).

    Returns ProtoPODGPCCircuitDesc[]

    an array of the corresponding circuit descriptions arranged in order of increasing circuit size.

  • Checks whether a described circuit can meet a required set of parameters. This will be true if each of the circuit's parameters is greater than or equal to the required value.

    Parameters

    Returns boolean

    true if the circuit meets the requirements.

  • Generates a circuit name based on parameters.

    Parameters

    Returns string

  • Finds the description of a circuit in this family by name.

    Parameters

    • familyName: string

      the circuit family name

    • circuitName: string

      the name of the circuit

    • Optional circuitFamily: ProtoPODGPCCircuitDesc[] = ProtoPODGPC.CIRCUIT_FAMILY

      the circuit family to search

    Returns undefined | ProtoPODGPCCircuitDesc

    the circuit description, or undefined if the name is unrecognized.

  • Creates a set of public signals for verification, given public inputs and outputs of a circuit.

    Some values are replaced with their 0-residues modulo BABY_JUB_PRIME to agree with the values returned by the Groth16 prover, which are always normalised this way.

    Returns bigint[]

  • Extract named outputs from the public circuit signals.

    Because of the flattened array representation of the public signals, the circuit's maxEntries and includeOwner parameters must be known to properly reconstruct output arrays.

    Parameters

    • publicSignals: bigint[]
    • maxEntries: number
    • maxVirtualEntries: number
    • includeOwnerV3: boolean
    • includeOwnerV4: boolean

    Returns ProtoPODGPCOutputs

  • Picks the smallest available circuit in this family which can handle the size parameters of a desired configuration.

    Parameters

    • requiredParameters: ProtoPODGPCCircuitParams

      a lower bound on the parameters required

    • Optional circuitFamily: ProtoPODGPCCircuitDesc[] = ProtoPODGPC.CIRCUIT_FAMILY

      the circuit family to pick the circuit from. This must be sorted in order of increasing circuit size (constraint count).

    Returns undefined | ProtoPODGPCCircuitDesc

    the circuit description, or undefined if no circuit can handle the required parameters.

  • Generate a Groth16 proof for a circuit in this family.

    Parameters

    Returns Promise<{
        outputs: ProtoPODGPCOutputs;
        proof: Groth16Proof;
        publicSignals: bigint[];
    }>

    Groth16 proof, circuit outputs, and full set of public signals (primarily for verification in tests).

  • Verify a proof for a circuit in this library.

    Parameters

    Returns Promise<boolean>

    true if the proof is valid

Generated using TypeDoc