Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lookup tables #1266

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bindings
14 changes: 12 additions & 2 deletions src/lib/proof_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ function ZkProgram<
}
): {
name: string;
compile: (options?: { cache: Cache }) => Promise<{ verificationKey: string }>;
compile: (options?: {
cache?: Cache;
forceRecompile?: boolean;
}) => Promise<{ verificationKey: string }>;
verify: (
proof: Proof<
InferProvableOrUndefined<Get<StatementType, 'publicInput'>>,
Expand Down Expand Up @@ -338,7 +341,10 @@ function ZkProgram<
}
| undefined;

async function compile({ cache = Cache.FileSystemDefault } = {}) {
async function compile({
cache = Cache.FileSystemDefault,
forceRecompile = false,
} = {}) {
let methodsMeta = methodIntfs.map((methodEntry, i) =>
analyzeMethod(publicInputType, methodEntry, methodFunctions[i])
);
Expand All @@ -351,6 +357,7 @@ function ZkProgram<
gates,
proofSystemTag: selfTag,
cache,
forceRecompile,
overrideWrapDomain: config.overrideWrapDomain,
});
compileOutput = { provers, verify };
Expand Down Expand Up @@ -603,6 +610,7 @@ async function compileProgram({
gates,
proofSystemTag,
cache,
forceRecompile,
overrideWrapDomain,
}: {
publicInputType: ProvablePure<any>;
Expand All @@ -612,6 +620,7 @@ async function compileProgram({
gates: Gate[][];
proofSystemTag: { name: string };
cache: Cache;
forceRecompile: boolean;
overrideWrapDomain?: 0 | 1 | 2;
}) {
let rules = methodIntfs.map((methodEntry, i) =>
Expand All @@ -630,6 +639,7 @@ async function compileProgram({
let picklesCache: Pickles.Cache = [
0,
function read_(mlHeader) {
if (forceRecompile) return MlResult.unitError();
let header = parseHeader(proofSystemTag.name, methodIntfs, mlHeader);
let result = readCache(cache, header, (bytes) =>
decodeProverKey(mlHeader, bytes)
Expand Down
6 changes: 5 additions & 1 deletion src/lib/zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ class SmartContract {
* it so that proofs end up in the original finite field). These are fairly expensive operations, so **expect compiling to take at least 20 seconds**,
* up to several minutes if your circuit is large or your hardware is not optimal for these operations.
*/
static async compile({ cache = Cache.FileSystemDefault } = {}) {
static async compile({
cache = Cache.FileSystemDefault,
forceRecompile = false,
} = {}) {
let methodIntfs = this._methods ?? [];
let methods = methodIntfs.map(({ methodName }) => {
return (
Expand Down Expand Up @@ -690,6 +693,7 @@ class SmartContract {
gates,
proofSystemTag: this,
cache,
forceRecompile,
});
let verificationKey = {
data: verificationKey_.data,
Expand Down
Loading