@aztec/bb-prover 0.0.0-test.0
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 +25 -0
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -0
- package/dest/avm_proving_tests/avm_proving_tester.js +105 -0
- package/dest/bb/cli.d.ts +12 -0
- package/dest/bb/cli.d.ts.map +1 -0
- package/dest/bb/cli.js +19 -0
- package/dest/bb/execute.d.ts +140 -0
- package/dest/bb/execute.d.ts.map +1 -0
- package/dest/bb/execute.js +780 -0
- package/dest/bb/index.d.ts +3 -0
- package/dest/bb/index.d.ts.map +1 -0
- package/dest/bb/index.js +16 -0
- package/dest/config.d.ts +13 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +1 -0
- package/dest/honk.d.ts +13 -0
- package/dest/honk.d.ts.map +1 -0
- package/dest/honk.js +18 -0
- package/dest/index.d.ts +8 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +6 -0
- package/dest/instrumentation.d.ts +47 -0
- package/dest/instrumentation.d.ts.map +1 -0
- package/dest/instrumentation.js +100 -0
- package/dest/prover/bb_native_private_kernel_prover.d.ts +25 -0
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/bb_native_private_kernel_prover.js +69 -0
- package/dest/prover/bb_private_kernel_prover.d.ts +32 -0
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/bb_private_kernel_prover.js +109 -0
- package/dest/prover/bb_prover.d.ts +120 -0
- package/dest/prover/bb_prover.d.ts.map +1 -0
- package/dest/prover/bb_prover.js +423 -0
- package/dest/prover/client_ivc_proof_utils.d.ts +25 -0
- package/dest/prover/client_ivc_proof_utils.d.ts.map +1 -0
- package/dest/prover/client_ivc_proof_utils.js +43 -0
- package/dest/prover/index.d.ts +4 -0
- package/dest/prover/index.d.ts.map +1 -0
- package/dest/prover/index.js +3 -0
- package/dest/stats.d.ts +5 -0
- package/dest/stats.d.ts.map +1 -0
- package/dest/stats.js +62 -0
- package/dest/test/delay_values.d.ts +4 -0
- package/dest/test/delay_values.d.ts.map +1 -0
- package/dest/test/delay_values.js +29 -0
- package/dest/test/index.d.ts +3 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +2 -0
- package/dest/test/test_circuit_prover.d.ts +81 -0
- package/dest/test/test_circuit_prover.d.ts.map +1 -0
- package/dest/test/test_circuit_prover.js +175 -0
- package/dest/test/test_verifier.d.ts +6 -0
- package/dest/test/test_verifier.d.ts.map +1 -0
- package/dest/test/test_verifier.js +5 -0
- package/dest/verification_key/verification_key_data.d.ts +9 -0
- package/dest/verification_key/verification_key_data.d.ts.map +1 -0
- package/dest/verification_key/verification_key_data.js +44 -0
- package/dest/verifier/bb_verifier.d.ts +17 -0
- package/dest/verifier/bb_verifier.d.ts.map +1 -0
- package/dest/verifier/bb_verifier.js +86 -0
- package/dest/verifier/index.d.ts +2 -0
- package/dest/verifier/index.d.ts.map +1 -0
- package/dest/verifier/index.js +1 -0
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +17 -0
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -0
- package/dest/wasm/bb_wasm_private_kernel_prover.js +46 -0
- package/dest/wasm/bundle.d.ts +6 -0
- package/dest/wasm/bundle.d.ts.map +1 -0
- package/dest/wasm/bundle.js +8 -0
- package/dest/wasm/lazy.d.ts +6 -0
- package/dest/wasm/lazy.d.ts.map +1 -0
- package/dest/wasm/lazy.js +8 -0
- package/package.json +111 -0
- package/src/avm_proving_tests/avm_proving_tester.ts +170 -0
- package/src/bb/cli.ts +32 -0
- package/src/bb/execute.ts +853 -0
- package/src/bb/index.ts +23 -0
- package/src/config.ts +13 -0
- package/src/honk.ts +30 -0
- package/src/index.ts +8 -0
- package/src/instrumentation.ts +144 -0
- package/src/prover/bb_native_private_kernel_prover.ts +119 -0
- package/src/prover/bb_private_kernel_prover.ts +249 -0
- package/src/prover/bb_prover.ts +781 -0
- package/src/prover/client_ivc_proof_utils.ts +42 -0
- package/src/prover/index.ts +3 -0
- package/src/stats.ts +64 -0
- package/src/test/delay_values.ts +31 -0
- package/src/test/index.ts +2 -0
- package/src/test/test_circuit_prover.ts +368 -0
- package/src/test/test_verifier.ts +8 -0
- package/src/verification_key/verification_key_data.ts +45 -0
- package/src/verifier/bb_verifier.ts +114 -0
- package/src/verifier/index.ts +1 -0
- package/src/wasm/bb_wasm_private_kernel_prover.ts +55 -0
- package/src/wasm/bundle.ts +11 -0
- package/src/wasm/lazy.ts +11 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PublicTxSimulationTester, type TestEnqueuedCall } from '@aztec/simulator/public/fixtures';
|
|
2
|
+
import { SimpleContractDataSource, WorldStateDB } from '@aztec/simulator/server';
|
|
3
|
+
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { type BBResult, type BBSuccess } from '../bb/execute.js';
|
|
7
|
+
export declare class AvmProvingTester extends PublicTxSimulationTester {
|
|
8
|
+
private bbWorkingDirectory;
|
|
9
|
+
private checkCircuitOnly;
|
|
10
|
+
constructor(bbWorkingDirectory: string, checkCircuitOnly: boolean, worldStateDB: WorldStateDB, contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations);
|
|
11
|
+
static create(checkCircuitOnly?: boolean): Promise<AvmProvingTester>;
|
|
12
|
+
prove(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
13
|
+
verify(proofRes: BBSuccess): Promise<BBResult>;
|
|
14
|
+
simProveVerify(sender: AztecAddress, setupCalls: TestEnqueuedCall[], appCalls: TestEnqueuedCall[], teardownCall: TestEnqueuedCall | undefined, expectRevert: boolean | undefined, feePayer?: AztecAddress): Promise<void>;
|
|
15
|
+
simProveVerifyAppLogic(appCall: TestEnqueuedCall, expectRevert?: boolean): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
18
|
+
private bbWorkingDirectory;
|
|
19
|
+
constructor(bbWorkingDirectory: string, worldStateDB: WorldStateDB, contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations);
|
|
20
|
+
static create(): Promise<AvmProvingTesterV2>;
|
|
21
|
+
proveV2(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
22
|
+
verifyV2(proofRes: BBSuccess): Promise<BBResult>;
|
|
23
|
+
simProveVerifyV2(sender: AztecAddress, setupCalls: TestEnqueuedCall[], appCalls: TestEnqueuedCall[], teardownCall: TestEnqueuedCall | undefined, expectRevert: boolean | undefined, feePayer?: AztecAddress): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=avm_proving_tester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avm_proving_tester.d.ts","sourceRoot":"","sources":["../../src/avm_proving_tests/avm_proving_tester.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AASjF,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,EAMf,MAAM,kBAAkB,CAAC;AAK1B,qBAAa,gBAAiB,SAAQ,wBAAwB;IAE1D,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,gBAAgB;gBADhB,kBAAkB,EAAE,MA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B } from '@aztec/simulator/server';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { makeAvmCircuitInputs } from '@aztec/stdlib/testing';
|
|
5
|
+
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
6
|
+
import { NativeWorldStateService } from '@aztec/world-state';
|
|
7
|
+
import fs from 'node:fs/promises';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { BB_RESULT, generateAvmProof, generateAvmProofV2, verifyAvmProof, verifyAvmProofV2 } from '../bb/execute.js';
|
|
11
|
+
import { extractAvmVkData } from '../verification_key/verification_key_data.js';
|
|
12
|
+
const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb');
|
|
13
|
+
export class AvmProvingTester extends PublicTxSimulationTester {
|
|
14
|
+
bbWorkingDirectory;
|
|
15
|
+
checkCircuitOnly;
|
|
16
|
+
constructor(bbWorkingDirectory, checkCircuitOnly, worldStateDB, contractDataSource, merkleTrees){
|
|
17
|
+
super(worldStateDB, contractDataSource, merkleTrees), this.bbWorkingDirectory = bbWorkingDirectory, this.checkCircuitOnly = checkCircuitOnly;
|
|
18
|
+
}
|
|
19
|
+
static async create(checkCircuitOnly = false) {
|
|
20
|
+
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
21
|
+
const contractDataSource = new SimpleContractDataSource();
|
|
22
|
+
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
23
|
+
const worldStateDB = new WorldStateDB(merkleTrees, contractDataSource);
|
|
24
|
+
return new AvmProvingTester(bbWorkingDirectory, checkCircuitOnly, worldStateDB, contractDataSource, merkleTrees);
|
|
25
|
+
}
|
|
26
|
+
async prove(avmCircuitInputs) {
|
|
27
|
+
// Then we prove.
|
|
28
|
+
const proofRes = await generateAvmProof(BB_PATH, this.bbWorkingDirectory, avmCircuitInputs, this.logger, this.checkCircuitOnly);
|
|
29
|
+
if (proofRes.status === BB_RESULT.FAILURE) {
|
|
30
|
+
this.logger.error(`Proof generation failed: ${proofRes.reason}`);
|
|
31
|
+
}
|
|
32
|
+
return proofRes;
|
|
33
|
+
}
|
|
34
|
+
async verify(proofRes) {
|
|
35
|
+
if (this.checkCircuitOnly) {
|
|
36
|
+
// Skip verification if we're only checking the circuit.
|
|
37
|
+
// Check-circuit doesn't generate a proof to verify.
|
|
38
|
+
return proofRes;
|
|
39
|
+
}
|
|
40
|
+
// Then we test VK extraction and serialization.
|
|
41
|
+
const succeededRes = proofRes;
|
|
42
|
+
const vkData = await extractAvmVkData(succeededRes.vkPath);
|
|
43
|
+
VerificationKeyData.fromBuffer(vkData.toBuffer());
|
|
44
|
+
// Then we verify.
|
|
45
|
+
const rawVkPath = path.join(succeededRes.vkPath, 'vk');
|
|
46
|
+
return await verifyAvmProof(BB_PATH, succeededRes.proofPath, rawVkPath, this.logger);
|
|
47
|
+
}
|
|
48
|
+
async simProveVerify(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender) {
|
|
49
|
+
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer);
|
|
50
|
+
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
51
|
+
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
52
|
+
const provingRes = await this.prove(avmCircuitInputs);
|
|
53
|
+
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
54
|
+
const verificationRes = await this.verify(provingRes);
|
|
55
|
+
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
56
|
+
}
|
|
57
|
+
async simProveVerifyAppLogic(appCall, expectRevert) {
|
|
58
|
+
const simRes = await this.simulateTx(/*sender=*/ AztecAddress.fromNumber(42), /*setupCalls=*/ [], [
|
|
59
|
+
appCall
|
|
60
|
+
]);
|
|
61
|
+
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
62
|
+
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
63
|
+
const provingRes = await this.prove(avmCircuitInputs);
|
|
64
|
+
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
65
|
+
const verificationRes = await this.verify(provingRes);
|
|
66
|
+
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
70
|
+
bbWorkingDirectory;
|
|
71
|
+
constructor(bbWorkingDirectory, worldStateDB, contractDataSource, merkleTrees){
|
|
72
|
+
super(worldStateDB, contractDataSource, merkleTrees), this.bbWorkingDirectory = bbWorkingDirectory;
|
|
73
|
+
}
|
|
74
|
+
static async create() {
|
|
75
|
+
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
76
|
+
const contractDataSource = new SimpleContractDataSource();
|
|
77
|
+
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
78
|
+
const worldStateDB = new WorldStateDB(merkleTrees, contractDataSource);
|
|
79
|
+
return new AvmProvingTesterV2(bbWorkingDirectory, worldStateDB, contractDataSource, merkleTrees);
|
|
80
|
+
}
|
|
81
|
+
async proveV2(avmCircuitInputs) {
|
|
82
|
+
// Then we prove.
|
|
83
|
+
const proofRes = await generateAvmProofV2(BB_PATH, this.bbWorkingDirectory, avmCircuitInputs, this.logger);
|
|
84
|
+
if (proofRes.status === BB_RESULT.FAILURE) {
|
|
85
|
+
this.logger.error(`Proof generation failed: ${proofRes.reason}`);
|
|
86
|
+
}
|
|
87
|
+
expect(proofRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
88
|
+
return proofRes;
|
|
89
|
+
}
|
|
90
|
+
async verifyV2(proofRes) {
|
|
91
|
+
// TODO: Placeholder for now. They get ignored in C++.
|
|
92
|
+
const inputs = await makeAvmCircuitInputs();
|
|
93
|
+
const rawVkPath = path.join(proofRes.vkPath, 'vk');
|
|
94
|
+
return await verifyAvmProofV2(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath, inputs.publicInputs, rawVkPath, this.logger);
|
|
95
|
+
}
|
|
96
|
+
async simProveVerifyV2(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender) {
|
|
97
|
+
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer);
|
|
98
|
+
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
99
|
+
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
100
|
+
const provingRes = await this.proveV2(avmCircuitInputs);
|
|
101
|
+
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
102
|
+
const verificationRes = await this.verifyV2(provingRes);
|
|
103
|
+
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
104
|
+
}
|
|
105
|
+
}
|
package/dest/bb/cli.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
import type { ProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
3
|
+
import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
export declare const ProtocolCircuitArtifacts: Record<ProtocolArtifact, NoirCompiledCircuit>;
|
|
6
|
+
/**
|
|
7
|
+
* Returns commander program that defines the CLI.
|
|
8
|
+
* @param log - Console logger.
|
|
9
|
+
* @returns The CLI.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getProgram(log: LogFn): Command;
|
|
12
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/bb/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAGlF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,CAa9C"}
|
package/dest/bb/cli.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ClientCircuitArtifacts } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
2
|
+
import { ServerCircuitArtifacts } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
export const ProtocolCircuitArtifacts = {
|
|
5
|
+
...ClientCircuitArtifacts,
|
|
6
|
+
...ServerCircuitArtifacts
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Returns commander program that defines the CLI.
|
|
10
|
+
* @param log - Console logger.
|
|
11
|
+
* @returns The CLI.
|
|
12
|
+
*/ export function getProgram(log) {
|
|
13
|
+
const program = new Command('bb-cli');
|
|
14
|
+
program.description('CLI for interacting with Barretenberg.');
|
|
15
|
+
program.command('protocol-circuits').description('Lists the available protocol circuit artifacts').action(()=>{
|
|
16
|
+
log(Object.keys(ProtocolCircuitArtifacts).reduce((prev, x)=>prev.concat(`\n${x}`)));
|
|
17
|
+
});
|
|
18
|
+
return program;
|
|
19
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
5
|
+
import type { UltraHonkFlavor } from '../honk.js';
|
|
6
|
+
export declare const VK_FILENAME = "vk";
|
|
7
|
+
export declare const VK_FIELDS_FILENAME = "vk_fields.json";
|
|
8
|
+
export declare const PROOF_FILENAME = "proof";
|
|
9
|
+
export declare const PROOF_FIELDS_FILENAME = "proof_fields.json";
|
|
10
|
+
export declare const AVM_INPUTS_FILENAME = "avm_inputs.bin";
|
|
11
|
+
export declare const AVM_BYTECODE_FILENAME = "avm_bytecode.bin";
|
|
12
|
+
export declare const AVM_PUBLIC_INPUTS_FILENAME = "avm_public_inputs.bin";
|
|
13
|
+
export declare const AVM_HINTS_FILENAME = "avm_hints.bin";
|
|
14
|
+
export declare enum BB_RESULT {
|
|
15
|
+
SUCCESS = 0,
|
|
16
|
+
FAILURE = 1,
|
|
17
|
+
ALREADY_PRESENT = 2
|
|
18
|
+
}
|
|
19
|
+
export type BBSuccess = {
|
|
20
|
+
status: BB_RESULT.SUCCESS | BB_RESULT.ALREADY_PRESENT;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
/** Full path of the public key. */
|
|
23
|
+
pkPath?: string;
|
|
24
|
+
/** Base directory for the VKs (raw, fields). */
|
|
25
|
+
vkPath?: string;
|
|
26
|
+
/** Full path of the proof. */
|
|
27
|
+
proofPath?: string;
|
|
28
|
+
/** Full path of the contract. */
|
|
29
|
+
contractPath?: string;
|
|
30
|
+
/** The number of gates in the circuit. */
|
|
31
|
+
circuitSize?: number;
|
|
32
|
+
};
|
|
33
|
+
export type BBFailure = {
|
|
34
|
+
status: BB_RESULT.FAILURE;
|
|
35
|
+
reason: string;
|
|
36
|
+
retry?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type BBResult = BBSuccess | BBFailure;
|
|
39
|
+
export type VerificationFunction = typeof verifyProof | typeof verifyAvmProof;
|
|
40
|
+
type BBExecResult = {
|
|
41
|
+
status: BB_RESULT;
|
|
42
|
+
exitCode: number;
|
|
43
|
+
signal: string | undefined;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Invokes the Barretenberg binary with the provided command and args
|
|
47
|
+
* @param pathToBB - The path to the BB binary
|
|
48
|
+
* @param command - The command to execute
|
|
49
|
+
* @param args - The arguments to pass
|
|
50
|
+
* @param logger - A log function
|
|
51
|
+
* @param resultParser - An optional handler for detecting success or failure
|
|
52
|
+
* @returns The completed partial witness outputted from the circuit
|
|
53
|
+
*/
|
|
54
|
+
export declare function executeBB(pathToBB: string, command: string, args: string[], logger: LogFn, resultParser?: (code: number) => boolean): Promise<BBExecResult>;
|
|
55
|
+
export declare function executeBbClientIvcProof(pathToBB: string, workingDirectory: string, bytecodeStackPath: string, witnessStackPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
56
|
+
/**
|
|
57
|
+
* Used for generating proofs of noir circuits.
|
|
58
|
+
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
59
|
+
* @param pathToBB - The full path to the bb binary
|
|
60
|
+
* @param workingDirectory - A working directory for use by bb
|
|
61
|
+
* @param circuitName - An identifier for the circuit
|
|
62
|
+
* @param bytecode - The compiled circuit bytecode
|
|
63
|
+
* @param inputWitnessFile - The circuit input witness
|
|
64
|
+
* @param log - A logging function
|
|
65
|
+
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
66
|
+
*/
|
|
67
|
+
export declare function generateProof(pathToBB: string, workingDirectory: string, circuitName: string, bytecode: Buffer, recursive: boolean, inputWitnessFile: string, flavor: UltraHonkFlavor, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
68
|
+
/**
|
|
69
|
+
* Used for generating proofs of the tube circuit
|
|
70
|
+
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
71
|
+
* @param pathToBB - The full path to the bb binary
|
|
72
|
+
* @param workingDirectory - A working directory for use by bb
|
|
73
|
+
* @param circuitName - An identifier for the circuit
|
|
74
|
+
* @param bytecode - The compiled circuit bytecode
|
|
75
|
+
* @param inputWitnessFile - The circuit input witness
|
|
76
|
+
* @param log - A logging function
|
|
77
|
+
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
78
|
+
*/
|
|
79
|
+
export declare function generateTubeProof(pathToBB: string, workingDirectory: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
80
|
+
/**
|
|
81
|
+
* Used for generating AVM proofs.
|
|
82
|
+
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
83
|
+
* @param pathToBB - The full path to the bb binary
|
|
84
|
+
* @param workingDirectory - A working directory for use by bb
|
|
85
|
+
* @param input - The inputs for the public function to be proven
|
|
86
|
+
* @param log - A logging function
|
|
87
|
+
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
88
|
+
*/
|
|
89
|
+
export declare function generateAvmProofV2(pathToBB: string, workingDirectory: string, input: AvmCircuitInputs, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
90
|
+
/**
|
|
91
|
+
* Used for generating AVM proofs (or doing check-circuit).
|
|
92
|
+
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
93
|
+
* @param pathToBB - The full path to the bb binary
|
|
94
|
+
* @param workingDirectory - A working directory for use by bb
|
|
95
|
+
* @param bytecode - The AVM bytecode for the public function to be proven (expected to be decompressed)
|
|
96
|
+
* @param log - A logging function
|
|
97
|
+
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
98
|
+
*/
|
|
99
|
+
export declare function generateAvmProof(pathToBB: string, workingDirectory: string, _input: AvmCircuitInputs, logger: Logger, checkCircuitOnly?: boolean): Promise<BBFailure | BBSuccess>;
|
|
100
|
+
/**
|
|
101
|
+
* Used for verifying proofs of noir circuits
|
|
102
|
+
* @param pathToBB - The full path to the bb binary
|
|
103
|
+
* @param proofFullPath - The full path to the proof to be verified
|
|
104
|
+
* @param verificationKeyPath - The full path to the circuit verification key
|
|
105
|
+
* @param log - A logging function
|
|
106
|
+
* @returns An object containing a result indication and duration taken
|
|
107
|
+
*/
|
|
108
|
+
export declare function verifyProof(pathToBB: string, proofFullPath: string, verificationKeyPath: string, ultraHonkFlavor: UltraHonkFlavor, log: Logger): Promise<BBFailure | BBSuccess>;
|
|
109
|
+
/**
|
|
110
|
+
* Used for verifying proofs of the AVM
|
|
111
|
+
* @param pathToBB - The full path to the bb binary
|
|
112
|
+
* @param proofFullPath - The full path to the proof to be verified
|
|
113
|
+
* @param verificationKeyPath - The full path to the circuit verification key
|
|
114
|
+
* @param log - A logging function
|
|
115
|
+
* @returns An object containing a result indication and duration taken
|
|
116
|
+
*/
|
|
117
|
+
export declare function verifyAvmProof(pathToBB: string, proofFullPath: string, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
118
|
+
export declare function verifyAvmProofV2(pathToBB: string, workingDirectory: string, proofFullPath: string, publicInputs: AvmCircuitPublicInputs, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
119
|
+
/**
|
|
120
|
+
* Verifies a ClientIvcProof
|
|
121
|
+
* TODO(#7370) The verification keys should be supplied separately
|
|
122
|
+
* @param pathToBB - The full path to the bb binary
|
|
123
|
+
* @param targetPath - The path to the folder with the proof, accumulator, and verification keys
|
|
124
|
+
* @param log - A logging function
|
|
125
|
+
* @returns An object containing a result indication and duration taken
|
|
126
|
+
*/
|
|
127
|
+
export declare function verifyClientIvcProof(pathToBB: string, proofPath: string, keyPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
128
|
+
export declare function generateContractForVerificationKey(pathToBB: string, vkFilePath: string, contractPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
129
|
+
/**
|
|
130
|
+
* Compute bb gate count for a given circuit
|
|
131
|
+
* @param pathToBB - The full path to the bb binary
|
|
132
|
+
* @param workingDirectory - A temporary directory for writing the bytecode
|
|
133
|
+
* @param circuitName - The name of the circuit
|
|
134
|
+
* @param bytecode - The bytecode of the circuit
|
|
135
|
+
* @param flavor - The flavor of the backend - mega_honk or ultra_honk variants
|
|
136
|
+
* @returns An object containing the status, gate count, and time taken
|
|
137
|
+
*/
|
|
138
|
+
export declare function computeGateCountForCircuit(pathToBB: string, workingDirectory: string, circuitName: string, bytecode: Buffer, flavor: UltraHonkFlavor | 'mega_honk', log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/bb/execute.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAMlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,cAAc,UAAU,CAAC;AACtC,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AACxD,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAClE,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD,oBAAY,SAAS;IACnB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,eAAe,IAAA;CAChB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,eAAe,CAAC;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,SAAS,CAAC,OAAO,C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