@aztec/bb.js 0.0.1-alpha.7 → 0.3.2
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/README.md +3 -3
- package/dest/barretenberg-threads.wasm +0 -0
- package/dest/barretenberg.wasm +0 -0
- package/dest/barretenberg_api/common.test.js +2 -2
- package/dest/barretenberg_api/pedersen.test.js +1 -1
- package/dest/barretenberg_wasm/barretenberg_wasm.js +2 -2
- package/dest/barretenberg_wasm/barretenberg_wasm.test.js +5 -1
- package/dest/barretenberg_wasm.js +1 -1
- package/dest/crs/node/index.d.ts +1 -1
- package/dest/crs/node/index.d.ts.map +1 -1
- package/dest/crs/node/index.js +3 -3
- package/dest/examples/simple.test.js +1 -1
- package/dest/main.d.ts +4 -4
- package/dest/main.d.ts.map +1 -1
- package/dest/main.js +17 -16
- package/dest/simple_test.js +1 -1
- package/package.json +3 -3
- package/src/barretenberg_api/common.test.ts +1 -1
- package/src/barretenberg_api/pedersen.test.ts +1 -1
- package/src/barretenberg_wasm/barretenberg_wasm.test.ts +5 -0
- package/src/barretenberg_wasm/barretenberg_wasm.ts +1 -1
- package/src/crs/node/index.ts +2 -2
- package/src/examples/simple.test.ts +1 -1
- package/src/main.ts +22 -15
package/src/main.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import { Crs, BarretenbergApiAsync, newBarretenbergApiAsync, RawBuffer } from './index.js';
|
|
3
3
|
import createDebug from 'debug';
|
|
4
4
|
import { readFileSync, writeFileSync } from 'fs';
|
|
@@ -49,7 +49,7 @@ async function computeCircuitSize(jsonPath: string, api: BarretenbergApiAsync) {
|
|
|
49
49
|
return { exact, total, subgroup };
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
async function init(jsonPath: string) {
|
|
52
|
+
async function init(jsonPath: string, crsPath: string) {
|
|
53
53
|
const api = await newBarretenbergApiAsync();
|
|
54
54
|
|
|
55
55
|
const circuitSize = await getGates(jsonPath, api);
|
|
@@ -62,7 +62,7 @@ async function init(jsonPath: string) {
|
|
|
62
62
|
debug(`subgroup size: ${subgroupSize}`);
|
|
63
63
|
debug('loading crs...');
|
|
64
64
|
// Plus 1 needed! (Move +1 into Crs?)
|
|
65
|
-
const crs = await Crs.new(subgroupSize + 1);
|
|
65
|
+
const crs = await Crs.new(subgroupSize + 1, crsPath);
|
|
66
66
|
|
|
67
67
|
// Important to init slab allocator as first thing, to ensure maximum memory efficiency.
|
|
68
68
|
await api.commonInitSlabAllocator(subgroupSize);
|
|
@@ -88,8 +88,8 @@ async function initLite() {
|
|
|
88
88
|
return { api, acirComposer };
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export async function proveAndVerify(jsonPath: string, witnessPath: string, isRecursive: boolean) {
|
|
92
|
-
const { api, acirComposer } = await init(jsonPath);
|
|
91
|
+
export async function proveAndVerify(jsonPath: string, witnessPath: string, crsPath: string, isRecursive: boolean) {
|
|
92
|
+
const { api, acirComposer } = await init(jsonPath, crsPath);
|
|
93
93
|
try {
|
|
94
94
|
debug(`creating proof...`);
|
|
95
95
|
const bytecode = getBytecode(jsonPath);
|
|
@@ -105,8 +105,14 @@ export async function proveAndVerify(jsonPath: string, witnessPath: string, isRe
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export async function prove(
|
|
109
|
-
|
|
108
|
+
export async function prove(
|
|
109
|
+
jsonPath: string,
|
|
110
|
+
witnessPath: string,
|
|
111
|
+
crsPath: string,
|
|
112
|
+
isRecursive: boolean,
|
|
113
|
+
outputPath: string,
|
|
114
|
+
) {
|
|
115
|
+
const { api, acirComposer } = await init(jsonPath, crsPath);
|
|
110
116
|
try {
|
|
111
117
|
debug(`creating proof...`);
|
|
112
118
|
const bytecode = getBytecode(jsonPath);
|
|
@@ -158,8 +164,8 @@ export async function contract(outputPath: string, vkPath: string) {
|
|
|
158
164
|
}
|
|
159
165
|
}
|
|
160
166
|
|
|
161
|
-
export async function writeVk(jsonPath: string, outputPath: string) {
|
|
162
|
-
const { api, acirComposer } = await init(jsonPath);
|
|
167
|
+
export async function writeVk(jsonPath: string, crsPath: string, outputPath: string) {
|
|
168
|
+
const { api, acirComposer } = await init(jsonPath, crsPath);
|
|
163
169
|
try {
|
|
164
170
|
debug('initing proving key...');
|
|
165
171
|
const bytecode = getBytecode(jsonPath);
|
|
@@ -214,6 +220,7 @@ export async function vkAsFields(vkPath: string, vkeyOutputPath: string) {
|
|
|
214
220
|
const program = new Command();
|
|
215
221
|
|
|
216
222
|
program.option('-v, --verbose', 'enable verbose logging', false);
|
|
223
|
+
program.option('-c, --crs-path <path>', 'set crs path', './crs');
|
|
217
224
|
|
|
218
225
|
function handleGlobalOptions() {
|
|
219
226
|
if (program.opts().verbose) {
|
|
@@ -227,9 +234,9 @@ program
|
|
|
227
234
|
.option('-j, --json-path <path>', 'Specify the JSON path', './target/main.json')
|
|
228
235
|
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.tr')
|
|
229
236
|
.option('-r, --recursive', 'prove and verify using recursive prover and verifier', false)
|
|
230
|
-
.action(async ({ jsonPath, witnessPath, recursive }) => {
|
|
237
|
+
.action(async ({ jsonPath, witnessPath, recursive, crsPath }) => {
|
|
231
238
|
handleGlobalOptions();
|
|
232
|
-
const result = await proveAndVerify(jsonPath, witnessPath, recursive);
|
|
239
|
+
const result = await proveAndVerify(jsonPath, witnessPath, crsPath, recursive);
|
|
233
240
|
process.exit(result ? 0 : 1);
|
|
234
241
|
});
|
|
235
242
|
|
|
@@ -240,9 +247,9 @@ program
|
|
|
240
247
|
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.tr')
|
|
241
248
|
.option('-r, --recursive', 'prove using recursive prover', false)
|
|
242
249
|
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
243
|
-
.action(async ({ jsonPath, witnessPath, recursive, outputPath }) => {
|
|
250
|
+
.action(async ({ jsonPath, witnessPath, recursive, outputPath, crsPath }) => {
|
|
244
251
|
handleGlobalOptions();
|
|
245
|
-
await prove(jsonPath, witnessPath, recursive, outputPath);
|
|
252
|
+
await prove(jsonPath, witnessPath, crsPath, recursive, outputPath);
|
|
246
253
|
});
|
|
247
254
|
|
|
248
255
|
program
|
|
@@ -282,9 +289,9 @@ program
|
|
|
282
289
|
.description('Output verification key.')
|
|
283
290
|
.option('-j, --json-path <path>', 'Specify the JSON path', './target/main.json')
|
|
284
291
|
.requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
|
|
285
|
-
.action(async ({ jsonPath, outputPath }) => {
|
|
292
|
+
.action(async ({ jsonPath, outputPath, crsPath }) => {
|
|
286
293
|
handleGlobalOptions();
|
|
287
|
-
await writeVk(jsonPath, outputPath);
|
|
294
|
+
await writeVk(jsonPath, crsPath, outputPath);
|
|
288
295
|
});
|
|
289
296
|
|
|
290
297
|
program
|