BaseProof
We build proofs using a BaseProof
class that optionally supports verification. Proof data can be expressed in one of two formats:
SnarkProof
objects for verification bysnarkjs
bigint[]
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.
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'
}
}
BaseProof
The base class for a proof that can be verified using a Prover
.
constructor
Create a new instance of the class.
constructor(
publicSignals: bigint[],
proof: SnarkProof | bigint[],
prover?: Prover
)
_snarkProof
The proof data in SnarkProof
format. Use this when manually verifying with snarkjs
.
proof._snarkProof
circuit
The string name of the type of circuit this proof came from. For the BaseProof
class this is undefined.
proof.circuit
publicSignals
The raw array of public signals for the proof.
proof.publicSignals
proof
The proof data formatted as bigint[]
. Use this property when interacting with smart contracts.
proof.proof
verify
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.
proof.verify(): Promise<boolean>