diff --git a/src/bindings b/src/bindings index 87996f7d27..a1c177d3e8 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 87996f7d27b37208d536349ab9449047964736f2 +Subproject commit a1c177d3e8c2d8afcdd892b23fe0bd5d09b8a9f6 diff --git a/src/lib/proof_system.ts b/src/lib/proof_system.ts index c952b7aa6d..312521374b 100644 --- a/src/lib/proof_system.ts +++ b/src/lib/proof_system.ts @@ -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>, @@ -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]) ); @@ -351,6 +357,7 @@ function ZkProgram< gates, proofSystemTag: selfTag, cache, + forceRecompile, overrideWrapDomain: config.overrideWrapDomain, }); compileOutput = { provers, verify }; @@ -603,6 +610,7 @@ async function compileProgram({ gates, proofSystemTag, cache, + forceRecompile, overrideWrapDomain, }: { publicInputType: ProvablePure; @@ -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) => @@ -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) diff --git a/src/lib/zkapp.ts b/src/lib/zkapp.ts index 11f4978e15..a0df136baf 100644 --- a/src/lib/zkapp.ts +++ b/src/lib/zkapp.ts @@ -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 ( @@ -690,6 +693,7 @@ class SmartContract { gates, proofSystemTag: this, cache, + forceRecompile, }); let verificationKey = { data: verificationKey_.data,