import { ProvablePure, Pickles } from '../snarky.js'; import { Bool } from './core.js'; import { FlexibleProvable, FlexibleProvablePure, InferProvable, ProvablePureExtended } from './circuit_value.js'; import { Provable } from './provable.js'; export { Proof, SelfProof, JsonProof, ZkProgram, verify, Empty, Undefined, Void, }; export { CompiledTag, sortMethodArguments, getPreviousProofsForProver, MethodInterface, GenericArgument, picklesRuleFromFunction, compileProgram, analyzeMethod, emptyValue, emptyWitness, synthesizeMethodArguments, methodArgumentsToConstant, methodArgumentTypesAndValues, isAsFields, Prover, dummyBase64Proof, }; type Undefined = undefined; declare const Undefined: ProvablePureExtended; type Empty = Undefined; declare const Empty: ProvablePureExtended; type Void = undefined; declare const Void: ProvablePureExtended; declare class Proof { static publicInputType: FlexibleProvablePure; static publicOutputType: FlexibleProvablePure; static tag: () => { name: string; }; publicInput: Input; publicOutput: Output; proof: Pickles.Proof; maxProofsVerified: 0 | 1 | 2; shouldVerify: import("./bool.js").Bool; verify(): void; verifyIf(condition: Bool): void; toJSON(): JsonProof; static fromJSON>(this: S, { maxProofsVerified, proof: proofString, publicInput: publicInputJson, publicOutput: publicOutputJson, }: JsonProof): Proof, InferProvable>; constructor({ proof, publicInput, publicOutput, maxProofsVerified, }: { proof: Pickles.Proof; publicInput: Input; publicOutput: Output; maxProofsVerified: 0 | 1 | 2; }); } declare function verify(proof: Proof | JsonProof, verificationKey: string): Promise; type JsonProof = { publicInput: string[]; publicOutput: string[]; maxProofsVerified: 0 | 1 | 2; proof: string; }; type CompiledTag = unknown; declare let CompiledTag: { get(tag: any): CompiledTag | undefined; store(tag: any, compiledTag: CompiledTag): void; }; declare function ZkProgram; publicOutput?: FlexibleProvablePure; }, Types extends { [I in string]: Tuple; }>(config: StatementType & { methods: { [I in keyof Types]: Method>, InferProvableOrVoid>, Types[I]>; }; }): { name: string; compile: () => Promise<{ verificationKey: string; }>; verify: (proof: Proof>, InferProvableOrVoid>>) => Promise; digest: () => string; analyzeMethods: () => ReturnType[]; publicInputType: ProvableOrUndefined>; publicOutputType: ProvableOrVoid>; } & { [I in keyof Types]: Prover>, InferProvableOrVoid>, Types[I]>; }; declare namespace ZkProgram { var Proof: , PublicOutputType extends FlexibleProvablePure>(program: { name: string; publicInputType: PublicInputType; publicOutputType: PublicOutputType; }) => { new ({ proof, publicInput, publicOutput, maxProofsVerified, }: { proof: unknown; publicInput: InferProvable; publicOutput: InferProvable; maxProofsVerified: 0 | 2 | 1; }): { publicInput: InferProvable; publicOutput: InferProvable; proof: unknown; maxProofsVerified: 0 | 2 | 1; shouldVerify: import("./bool.js").Bool; verify(): void; verifyIf(condition: import("./bool.js").Bool): void; toJSON(): JsonProof; }; publicInputType: PublicInputType; publicOutputType: PublicOutputType; tag: () => { name: string; publicInputType: PublicInputType; publicOutputType: PublicOutputType; }; fromJSON>(this: S, { maxProofsVerified, proof: proofString, publicInput: publicInputJson, publicOutput: publicOutputJson, }: JsonProof): Proof, InferProvable>; }; } declare class SelfProof extends Proof { } declare function sortMethodArguments(programName: string, methodName: string, privateInputs: unknown[], selfProof: Subclass): MethodInterface; declare function isAsFields(type: unknown): type is Provable & ObjectConstructor; declare class GenericArgument { isEmpty: boolean; constructor(isEmpty?: boolean); } declare function getPreviousProofsForProver(methodArgs: any[], { allArgs }: MethodInterface): unknown[]; type MethodInterface = { methodName: string; witnessArgs: Provable[]; proofArgs: Subclass[]; genericArgs: Subclass[]; allArgs: { type: 'witness' | 'proof' | 'generic'; index: number; }[]; returnType?: Provable; }; declare function compileProgram(publicInputType: ProvablePure, publicOutputType: ProvablePure, methodIntfs: MethodInterface[], methods: ((...args: any) => void)[], proofSystemTag: { name: string; }): Promise<{ verificationKey: { data: string; hash: import("./field.js").Field; }; provers: Pickles.Prover[]; verify: (statement: Pickles.Statement, proof: Pickles.Proof) => Promise; tag: unknown; }>; declare function analyzeMethod(publicInputType: ProvablePure, methodIntf: MethodInterface, method: (...args: any) => T): { rows: number; digest: string; result: T; gates: import("../snarky.js").Gate[]; publicInputSize: number; }; declare function picklesRuleFromFunction(publicInputType: ProvablePure, publicOutputType: ProvablePure, func: (...args: unknown[]) => any, proofSystemTag: { name: string; }, { methodName, witnessArgs, proofArgs, allArgs }: MethodInterface): Pickles.Rule; declare function synthesizeMethodArguments({ allArgs, proofArgs, witnessArgs }: MethodInterface, asVariables?: boolean): unknown[]; declare function methodArgumentsToConstant({ allArgs, proofArgs, witnessArgs }: MethodInterface, args: any[]): any[]; type TypeAndValue = { type: Provable; value: T; }; declare function methodArgumentTypesAndValues({ allArgs, proofArgs, witnessArgs }: MethodInterface, args: unknown[]): TypeAndValue[]; declare function emptyValue(type: FlexibleProvable): T; declare function emptyWitness(type: FlexibleProvable): T; declare function dummyBase64Proof(): Promise; declare function Prover(): { run(witnesses: unknown[], proverData: ProverData, callback: () => Promise): Promise; getData(): ProverData; }; type Infer = T extends Subclass ? InstanceType : InferProvable; type Tuple = [T, ...T[]] | []; type TupleToInstances = { [I in keyof T]: Infer; } & any[]; type Subclass any> = (new (...args: any) => InstanceType) & { [K in keyof Class]: Class[K]; } & { prototype: InstanceType; }; type PrivateInput = Provable | Subclass; type Method> = PublicInput extends undefined ? { privateInputs: Args; method(...args: TupleToInstances): PublicOutput; } : { privateInputs: Args; method(publicInput: PublicInput, ...args: TupleToInstances): PublicOutput; }; type Prover> = PublicInput extends undefined ? (...args: TupleToInstances) => Promise> : (publicInput: PublicInput, ...args: TupleToInstances) => Promise>; type ProvableOrUndefined = A extends undefined ? typeof Undefined : A; type ProvableOrVoid = A extends undefined ? typeof Void : A; type InferProvableOrUndefined = A extends undefined ? undefined : InferProvable; type InferProvableOrVoid = A extends undefined ? void : InferProvable; /** * helper to get property type from an object, in place of `T[Key]` * * assume `T extends { Key?: Something }`. * if we use `Get` instead of `T[Key]`, we allow `T` to be inferred _without_ the `Key` key, * and thus retain the precise type of `T` during inference */ type Get = T extends { [K in Key]: infer Value; } ? Value : undefined;