@aztec/bb-prover 0.0.1-commit.9ef841308 → 0.0.1-commit.a5db02d
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 +9 -5
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +147 -105
- 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 +385 -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/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/config.d.ts +7 -2
- package/dest/config.d.ts.map +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/prover/client/bb_private_kernel_prover.d.ts +12 -4
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +33 -7
- 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 +24 -1
- package/dest/prover/server/bb_prover.d.ts +6 -7
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +210 -79
- package/dest/test/test_circuit_prover.d.ts +3 -3
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +2 -2
- package/dest/verification_key/verification_key_data.js +1 -1
- 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 +134 -45
- package/package.json +18 -17
- package/src/avm_proving_tests/avm_proving_tester.ts +46 -127
- package/src/bb/bb_js_backend.ts +441 -0
- package/src/bb/bb_js_debug.ts +227 -0
- package/src/bb/file_names.ts +6 -0
- package/src/config.ts +6 -1
- package/src/index.ts +2 -1
- package/src/prover/client/bb_private_kernel_prover.ts +118 -15
- package/src/prover/proof_utils.ts +41 -1
- package/src/prover/server/bb_prover.ts +130 -141
- package/src/test/test_circuit_prover.ts +3 -5
- package/src/verification_key/verification_key_data.ts +1 -1
- package/src/verifier/bb_verifier.ts +66 -76
- package/dest/bb/execute.d.ts +0 -108
- package/dest/bb/execute.d.ts.map +0 -1
- package/dest/bb/execute.js +0 -652
- package/src/bb/execute.ts +0 -687
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
|
|
|
@@ -5,18 +5,27 @@ import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
|
5
5
|
import {
|
|
6
6
|
convertHidingKernelPublicInputsToWitnessMapWithAbi,
|
|
7
7
|
convertHidingKernelToRollupInputsToWitnessMapWithAbi,
|
|
8
|
+
convertPrivateKernelInit2InputsToWitnessMapWithAbi,
|
|
9
|
+
convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
|
|
10
|
+
convertPrivateKernelInit3InputsToWitnessMapWithAbi,
|
|
11
|
+
convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
|
|
8
12
|
convertPrivateKernelInitInputsToWitnessMapWithAbi,
|
|
9
13
|
convertPrivateKernelInitOutputsFromWitnessMapWithAbi,
|
|
14
|
+
convertPrivateKernelInner2InputsToWitnessMapWithAbi,
|
|
15
|
+
convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
|
|
16
|
+
convertPrivateKernelInner3InputsToWitnessMapWithAbi,
|
|
17
|
+
convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
|
|
10
18
|
convertPrivateKernelInnerInputsToWitnessMapWithAbi,
|
|
11
19
|
convertPrivateKernelInnerOutputsFromWitnessMapWithAbi,
|
|
12
20
|
convertPrivateKernelResetInputsToWitnessMapWithAbi,
|
|
13
21
|
convertPrivateKernelResetOutputsFromWitnessMapWithAbi,
|
|
22
|
+
convertPrivateKernelResetTailInputsToWitnessMapWithAbi,
|
|
23
|
+
convertPrivateKernelResetTailToPublicInputsToWitnessMapWithAbi,
|
|
14
24
|
convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
|
|
15
|
-
convertPrivateKernelTailInputsToWitnessMapWithAbi,
|
|
16
25
|
convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
|
|
17
|
-
convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
|
|
18
26
|
foreignCallHandler,
|
|
19
27
|
getPrivateKernelResetArtifactName,
|
|
28
|
+
getPrivateKernelResetTailArtifactName,
|
|
20
29
|
updateResetCircuitSampleInputs,
|
|
21
30
|
} from '@aztec/noir-protocol-circuits-types/client';
|
|
22
31
|
import {
|
|
@@ -32,11 +41,15 @@ import type {
|
|
|
32
41
|
HidingKernelToRollupPrivateInputs,
|
|
33
42
|
PrivateExecutionStep,
|
|
34
43
|
PrivateKernelCircuitPublicInputs,
|
|
44
|
+
PrivateKernelInit2CircuitPrivateInputs,
|
|
45
|
+
PrivateKernelInit3CircuitPrivateInputs,
|
|
35
46
|
PrivateKernelInitCircuitPrivateInputs,
|
|
47
|
+
PrivateKernelInner2CircuitPrivateInputs,
|
|
48
|
+
PrivateKernelInner3CircuitPrivateInputs,
|
|
36
49
|
PrivateKernelInnerCircuitPrivateInputs,
|
|
37
50
|
PrivateKernelResetCircuitPrivateInputs,
|
|
51
|
+
PrivateKernelResetTailCircuitPrivateInputs,
|
|
38
52
|
PrivateKernelSimulateOutput,
|
|
39
|
-
PrivateKernelTailCircuitPrivateInputs,
|
|
40
53
|
PrivateKernelTailCircuitPublicInputs,
|
|
41
54
|
} from '@aztec/stdlib/kernel';
|
|
42
55
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
@@ -79,6 +92,50 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
79
92
|
);
|
|
80
93
|
}
|
|
81
94
|
|
|
95
|
+
public async generateInit2Output(
|
|
96
|
+
inputs: PrivateKernelInit2CircuitPrivateInputs,
|
|
97
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
98
|
+
return await this.generateCircuitOutput(
|
|
99
|
+
inputs,
|
|
100
|
+
'PrivateKernelInit2Artifact',
|
|
101
|
+
convertPrivateKernelInit2InputsToWitnessMapWithAbi,
|
|
102
|
+
convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public async simulateInit2(
|
|
107
|
+
inputs: PrivateKernelInit2CircuitPrivateInputs,
|
|
108
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
109
|
+
return await this.simulateCircuitOutput(
|
|
110
|
+
inputs,
|
|
111
|
+
'PrivateKernelInit2Artifact',
|
|
112
|
+
convertPrivateKernelInit2InputsToWitnessMapWithAbi,
|
|
113
|
+
convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public async generateInit3Output(
|
|
118
|
+
inputs: PrivateKernelInit3CircuitPrivateInputs,
|
|
119
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
120
|
+
return await this.generateCircuitOutput(
|
|
121
|
+
inputs,
|
|
122
|
+
'PrivateKernelInit3Artifact',
|
|
123
|
+
convertPrivateKernelInit3InputsToWitnessMapWithAbi,
|
|
124
|
+
convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public async simulateInit3(
|
|
129
|
+
inputs: PrivateKernelInit3CircuitPrivateInputs,
|
|
130
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
131
|
+
return await this.simulateCircuitOutput(
|
|
132
|
+
inputs,
|
|
133
|
+
'PrivateKernelInit3Artifact',
|
|
134
|
+
convertPrivateKernelInit3InputsToWitnessMapWithAbi,
|
|
135
|
+
convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
82
139
|
public async generateInnerOutput(
|
|
83
140
|
inputs: PrivateKernelInnerCircuitPrivateInputs,
|
|
84
141
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
@@ -101,6 +158,50 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
101
158
|
);
|
|
102
159
|
}
|
|
103
160
|
|
|
161
|
+
public async generateInner2Output(
|
|
162
|
+
inputs: PrivateKernelInner2CircuitPrivateInputs,
|
|
163
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
164
|
+
return await this.generateCircuitOutput(
|
|
165
|
+
inputs,
|
|
166
|
+
'PrivateKernelInner2Artifact',
|
|
167
|
+
convertPrivateKernelInner2InputsToWitnessMapWithAbi,
|
|
168
|
+
convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public async simulateInner2(
|
|
173
|
+
inputs: PrivateKernelInner2CircuitPrivateInputs,
|
|
174
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
175
|
+
return await this.simulateCircuitOutput(
|
|
176
|
+
inputs,
|
|
177
|
+
'PrivateKernelInner2Artifact',
|
|
178
|
+
convertPrivateKernelInner2InputsToWitnessMapWithAbi,
|
|
179
|
+
convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public async generateInner3Output(
|
|
184
|
+
inputs: PrivateKernelInner3CircuitPrivateInputs,
|
|
185
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
186
|
+
return await this.generateCircuitOutput(
|
|
187
|
+
inputs,
|
|
188
|
+
'PrivateKernelInner3Artifact',
|
|
189
|
+
convertPrivateKernelInner3InputsToWitnessMapWithAbi,
|
|
190
|
+
convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public async simulateInner3(
|
|
195
|
+
inputs: PrivateKernelInner3CircuitPrivateInputs,
|
|
196
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
197
|
+
return await this.simulateCircuitOutput(
|
|
198
|
+
inputs,
|
|
199
|
+
'PrivateKernelInner3Artifact',
|
|
200
|
+
convertPrivateKernelInner3InputsToWitnessMapWithAbi,
|
|
201
|
+
convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
104
205
|
public async generateResetOutput(
|
|
105
206
|
inputs: PrivateKernelResetCircuitPrivateInputs,
|
|
106
207
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
|
|
@@ -128,40 +229,42 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
128
229
|
);
|
|
129
230
|
}
|
|
130
231
|
|
|
131
|
-
public async
|
|
132
|
-
inputs:
|
|
232
|
+
public async generateResetTailOutput(
|
|
233
|
+
inputs: PrivateKernelResetTailCircuitPrivateInputs,
|
|
133
234
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
235
|
+
const artifactName = getPrivateKernelResetTailArtifactName(inputs.dimensions, inputs.isForPublic());
|
|
134
236
|
if (!inputs.isForPublic()) {
|
|
135
237
|
return await this.generateCircuitOutput(
|
|
136
238
|
inputs,
|
|
137
|
-
|
|
138
|
-
|
|
239
|
+
artifactName,
|
|
240
|
+
convertPrivateKernelResetTailInputsToWitnessMapWithAbi,
|
|
139
241
|
convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
|
|
140
242
|
);
|
|
141
243
|
}
|
|
142
244
|
return await this.generateCircuitOutput(
|
|
143
245
|
inputs,
|
|
144
|
-
|
|
145
|
-
|
|
246
|
+
artifactName,
|
|
247
|
+
convertPrivateKernelResetTailToPublicInputsToWitnessMapWithAbi,
|
|
146
248
|
convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
|
|
147
249
|
);
|
|
148
250
|
}
|
|
149
251
|
|
|
150
|
-
public async
|
|
151
|
-
inputs:
|
|
252
|
+
public async simulateResetTail(
|
|
253
|
+
inputs: PrivateKernelResetTailCircuitPrivateInputs,
|
|
152
254
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
255
|
+
const artifactName = getPrivateKernelResetTailArtifactName(inputs.dimensions, inputs.isForPublic());
|
|
153
256
|
if (!inputs.isForPublic()) {
|
|
154
257
|
return await this.simulateCircuitOutput(
|
|
155
258
|
inputs,
|
|
156
|
-
|
|
157
|
-
|
|
259
|
+
artifactName,
|
|
260
|
+
convertPrivateKernelResetTailInputsToWitnessMapWithAbi,
|
|
158
261
|
convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
|
|
159
262
|
);
|
|
160
263
|
}
|
|
161
264
|
return await this.simulateCircuitOutput(
|
|
162
265
|
inputs,
|
|
163
|
-
|
|
164
|
-
|
|
266
|
+
artifactName,
|
|
267
|
+
convertPrivateKernelResetTailToPublicInputsToWitnessMapWithAbi,
|
|
165
268
|
convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
|
|
166
269
|
);
|
|
167
270
|
}
|
|
@@ -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
|
+
}
|