@aztec/bb-prover 0.0.1-commit.24de95ac → 0.0.1-commit.2606882
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 +15 -11
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +167 -108
- package/dest/bb/bb_js_backend.d.ts +196 -0
- package/dest/bb/bb_js_backend.d.ts.map +1 -0
- package/dest/bb/bb_js_backend.js +379 -0
- package/dest/bb/bb_js_debug.d.ts +52 -0
- package/dest/bb/bb_js_debug.d.ts.map +1 -0
- package/dest/bb/bb_js_debug.js +176 -0
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/file_names.d.ts +4 -0
- package/dest/bb/file_names.d.ts.map +1 -0
- package/dest/bb/file_names.js +5 -0
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +17 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/honk.d.ts +1 -1
- package/dest/index.d.ts +3 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -1
- package/dest/instrumentation.d.ts +1 -1
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +21 -43
- package/dest/prover/client/bb_private_kernel_prover.d.ts +20 -6
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +73 -8
- 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 +11 -1
- package/dest/prover/proof_utils.d.ts.map +1 -1
- package/dest/prover/proof_utils.js +25 -2
- package/dest/prover/server/bb_prover.d.ts +8 -21
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +614 -112
- package/dest/test/delay_values.d.ts +1 -1
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +29 -27
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/test_circuit_prover.d.ts +4 -4
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +462 -59
- 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 -8
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +2 -21
- package/dest/verifier/batch_chonk_verifier.d.ts +56 -0
- package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/batch_chonk_verifier.js +384 -0
- package/dest/verifier/bb_verifier.d.ts +4 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +137 -48
- package/dest/verifier/index.d.ts +2 -1
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- package/dest/verifier/queued_chonk_verifier.d.ts +2 -3
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
- package/dest/verifier/queued_chonk_verifier.js +15 -45
- package/package.json +26 -23
- package/src/avm_proving_tests/avm_proving_tester.ts +69 -138
- package/src/bb/bb_js_backend.ts +435 -0
- package/src/bb/bb_js_debug.ts +227 -0
- package/src/bb/file_names.ts +6 -0
- package/src/config.ts +16 -0
- package/src/index.ts +2 -1
- package/src/instrumentation.ts +20 -43
- package/src/prover/client/bb_private_kernel_prover.ts +158 -8
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/proof_utils.ts +42 -2
- package/src/prover/server/bb_prover.ts +139 -159
- package/src/test/delay_values.ts +31 -27
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +10 -13
- package/src/test/test_verifier.ts +8 -0
- package/src/verification_key/verification_key_data.ts +2 -27
- package/src/verifier/batch_chonk_verifier.ts +415 -0
- package/src/verifier/bb_verifier.ts +69 -80
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_chonk_verifier.ts +15 -47
- package/dest/bb/execute.d.ts +0 -107
- package/dest/bb/execute.d.ts.map +0 -1
- package/dest/bb/execute.js +0 -672
- 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/src/bb/execute.ts +0 -709
- package/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -105
- package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -58
- package/src/prover/client/wasm/bundle.ts +0 -11
- package/src/prover/client/wasm/lazy.ts +0 -11
package/src/index.ts
CHANGED
|
@@ -2,7 +2,8 @@ export * from './prover/index.js';
|
|
|
2
2
|
export * from './test/index.js';
|
|
3
3
|
export * from './verifier/index.js';
|
|
4
4
|
export * from './config.js';
|
|
5
|
-
export * from './bb/
|
|
5
|
+
export * from './bb/file_names.js';
|
|
6
|
+
export * from './bb/bb_js_backend.js';
|
|
6
7
|
export * from './honk.js';
|
|
7
8
|
export * from './verification_key/verification_key_data.js';
|
|
8
9
|
|
package/src/instrumentation.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
Metrics,
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type Tracer,
|
|
10
|
-
ValueType,
|
|
11
10
|
} from '@aztec/telemetry-client';
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -31,51 +30,21 @@ export class ProverInstrumentation {
|
|
|
31
30
|
this.tracer = telemetry.getTracer(name);
|
|
32
31
|
const meter = telemetry.getMeter(name);
|
|
33
32
|
|
|
34
|
-
this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION
|
|
35
|
-
description: 'Records how long it takes to simulate a circuit',
|
|
36
|
-
unit: 'ms',
|
|
37
|
-
valueType: ValueType.INT,
|
|
38
|
-
});
|
|
33
|
+
this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION);
|
|
39
34
|
|
|
40
|
-
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION
|
|
41
|
-
description: 'Records how long it takes to generate the partial witness for a circuit',
|
|
42
|
-
unit: 's',
|
|
43
|
-
valueType: ValueType.DOUBLE,
|
|
44
|
-
});
|
|
35
|
+
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION);
|
|
45
36
|
|
|
46
|
-
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION
|
|
47
|
-
unit: 's',
|
|
48
|
-
description: 'Records how long it takes to prove a circuit',
|
|
49
|
-
valueType: ValueType.DOUBLE,
|
|
50
|
-
});
|
|
37
|
+
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION);
|
|
51
38
|
|
|
52
|
-
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE
|
|
53
|
-
unit: 'By',
|
|
54
|
-
description: 'Records the size of the input to the witness generation',
|
|
55
|
-
valueType: ValueType.INT,
|
|
56
|
-
});
|
|
39
|
+
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE);
|
|
57
40
|
|
|
58
|
-
this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE
|
|
59
|
-
unit: 'By',
|
|
60
|
-
description: 'Records the size of the output of the witness generation',
|
|
61
|
-
valueType: ValueType.INT,
|
|
62
|
-
});
|
|
41
|
+
this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE);
|
|
63
42
|
|
|
64
|
-
this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE
|
|
65
|
-
unit: 'By',
|
|
66
|
-
description: 'Records the size of the proof generated for a circuit',
|
|
67
|
-
valueType: ValueType.INT,
|
|
68
|
-
});
|
|
43
|
+
this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE);
|
|
69
44
|
|
|
70
|
-
this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT
|
|
71
|
-
description: 'Records the number of public inputs in a circuit',
|
|
72
|
-
valueType: ValueType.INT,
|
|
73
|
-
});
|
|
45
|
+
this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT);
|
|
74
46
|
|
|
75
|
-
this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE
|
|
76
|
-
description: 'Records the size of the circuit in gates',
|
|
77
|
-
valueType: ValueType.INT,
|
|
78
|
-
});
|
|
47
|
+
this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE);
|
|
79
48
|
}
|
|
80
49
|
|
|
81
50
|
/**
|
|
@@ -89,10 +58,18 @@ export class ProverInstrumentation {
|
|
|
89
58
|
circuitName: CircuitName,
|
|
90
59
|
timerOrMS: Timer | number,
|
|
91
60
|
) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
61
|
+
// Simulation duration is stored in ms, while the others are stored in seconds
|
|
62
|
+
if (metric === 'simulationDuration') {
|
|
63
|
+
const ms = typeof timerOrMS === 'number' ? timerOrMS : timerOrMS.ms();
|
|
64
|
+
this[metric].record(Math.trunc(ms), {
|
|
65
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
|
|
69
|
+
this[metric].record(s, {
|
|
70
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
96
73
|
}
|
|
97
74
|
|
|
98
75
|
/**
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AztecClientBackend, type BackendOptions, Barretenberg } from '@aztec/bb.js';
|
|
2
|
+
import { type LogLevel, type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
2
5
|
import {
|
|
3
6
|
convertHidingKernelPublicInputsToWitnessMapWithAbi,
|
|
4
7
|
convertHidingKernelToRollupInputsToWitnessMapWithAbi,
|
|
8
|
+
convertPrivateKernelInit2InputsToWitnessMapWithAbi,
|
|
9
|
+
convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
|
|
10
|
+
convertPrivateKernelInit3InputsToWitnessMapWithAbi,
|
|
11
|
+
convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
|
|
5
12
|
convertPrivateKernelInitInputsToWitnessMapWithAbi,
|
|
6
13
|
convertPrivateKernelInitOutputsFromWitnessMapWithAbi,
|
|
14
|
+
convertPrivateKernelInner2InputsToWitnessMapWithAbi,
|
|
15
|
+
convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
|
|
16
|
+
convertPrivateKernelInner3InputsToWitnessMapWithAbi,
|
|
17
|
+
convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
|
|
7
18
|
convertPrivateKernelInnerInputsToWitnessMapWithAbi,
|
|
8
19
|
convertPrivateKernelInnerOutputsFromWitnessMapWithAbi,
|
|
9
20
|
convertPrivateKernelResetInputsToWitnessMapWithAbi,
|
|
@@ -29,7 +40,11 @@ import type {
|
|
|
29
40
|
HidingKernelToRollupPrivateInputs,
|
|
30
41
|
PrivateExecutionStep,
|
|
31
42
|
PrivateKernelCircuitPublicInputs,
|
|
43
|
+
PrivateKernelInit2CircuitPrivateInputs,
|
|
44
|
+
PrivateKernelInit3CircuitPrivateInputs,
|
|
32
45
|
PrivateKernelInitCircuitPrivateInputs,
|
|
46
|
+
PrivateKernelInner2CircuitPrivateInputs,
|
|
47
|
+
PrivateKernelInner3CircuitPrivateInputs,
|
|
33
48
|
PrivateKernelInnerCircuitPrivateInputs,
|
|
34
49
|
PrivateKernelResetCircuitPrivateInputs,
|
|
35
50
|
PrivateKernelSimulateOutput,
|
|
@@ -37,15 +52,22 @@ import type {
|
|
|
37
52
|
PrivateKernelTailCircuitPublicInputs,
|
|
38
53
|
} from '@aztec/stdlib/kernel';
|
|
39
54
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
40
|
-
import
|
|
55
|
+
import { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
41
56
|
import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
42
57
|
|
|
58
|
+
import { ungzip } from 'pako';
|
|
59
|
+
|
|
60
|
+
export type BBPrivateKernelProverOptions = Omit<BackendOptions, 'logger'> & { logger?: Logger };
|
|
43
61
|
export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
62
|
+
private log: Logger;
|
|
63
|
+
|
|
44
64
|
constructor(
|
|
45
65
|
protected artifactProvider: ArtifactProvider,
|
|
46
66
|
protected simulator: CircuitSimulator,
|
|
47
|
-
protected
|
|
48
|
-
) {
|
|
67
|
+
protected options: BBPrivateKernelProverOptions = {},
|
|
68
|
+
) {
|
|
69
|
+
this.log = options.logger || createLogger('bb-prover:private-kernel');
|
|
70
|
+
}
|
|
49
71
|
|
|
50
72
|
public async generateInitOutput(
|
|
51
73
|
inputs: PrivateKernelInitCircuitPrivateInputs,
|
|
@@ -69,6 +91,50 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
69
91
|
);
|
|
70
92
|
}
|
|
71
93
|
|
|
94
|
+
public async generateInit2Output(
|
|
95
|
+
inputs: PrivateKernelInit2CircuitPrivateInputs,
|
|
96
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
97
|
+
return await this.generateCircuitOutput(
|
|
98
|
+
inputs,
|
|
99
|
+
'PrivateKernelInit2Artifact',
|
|
100
|
+
convertPrivateKernelInit2InputsToWitnessMapWithAbi,
|
|
101
|
+
convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public async simulateInit2(
|
|
106
|
+
inputs: PrivateKernelInit2CircuitPrivateInputs,
|
|
107
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
108
|
+
return await this.simulateCircuitOutput(
|
|
109
|
+
inputs,
|
|
110
|
+
'PrivateKernelInit2Artifact',
|
|
111
|
+
convertPrivateKernelInit2InputsToWitnessMapWithAbi,
|
|
112
|
+
convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public async generateInit3Output(
|
|
117
|
+
inputs: PrivateKernelInit3CircuitPrivateInputs,
|
|
118
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
119
|
+
return await this.generateCircuitOutput(
|
|
120
|
+
inputs,
|
|
121
|
+
'PrivateKernelInit3Artifact',
|
|
122
|
+
convertPrivateKernelInit3InputsToWitnessMapWithAbi,
|
|
123
|
+
convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public async simulateInit3(
|
|
128
|
+
inputs: PrivateKernelInit3CircuitPrivateInputs,
|
|
129
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
130
|
+
return await this.simulateCircuitOutput(
|
|
131
|
+
inputs,
|
|
132
|
+
'PrivateKernelInit3Artifact',
|
|
133
|
+
convertPrivateKernelInit3InputsToWitnessMapWithAbi,
|
|
134
|
+
convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
72
138
|
public async generateInnerOutput(
|
|
73
139
|
inputs: PrivateKernelInnerCircuitPrivateInputs,
|
|
74
140
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
@@ -91,6 +157,50 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
91
157
|
);
|
|
92
158
|
}
|
|
93
159
|
|
|
160
|
+
public async generateInner2Output(
|
|
161
|
+
inputs: PrivateKernelInner2CircuitPrivateInputs,
|
|
162
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
163
|
+
return await this.generateCircuitOutput(
|
|
164
|
+
inputs,
|
|
165
|
+
'PrivateKernelInner2Artifact',
|
|
166
|
+
convertPrivateKernelInner2InputsToWitnessMapWithAbi,
|
|
167
|
+
convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public async simulateInner2(
|
|
172
|
+
inputs: PrivateKernelInner2CircuitPrivateInputs,
|
|
173
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
174
|
+
return await this.simulateCircuitOutput(
|
|
175
|
+
inputs,
|
|
176
|
+
'PrivateKernelInner2Artifact',
|
|
177
|
+
convertPrivateKernelInner2InputsToWitnessMapWithAbi,
|
|
178
|
+
convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public async generateInner3Output(
|
|
183
|
+
inputs: PrivateKernelInner3CircuitPrivateInputs,
|
|
184
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
185
|
+
return await this.generateCircuitOutput(
|
|
186
|
+
inputs,
|
|
187
|
+
'PrivateKernelInner3Artifact',
|
|
188
|
+
convertPrivateKernelInner3InputsToWitnessMapWithAbi,
|
|
189
|
+
convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public async simulateInner3(
|
|
194
|
+
inputs: PrivateKernelInner3CircuitPrivateInputs,
|
|
195
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
196
|
+
return await this.simulateCircuitOutput(
|
|
197
|
+
inputs,
|
|
198
|
+
'PrivateKernelInner3Artifact',
|
|
199
|
+
convertPrivateKernelInner3InputsToWitnessMapWithAbi,
|
|
200
|
+
convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
94
204
|
public async generateResetOutput(
|
|
95
205
|
inputs: PrivateKernelResetCircuitPrivateInputs,
|
|
96
206
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
@@ -263,11 +373,51 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
263
373
|
return kernelProofOutput;
|
|
264
374
|
}
|
|
265
375
|
|
|
266
|
-
public createChonkProof(
|
|
267
|
-
|
|
376
|
+
public async createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs> {
|
|
377
|
+
const timer = new Timer();
|
|
378
|
+
this.log.info(`Generating ClientIVC proof...`);
|
|
379
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
380
|
+
...this.options,
|
|
381
|
+
logger: this.options.logger?.verbose,
|
|
382
|
+
});
|
|
383
|
+
const backend = new AztecClientBackend(
|
|
384
|
+
executionSteps.map(step => ungzip(step.bytecode)),
|
|
385
|
+
barretenberg,
|
|
386
|
+
executionSteps.map(step => step.functionName),
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
// Use compressed prove path to get both proof fields and compressed proof bytes
|
|
390
|
+
const result = await backend.prove(
|
|
391
|
+
executionSteps.map(step => ungzip(serializeWitness(step.witness))),
|
|
392
|
+
executionSteps.map(step => step.vk),
|
|
393
|
+
{ compress: true },
|
|
394
|
+
);
|
|
395
|
+
this.log.info(`Generated ClientIVC proof`, {
|
|
396
|
+
eventName: 'client-ivc-proof-generation',
|
|
397
|
+
duration: timer.ms(),
|
|
398
|
+
proofSize: result.proofFields.length,
|
|
399
|
+
compressedSize: result.compressedProof?.length,
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// Create ChonkProofWithPublicInputs from the flat field elements
|
|
403
|
+
const proofWithPubInputs = ChonkProofWithPublicInputs.fromBufferArray(result.proofFields);
|
|
404
|
+
|
|
405
|
+
// Attach compressed proof bytes to the ChonkProof (without public inputs).
|
|
406
|
+
// The compressed bytes are for the full proof WITH public inputs from bb;
|
|
407
|
+
// when deserializing, the decompressor will strip them to match CHONK_PROOF_LENGTH.
|
|
408
|
+
proofWithPubInputs.compressedProof = result.compressedProof ? Buffer.from(result.compressedProof) : undefined;
|
|
409
|
+
|
|
410
|
+
return proofWithPubInputs;
|
|
268
411
|
}
|
|
269
412
|
|
|
270
|
-
public computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
271
|
-
|
|
413
|
+
public async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
414
|
+
// Note we do not pass the vk to the backend. This is unneeded for gate counts.
|
|
415
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
416
|
+
...this.options,
|
|
417
|
+
logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
|
|
418
|
+
});
|
|
419
|
+
const backend = new AztecClientBackend([ungzip(_bytecode)], barretenberg, [_circuitName]);
|
|
420
|
+
const gateCount = await backend.gates();
|
|
421
|
+
return gateCount[0];
|
|
272
422
|
}
|
|
273
423
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
2
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
5
|
+
|
|
6
|
+
export class BBBundlePrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new BundleArtifactProvider(), simulator, options);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
2
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
5
|
+
|
|
6
|
+
export class BBLazyPrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new LazyArtifactProvider(), simulator, options);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
PAIRING_POINTS_SIZE,
|
|
8
8
|
ULTRA_KECCAK_PROOF_LENGTH,
|
|
9
9
|
} from '@aztec/constants';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
12
12
|
import { ChonkProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
13
13
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
@@ -16,7 +16,7 @@ import assert from 'assert';
|
|
|
16
16
|
import { promises as fs } from 'fs';
|
|
17
17
|
import * as path from 'path';
|
|
18
18
|
|
|
19
|
-
import { PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/
|
|
19
|
+
import { PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/file_names.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Create a ChonkProof proof file.
|
|
@@ -113,3 +113,43 @@ export async function readProofsFromOutputDirectory<PROOF_LENGTH extends number>
|
|
|
113
113
|
proofLength,
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Construct a RecursiveProof from in-memory proof and public input field arrays
|
|
119
|
+
* returned by the bb.js circuitProve API, without reading from files.
|
|
120
|
+
*
|
|
121
|
+
* @param proofFields - Proof fields as 32-byte Uint8Arrays from circuitProve.
|
|
122
|
+
* @param publicInputFields - Public input fields as 32-byte Uint8Arrays from circuitProve.
|
|
123
|
+
* @param vkData - Verification key data for the circuit.
|
|
124
|
+
* @param proofLength - Expected proof field count.
|
|
125
|
+
*/
|
|
126
|
+
export function constructRecursiveProofFromBuffers<PROOF_LENGTH extends number>(
|
|
127
|
+
proofFields: Uint8Array[],
|
|
128
|
+
publicInputFields: Uint8Array[],
|
|
129
|
+
vkData: VerificationKeyData,
|
|
130
|
+
proofLength: PROOF_LENGTH,
|
|
131
|
+
): RecursiveProof<PROOF_LENGTH> {
|
|
132
|
+
assert(
|
|
133
|
+
proofLength == NESTED_RECURSIVE_PROOF_LENGTH ||
|
|
134
|
+
proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH ||
|
|
135
|
+
proofLength == ULTRA_KECCAK_PROOF_LENGTH,
|
|
136
|
+
`Proof length must be one of the expected proof lengths, received ${proofLength}`,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// Convert Uint8Array fields to Fr instances
|
|
140
|
+
const proofFieldsFr = proofFields.map(f => Fr.fromBuffer(Buffer.from(f)));
|
|
141
|
+
|
|
142
|
+
assert(
|
|
143
|
+
proofFieldsFr.length == proofLength,
|
|
144
|
+
`Proof fields length mismatch: ${proofFieldsFr.length} != ${proofLength}`,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Reconstruct the binary proof with public inputs prepended (same format as file-based path)
|
|
148
|
+
const binaryPublicInputs = Buffer.concat(publicInputFields.map(f => Buffer.from(f)));
|
|
149
|
+
const binaryProof = Buffer.concat(proofFields.map(f => Buffer.from(f)));
|
|
150
|
+
const binaryProofWithPublicInputs = Buffer.concat([binaryPublicInputs, binaryProof]);
|
|
151
|
+
|
|
152
|
+
const numPublicInputs = getNumCustomPublicInputs(proofLength, vkData);
|
|
153
|
+
|
|
154
|
+
return new RecursiveProof(proofFieldsFr, new Proof(binaryProofWithPublicInputs, numPublicInputs), true, proofLength);
|
|
155
|
+
}
|