@aztec/bb-prover 3.0.0-devnet.2 → 3.0.0-devnet.2-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/avm_proving_tests/avm_proving_tester.d.ts +3 -4
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +16 -2
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +4 -4
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +19 -15
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/honk.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/instrumentation.d.ts +1 -1
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.d.ts +11 -5
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +35 -6
- package/dest/prover/client/bundle.d.ts +6 -0
- package/dest/prover/client/bundle.d.ts.map +1 -0
- package/dest/prover/client/bundle.js +7 -0
- package/dest/prover/client/lazy.d.ts +6 -0
- package/dest/prover/client/lazy.d.ts.map +1 -0
- package/dest/prover/client/lazy.js +7 -0
- package/dest/prover/index.d.ts +1 -1
- package/dest/prover/proof_utils.d.ts +8 -8
- package/dest/prover/proof_utils.d.ts.map +1 -1
- package/dest/prover/proof_utils.js +18 -18
- package/dest/prover/server/bb_prover.d.ts +3 -12
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +6 -6
- package/dest/test/delay_values.d.ts +1 -1
- package/dest/test/delay_values.js +23 -23
- package/dest/test/index.d.ts +1 -1
- package/dest/test/test_circuit_prover.d.ts +3 -3
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +3 -3
- package/dest/test/test_verifier.d.ts +3 -1
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +15 -0
- package/dest/verification_key/verification_key_data.d.ts +1 -1
- package/dest/verification_key/verification_key_data.js +1 -1
- package/dest/verifier/bb_verifier.d.ts +1 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +9 -6
- package/dest/verifier/index.d.ts +2 -2
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -1
- package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/{queued_ivc_verifier.js → queued_chonk_verifier.js} +3 -3
- package/package.json +23 -22
- package/src/avm_proving_tests/avm_proving_tester.ts +17 -3
- package/src/bb/execute.ts +12 -15
- package/src/prover/client/bb_private_kernel_prover.ts +45 -8
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/proof_utils.ts +18 -18
- package/src/prover/server/bb_prover.ts +14 -12
- package/src/test/delay_values.ts +23 -23
- package/src/test/test_circuit_prover.ts +10 -8
- package/src/test/test_verifier.ts +8 -0
- package/src/verification_key/verification_key_data.ts +1 -1
- package/src/verifier/bb_verifier.ts +9 -9
- package/src/verifier/index.ts +1 -1
- package/src/verifier/{queued_ivc_verifier.ts → queued_chonk_verifier.ts} +3 -3
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +0 -23
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/client/native/bb_native_private_kernel_prover.js +0 -66
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +0 -15
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.js +0 -46
- package/dest/prover/client/wasm/bundle.d.ts +0 -6
- package/dest/prover/client/wasm/bundle.d.ts.map +0 -1
- package/dest/prover/client/wasm/bundle.js +0 -8
- package/dest/prover/client/wasm/lazy.d.ts +0 -6
- package/dest/prover/client/wasm/lazy.d.ts.map +0 -1
- package/dest/prover/client/wasm/lazy.js +0 -8
- package/dest/verifier/queued_ivc_verifier.d.ts +0 -15
- package/dest/verifier/queued_ivc_verifier.d.ts.map +0 -1
- package/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -107
- package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -60
- package/src/prover/client/wasm/bundle.ts +0 -11
- package/src/prover/client/wasm/lazy.ts +0 -11
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bb_native_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/native/bb_native_private_kernel_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAkC,MAAM,sBAAsB,CAAC;AACjG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAM3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,qBAAqB;IAElE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,WAAW;cACA,SAAS,EAAE,gBAAgB;cAC3B,GAAG;IALxB,OAAO;WAUa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,MAAM;YAWrE,qBAAqB;IAuBb,oBAAoB,CACxC,cAAc,EAAE,oBAAoB,EAAE,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAQpB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxG,OAAO,CAAC,cAAc;CAavB"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
4
|
-
import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
5
|
-
import { promises as fs } from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../../../bb/execute.js';
|
|
8
|
-
import { readClientIVCProofFromOutputDirectory } from '../../proof_utils.js';
|
|
9
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
10
|
-
/**
|
|
11
|
-
* This proof creator implementation uses the native bb binary.
|
|
12
|
-
*/ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
13
|
-
bbBinaryPath;
|
|
14
|
-
bbWorkingDirectory;
|
|
15
|
-
skipCleanup;
|
|
16
|
-
simulator;
|
|
17
|
-
log;
|
|
18
|
-
constructor(bbBinaryPath, bbWorkingDirectory, skipCleanup, simulator, log = createLogger('bb-prover:native')){
|
|
19
|
-
super(new BundleArtifactProvider(), simulator, log), this.bbBinaryPath = bbBinaryPath, this.bbWorkingDirectory = bbWorkingDirectory, this.skipCleanup = skipCleanup, this.simulator = simulator, this.log = log;
|
|
20
|
-
}
|
|
21
|
-
static async new(config, simulator, log) {
|
|
22
|
-
await fs.mkdir(config.bbWorkingDirectory, {
|
|
23
|
-
recursive: true
|
|
24
|
-
});
|
|
25
|
-
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulator, log);
|
|
26
|
-
}
|
|
27
|
-
async _createClientIvcProof(directory, executionSteps) {
|
|
28
|
-
const inputsPath = path.join(directory, 'ivc-inputs.msgpack');
|
|
29
|
-
await fs.writeFile(inputsPath, serializePrivateExecutionSteps(executionSteps));
|
|
30
|
-
const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, inputsPath, this.log.info);
|
|
31
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
32
|
-
this.log.error(`Failed to generate client ivc proof`);
|
|
33
|
-
throw new Error(provingResult.reason);
|
|
34
|
-
}
|
|
35
|
-
const proof = await readClientIVCProofFromOutputDirectory(directory);
|
|
36
|
-
this.log.info(`Generated IVC proof`, {
|
|
37
|
-
duration: provingResult.durationMs,
|
|
38
|
-
eventName: 'circuit-proving'
|
|
39
|
-
});
|
|
40
|
-
return proof;
|
|
41
|
-
}
|
|
42
|
-
async createClientIvcProof(executionSteps) {
|
|
43
|
-
this.log.info(`Generating Client IVC proof`);
|
|
44
|
-
const operation = async (directory)=>{
|
|
45
|
-
return await this._createClientIvcProof(directory, executionSteps);
|
|
46
|
-
};
|
|
47
|
-
return await this.runInDirectory(operation);
|
|
48
|
-
}
|
|
49
|
-
async computeGateCountForCircuit(bytecode, circuitName) {
|
|
50
|
-
const logFunction = (message)=>{
|
|
51
|
-
this.log.debug(`$bb gates ${circuitName} - ${message}`);
|
|
52
|
-
};
|
|
53
|
-
const result = await computeGateCountForCircuit(this.bbBinaryPath, this.bbWorkingDirectory, circuitName, bytecode, 'mega_honk', logFunction);
|
|
54
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
55
|
-
throw new Error(result.reason);
|
|
56
|
-
}
|
|
57
|
-
return result.circuitSize;
|
|
58
|
-
}
|
|
59
|
-
runInDirectory(fn) {
|
|
60
|
-
const log = this.log;
|
|
61
|
-
return runInDirectory(this.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
|
|
62
|
-
log.error(`Error running operation at ${dir}: ${err}`);
|
|
63
|
-
throw err;
|
|
64
|
-
}), this.skipCleanup, this.log);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
|
|
2
|
-
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
-
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
4
|
-
import { ClientIvcProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
5
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
6
|
-
export declare abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
-
protected artifactProvider: ArtifactProvider;
|
|
8
|
-
protected simulator: CircuitSimulator;
|
|
9
|
-
private threads;
|
|
10
|
-
protected log: import("@aztec/foundation/log").Logger;
|
|
11
|
-
constructor(artifactProvider: ArtifactProvider, simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
12
|
-
createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProofWithPublicInputs>;
|
|
13
|
-
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=bb_wasm_private_kernel_prover.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bb_wasm_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/bb_wasm_private_kernel_prover.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAItE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,8BAAsB,yBAA0B,SAAQ,qBAAqB;cAEtD,gBAAgB,EAAE,gBAAgB;cAClC,SAAS,EAAE,gBAAgB;IAC9C,OAAO,CAAC,OAAO;cACI,GAAG;gBAHH,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,gBAAgB,EACtC,OAAO,GAAE,MAAU,EACR,GAAG,yCAAiC;IAKnC,oBAAoB,CACxC,cAAc,EAAE,oBAAoB,EAAE,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAqBpB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAa3G"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { AztecClientBackend } from '@aztec/bb.js';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
-
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
5
|
-
import { ClientIvcProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
6
|
-
import { ungzip } from 'pako';
|
|
7
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
8
|
-
export class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
9
|
-
artifactProvider;
|
|
10
|
-
simulator;
|
|
11
|
-
threads;
|
|
12
|
-
log;
|
|
13
|
-
constructor(artifactProvider, simulator, threads = 1, log = createLogger('bb-prover:wasm')){
|
|
14
|
-
super(artifactProvider, simulator, log), this.artifactProvider = artifactProvider, this.simulator = simulator, this.threads = threads, this.log = log;
|
|
15
|
-
}
|
|
16
|
-
async createClientIvcProof(executionSteps) {
|
|
17
|
-
const timer = new Timer();
|
|
18
|
-
this.log.info(`Generating ClientIVC proof...`);
|
|
19
|
-
const backend = new AztecClientBackend(executionSteps.map((step)=>ungzip(step.bytecode)), {
|
|
20
|
-
threads: this.threads,
|
|
21
|
-
logger: this.log.verbose,
|
|
22
|
-
wasmPath: process.env.BB_WASM_PATH
|
|
23
|
-
});
|
|
24
|
-
const [proof] = await backend.prove(executionSteps.map((step)=>ungzip(serializeWitness(step.witness))), executionSteps.map((step)=>step.vk));
|
|
25
|
-
await backend.destroy();
|
|
26
|
-
this.log.info(`Generated ClientIVC proof`, {
|
|
27
|
-
eventName: 'client-ivc-proof-generation',
|
|
28
|
-
duration: timer.ms(),
|
|
29
|
-
proofSize: proof.length
|
|
30
|
-
});
|
|
31
|
-
return ClientIvcProofWithPublicInputs.fromBufferArray(proof);
|
|
32
|
-
}
|
|
33
|
-
async computeGateCountForCircuit(_bytecode, _circuitName) {
|
|
34
|
-
// Note we do not pass the vk to the backend. This is unneeded for gate counts.
|
|
35
|
-
const backend = new AztecClientBackend([
|
|
36
|
-
ungzip(_bytecode)
|
|
37
|
-
], {
|
|
38
|
-
threads: this.threads,
|
|
39
|
-
logger: this.log.verbose,
|
|
40
|
-
wasmPath: process.env.BB_WASM_PATH
|
|
41
|
-
});
|
|
42
|
-
const gateCount = await backend.gates();
|
|
43
|
-
await backend.destroy();
|
|
44
|
-
return gateCount[0];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
2
|
-
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
3
|
-
export declare class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
4
|
-
constructor(simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,+BAAgC,SAAQ,yBAAyB;gBAChE,SAAS,EAAE,gBAAgB,EAAE,OAAO,SAAK,EAAE,GAAG,yCAAwC;CAGnG"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
3
|
-
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
4
|
-
export class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
5
|
-
constructor(simulator, threads = 16, log = createLogger('bb-prover:wasm:bundle')){
|
|
6
|
-
super(new BundleArtifactProvider(), simulator, threads, log);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
2
|
-
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
3
|
-
export declare class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
4
|
-
constructor(simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/lazy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,6BAA8B,SAAQ,yBAAyB;gBAC9D,SAAS,EAAE,gBAAgB,EAAE,OAAO,SAAK,EAAE,GAAG,yCAAsC;CAGjG"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
3
|
-
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
4
|
-
export class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
5
|
-
constructor(simulator, threads = 16, log = createLogger('bb-prover:wasm:lazy')){
|
|
6
|
-
super(new LazyArtifactProvider(), simulator, threads, log);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
|
-
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
-
import type { BBConfig } from '../config.js';
|
|
5
|
-
export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
6
|
-
private verifier;
|
|
7
|
-
private telemetry;
|
|
8
|
-
private logger;
|
|
9
|
-
private queue;
|
|
10
|
-
private metrics;
|
|
11
|
-
constructor(config: BBConfig, verifier: ClientProtocolCircuitVerifier, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
|
|
12
|
-
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
13
|
-
stop(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=queued_ivc_verifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queued_ivc_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_ivc_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAgG7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAMnE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAqB;gBAGlC,MAAM,EAAE,QAAQ,EACR,QAAQ,EAAE,6BAA6B,EACvC,SAAS,GAAE,eAAsC,EACjD,MAAM,yCAAgD;IAQnD,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAMrE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtB"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
4
|
-
import type { CircuitSimulator } from '@aztec/simulator/server';
|
|
5
|
-
import { type PrivateExecutionStep, serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
6
|
-
import type { ClientIvcProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
7
|
-
|
|
8
|
-
import { promises as fs } from 'fs';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
|
|
11
|
-
import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../../../bb/execute.js';
|
|
12
|
-
import type { BBConfig } from '../../../config.js';
|
|
13
|
-
import { readClientIVCProofFromOutputDirectory } from '../../proof_utils.js';
|
|
14
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* This proof creator implementation uses the native bb binary.
|
|
18
|
-
*/
|
|
19
|
-
export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
20
|
-
private constructor(
|
|
21
|
-
private bbBinaryPath: string,
|
|
22
|
-
private bbWorkingDirectory: string,
|
|
23
|
-
private skipCleanup: boolean,
|
|
24
|
-
protected override simulator: CircuitSimulator,
|
|
25
|
-
protected override log = createLogger('bb-prover:native'),
|
|
26
|
-
) {
|
|
27
|
-
super(new BundleArtifactProvider(), simulator, log);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public static async new(config: BBConfig, simulator: CircuitSimulator, log?: Logger) {
|
|
31
|
-
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
32
|
-
return new BBNativePrivateKernelProver(
|
|
33
|
-
config.bbBinaryPath,
|
|
34
|
-
config.bbWorkingDirectory,
|
|
35
|
-
!!config.bbSkipCleanup,
|
|
36
|
-
simulator,
|
|
37
|
-
log,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private async _createClientIvcProof(
|
|
42
|
-
directory: string,
|
|
43
|
-
executionSteps: PrivateExecutionStep[],
|
|
44
|
-
): Promise<ClientIvcProofWithPublicInputs> {
|
|
45
|
-
const inputsPath = path.join(directory, 'ivc-inputs.msgpack');
|
|
46
|
-
await fs.writeFile(inputsPath, serializePrivateExecutionSteps(executionSteps));
|
|
47
|
-
const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, inputsPath, this.log.info);
|
|
48
|
-
|
|
49
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
50
|
-
this.log.error(`Failed to generate client ivc proof`);
|
|
51
|
-
throw new Error(provingResult.reason);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const proof = await readClientIVCProofFromOutputDirectory(directory);
|
|
55
|
-
|
|
56
|
-
this.log.info(`Generated IVC proof`, {
|
|
57
|
-
duration: provingResult.durationMs,
|
|
58
|
-
eventName: 'circuit-proving',
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return proof;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public override async createClientIvcProof(
|
|
65
|
-
executionSteps: PrivateExecutionStep[],
|
|
66
|
-
): Promise<ClientIvcProofWithPublicInputs> {
|
|
67
|
-
this.log.info(`Generating Client IVC proof`);
|
|
68
|
-
const operation = async (directory: string) => {
|
|
69
|
-
return await this._createClientIvcProof(directory, executionSteps);
|
|
70
|
-
};
|
|
71
|
-
return await this.runInDirectory(operation);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public override async computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number> {
|
|
75
|
-
const logFunction = (message: string) => {
|
|
76
|
-
this.log.debug(`$bb gates ${circuitName} - ${message}`);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const result = await computeGateCountForCircuit(
|
|
80
|
-
this.bbBinaryPath,
|
|
81
|
-
this.bbWorkingDirectory,
|
|
82
|
-
circuitName,
|
|
83
|
-
bytecode,
|
|
84
|
-
'mega_honk',
|
|
85
|
-
logFunction,
|
|
86
|
-
);
|
|
87
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
88
|
-
throw new Error(result.reason);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return result.circuitSize as number;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private runInDirectory<T>(fn: (dir: string) => Promise<T>) {
|
|
95
|
-
const log = this.log;
|
|
96
|
-
return runInDirectory(
|
|
97
|
-
this.bbWorkingDirectory,
|
|
98
|
-
(dir: string) =>
|
|
99
|
-
fn(dir).catch(err => {
|
|
100
|
-
log.error(`Error running operation at ${dir}: ${err}`);
|
|
101
|
-
throw err;
|
|
102
|
-
}),
|
|
103
|
-
this.skipCleanup,
|
|
104
|
-
this.log,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { AztecClientBackend } from '@aztec/bb.js';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
-
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
5
|
-
import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
|
|
6
|
-
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
7
|
-
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
8
|
-
import { ClientIvcProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
9
|
-
|
|
10
|
-
import { ungzip } from 'pako';
|
|
11
|
-
|
|
12
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
13
|
-
|
|
14
|
-
export abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
15
|
-
constructor(
|
|
16
|
-
protected override artifactProvider: ArtifactProvider,
|
|
17
|
-
protected override simulator: CircuitSimulator,
|
|
18
|
-
private threads: number = 1,
|
|
19
|
-
protected override log = createLogger('bb-prover:wasm'),
|
|
20
|
-
) {
|
|
21
|
-
super(artifactProvider, simulator, log);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public override async createClientIvcProof(
|
|
25
|
-
executionSteps: PrivateExecutionStep[],
|
|
26
|
-
): Promise<ClientIvcProofWithPublicInputs> {
|
|
27
|
-
const timer = new Timer();
|
|
28
|
-
this.log.info(`Generating ClientIVC proof...`);
|
|
29
|
-
const backend = new AztecClientBackend(
|
|
30
|
-
executionSteps.map(step => ungzip(step.bytecode)),
|
|
31
|
-
{ threads: this.threads, logger: this.log.verbose, wasmPath: process.env.BB_WASM_PATH },
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const [proof] = await backend.prove(
|
|
35
|
-
executionSteps.map(step => ungzip(serializeWitness(step.witness))),
|
|
36
|
-
executionSteps.map(step => step.vk),
|
|
37
|
-
);
|
|
38
|
-
await backend.destroy();
|
|
39
|
-
this.log.info(`Generated ClientIVC proof`, {
|
|
40
|
-
eventName: 'client-ivc-proof-generation',
|
|
41
|
-
duration: timer.ms(),
|
|
42
|
-
proofSize: proof.length,
|
|
43
|
-
});
|
|
44
|
-
return ClientIvcProofWithPublicInputs.fromBufferArray(proof);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public override async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
48
|
-
// Note we do not pass the vk to the backend. This is unneeded for gate counts.
|
|
49
|
-
const backend = new AztecClientBackend([ungzip(_bytecode)], {
|
|
50
|
-
threads: this.threads,
|
|
51
|
-
logger: this.log.verbose,
|
|
52
|
-
wasmPath: process.env.BB_WASM_PATH,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const gateCount = await backend.gates();
|
|
56
|
-
await backend.destroy();
|
|
57
|
-
|
|
58
|
-
return gateCount[0];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
3
|
-
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
4
|
-
|
|
5
|
-
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
6
|
-
|
|
7
|
-
export class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
8
|
-
constructor(simulator: CircuitSimulator, threads = 16, log = createLogger('bb-prover:wasm:bundle')) {
|
|
9
|
-
super(new BundleArtifactProvider(), simulator, threads, log);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
3
|
-
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
4
|
-
|
|
5
|
-
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
6
|
-
|
|
7
|
-
export class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
8
|
-
constructor(simulator: CircuitSimulator, threads = 16, log = createLogger('bb-prover:wasm:lazy')) {
|
|
9
|
-
super(new LazyArtifactProvider(), simulator, threads, log);
|
|
10
|
-
}
|
|
11
|
-
}
|