ZkProgram
function ZkProgram<Config, _>(config: Config & {
methods: { [I in string | number | symbol]: InferMethodType<Config>[I] };
name: string;
numChunks?: number;
overrideWrapDomain?: 0 | 2 | 1;
}): {
analyzeMethods: () => Promise<{ [I in string | number | symbol]: MethodAnalysis }>;
auxiliaryOutputTypes: InferAuxiliaryOutputs<Config>;
compile: (options?: {
cache?: Cache;
forceRecompile?: boolean;
lazyMode?: boolean;
numChunks?: number;
proofsEnabled?: boolean;
withRuntimeTables?: boolean;
}) => Promise<{
verificationKey: {
data: string;
hash: Field;
};
}>;
digest: () => Promise<string>;
name: string;
privateInputTypes: InferPrivateInput<Config>;
Proof: typeof Proof;
proofsEnabled: boolean;
publicInputType: ProvableOrUndefined<Get<Config, "publicInput">>;
publicOutputType: ProvableOrVoid<Get<Config, "publicOutput">>;
rawMethods: { [I in string | number | symbol]: InferMethodType<Config>[I]["method"] };
verify: (proof: Proof<InferProvableOrUndefined<Get<Config, "publicInput">>, InferProvableOrVoid<Get<Config, "publicOutput">>>) => Promise<boolean>;
analyzeSingleMethod: Promise<MethodAnalysis>;
maxProofsVerified: Promise<0 | 1 | 2>;
setProofsEnabled: void;
} & { [I in string | number | symbol]: Prover<InferProvableOrUndefined<Get<Config, "publicInput">>, ProvableOrUndefined<Get<Config, "publicInput">>, InferProvableOrVoid<Get<Config, "publicOutput">>, InferPrivateInput<Config>[I], InferProvableOrUndefined<InferAuxiliaryOutputs<Config>[I]>> };
Defined in: lib/proof-system/zkprogram.ts:226
Wraps config + provable code into a program capable of producing Proofs.
Type Parameters
Config
Config
extends ConfigBaseType
_
_
extends unknown
= unknown
Parameters
config
Config
& {
methods
: { [I in string | number | symbol]: InferMethodType<Config>[I] };
name
: string
;
numChunks?
: number
;
overrideWrapDomain?
: 0
| 2
| 1
;
}
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.
Returns
an object that can be used to compile, prove, and verify the program.
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) }
}
}
}
});