Prover class for zero-knowledge proof systems using SNARKJS and CIRCOM circuits.

Hierarchy

  • Prover

Constructors

  • Constructs a new Prover instance.

    Parameters

    • idl: Idl

      The Interface Description Language (IDL) for the proof system, as generated by ANCHOR framework. Used to retrieve a parsed account struct to read an object of a circuit proof inputs.

    • firstPath: string

      The initial path used for building paths to circuit-related files i.e. wasm and zkey files.

    Returns Prover

Properties

circuitName: string
firstPath: string
idl: Idl
proof: proofData
proofInputs: any
publicInputs: string[] = []
vKey: vKeyData
wasmPath: string
zkeyPath: string

Methods

  • Adds proof inputs after reading and parsing the circuit's proof inputs struct from the idl.

    Throws

    Will throw an error if the circuit's proof inputs structure does not exist in the IDL, or if any of the required proof inputs is missing.

    Parameters

    • proofInputs: any

      An object containing the proof inputs to be added. The keys of this object should correspond to the field names in the zk-SNARK circuit's proof inputs structure in the IDL, and the values should be the corresponding proof inputs.

    Returns Promise<void>

  • Generate a zk-SNARK proof & publicSignals using the Groth16 proving scheme.

    Returns Promise<void>

  • Performs a full proof generation and parsing process.

    Returns Promise<{
        parsedProof: {
            proofA: number[];
            proofB: number[][];
            proofC: number[];
        };
        parsedPublicInputs: number[][];
    }>

    An object containing the parsed proof and parsed public inputs.

  • Get exported verification key from the zkey file that will be used later for proof verification

    Returns Promise<void>

  • Parses a proof to a bytes array that will be used for zk proof verification for the groth16-solana crate.

    Parameters

    Returns {
        proofA: number[];
        proofB: number[][];
        proofC: number[];
    }

    An object containing the parsed proof.

    • proofA: number[]
    • proofB: number[][]
    • proofC: number[]
  • Throws

    Will throw an error if the public input array is undefined, or if the number of public inputs does not match the expected number.

    Parameters

    • publicInputsBytes: number[][]

      A two-dimensional array of numbers representing the public inputs for a zk-SNARK, where each inner array is a byte array of a public input value.

    Returns any

    An object where each key is the name of a public input, and each value is the parsed public input value. The shape and structure of the values depend on the specific zk-SNARK circuit.

  • Parses public signals to a bytes array.

    Parameters

    • publicSignals: string[]

      The public signals to be parsed.

    Returns number[][]

    An array of n public inputs parsed into a number array and pushed according to the same order of the input.

  • Verifies the proof generated by this class or a passed in proof.

    Parameters

    • Optional proof: proofData

      The optional proof to be verified. If not provided, the proof generated by this class is verified.

    Returns Promise<boolean>

    A promise that resolves to a boolean indicating whether the proof is valid.

Generated using TypeDoc