@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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bb/index.ts"],"names":[],"mappings":";AAGA,OAAO,gCAAgC,CAAC"}
|
package/dest/bb/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
import { createConsoleLogger } from '@aztec/foundation/log';
|
|
3
|
+
import 'source-map-support/register.js';
|
|
4
|
+
import { getProgram } from './cli.js';
|
|
5
|
+
const log = createConsoleLogger();
|
|
6
|
+
/** CLI main entrypoint */ async function main() {
|
|
7
|
+
process.once('SIGINT', ()=>process.exit(0));
|
|
8
|
+
process.once('SIGTERM', ()=>process.exit(0));
|
|
9
|
+
const program = getProgram(log);
|
|
10
|
+
await program.parseAsync(process.argv);
|
|
11
|
+
}
|
|
12
|
+
main().catch((err)=>{
|
|
13
|
+
log(`Error in command execution`);
|
|
14
|
+
log(err);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
});
|
package/dest/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface BBConfig {
|
|
2
|
+
bbBinaryPath: string;
|
|
3
|
+
bbWorkingDirectory: string;
|
|
4
|
+
/** Whether to skip tmp dir cleanup for debugging purposes */
|
|
5
|
+
bbSkipCleanup: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ACVMConfig {
|
|
8
|
+
/** The path to the ACVM binary */
|
|
9
|
+
acvmBinaryPath: string;
|
|
10
|
+
/** The working directory to use for simulation/proving */
|
|
11
|
+
acvmWorkingDirectory: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
|
package/dest/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dest/honk.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
2
|
+
export type UltraHonkFlavor = 'ultra_honk' | 'ultra_keccak_honk' | 'ultra_rollup_honk';
|
|
3
|
+
declare const UltraKeccakHonkCircuits: ["RootRollupArtifact"];
|
|
4
|
+
declare const UltraHonkCircuits: ["BaseParityArtifact", "RootParityArtifact"];
|
|
5
|
+
export type UltraKeccakHonkServerProtocolArtifact = (typeof UltraKeccakHonkCircuits)[number];
|
|
6
|
+
export type UltraHonkServerProtocolArtifact = (typeof UltraHonkCircuits)[number];
|
|
7
|
+
export type UltraRollupHonkServerProtocolArtifact = Exclude<Exclude<ServerProtocolArtifact, UltraKeccakHonkServerProtocolArtifact>, UltraHonkServerProtocolArtifact>;
|
|
8
|
+
export declare function getUltraHonkFlavorForCircuit(artifact: UltraKeccakHonkServerProtocolArtifact): 'ultra_keccak_honk';
|
|
9
|
+
export declare function getUltraHonkFlavorForCircuit(artifact: UltraHonkServerProtocolArtifact): 'ultra_honk';
|
|
10
|
+
export declare function getUltraHonkFlavorForCircuit(artifact: UltraRollupHonkServerProtocolArtifact): 'ultra_rollup_honk';
|
|
11
|
+
export declare function getUltraHonkFlavorForCircuit(artifact: ServerProtocolArtifact): UltraHonkFlavor;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=honk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honk.d.ts","sourceRoot":"","sources":["../src/honk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAEvF,QAAA,MAAM,uBAAuB,wBAAqE,CAAC;AACnG,QAAA,MAAM,iBAAiB,8CAA2F,CAAC;AAEnH,MAAM,MAAM,qCAAqC,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7F,MAAM,MAAM,+BAA+B,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjF,MAAM,MAAM,qCAAqC,GAAG,OAAO,CACzD,OAAO,CAAC,sBAAsB,EAAE,qCAAqC,CAAC,EACtE,+BAA+B,CAChC,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,qCAAqC,GAAG,mBAAmB,CAAC;AACnH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,+BAA+B,GAAG,YAAY,CAAC;AACtG,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,qCAAqC,GAAG,mBAAmB,CAAC;AACnH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,sBAAsB,GAAG,eAAe,CAAC"}
|
package/dest/honk.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const UltraKeccakHonkCircuits = [
|
|
2
|
+
'RootRollupArtifact'
|
|
3
|
+
];
|
|
4
|
+
const UltraHonkCircuits = [
|
|
5
|
+
'BaseParityArtifact',
|
|
6
|
+
'RootParityArtifact'
|
|
7
|
+
];
|
|
8
|
+
export function getUltraHonkFlavorForCircuit(artifact) {
|
|
9
|
+
if (isUltraKeccakHonkCircuit(artifact)) {
|
|
10
|
+
return 'ultra_keccak_honk';
|
|
11
|
+
} else if (UltraHonkCircuits.includes(artifact)) {
|
|
12
|
+
return 'ultra_honk';
|
|
13
|
+
}
|
|
14
|
+
return 'ultra_rollup_honk';
|
|
15
|
+
}
|
|
16
|
+
function isUltraKeccakHonkCircuit(artifact) {
|
|
17
|
+
return UltraKeccakHonkCircuits.includes(artifact);
|
|
18
|
+
}
|
package/dest/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './prover/index.js';
|
|
2
|
+
export * from './test/index.js';
|
|
3
|
+
export * from './verifier/index.js';
|
|
4
|
+
export * from './config.js';
|
|
5
|
+
export * from './bb/execute.js';
|
|
6
|
+
export * from './honk.js';
|
|
7
|
+
export { type ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dest/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
+
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
3
|
+
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
4
|
+
/**
|
|
5
|
+
* Instrumentation class for Prover implementations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ProverInstrumentation {
|
|
8
|
+
private simulationDuration;
|
|
9
|
+
private witGenDuration;
|
|
10
|
+
private provingDuration;
|
|
11
|
+
private witGenInputSize;
|
|
12
|
+
private witGenOutputSize;
|
|
13
|
+
private proofSize;
|
|
14
|
+
private circuitSize;
|
|
15
|
+
private circuitPublicInputCount;
|
|
16
|
+
readonly tracer: Tracer;
|
|
17
|
+
constructor(telemetry: TelemetryClient, name: string);
|
|
18
|
+
/**
|
|
19
|
+
* Records the duration of a circuit operation.
|
|
20
|
+
* @param metric - The metric to record
|
|
21
|
+
* @param circuitName - The name of the circuit
|
|
22
|
+
* @param timerOrMS - The duration
|
|
23
|
+
*/
|
|
24
|
+
recordDuration(metric: 'simulationDuration' | 'witGenDuration' | 'provingDuration', circuitName: CircuitName | 'tubeCircuit', timerOrMS: Timer | number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Records the duration of an AVM circuit operation.
|
|
27
|
+
* @param metric - The metric to record
|
|
28
|
+
* @param appCircuitName - The name of the function circuit (should be a `contract:function` string)
|
|
29
|
+
* @param timerOrMS - The duration
|
|
30
|
+
*/
|
|
31
|
+
recordAvmDuration(metric: 'witGenDuration' | 'provingDuration', appCircuitName: string, timerOrMS: Timer | number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Records the size of a circuit operation.
|
|
34
|
+
* @param metric - Records the size of a circuit operation.
|
|
35
|
+
* @param circuitName - The name of the circuit
|
|
36
|
+
* @param size - The size
|
|
37
|
+
*/
|
|
38
|
+
recordSize(metric: 'witGenInputSize' | 'witGenOutputSize' | 'proofSize' | 'circuitSize' | 'circuitPublicInputCount', circuitName: CircuitName | 'tubeCircuit', size: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Records the size of an AVM circuit operation.
|
|
41
|
+
* @param metric - The metric to record
|
|
42
|
+
* @param appCircuitName - The name of the function circuit (should be a `contract:function` string)
|
|
43
|
+
* @param size - The size
|
|
44
|
+
*/
|
|
45
|
+
recordAvmSize(metric: 'witGenInputSize' | 'witGenOutputSize' | 'proofSize' | 'circuitSize' | 'circuitPublicInputCount', appCircuitName: string, size: number): void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,MAAM,EAEZ,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,eAAe,CAAY;IAEnC,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,gBAAgB,CAAQ;IAEhC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,uBAAuB,CAAQ;IAEvC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAmDpD;;;;;OAKG;IACH,cAAc,CACZ,MAAM,EAAE,oBAAoB,GAAG,gBAAgB,GAAG,iBAAiB,EACnE,WAAW,EAAE,WAAW,GAAG,aAAa,EACxC,SAAS,EAAE,KAAK,GAAG,MAAM;IAS3B;;;;;OAKG;IACH,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAOjH;;;;;OAKG;IACH,UAAU,CACR,MAAM,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,WAAW,GAAG,aAAa,GAAG,yBAAyB,EACxG,WAAW,EAAE,WAAW,GAAG,aAAa,EACxC,IAAI,EAAE,MAAM;IAQd;;;;;OAKG;IACH,aAAa,CACX,MAAM,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,WAAW,GAAG,aAAa,GAAG,yBAAyB,EACxG,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM;CAMf"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
2
|
+
/**
|
|
3
|
+
* Instrumentation class for Prover implementations.
|
|
4
|
+
*/ export class ProverInstrumentation {
|
|
5
|
+
simulationDuration;
|
|
6
|
+
witGenDuration;
|
|
7
|
+
provingDuration;
|
|
8
|
+
witGenInputSize;
|
|
9
|
+
witGenOutputSize;
|
|
10
|
+
proofSize;
|
|
11
|
+
circuitSize;
|
|
12
|
+
circuitPublicInputCount;
|
|
13
|
+
tracer;
|
|
14
|
+
constructor(telemetry, name){
|
|
15
|
+
this.tracer = telemetry.getTracer(name);
|
|
16
|
+
const meter = telemetry.getMeter(name);
|
|
17
|
+
this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION, {
|
|
18
|
+
description: 'Records how long it takes to simulate a circuit',
|
|
19
|
+
unit: 'ms',
|
|
20
|
+
valueType: ValueType.INT
|
|
21
|
+
});
|
|
22
|
+
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION, {
|
|
23
|
+
description: 'Records how long it takes to generate the partial witness for a circuit',
|
|
24
|
+
unit: 's',
|
|
25
|
+
valueType: ValueType.DOUBLE
|
|
26
|
+
});
|
|
27
|
+
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION, {
|
|
28
|
+
unit: 's',
|
|
29
|
+
description: 'Records how long it takes to prove a circuit',
|
|
30
|
+
valueType: ValueType.DOUBLE
|
|
31
|
+
});
|
|
32
|
+
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE, {
|
|
33
|
+
unit: 'By',
|
|
34
|
+
description: 'Records the size of the input to the witness generation',
|
|
35
|
+
valueType: ValueType.INT
|
|
36
|
+
});
|
|
37
|
+
this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE, {
|
|
38
|
+
unit: 'By',
|
|
39
|
+
description: 'Records the size of the output of the witness generation',
|
|
40
|
+
valueType: ValueType.INT
|
|
41
|
+
});
|
|
42
|
+
this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE, {
|
|
43
|
+
unit: 'By',
|
|
44
|
+
description: 'Records the size of the proof generated for a circuit',
|
|
45
|
+
valueType: ValueType.INT
|
|
46
|
+
});
|
|
47
|
+
this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT, {
|
|
48
|
+
description: 'Records the number of public inputs in a circuit',
|
|
49
|
+
valueType: ValueType.INT
|
|
50
|
+
});
|
|
51
|
+
this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE, {
|
|
52
|
+
description: 'Records the size of the circuit in gates',
|
|
53
|
+
valueType: ValueType.INT
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Records the duration of a circuit operation.
|
|
58
|
+
* @param metric - The metric to record
|
|
59
|
+
* @param circuitName - The name of the circuit
|
|
60
|
+
* @param timerOrMS - The duration
|
|
61
|
+
*/ recordDuration(metric, circuitName, timerOrMS) {
|
|
62
|
+
const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
|
|
63
|
+
this[metric].record(s, {
|
|
64
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
|
|
65
|
+
[Attributes.PROTOCOL_CIRCUIT_TYPE]: 'server'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Records the duration of an AVM circuit operation.
|
|
70
|
+
* @param metric - The metric to record
|
|
71
|
+
* @param appCircuitName - The name of the function circuit (should be a `contract:function` string)
|
|
72
|
+
* @param timerOrMS - The duration
|
|
73
|
+
*/ recordAvmDuration(metric, appCircuitName, timerOrMS) {
|
|
74
|
+
const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
|
|
75
|
+
this[metric].record(s, {
|
|
76
|
+
[Attributes.APP_CIRCUIT_NAME]: appCircuitName
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Records the size of a circuit operation.
|
|
81
|
+
* @param metric - Records the size of a circuit operation.
|
|
82
|
+
* @param circuitName - The name of the circuit
|
|
83
|
+
* @param size - The size
|
|
84
|
+
*/ recordSize(metric, circuitName, size) {
|
|
85
|
+
this[metric].record(Math.ceil(size), {
|
|
86
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
|
|
87
|
+
[Attributes.PROTOCOL_CIRCUIT_TYPE]: 'server'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Records the size of an AVM circuit operation.
|
|
92
|
+
* @param metric - The metric to record
|
|
93
|
+
* @param appCircuitName - The name of the function circuit (should be a `contract:function` string)
|
|
94
|
+
* @param size - The size
|
|
95
|
+
*/ recordAvmSize(metric, appCircuitName, size) {
|
|
96
|
+
this[metric].record(Math.ceil(size), {
|
|
97
|
+
[Attributes.APP_CIRCUIT_NAME]: appCircuitName
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { SimulationProvider } from '@aztec/simulator/server';
|
|
5
|
+
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
6
|
+
import type { WitnessMap } from '@noir-lang/types';
|
|
7
|
+
import type { BBConfig } from '../config.js';
|
|
8
|
+
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
9
|
+
/**
|
|
10
|
+
* This proof creator implementation uses the native bb binary.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
13
|
+
private bbBinaryPath;
|
|
14
|
+
private bbWorkingDirectory;
|
|
15
|
+
private skipCleanup;
|
|
16
|
+
protected simulationProvider: SimulationProvider;
|
|
17
|
+
protected log: Logger;
|
|
18
|
+
private constructor();
|
|
19
|
+
static new(config: BBConfig, simulationProvider: SimulationProvider, log?: Logger): Promise<BBNativePrivateKernelProver>;
|
|
20
|
+
private _createClientIvcProof;
|
|
21
|
+
createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof>;
|
|
22
|
+
computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number>;
|
|
23
|
+
private runInDirectory;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=bb_native_private_kernel_prover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bb_native_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_native_private_kernel_prover.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,qBAAqB;IAElE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,WAAW;cACA,kBAAkB,EAAE,kBAAkB;cACtC,GAAG;IALxB,OAAO;WAUa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,CAAC,EAAE,MAAM;YAWhF,qBAAqB;IAmCb,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ1F,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxG,OAAO,CAAC,cAAc;CAavB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { encode } from '@msgpack/msgpack';
|
|
5
|
+
import { serializeWitness } from '@noir-lang/noirc_abi';
|
|
6
|
+
import { promises as fs } from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../bb/execute.js';
|
|
9
|
+
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
10
|
+
import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
|
|
11
|
+
/**
|
|
12
|
+
* This proof creator implementation uses the native bb binary.
|
|
13
|
+
*/ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
14
|
+
bbBinaryPath;
|
|
15
|
+
bbWorkingDirectory;
|
|
16
|
+
skipCleanup;
|
|
17
|
+
simulationProvider;
|
|
18
|
+
log;
|
|
19
|
+
constructor(bbBinaryPath, bbWorkingDirectory, skipCleanup, simulationProvider, log = createLogger('bb-prover:native')){
|
|
20
|
+
super(new BundleArtifactProvider(), simulationProvider, log), this.bbBinaryPath = bbBinaryPath, this.bbWorkingDirectory = bbWorkingDirectory, this.skipCleanup = skipCleanup, this.simulationProvider = simulationProvider, this.log = log;
|
|
21
|
+
}
|
|
22
|
+
static async new(config, simulationProvider, log) {
|
|
23
|
+
await fs.mkdir(config.bbWorkingDirectory, {
|
|
24
|
+
recursive: true
|
|
25
|
+
});
|
|
26
|
+
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulationProvider, log);
|
|
27
|
+
}
|
|
28
|
+
async _createClientIvcProof(directory, acirs, witnessStack) {
|
|
29
|
+
// TODO(#7371): Longer term we won't use this hacked together msgpack format
|
|
30
|
+
// and instead properly create the bincode serialization from rust
|
|
31
|
+
await fs.writeFile(path.join(directory, 'acir.msgpack'), encode(acirs));
|
|
32
|
+
await fs.writeFile(path.join(directory, 'witnesses.msgpack'), encode(witnessStack.map((map)=>serializeWitness(map))));
|
|
33
|
+
const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, path.join(directory, 'acir.msgpack'), path.join(directory, 'witnesses.msgpack'), this.log.info);
|
|
34
|
+
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
35
|
+
this.log.error(`Failed to generate client ivc proof`);
|
|
36
|
+
throw new Error(provingResult.reason);
|
|
37
|
+
}
|
|
38
|
+
const proof = await readFromOutputDirectory(directory);
|
|
39
|
+
this.log.info(`Generated IVC proof`, {
|
|
40
|
+
duration: provingResult.durationMs,
|
|
41
|
+
eventName: 'circuit-proving'
|
|
42
|
+
});
|
|
43
|
+
return proof;
|
|
44
|
+
}
|
|
45
|
+
async createClientIvcProof(acirs, witnessStack) {
|
|
46
|
+
this.log.info(`Generating Client IVC proof`);
|
|
47
|
+
const operation = async (directory)=>{
|
|
48
|
+
return await this._createClientIvcProof(directory, acirs, witnessStack);
|
|
49
|
+
};
|
|
50
|
+
return await this.runInDirectory(operation);
|
|
51
|
+
}
|
|
52
|
+
async computeGateCountForCircuit(bytecode, circuitName) {
|
|
53
|
+
const logFunction = (message)=>{
|
|
54
|
+
this.log.debug(`$bb gates ${circuitName} - ${message}`);
|
|
55
|
+
};
|
|
56
|
+
const result = await computeGateCountForCircuit(this.bbBinaryPath, this.bbWorkingDirectory, circuitName, bytecode, 'mega_honk', logFunction);
|
|
57
|
+
if (result.status === BB_RESULT.FAILURE) {
|
|
58
|
+
throw new Error(result.reason);
|
|
59
|
+
}
|
|
60
|
+
return result.circuitSize;
|
|
61
|
+
}
|
|
62
|
+
runInDirectory(fn) {
|
|
63
|
+
const log = this.log;
|
|
64
|
+
return runInDirectory(this.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
|
|
65
|
+
log.error(`Error running operation at ${dir}: ${err}`);
|
|
66
|
+
throw err;
|
|
67
|
+
}), this.skipCleanup, this.log);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { ArtifactProvider, ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
4
|
+
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
5
|
+
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
6
|
+
import type { PrivateKernelCircuitPublicInputs, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelResetCircuitPrivateInputs, PrivateKernelSimulateOutput, PrivateKernelTailCircuitPrivateInputs, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
7
|
+
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
8
|
+
import type { Abi, WitnessMap } from '@noir-lang/types';
|
|
9
|
+
export declare abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
10
|
+
protected artifactProvider: ArtifactProvider;
|
|
11
|
+
protected simulationProvider: SimulationProvider;
|
|
12
|
+
protected log: import("@aztec/foundation/log").Logger;
|
|
13
|
+
constructor(artifactProvider: ArtifactProvider, simulationProvider: SimulationProvider, log?: import("@aztec/foundation/log").Logger);
|
|
14
|
+
generateInitOutput(inputs: PrivateKernelInitCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
15
|
+
simulateInit(inputs: PrivateKernelInitCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
16
|
+
generateInnerOutput(inputs: PrivateKernelInnerCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
17
|
+
simulateInner(inputs: PrivateKernelInnerCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
18
|
+
generateResetOutput(inputs: PrivateKernelResetCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
19
|
+
simulateReset(inputs: PrivateKernelResetCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
20
|
+
generateTailOutput(inputs: PrivateKernelTailCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
21
|
+
simulateTail(inputs: PrivateKernelTailCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
22
|
+
simulateCircuitOutput<I extends {
|
|
23
|
+
toBuffer: () => Buffer;
|
|
24
|
+
}, O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs>(inputs: I, circuitType: ClientProtocolArtifact, convertInputs: (inputs: I, abi: Abi) => WitnessMap, convertOutputs: (outputs: WitnessMap, abi: Abi) => O): Promise<PrivateKernelSimulateOutput<O>>;
|
|
25
|
+
generateCircuitOutput<I extends {
|
|
26
|
+
toBuffer: () => Buffer;
|
|
27
|
+
}, O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs>(inputs: I, circuitType: ClientProtocolArtifact, convertInputs: (inputs: I, abi: Abi) => WitnessMap, convertOutputs: (outputs: WitnessMap, abi: Abi) => O): Promise<PrivateKernelSimulateOutput<O>>;
|
|
28
|
+
makeEmptyKernelSimulateOutput<PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs>(publicInputs: PublicInputsType, circuitType: ClientProtocolArtifact): Promise<PrivateKernelSimulateOutput<PublicInputsType>>;
|
|
29
|
+
createClientIvcProof(_acirs: Buffer[], _witnessStack: WitnessMap[]): Promise<ClientIvcProof>;
|
|
30
|
+
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=bb_private_kernel_prover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bb_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_private_kernel_prover.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
3
|
+
import { convertPrivateKernelInitInputsToWitnessMapWithAbi, convertPrivateKernelInitOutputsFromWitnessMapWithAbi, convertPrivateKernelInnerInputsToWitnessMapWithAbi, convertPrivateKernelInnerOutputsFromWitnessMapWithAbi, convertPrivateKernelResetInputsToWitnessMapWithAbi, convertPrivateKernelResetOutputsFromWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi, convertPrivateKernelTailInputsToWitnessMapWithAbi, convertPrivateKernelTailOutputsFromWitnessMapWithAbi, convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi, getPrivateKernelResetArtifactName, updateResetCircuitSampleInputs } from '@aztec/noir-protocol-circuits-types/client';
|
|
4
|
+
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
5
|
+
export class BBPrivateKernelProver {
|
|
6
|
+
artifactProvider;
|
|
7
|
+
simulationProvider;
|
|
8
|
+
log;
|
|
9
|
+
constructor(artifactProvider, simulationProvider, log = createLogger('bb-prover')){
|
|
10
|
+
this.artifactProvider = artifactProvider;
|
|
11
|
+
this.simulationProvider = simulationProvider;
|
|
12
|
+
this.log = log;
|
|
13
|
+
}
|
|
14
|
+
async generateInitOutput(inputs) {
|
|
15
|
+
return await this.generateCircuitOutput(inputs, 'PrivateKernelInitArtifact', convertPrivateKernelInitInputsToWitnessMapWithAbi, convertPrivateKernelInitOutputsFromWitnessMapWithAbi);
|
|
16
|
+
}
|
|
17
|
+
async simulateInit(inputs) {
|
|
18
|
+
return await this.simulateCircuitOutput(inputs, 'PrivateKernelInitArtifact', convertPrivateKernelInitInputsToWitnessMapWithAbi, convertPrivateKernelInitOutputsFromWitnessMapWithAbi);
|
|
19
|
+
}
|
|
20
|
+
async generateInnerOutput(inputs) {
|
|
21
|
+
return await this.generateCircuitOutput(inputs, 'PrivateKernelInnerArtifact', convertPrivateKernelInnerInputsToWitnessMapWithAbi, convertPrivateKernelInnerOutputsFromWitnessMapWithAbi);
|
|
22
|
+
}
|
|
23
|
+
async simulateInner(inputs) {
|
|
24
|
+
return await this.simulateCircuitOutput(inputs, 'PrivateKernelInnerArtifact', convertPrivateKernelInnerInputsToWitnessMapWithAbi, convertPrivateKernelInnerOutputsFromWitnessMapWithAbi);
|
|
25
|
+
}
|
|
26
|
+
async generateResetOutput(inputs) {
|
|
27
|
+
const variantInputs = inputs.trimToSizes();
|
|
28
|
+
const artifactName = getPrivateKernelResetArtifactName(inputs.dimensions);
|
|
29
|
+
return await this.generateCircuitOutput(variantInputs, artifactName, convertPrivateKernelResetInputsToWitnessMapWithAbi, convertPrivateKernelResetOutputsFromWitnessMapWithAbi);
|
|
30
|
+
}
|
|
31
|
+
async simulateReset(inputs) {
|
|
32
|
+
updateResetCircuitSampleInputs(inputs);
|
|
33
|
+
const variantInputs = inputs.trimToSizes();
|
|
34
|
+
const artifactName = getPrivateKernelResetArtifactName(inputs.dimensions);
|
|
35
|
+
return await this.simulateCircuitOutput(variantInputs, artifactName, convertPrivateKernelResetInputsToWitnessMapWithAbi, convertPrivateKernelResetOutputsFromWitnessMapWithAbi);
|
|
36
|
+
}
|
|
37
|
+
async generateTailOutput(inputs) {
|
|
38
|
+
if (!inputs.isForPublic()) {
|
|
39
|
+
return await this.generateCircuitOutput(inputs, 'PrivateKernelTailArtifact', convertPrivateKernelTailInputsToWitnessMapWithAbi, convertPrivateKernelTailOutputsFromWitnessMapWithAbi);
|
|
40
|
+
}
|
|
41
|
+
return await this.generateCircuitOutput(inputs, 'PrivateKernelTailToPublicArtifact', convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi);
|
|
42
|
+
}
|
|
43
|
+
async simulateTail(inputs) {
|
|
44
|
+
if (!inputs.isForPublic()) {
|
|
45
|
+
return await this.simulateCircuitOutput(inputs, 'PrivateKernelTailArtifact', convertPrivateKernelTailInputsToWitnessMapWithAbi, convertPrivateKernelTailOutputsFromWitnessMapWithAbi);
|
|
46
|
+
}
|
|
47
|
+
return await this.simulateCircuitOutput(inputs, 'PrivateKernelTailToPublicArtifact', convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi);
|
|
48
|
+
}
|
|
49
|
+
async simulateCircuitOutput(inputs, circuitType, convertInputs, convertOutputs) {
|
|
50
|
+
const compiledCircuit = await this.artifactProvider.getSimulatedClientCircuitArtifactByName(circuitType);
|
|
51
|
+
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
52
|
+
const timer = new Timer();
|
|
53
|
+
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit).catch((err)=>{
|
|
54
|
+
this.log.debug(`Failed to simulate ${circuitType}`, {
|
|
55
|
+
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
56
|
+
error: err
|
|
57
|
+
});
|
|
58
|
+
throw err;
|
|
59
|
+
});
|
|
60
|
+
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
61
|
+
this.log.debug(`Simulated ${circuitType}`, {
|
|
62
|
+
eventName: 'circuit-simulation',
|
|
63
|
+
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
64
|
+
duration: timer.ms(),
|
|
65
|
+
inputSize: inputs.toBuffer().length,
|
|
66
|
+
outputSize: output.toBuffer().length
|
|
67
|
+
});
|
|
68
|
+
return this.makeEmptyKernelSimulateOutput(output, circuitType);
|
|
69
|
+
}
|
|
70
|
+
async generateCircuitOutput(inputs, circuitType, convertInputs, convertOutputs) {
|
|
71
|
+
this.log.debug(`Generating witness for ${circuitType}`);
|
|
72
|
+
const compiledCircuit = await this.artifactProvider.getClientCircuitArtifactByName(circuitType);
|
|
73
|
+
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
74
|
+
const timer = new Timer();
|
|
75
|
+
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit);
|
|
76
|
+
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
77
|
+
this.log.debug(`Generated witness for ${circuitType}`, {
|
|
78
|
+
eventName: 'circuit-witness-generation',
|
|
79
|
+
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
80
|
+
duration: timer.ms(),
|
|
81
|
+
inputSize: inputs.toBuffer().length,
|
|
82
|
+
outputSize: output.toBuffer().length
|
|
83
|
+
});
|
|
84
|
+
const verificationKey = (await this.artifactProvider.getCircuitVkByName(circuitType)).keyAsFields;
|
|
85
|
+
const bytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
86
|
+
const kernelOutput = {
|
|
87
|
+
publicInputs: output,
|
|
88
|
+
verificationKey,
|
|
89
|
+
outputWitness,
|
|
90
|
+
bytecode
|
|
91
|
+
};
|
|
92
|
+
return kernelOutput;
|
|
93
|
+
}
|
|
94
|
+
async makeEmptyKernelSimulateOutput(publicInputs, circuitType) {
|
|
95
|
+
const kernelProofOutput = {
|
|
96
|
+
publicInputs,
|
|
97
|
+
verificationKey: (await this.artifactProvider.getCircuitVkByName(circuitType)).keyAsFields,
|
|
98
|
+
outputWitness: new Map(),
|
|
99
|
+
bytecode: Buffer.from([])
|
|
100
|
+
};
|
|
101
|
+
return kernelProofOutput;
|
|
102
|
+
}
|
|
103
|
+
createClientIvcProof(_acirs, _witnessStack) {
|
|
104
|
+
throw new Error('Not implemented');
|
|
105
|
+
}
|
|
106
|
+
computeGateCountForCircuit(_bytecode, _circuitName) {
|
|
107
|
+
throw new Error('Not implemented');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AVM_PROOF_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
|
|
2
|
+
import { type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
|
+
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
4
|
+
import { type ProofAndVerificationKey, type PublicInputsAndRecursiveProof, type ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
import type { BaseParityInputs, ParityPublicInputs, RootParityInputs } from '@aztec/stdlib/parity';
|
|
6
|
+
import { Proof } from '@aztec/stdlib/proofs';
|
|
7
|
+
import type { BaseOrMergeRollupPublicInputs, BlockMergeRollupInputs, BlockRootOrBlockMergePublicInputs, BlockRootRollupInputs, EmptyBlockRootRollupInputs, MergeRollupInputs, PrivateBaseRollupInputs, PublicBaseRollupInputs, RootRollupInputs, RootRollupPublicInputs, SingleTxBlockRootRollupInputs, TubeInputs } from '@aztec/stdlib/rollup';
|
|
8
|
+
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
9
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
+
import type { ACVMConfig, BBConfig } from '../config.js';
|
|
11
|
+
import { type UltraHonkFlavor } from '../honk.js';
|
|
12
|
+
export interface BBProverConfig extends BBConfig, ACVMConfig {
|
|
13
|
+
circuitFilter?: ServerProtocolArtifact[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Prover implementation that uses barretenberg native proving
|
|
17
|
+
*/
|
|
18
|
+
export declare class BBNativeRollupProver implements ServerCircuitProver {
|
|
19
|
+
private config;
|
|
20
|
+
private instrumentation;
|
|
21
|
+
constructor(config: BBProverConfig, telemetry: TelemetryClient);
|
|
22
|
+
get tracer(): import("@aztec/telemetry-client").Tracer;
|
|
23
|
+
static new(config: BBProverConfig, telemetry?: TelemetryClient): Promise<BBNativeRollupProver>;
|
|
24
|
+
/**
|
|
25
|
+
* Simulates the base parity circuit from its inputs.
|
|
26
|
+
* @param inputs - Inputs to the circuit.
|
|
27
|
+
* @returns The public inputs of the parity circuit.
|
|
28
|
+
*/
|
|
29
|
+
getBaseParityProof(inputs: BaseParityInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>>;
|
|
30
|
+
/**
|
|
31
|
+
* Simulates the root parity circuit from its inputs.
|
|
32
|
+
* @param inputs - Inputs to the circuit.
|
|
33
|
+
* @returns The public inputs of the parity circuit.
|
|
34
|
+
*/
|
|
35
|
+
getRootParityProof(inputs: RootParityInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates an AVM proof and verifies it.
|
|
38
|
+
* @param inputs - The inputs to the AVM circuit.
|
|
39
|
+
* @returns The proof.
|
|
40
|
+
*/
|
|
41
|
+
getAvmProof(inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>>;
|
|
42
|
+
/**
|
|
43
|
+
* Simulates the base rollup circuit from its inputs.
|
|
44
|
+
* @param inputs - Inputs to the circuit.
|
|
45
|
+
* @returns The public inputs as outputs of the simulation.
|
|
46
|
+
*/
|
|
47
|
+
getPrivateBaseRollupProof(inputs: PrivateBaseRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
48
|
+
/**
|
|
49
|
+
* Requests that the public kernel tail circuit be executed and the proof generated
|
|
50
|
+
* @param kernelRequest - The object encapsulating the request for a proof
|
|
51
|
+
* @returns The requested circuit's public inputs and proof
|
|
52
|
+
*/
|
|
53
|
+
getPublicBaseRollupProof(inputs: PublicBaseRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
54
|
+
/**
|
|
55
|
+
* Simulates the merge rollup circuit from its inputs.
|
|
56
|
+
* @param input - Inputs to the circuit.
|
|
57
|
+
* @returns The public inputs as outputs of the simulation.
|
|
58
|
+
*/
|
|
59
|
+
getMergeRollupProof(input: MergeRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
60
|
+
/**
|
|
61
|
+
* Simulates the block root rollup circuit from its inputs.
|
|
62
|
+
* @param input - Inputs to the circuit.
|
|
63
|
+
* @returns The public inputs as outputs of the simulation.
|
|
64
|
+
*/
|
|
65
|
+
getBlockRootRollupProof(input: BlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
66
|
+
getSingleTxBlockRootRollupProof(input: SingleTxBlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
67
|
+
/**
|
|
68
|
+
* Simulates the empty block root rollup circuit from its inputs.
|
|
69
|
+
* @param input - Inputs to the circuit.
|
|
70
|
+
* @returns The public inputs as outputs of the simulation.
|
|
71
|
+
*/
|
|
72
|
+
getEmptyBlockRootRollupProof(input: EmptyBlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
73
|
+
/**
|
|
74
|
+
* Simulates the block merge rollup circuit from its inputs.
|
|
75
|
+
* @param input - Inputs to the circuit.
|
|
76
|
+
* @returns The public inputs as outputs of the simulation.
|
|
77
|
+
*/
|
|
78
|
+
getBlockMergeRollupProof(input: BlockMergeRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
79
|
+
/**
|
|
80
|
+
* Simulates the root rollup circuit from its inputs.
|
|
81
|
+
* @param input - Inputs to the circuit.
|
|
82
|
+
* @returns The public inputs as outputs of the simulation.
|
|
83
|
+
*/
|
|
84
|
+
getRootRollupProof(input: RootRollupInputs): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>>;
|
|
85
|
+
private generateProofWithBB;
|
|
86
|
+
private createProof;
|
|
87
|
+
private generateAvmProofWithBB;
|
|
88
|
+
private generateTubeProofWithBB;
|
|
89
|
+
private createAvmProof;
|
|
90
|
+
getTubeProof(input: TubeInputs): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>>;
|
|
91
|
+
/**
|
|
92
|
+
* Executes a circuit and returns its outputs and corresponding proof with embedded aggregation object
|
|
93
|
+
* @param witnessMap - The input witness
|
|
94
|
+
* @param circuitType - The type of circuit to be executed
|
|
95
|
+
* @param proofLength - The length of the proof to be generated. This is a dummy parameter to aid in type checking
|
|
96
|
+
* @param convertInput - Function for mapping the input object to a witness map.
|
|
97
|
+
* @param convertOutput - Function for parsing the output witness to it's corresponding object
|
|
98
|
+
* @returns The circuits output object and it's proof
|
|
99
|
+
*/
|
|
100
|
+
private createRecursiveProof;
|
|
101
|
+
/**
|
|
102
|
+
* Verifies a proof, will generate the verification key if one is not cached internally
|
|
103
|
+
* @param circuitType - The type of circuit whose proof is to be verified
|
|
104
|
+
* @param proof - The proof to be verified
|
|
105
|
+
*/
|
|
106
|
+
verifyProof(circuitType: ServerProtocolArtifact, proof: Proof): Promise<void>;
|
|
107
|
+
verifyAvmProof(proof: Proof, verificationKey: VerificationKeyData): Promise<void>;
|
|
108
|
+
verifyWithKey(flavor: UltraHonkFlavor, verificationKey: VerificationKeyData, proof: Proof): Promise<void>;
|
|
109
|
+
private verifyWithKeyInternal;
|
|
110
|
+
/**
|
|
111
|
+
* Returns the verification key data for a circuit.
|
|
112
|
+
* @param circuitType - The type of circuit for which the verification key is required
|
|
113
|
+
* @returns The verification key data
|
|
114
|
+
*/
|
|
115
|
+
private getVerificationKeyDataForCircuit;
|
|
116
|
+
private readProofAsFields;
|
|
117
|
+
private readAvmProofAsFields;
|
|
118
|
+
private runInDirectory;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=bb_prover.d.ts.map
|