Skip to content

Commit 353f639

Browse files
committed
remove the need to export regular provers
1 parent d0ffd75 commit 353f639

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/lib/proof-system/recursive.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ProvableType } from '../provable/types/provable-intf.js';
44
import { Tuple } from '../util/types.js';
55
import { Proof } from './proof.js';
66
import { mapObject, mapToObject, zip } from '../util/arrays.js';
7-
import { RegularProver, Undefined, Void } from './zkprogram.js';
7+
import { Undefined, Void } from './zkprogram.js';
88

99
export { Recursive };
1010

@@ -14,25 +14,26 @@ function Recursive<
1414
PrivateInputs extends {
1515
[Key in string]: Tuple<ProvableType>;
1616
}
17-
>(zkprogram: {
18-
name: string;
19-
publicInputType: PublicInputType;
20-
publicOutputType: PublicOutputType;
21-
privateInputTypes: PrivateInputs;
22-
rawMethods: {
23-
[Key in keyof PrivateInputs]: (
24-
...args: any
25-
) => Promise<{ publicOutput: InferProvable<PublicOutputType> }>;
26-
};
27-
provers: {
28-
[Key in keyof PrivateInputs]: RegularProver<
29-
InferProvable<PublicInputType>,
30-
InferProvable<PublicOutputType>,
31-
any,
32-
any
33-
>;
34-
};
35-
}): {
17+
>(
18+
zkprogram: {
19+
name: string;
20+
publicInputType: PublicInputType;
21+
publicOutputType: PublicOutputType;
22+
privateInputTypes: PrivateInputs;
23+
rawMethods: {
24+
[Key in keyof PrivateInputs]: (
25+
...args: any
26+
) => Promise<{ publicOutput: InferProvable<PublicOutputType> }>;
27+
};
28+
} & {
29+
[Key in keyof PrivateInputs]: (...args: any) => Promise<{
30+
proof: Proof<
31+
InferProvable<PublicInputType>,
32+
InferProvable<PublicOutputType>
33+
>;
34+
}>;
35+
}
36+
): {
3637
[Key in keyof PrivateInputs]: RecursiveProver<
3738
InferProvable<PublicInputType>,
3839
InferProvable<PublicOutputType>,
@@ -48,7 +49,6 @@ function Recursive<
4849
publicOutputType,
4950
privateInputTypes: privateInputs,
5051
rawMethods: methods,
51-
provers,
5252
} = zkprogram;
5353

5454
let hasPublicInput =
@@ -62,7 +62,7 @@ function Recursive<
6262

6363
let methodKeys: MethodKey[] = Object.keys(methods);
6464

65-
let regularRecursiveProvers = mapObject(provers, (prover, key) => {
65+
let regularRecursiveProvers = mapObject(zkprogram, (prover, key) => {
6666
return async function proveRecursively_(
6767
publicInput: PublicInput,
6868
...args: TupleToInstances<PrivateInputs[MethodKey]>
@@ -77,8 +77,13 @@ function Recursive<
7777
let constArgs = zip(args, privateInputs[key]).map(([arg, type]) =>
7878
Provable.toConstant(type, arg)
7979
);
80-
let { proof } = await prover(constInput, ...(constArgs as any));
81-
return proof;
80+
if (hasPublicInput) {
81+
let { proof } = await prover(constInput, ...constArgs);
82+
return proof;
83+
} else {
84+
let { proof } = await prover(...constArgs);
85+
return proof;
86+
}
8287
});
8388

8489
// assert that the witnessed proof has the correct public input (which will be used by Pickles as part of verification)

0 commit comments

Comments
 (0)