Skip to main content
Version: 2.1.x

Class: BaseProof

src.BaseProof

We build proofs using a BaseProof class that optionally supports verification. Proof data can be expressed in one of two formats:

  1. SnarkProof objects for verification by snarkjs
  2. string[] for contract verification.

The BaseProof class can be used to convert between the two formats. This class should not be used directly, but should instead be inherited.

The base class for a proof that can be verified using a Prover.

Hierarchy

Constructors

constructor

new BaseProof(publicSignals, proof, prover?)

Create a new instance of the class.

Parameters

NameTypeDescription
publicSignals(string | bigint)[]The public signals of the proof that can be verified by the prover
proofGroth16Proof | (string | bigint)[]The proof that can be verified by the prover
prover?ProverThe prover that can verify the public signals and the proof

Example

import { BaseProof } from '@unirep/circuits'

class MyCustomProof extends BaseProof {
constructor(publicSignals, proof, prover) {
super(publicSignals, proof, prover)

// Specify a circuit name for the Prover
// This is typically a filename
this.circuit = 'MyCustomProof'
}
}

Defined in

circuits/src/BaseProof.ts:63

Properties

_snarkProof

Readonly _snarkProof: Groth16Proof

The proof data in Groth16Proof format. Use this when manually verifying with snarkjs.

Defined in

circuits/src/BaseProof.ts:24


circuit

Protected Optional circuit: Circuit

The string name of the type of circuit this proof came from. For the BaseProof class this is undefined.

Defined in

circuits/src/BaseProof.ts:28


proof

proof: bigint[]

The proof data formatted as string[]. Use this property when interacting with smart contracts.

Defined in

circuits/src/BaseProof.ts:37


prover

Optional prover: Prover

The Prover object.

Defined in

circuits/src/BaseProof.ts:41


publicSignals

Readonly publicSignals: bigint[]

The raw array of public signals for the proof.

Defined in

circuits/src/BaseProof.ts:33

Methods

verify

verify(): Promise<boolean>

A function to verify the proof with the supplied Prover. The prover property must be set either in the constructor or manually, otherwise this will throw.

Returns

Promise<boolean>

True if the proof is valid, false otherwise

Example

const isValid: boolean = await proof.verify()

Defined in

circuits/src/BaseProof.ts:95