1- import { EmptyUndefined , EmptyVoid } from '../../bindings/lib/generic.js' ;
21import {
32 Base64ProofString ,
43 Base64VerificationKeyString ,
4+ Gate ,
5+ Pickles ,
56 Snarky ,
67 initializeBindings ,
78 withThreadPool ,
89} from '../../bindings.js' ;
9- import { Pickles , Gate } from '../../bindings.js' ;
10- import { Field } from '../provable/wrapped.js' ;
11- import { FlexibleProvable , InferProvable , ProvablePureExtended } from '../provable/types/struct.js' ;
12- import { InferProvableType } from '../provable/types/provable-derivers.js' ;
13- import { Provable } from '../provable/provable.js' ;
14- import { assert , prettifyStacktracePromise } from '../util/errors.js' ;
10+ import { setSrsCache , unsetSrsCache } from '../../bindings/crypto/bindings/srs.js' ;
11+ import { prefixes } from '../../bindings/crypto/constants.js' ;
12+ import { prefixToField } from '../../bindings/lib/binable.js' ;
13+ import { EmptyUndefined , EmptyVoid } from '../../bindings/lib/generic.js' ;
14+ import { From , InferValue } from '../../bindings/lib/provable-generic.js' ;
15+ import { MlArray , MlBool , MlPair , MlResult } from '../ml/base.js' ;
16+ import { MlFieldArray , MlFieldConstArray } from '../ml/fields.js' ;
17+ import { FieldConst , FieldVar } from '../provable/core/fieldvar.js' ;
1518import { ConstraintSystemSummary , snarkContext } from '../provable/core/provable-context.js' ;
1619import { hashConstant } from '../provable/crypto/poseidon.js' ;
17- import { MlArray , MlBool , MlResult , MlPair } from '../ml/base.js' ;
18- import { MlFieldArray , MlFieldConstArray } from '../ml/fields.js' ;
19- import { FieldVar , FieldConst } from '../provable/core/fieldvar.js' ;
20- import { Cache , readCache , writeCache } from './cache.js' ;
21- import { decodeProverKey , encodeProverKey , parseHeader } from './prover-keys.js' ;
22- import { setSrsCache , unsetSrsCache } from '../../bindings/crypto/bindings/srs.js' ;
20+ import { Provable } from '../provable/provable.js' ;
21+ import { InferProvableType } from '../provable/types/provable-derivers.js' ;
2322import { ProvableType , ToProvable } from '../provable/types/provable-intf.js' ;
24- import { prefixToField } from '../../bindings/lib/binable.js' ;
25- import { prefixes } from '../../bindings/crypto/constants.js' ;
26- import { Subclass , Tuple , Get } from '../util/types.js' ;
23+ import { FlexibleProvable , InferProvable , ProvablePureExtended } from '../provable/types/struct.js' ;
24+ import { emptyWitness } from '../provable/types/util.js' ;
25+ import { Field } from '../provable/wrapped.js' ;
26+ import { mapObject , mapToObject , zip } from '../util/arrays.js' ;
27+ import { assert , prettifyStacktracePromise } from '../util/errors.js' ;
28+ import { Get , Subclass , Tuple } from '../util/types.js' ;
29+ import { Cache , readCache , writeCache } from './cache.js' ;
30+ import { featureFlagsFromGates , featureFlagsToMlOption } from './feature-flags.js' ;
2731import {
28- dummyProof ,
2932 DynamicProof ,
30- extractProofs ,
31- extractProofTypes ,
3233 Proof ,
3334 ProofBase ,
3435 ProofClass ,
3536 ProofValue ,
37+ dummyProof ,
38+ extractProofTypes ,
39+ extractProofs ,
3640} from './proof.js' ;
37- import { featureFlagsFromGates , featureFlagsToMlOption } from './feature-flags.js' ;
38- import { emptyWitness } from '../provable/types/util.js' ;
39- import { From , InferValue } from '../../bindings/lib/provable-generic.js' ;
40- import { DeclaredProof , ZkProgramContext } from './zkprogram-context.js' ;
41- import { mapObject , mapToObject , zip } from '../util/arrays.js' ;
41+ import { decodeProverKey , encodeProverKey , parseHeader } from './prover-keys.js' ;
4242import { VerificationKey } from './verification-key.js' ;
43+ import { DeclaredProof , ZkProgramContext } from './zkprogram-context.js' ;
4344
4445// public API
45- export { SelfProof , JsonProof , ZkProgram , verify , Empty , Undefined , Void , Method } ;
46+ export { Empty , JsonProof , Method , SelfProof , Undefined , Void , ZkProgram , verify } ;
4647
4748// internal API
4849export {
4950 CompiledTag ,
50- sortMethodArguments ,
5151 MethodInterface ,
5252 MethodReturnType ,
53- picklesRuleFromFunction ,
54- compileProgram ,
55- analyzeMethod ,
53+ PrivateInput ,
54+ Proof ,
5655 Prover ,
57- dummyBase64Proof ,
58- computeMaxProofsVerified ,
5956 RegularProver ,
6057 TupleToInstances ,
61- PrivateInput ,
62- Proof ,
58+ analyzeMethod ,
59+ compileProgram ,
60+ computeMaxProofsVerified ,
61+ dummyBase64Proof ,
6362 inCircuitVkHash ,
63+ picklesRuleFromFunction ,
64+ sortMethodArguments ,
6465} ;
6566
6667type Undefined = undefined ;
@@ -225,7 +226,7 @@ type InferMethodType<Config extends ConfigBaseType> = {
225226 */
226227function ZkProgram <
227228 Config extends ConfigBaseType ,
228- _ extends unknown = unknown // weird hack that makes methods infer correctly when their inputs are not annotated
229+ _ extends unknown = unknown , // weird hack that makes methods infer correctly when their inputs are not annotated
229230> (
230231 config : Config & {
231232 name : string ;
@@ -603,7 +604,7 @@ type ZkProgram<
603604 auxiliaryOutput ?: ProvableType ;
604605 } ;
605606 } ;
606- }
607+ } ,
607608> = ReturnType < typeof ZkProgram < Config > > ;
608609
609610/**
@@ -1059,7 +1060,7 @@ function toFieldAndAuxConsts<T>(type: Provable<T>, value: T) {
10591060
10601061ZkProgram . Proof = function <
10611062 PublicInputType extends FlexibleProvable < any > ,
1062- PublicOutputType extends FlexibleProvable < any >
1063+ PublicOutputType extends FlexibleProvable < any > ,
10631064> ( program : {
10641065 name : string ;
10651066 publicInputType : PublicInputType ;
@@ -1111,11 +1112,12 @@ function Prover<ProverData>() {
11111112
11121113// helper types
11131114
1114- type Infer < T > = T extends Subclass < typeof ProofBase >
1115- ? InstanceType < T >
1116- : T extends ProvableType
1117- ? InferProvableType < T >
1118- : never ;
1115+ type Infer < T > =
1116+ T extends Subclass < typeof ProofBase >
1117+ ? InstanceType < T >
1118+ : T extends ProvableType
1119+ ? InferProvableType < T >
1120+ : never ;
11191121
11201122type TupleToInstances < T > = {
11211123 [ I in keyof T ] : Infer < T [ I ] > ;
@@ -1133,21 +1135,21 @@ type MethodReturnType<PublicOutput, AuxiliaryOutput> = PublicOutput extends void
11331135 auxiliaryOutput : AuxiliaryOutput ;
11341136 }
11351137 : AuxiliaryOutput extends undefined
1136- ? {
1137- publicOutput : PublicOutput ;
1138- }
1139- : {
1140- publicOutput : PublicOutput ;
1141- auxiliaryOutput : AuxiliaryOutput ;
1142- } ;
1138+ ? {
1139+ publicOutput : PublicOutput ;
1140+ }
1141+ : {
1142+ publicOutput : PublicOutput ;
1143+ auxiliaryOutput : AuxiliaryOutput ;
1144+ } ;
11431145
11441146type Method <
11451147 PublicInput ,
11461148 PublicOutput ,
11471149 MethodSignature extends {
11481150 privateInputs : Tuple < PrivateInput > ;
11491151 auxiliaryOutput ?: ProvableType ;
1150- }
1152+ } ,
11511153> = PublicInput extends undefined
11521154 ? {
11531155 method (
@@ -1176,7 +1178,7 @@ type RegularProver<
11761178 PublicInputType ,
11771179 PublicOutput ,
11781180 Args extends Tuple < PrivateInput > ,
1179- AuxiliaryOutput
1181+ AuxiliaryOutput ,
11801182> = (
11811183 publicInput : From < PublicInputType > ,
11821184 ...args : TupleFrom < Args >
@@ -1190,7 +1192,7 @@ type Prover<
11901192 PublicInputType ,
11911193 PublicOutput ,
11921194 Args extends Tuple < PrivateInput > ,
1193- AuxiliaryOutput
1195+ AuxiliaryOutput ,
11941196> = PublicInput extends undefined
11951197 ? ( ...args : TupleFrom < Args > ) => Promise < {
11961198 proof : Proof < PublicInput , PublicOutput > ;
@@ -1210,8 +1212,8 @@ type ProvableOrVoid<A> = A extends undefined ? typeof Void : ToProvable<A>;
12101212type InferProvableOrUndefined < A > = A extends undefined
12111213 ? undefined
12121214 : A extends ProvableType
1213- ? InferProvable < A >
1214- : InferProvable < A > | undefined ;
1215+ ? InferProvable < A >
1216+ : InferProvable < A > | undefined ;
12151217type InferProvableOrVoid < A > = A extends undefined ? void : InferProvable < A > ;
12161218
12171219type UnwrapPromise < P > = P extends Promise < infer T > ? T : never ;
0 commit comments