DynamicProof
The DynamicProof
class enables circuits to verify proofs using in-ciruit verfication keys.
This is opposed to the baked-in verification keys of the Proof
class.
In order to use this, a subclass of DynamicProof that specifies the public input and output types along with the maxProofsVerified number has to be created.
export class SideloadedProgramProof extends DynamicProof<MyStruct, Field> {
static publicInputType = MyStruct;
static publicOutputType = Field;
static maxProofsVerified = 0 as const;
}
The maxProofsVerified
constant is a product of the child circuit and indicates the maximum number that that circuit verifies itself.
If you are unsure about what that is for you, you should use 2
.
Any DynamicProof
subclass can be used as private input to ZkPrograms or SmartContracts along with a VerificationKey
input.
proof.verify(verificationKey)
NOTE: In the case of DynamicProof
s, the circuit makes no assertions about the verificationKey used on its own.
This is the responsibility of the application developer and should always implement appropriate checks.
This pattern differs a lot from the usage of normal Proof
, where the verification key is baked into the compiled circuit.
See
src/examples/zkprogram/dynamic-keys-merkletree.ts for an example of how this can be done using merkle trees
Assertions generally only happen using the vk hash that is part of the VerificationKey
struct along with the raw vk data as auxilary data.
When using verify() on a DynamicProof
, Pickles makes sure that the verification key data matches the hash.
Therefore all manual assertions have to be made on the vk's hash and it can be assumed that the vk's data is checked to match the hash if it is used with verify().
Extends
ProofBase
\<Input
,Output
>
Type parameters
• Input
• Output
Constructors
new DynamicProof()
new DynamicProof<Input, Output>(__namedParameters: {
"maxProofsVerified": 0 | 1 | 2;
"proof": unknown;
"publicInput": Input;
"publicOutput": Output;
}): DynamicProof<Input, Output>
Parameters
• __namedParameters
• __namedParameters.maxProofsVerified: 0
| 1
| 2
• __namedParameters.proof: unknown
• __namedParameters.publicInput: Input
• __namedParameters.publicOutput: Output
Returns
DynamicProof
\<Input
, Output
>
Inherited from
Source
lib/proof-system/zkprogram.ts:111
Properties
maxProofsVerified
maxProofsVerified: 0 | 1 | 2;
Inherited from
Source
lib/proof-system/zkprogram.ts:98
proof
proof: unknown;
Inherited from
Source
lib/proof-system/zkprogram.ts:97
publicInput
publicInput: Input;
Inherited from
Source
lib/proof-system/zkprogram.ts:95
publicOutput
publicOutput: Output;
Inherited from
Source
lib/proof-system/zkprogram.ts:96
shouldVerify
shouldVerify: Bool;
Inherited from
Source
lib/proof-system/zkprogram.ts:99
usedVerificationKey?
optional usedVerificationKey: VerificationKey;
Source
lib/proof-system/zkprogram.ts:250
maxProofsVerified
static maxProofsVerified: 0 | 1 | 2;
Source
lib/proof-system/zkprogram.ts:235
publicInputType
static publicInputType: FlexibleProvablePure<any>;
Inherited from
Source
lib/proof-system/zkprogram.ts:87
publicOutputType
static publicOutputType: FlexibleProvablePure<any>;
Inherited from
Source
lib/proof-system/zkprogram.ts:88
Methods
toJSON()
toJSON(): JsonProof
Returns
Inherited from
Source
lib/proof-system/zkprogram.ts:101
verify()
verify(vk: VerificationKey): void
Verifies this DynamicProof using a given verification key
Parameters
• vk: VerificationKey
The verification key this proof will be verified against
Returns
void
Source
lib/proof-system/zkprogram.ts:256
verifyIf()
verifyIf(vk: VerificationKey, condition: Bool): void
Parameters
• vk: VerificationKey
• condition: Bool
Returns
void
Source
lib/proof-system/zkprogram.ts:260
dummy()
static dummy<S>(
this: S,
publicInput: InferProvable<S["publicInputType"]>,
publicOutput: InferProvable<S["publicOutputType"]>,
maxProofsVerified: 0 | 1 | 2,
domainLog2: number): Promise<InstanceType<S>>
Type parameters
• S extends Subclass
\<typeof DynamicProof
>
Parameters
• this: S
• publicInput: InferProvable
\<S
["publicInputType"
]>
• publicOutput: InferProvable
\<S
["publicOutputType"
]>
• maxProofsVerified: 0
| 1
| 2
• domainLog2: number
= 14
Returns
Promise
\<InstanceType
\<S
>>
Source
lib/proof-system/zkprogram.ts:292
fromJSON()
static fromJSON<S>(this: S, __namedParameters: JsonProof): Promise<DynamicProof<InferProvable<S["publicInputType"]>, InferProvable<S["publicOutputType"]>>>
Type parameters
• S extends Subclass
\<typeof DynamicProof
>
Parameters
• this: S
• __namedParameters: JsonProof
Returns
Promise
\<DynamicProof
\<InferProvable
\<S
["publicInputType"
]>, InferProvable
\<S
["publicOutputType"
]>>>
Source
lib/proof-system/zkprogram.ts:265
fromProof()
static fromProof<S>(this: S, proof: Proof<InferProvable<S["publicInputType"]>, InferProvable<S["publicOutputType"]>>): InstanceType<S>
Converts a Proof into a DynamicProof carrying over all relevant data. This method can be used to convert a Proof computed by a ZkProgram into a DynamicProof that is accepted in a circuit that accepts DynamicProofs
Type parameters
• S extends Subclass
\<typeof DynamicProof
>
Parameters
• this: S
• proof: Proof
\<InferProvable
\<S
["publicInputType"
]>, InferProvable
\<S
["publicOutputType"
]>>
Returns
InstanceType
\<S
>
Source
lib/proof-system/zkprogram.ts:312
tag()
static tag(): {
"name": string;
}
Returns
{
"name": string;
}
name
name: string;
Overrides
ProofBase.tag