ZkProgram
type ZkProgram<Config> = ReturnType<typeof ZkProgram>;
Defined in: lib/proof-system/zkprogram.ts:237
Wraps config + provable code into a program capable of producing Proofs.
Type Parameters
Config
Config extends {
methods: { [I in string]: { auxiliaryOutput?: ProvableType; privateInputs: Tuple<PrivateInput> } };
publicInput?: ProvableType;
publicOutput?: ProvableType;
}
Example
const ExampleProgram = ZkProgram({
name: 'ExampleProgram',
publicOutput: Int64,
methods: {
// Prove that I know 2 numbers less than 100 each, whose product is greater than 1000
provableMultiply: {
privateInputs: [Int64, Int64],
method: async (n1: Int64, n2: Int64) => {
n1.assertLessThan(100);
n2.assertLessThan(100);
const publicOutput = n1.mul(n2);
publicOutput.assertGreaterThan(1000);
return { publicOutput: n1.mul(n2) }
}
}
}
});
Param
The configuration of the program, describing the type of the public input and public output, as well as defining the methods which can be executed provably.
Param
Optional number of chunks to split each method's circuit into. Use a
value greater than 1 (1 < numChunks <= 4) if a method exceeds the single-circuit row limit
of 2^16; default is 1. Up to 8 chunks are supported if the degree of the constraints of the
underlying circuit is low enough (e.g. generic gates) so the wrap domain can still be 2.
Param
Optional override for the wrap circuit domain (0 | 1 | 2). Defaults to a value derived from the maximum proofs verified; set only if you need to force a specific domain for chunking. In general, uses 0 if no chunking, 1 for 2 chunks, and 2 for 4 chunks. When otherwise needed, the logs guide you through the right choice. If the constraints are simple enough (e.g. generic gates), 8 chunks may also use domain 2.
Returns
an object that can be used to compile, prove, and verify the program.