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:
SnarkProof
objects for verification bysnarkjs
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
BaseProof
Constructors
constructor
• new BaseProof(publicSignals
, proof
, prover?
)
Create a new instance of the class.
Parameters
Name | Type | Description |
---|---|---|
publicSignals | (string | bigint )[] | The public signals of the proof that can be verified by the prover |
proof | Groth16Proof | (string | bigint )[] | The proof that can be verified by the prover |
prover? | Prover | The 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
Properties
_snarkProof
• Readonly
_snarkProof: Groth16Proof
The proof data in Groth16Proof
format. Use this when manually verifying with snarkjs
.
Defined in
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
proof
• proof: bigint
[]
The proof data formatted as string[]
. Use this property when interacting with smart contracts.
Defined in
prover
• Optional
prover: Prover
The Prover
object.
Defined in
publicSignals
• Readonly
publicSignals: bigint
[]
The raw array of public signals for the proof.
Defined in
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()