SelfProof
Defined in: lib/proof-system/zkprogram.ts:612
A class representing the type of Proof produced by the ZkProgram in which it is used.
Example
const ExampleProgram = ZkProgram({
name: 'ExampleProgram',
publicOutput: Field,
methods: {
baseCase: {
privateInputs: [],
method: async () => {
return { publicOutput: Field(0) }
}
},
add: {
privateInputs: [SelfProof, Field],
// `previous` is the type of proof produced by ExampleProgram
method: async (previous: SelfProof<undefined, Field>, f: Field) => {
previous.verify();
return { publicOutput: previous.publicOutput.add(f) }
}
}
}
});
Extends
Proof<PublicInput,PublicOutput>
Type Parameters
• PublicInput
• PublicOutput
Constructors
new SelfProof()
new SelfProof<PublicInput, PublicOutput>(__namedParameters: {
maxProofsVerified: 0 | 1 | 2;
proof: unknown;
publicInput: PublicInput;
publicOutput: PublicOutput;
}): SelfProof<PublicInput, PublicOutput>
Defined in: lib/proof-system/proof.ts:71
Parameters
__namedParameters
maxProofsVerified
0 | 1 | 2
proof
unknown
publicInput
PublicInput
publicOutput
PublicOutput
Returns
SelfProof<PublicInput, PublicOutput>
Inherited from
Properties
maxProofsVerified
maxProofsVerified: 0 | 1 | 2;
Defined in: lib/proof-system/proof.ts:37
Inherited from
proof
proof: unknown;
Defined in: lib/proof-system/proof.ts:36
Inherited from
publicInput
publicInput: PublicInput;
Defined in: lib/proof-system/proof.ts:34
Inherited from
publicOutput
publicOutput: PublicOutput;
Defined in: lib/proof-system/proof.ts:35
Inherited from
shouldVerify
shouldVerify: Bool;
Defined in: lib/proof-system/proof.ts:38
Inherited from
publicInputType
static publicInputType: FlexibleProvable<any>;
Defined in: lib/proof-system/proof.ts:26
Inherited from
publicOutputType
static publicOutputType: FlexibleProvable<any>;
Defined in: lib/proof-system/proof.ts:27
Inherited from
tag()
static tag: () => {
name: string;
};
Defined in: lib/proof-system/proof.ts:28
Returns
{
name: string;
}
name
name: string;
Inherited from
Accessors
provable
Get Signature
get static provable(): ProvableProof<Proof<any, any>, any, any>
Defined in: lib/proof-system/proof.ts:184
Returns
ProvableProof<Proof<any, any>, any, any>
Inherited from
Methods
declare()
declare(): boolean
Defined in: lib/proof-system/proof.ts:54
To verify a recursive proof inside a ZkProgram method, it has to be "declared" as part of
the method. This is done by calling declare() on the proof.
Note: declare() is a low-level method that most users will not have to call directly.
For proofs that are inputs to the ZkProgram, it is done automatically.
You can think of declaring a proof as a similar step as witnessing a variable, which introduces that variable to the circuit. Declaring a proof will tell Pickles to add the additional constraints for recursive proof verification.
Similar to Provable.witness(), declare() is a no-op when run outside ZkProgram compilation or proving.
It returns false in that case, and true if the proof was actually declared.
Returns
boolean
Inherited from
publicFields()
publicFields(): {
input: Field[];
output: Field[];
}
Defined in: lib/proof-system/proof.ts:111
Returns
{
input: Field[];
output: Field[];
}
input
input: Field[];
output
output: Field[];
Inherited from
toJSON()
toJSON(): JsonProof
Defined in: lib/proof-system/proof.ts:61
Returns
Inherited from
verify()
verify(): void
Defined in: lib/proof-system/proof.ts:126
Returns
void
Inherited from
verifyIf()
verifyIf(condition: Bool): void
Defined in: lib/proof-system/proof.ts:129
Parameters
condition
Returns
void
Inherited from
_proofFromBase64()
static _proofFromBase64(proofString: string, maxProofsVerified: 0 | 1 | 2): unknown
Defined in: lib/proof-system/proof.ts:115
Parameters
proofString
string
maxProofsVerified
0 | 1 | 2
Returns
unknown
Inherited from
_proofToBase64()
static _proofToBase64(proof: unknown, maxProofsVerified: 0 | 1 | 2): string
Defined in: lib/proof-system/proof.ts:119
Parameters
proof
unknown
maxProofsVerified
0 | 1 | 2
Returns
string
Inherited from
dummy()
static dummy<Input, OutPut>(
publicInput: Input,
publicOutput: OutPut,
maxProofsVerified: 0 | 1 | 2,
domainLog2: number): Promise<Proof<Input, OutPut>>
Defined in: lib/proof-system/proof.ts:169
Dummy proof. This can be useful for ZkPrograms that handle the base case in the same method as the inductive case, using a pattern like this:
method(proof: SelfProof<I, O>, isRecursive: Bool) {
proof.verifyIf(isRecursive);
// ...
}
To use such a method in the base case, you need a dummy proof:
let dummy = await MyProof.dummy(publicInput, publicOutput, 1);
await myProgram.myMethod(dummy, Bool(false));
Note: The types of publicInput and publicOutput, as well as the maxProofsVerified parameter,
must match your ZkProgram. maxProofsVerified is the maximum number of proofs that any of your methods take as arguments.
Type Parameters
• Input
• OutPut
Parameters
publicInput
Input
publicOutput
OutPut
maxProofsVerified
0 | 1 | 2
domainLog2
number = 14
Returns
Promise<Proof<Input, OutPut>>
Inherited from
fromJSON()
static fromJSON<S>(this: S, __namedParameters: JsonProof): Promise<Proof<InferProvable<S["publicInputType"]>, InferProvable<S["publicOutputType"]>>>
Defined in: lib/proof-system/proof.ts:133
Type Parameters
• S extends Subclass<typeof Proof>
Parameters
this
S
__namedParameters
Returns
Promise<Proof<InferProvable<S["publicInputType"]>, InferProvable<S["publicOutputType"]>>>
Inherited from
publicFields()
static publicFields(value: ProofBase): {
input: Field[];
output: Field[];
}
Defined in: lib/proof-system/proof.ts:103
Parameters
value
Returns
{
input: Field[];
output: Field[];
}
input
input: Field[];
output
output: Field[];