@aztec/bb.js 0.0.1-alpha.7 → 0.0.1-fake-ceab37513c
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 +69 -32
- package/package.json +56 -45
- package/src/barretenberg/__snapshots__/pedersen.test.ts.snap +156 -0
- package/src/barretenberg/__snapshots__/poseidon.test.ts.snap +40 -0
- package/src/barretenberg/backend.ts +378 -0
- package/src/barretenberg/blake2s.test.ts +70 -0
- package/src/{barretenberg_api → barretenberg}/common.test.ts +7 -5
- package/src/barretenberg/index.ts +204 -0
- package/src/barretenberg/pedersen.test.ts +62 -0
- package/src/barretenberg/poseidon.test.ts +39 -0
- package/src/barretenberg_api/index.ts +982 -415
- package/src/barretenberg_wasm/barretenberg_wasm_base/index.ts +138 -0
- package/src/barretenberg_wasm/barretenberg_wasm_main/factory/browser/index.ts +11 -0
- package/src/barretenberg_wasm/barretenberg_wasm_main/factory/browser/main.worker.ts +13 -0
- package/src/barretenberg_wasm/barretenberg_wasm_main/factory/node/index.ts +21 -0
- package/src/barretenberg_wasm/barretenberg_wasm_main/factory/node/main.worker.ts +19 -0
- package/src/{barretenberg_binder/heap_allocator_sync.ts → barretenberg_wasm/barretenberg_wasm_main/heap_allocator.ts} +20 -17
- package/src/barretenberg_wasm/barretenberg_wasm_main/index.ts +167 -0
- package/src/barretenberg_wasm/barretenberg_wasm_thread/factory/browser/index.ts +11 -0
- package/src/barretenberg_wasm/barretenberg_wasm_thread/factory/browser/thread.worker.ts +13 -0
- package/src/barretenberg_wasm/barretenberg_wasm_thread/factory/node/index.ts +21 -0
- package/src/barretenberg_wasm/barretenberg_wasm_thread/factory/node/thread.worker.ts +19 -0
- package/src/barretenberg_wasm/barretenberg_wasm_thread/index.ts +47 -0
- package/src/barretenberg_wasm/fetch_code/browser/barretenberg-threads.ts +3 -0
- package/src/barretenberg_wasm/fetch_code/browser/barretenberg.ts +3 -0
- package/src/barretenberg_wasm/fetch_code/browser/index.ts +34 -0
- package/src/barretenberg_wasm/fetch_code/index.ts +1 -0
- package/src/barretenberg_wasm/fetch_code/node/index.ts +34 -0
- package/src/barretenberg_wasm/fetch_code/wasm-module.d.ts +4 -0
- package/src/barretenberg_wasm/helpers/browser/index.ts +47 -0
- package/src/barretenberg_wasm/helpers/index.ts +1 -0
- package/src/barretenberg_wasm/{node → helpers/node}/index.ts +24 -15
- package/src/barretenberg_wasm/index.test.ts +45 -0
- package/src/barretenberg_wasm/index.ts +22 -1
- package/src/benchmark/index.ts +26 -0
- package/src/benchmark/timer.ts +45 -0
- package/src/bigint-array/index.ts +39 -17
- package/src/bindgen/index.ts +2 -2
- package/src/bindgen/mappings.ts +3 -2
- package/src/bindgen/typescript.ts +50 -25
- package/src/cbind/README.md +1 -0
- package/src/cbind/generate.ts +89 -0
- package/src/cbind/schema_compiler.ts +833 -0
- package/src/crs/browser/cached_net_crs.ts +41 -1
- package/src/crs/browser/index.ts +1 -1
- package/src/crs/index.ts +1 -1
- package/src/crs/net_crs.ts +114 -19
- package/src/crs/node/index.ts +96 -26
- package/src/index.html +1 -1
- package/src/index.ts +13 -5
- package/src/log/browser/index.ts +35 -0
- package/src/log/index.ts +1 -0
- package/src/log/node/index.ts +52 -0
- package/src/log/types.ts +6 -0
- package/src/main.ts +391 -168
- package/src/proof/index.ts +94 -0
- package/src/random/browser/index.ts +1 -1
- package/src/retry/index.ts +50 -0
- package/src/serialize/buffer_reader.ts +4 -1
- package/src/types/fields.ts +46 -18
- package/src/types/point.ts +4 -1
- package/dest/async_map/index.d.ts +0 -10
- package/dest/async_map/index.d.ts.map +0 -1
- package/dest/async_map/index.js +0 -16
- package/dest/barretenberg-threads.wasm +0 -0
- package/dest/barretenberg.wasm +0 -0
- package/dest/barretenberg_api/blake2s.test.d.ts +0 -2
- package/dest/barretenberg_api/blake2s.test.d.ts.map +0 -1
- package/dest/barretenberg_api/blake2s.test.js +0 -30
- package/dest/barretenberg_api/common.test.d.ts +0 -2
- package/dest/barretenberg_api/common.test.d.ts.map +0 -1
- package/dest/barretenberg_api/common.test.js +0 -18
- package/dest/barretenberg_api/index.d.ts +0 -103
- package/dest/barretenberg_api/index.d.ts.map +0 -1
- package/dest/barretenberg_api/index.js +0 -379
- package/dest/barretenberg_api/pedersen.test.d.ts +0 -2
- package/dest/barretenberg_api/pedersen.test.d.ts.map +0 -1
- package/dest/barretenberg_api/pedersen.test.js +0 -69
- package/dest/barretenberg_api/schnorr.test.d.ts +0 -2
- package/dest/barretenberg_api/schnorr.test.d.ts.map +0 -1
- package/dest/barretenberg_api/schnorr.test.js +0 -113
- package/dest/barretenberg_binder/heap_allocator.d.ts +0 -22
- package/dest/barretenberg_binder/heap_allocator.d.ts.map +0 -1
- package/dest/barretenberg_binder/heap_allocator.js +0 -59
- package/dest/barretenberg_binder/heap_allocator_sync.d.ts +0 -22
- package/dest/barretenberg_binder/heap_allocator_sync.d.ts.map +0 -1
- package/dest/barretenberg_binder/heap_allocator_sync.js +0 -58
- package/dest/barretenberg_binder/index.d.ts +0 -32
- package/dest/barretenberg_binder/index.d.ts.map +0 -1
- package/dest/barretenberg_binder/index.js +0 -73
- package/dest/barretenberg_wasm/barretenberg_wasm.d.ts +0 -50
- package/dest/barretenberg_wasm/barretenberg_wasm.d.ts.map +0 -1
- package/dest/barretenberg_wasm/barretenberg_wasm.js +0 -212
- package/dest/barretenberg_wasm/barretenberg_wasm.test.d.ts +0 -2
- package/dest/barretenberg_wasm/barretenberg_wasm.test.d.ts.map +0 -1
- package/dest/barretenberg_wasm/barretenberg_wasm.test.js +0 -43
- package/dest/barretenberg_wasm/browser/index.d.ts +0 -8
- package/dest/barretenberg_wasm/browser/index.d.ts.map +0 -1
- package/dest/barretenberg_wasm/browser/index.js +0 -26
- package/dest/barretenberg_wasm/browser/worker.d.ts +0 -2
- package/dest/barretenberg_wasm/browser/worker.d.ts.map +0 -1
- package/dest/barretenberg_wasm/browser/worker.js +0 -11
- package/dest/barretenberg_wasm/index.d.ts +0 -2
- package/dest/barretenberg_wasm/index.d.ts.map +0 -1
- package/dest/barretenberg_wasm/index.js +0 -2
- package/dest/barretenberg_wasm/node/index.d.ts +0 -17
- package/dest/barretenberg_wasm/node/index.d.ts.map +0 -1
- package/dest/barretenberg_wasm/node/index.js +0 -40
- package/dest/barretenberg_wasm/node/node_endpoint.d.ts +0 -8
- package/dest/barretenberg_wasm/node/node_endpoint.d.ts.map +0 -1
- package/dest/barretenberg_wasm/node/node_endpoint.js +0 -28
- package/dest/barretenberg_wasm/node/worker.d.ts +0 -2
- package/dest/barretenberg_wasm/node/worker.d.ts.map +0 -1
- package/dest/barretenberg_wasm/node/worker.js +0 -9
- package/dest/barretenberg_wasm.js +0 -2
- package/dest/barretenberg_wasm.js.LICENSE.txt +0 -5
- package/dest/bigint-array/index.d.ts +0 -3
- package/dest/bigint-array/index.d.ts.map +0 -1
- package/dest/bigint-array/index.js +0 -21
- package/dest/bindgen/function_declaration.d.ts +0 -11
- package/dest/bindgen/function_declaration.d.ts.map +0 -1
- package/dest/bindgen/function_declaration.js +0 -2
- package/dest/bindgen/index.d.ts +0 -2
- package/dest/bindgen/index.d.ts.map +0 -1
- package/dest/bindgen/index.js +0 -15
- package/dest/bindgen/mappings.d.ts +0 -4
- package/dest/bindgen/mappings.d.ts.map +0 -1
- package/dest/bindgen/mappings.js +0 -63
- package/dest/bindgen/rust.d.ts +0 -2
- package/dest/bindgen/rust.d.ts.map +0 -1
- package/dest/bindgen/rust.js +0 -43
- package/dest/bindgen/to_camel_case.d.ts +0 -2
- package/dest/bindgen/to_camel_case.d.ts.map +0 -1
- package/dest/bindgen/to_camel_case.js +0 -11
- package/dest/bindgen/typescript.d.ts +0 -2
- package/dest/bindgen/typescript.d.ts.map +0 -1
- package/dest/bindgen/typescript.js +0 -80
- package/dest/crs/browser/cached_net_crs.d.ts +0 -25
- package/dest/crs/browser/cached_net_crs.d.ts.map +0 -1
- package/dest/crs/browser/cached_net_crs.js +0 -54
- package/dest/crs/browser/index.d.ts +0 -2
- package/dest/crs/browser/index.d.ts.map +0 -1
- package/dest/crs/browser/index.js +0 -2
- package/dest/crs/index.d.ts +0 -2
- package/dest/crs/index.d.ts.map +0 -1
- package/dest/crs/index.js +0 -2
- package/dest/crs/net_crs.d.ts +0 -36
- package/dest/crs/net_crs.d.ts.map +0 -1
- package/dest/crs/net_crs.js +0 -59
- package/dest/crs/node/ignition_files_crs.d.ts +0 -37
- package/dest/crs/node/ignition_files_crs.d.ts.map +0 -1
- package/dest/crs/node/ignition_files_crs.js +0 -51
- package/dest/crs/node/index.d.ts +0 -21
- package/dest/crs/node/index.d.ts.map +0 -1
- package/dest/crs/node/index.js +0 -54
- package/dest/examples/simple.rawtest.d.ts +0 -2
- package/dest/examples/simple.rawtest.d.ts.map +0 -1
- package/dest/examples/simple.rawtest.js +0 -29
- package/dest/examples/simple.test.d.ts +0 -2
- package/dest/examples/simple.test.d.ts.map +0 -1
- package/dest/examples/simple.test.js +0 -22
- package/dest/factory/index.d.ts +0 -21
- package/dest/factory/index.d.ts.map +0 -1
- package/dest/factory/index.js +0 -34
- package/dest/index.d.ts +0 -6
- package/dest/index.d.ts.map +0 -1
- package/dest/index.html +0 -1
- package/dest/index.js +0 -6
- package/dest/main.d.ts +0 -10
- package/dest/main.d.ts.map +0 -1
- package/dest/main.js +0 -275
- package/dest/random/browser/index.d.ts +0 -2
- package/dest/random/browser/index.d.ts.map +0 -1
- package/dest/random/browser/index.js +0 -31
- package/dest/random/index.d.ts +0 -2
- package/dest/random/index.d.ts.map +0 -1
- package/dest/random/index.js +0 -2
- package/dest/random/node/index.d.ts +0 -2
- package/dest/random/node/index.d.ts.map +0 -1
- package/dest/random/node/index.js +0 -5
- package/dest/serialize/buffer_reader.d.ts +0 -28
- package/dest/serialize/buffer_reader.d.ts.map +0 -1
- package/dest/serialize/buffer_reader.js +0 -66
- package/dest/serialize/index.d.ts +0 -4
- package/dest/serialize/index.d.ts.map +0 -1
- package/dest/serialize/index.js +0 -4
- package/dest/serialize/output_type.d.ts +0 -11
- package/dest/serialize/output_type.d.ts.map +0 -1
- package/dest/serialize/output_type.js +0 -44
- package/dest/serialize/serialize.d.ts +0 -53
- package/dest/serialize/serialize.d.ts.map +0 -1
- package/dest/serialize/serialize.js +0 -139
- package/dest/simple_test.js +0 -2
- package/dest/simple_test.js.LICENSE.txt +0 -14
- package/dest/types/fields.d.ts +0 -33
- package/dest/types/fields.d.ts.map +0 -1
- package/dest/types/fields.js +0 -86
- package/dest/types/fixed_size_buffer.d.ts +0 -26
- package/dest/types/fixed_size_buffer.d.ts.map +0 -1
- package/dest/types/fixed_size_buffer.js +0 -54
- package/dest/types/index.d.ts +0 -6
- package/dest/types/index.d.ts.map +0 -1
- package/dest/types/index.js +0 -6
- package/dest/types/point.d.ts +0 -17
- package/dest/types/point.d.ts.map +0 -1
- package/dest/types/point.js +0 -32
- package/dest/types/ptr.d.ts +0 -13
- package/dest/types/ptr.d.ts.map +0 -1
- package/dest/types/ptr.js +0 -20
- package/dest/types/raw_buffer.d.ts +0 -3
- package/dest/types/raw_buffer.d.ts.map +0 -1
- package/dest/types/raw_buffer.js +0 -5
- package/src/barretenberg_api/blake2s.test.ts +0 -39
- package/src/barretenberg_api/pedersen.test.ts +0 -84
- package/src/barretenberg_api/schnorr.test.ts +0 -169
- package/src/barretenberg_binder/heap_allocator.ts +0 -62
- package/src/barretenberg_binder/index.ts +0 -76
- package/src/barretenberg_wasm/barretenberg_wasm.test.ts +0 -52
- package/src/barretenberg_wasm/barretenberg_wasm.ts +0 -246
- package/src/barretenberg_wasm/browser/index.ts +0 -32
- package/src/barretenberg_wasm/browser/worker.ts +0 -13
- package/src/barretenberg_wasm/node/worker.ts +0 -10
- package/src/crs/node/ignition_files_crs.ts +0 -60
- package/src/examples/simple.rawtest.ts +0 -37
- package/src/examples/simple.test.ts +0 -27
- package/src/factory/index.ts +0 -36
- /package/src/barretenberg_wasm/{node → helpers/node}/node_endpoint.ts +0 -0
package/src/main.ts
CHANGED
|
@@ -1,311 +1,534 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'source-map-support/register.js';
|
|
3
|
+
import { Crs, Barretenberg, RawBuffer } from './index.js';
|
|
4
|
+
import { createDebugLogger, initLogger } from './log/index.js';
|
|
4
5
|
import { readFileSync, writeFileSync } from 'fs';
|
|
5
6
|
import { gunzipSync } from 'zlib';
|
|
6
|
-
import { numToUInt32BE } from './serialize/serialize.js';
|
|
7
7
|
import { Command } from 'commander';
|
|
8
|
+
import { UltraHonkBackendOptions } from './barretenberg/backend.js';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
const debug = createDebug('bb.js');
|
|
10
|
+
let debug: (msg: string) => void;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const MAX_CIRCUIT_SIZE = 2 ** 19;
|
|
12
|
+
const threads = +process.env.HARDWARE_CONCURRENCY! || undefined;
|
|
14
13
|
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
function getBytecode(bytecodePath: string): Uint8Array {
|
|
15
|
+
const extension = bytecodePath.substring(bytecodePath.lastIndexOf('.') + 1);
|
|
16
|
+
|
|
17
|
+
if (extension == 'json') {
|
|
18
|
+
const encodedCircuit = JSON.parse(readFileSync(bytecodePath, 'utf8'));
|
|
19
|
+
const decompressed = gunzipSync(Buffer.from(encodedCircuit.bytecode, 'base64'));
|
|
20
|
+
return Uint8Array.from(decompressed);
|
|
21
|
+
}
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const decompressed = gunzipSync(buffer);
|
|
25
|
-
return decompressed;
|
|
23
|
+
const encodedCircuit = readFileSync(bytecodePath);
|
|
24
|
+
const decompressed = gunzipSync(encodedCircuit);
|
|
25
|
+
return Uint8Array.from(decompressed);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return +parsed.gates;
|
|
32
|
-
}
|
|
33
|
-
const { total } = await computeCircuitSize(jsonPath, api);
|
|
34
|
-
const jsonData = getJsonData(jsonPath);
|
|
35
|
-
jsonData.gates = total;
|
|
36
|
-
writeFileSync(jsonPath, JSON.stringify(jsonData));
|
|
28
|
+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): split this into separate Plonk and Honk functions as their gate count differs
|
|
29
|
+
async function getGatesUltra(bytecodePath: string, recursive: boolean, honkRecursion: boolean, api: Barretenberg) {
|
|
30
|
+
const { total } = await computeCircuitSize(bytecodePath, recursive, honkRecursion, api);
|
|
37
31
|
return total;
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
function getWitness(witnessPath: string) {
|
|
34
|
+
function getWitness(witnessPath: string): Uint8Array {
|
|
41
35
|
const data = readFileSync(witnessPath);
|
|
42
|
-
|
|
36
|
+
const decompressed = gunzipSync(data);
|
|
37
|
+
return Uint8Array.from(decompressed);
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
async function computeCircuitSize(
|
|
46
|
-
debug(`
|
|
47
|
-
const bytecode = getBytecode(
|
|
48
|
-
const [
|
|
49
|
-
return {
|
|
40
|
+
async function computeCircuitSize(bytecodePath: string, recursive: boolean, honkRecursion: boolean, api: Barretenberg) {
|
|
41
|
+
debug(`Computing circuit size for ${bytecodePath}`);
|
|
42
|
+
const bytecode = getBytecode(bytecodePath);
|
|
43
|
+
const [total, subgroup] = await api.acirGetCircuitSizes(bytecode, recursive, honkRecursion);
|
|
44
|
+
return { total, subgroup };
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
async function
|
|
53
|
-
const api = await
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const subgroupSize = Math.pow(2, Math.ceil(Math.log2(circuitSize)));
|
|
57
|
-
if (subgroupSize > MAX_CIRCUIT_SIZE) {
|
|
58
|
-
throw new Error(`Circuit size of ${subgroupSize} exceeds max supported of ${MAX_CIRCUIT_SIZE}`);
|
|
59
|
-
}
|
|
47
|
+
async function initUltraHonk(bytecodePath: string, crsPath: string) {
|
|
48
|
+
const api = await Barretenberg.new({
|
|
49
|
+
threads,
|
|
50
|
+
});
|
|
60
51
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice.
|
|
53
|
+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraHonk function
|
|
54
|
+
// recursive here is useless for UH, as it does not affect anything
|
|
55
|
+
const circuitSize = await getGatesUltra(bytecodePath, /*recursive=*/ false, /*honkRecursion=*/ true, api);
|
|
56
|
+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin
|
|
57
|
+
const dyadicCircuitSize = Math.pow(2, Math.ceil(Math.log2(circuitSize)));
|
|
66
58
|
|
|
67
|
-
|
|
68
|
-
await
|
|
59
|
+
debug(`Loading CRS for UltraHonk with circuit-size=${circuitSize} dyadic-circuit-size=${dyadicCircuitSize}`);
|
|
60
|
+
const crs = await Crs.new(dyadicCircuitSize + 1, crsPath);
|
|
69
61
|
|
|
70
62
|
// Load CRS into wasm global CRS state.
|
|
71
|
-
// TODO: Make RawBuffer be default
|
|
63
|
+
// TODO: Make RawBuffer be default behavior, and have a specific Vector type for when wanting length prefixed.
|
|
72
64
|
await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
|
|
73
|
-
|
|
74
|
-
const acirComposer = await api.acirNewAcirComposer(subgroupSize);
|
|
75
|
-
return { api, acirComposer, circuitSize: subgroupSize };
|
|
65
|
+
return { api, circuitSize, dyadicCircuitSize };
|
|
76
66
|
}
|
|
77
67
|
|
|
78
|
-
async function initLite() {
|
|
79
|
-
const api = await
|
|
68
|
+
async function initLite(crsPath: string) {
|
|
69
|
+
const api = await Barretenberg.new({ threads: 1 });
|
|
80
70
|
|
|
81
71
|
// Plus 1 needed! (Move +1 into Crs?)
|
|
82
|
-
const crs = await Crs.new(1);
|
|
72
|
+
const crs = await Crs.new(1, crsPath);
|
|
83
73
|
|
|
84
74
|
// Load CRS into wasm global CRS state.
|
|
85
75
|
await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
return { api, acirComposer };
|
|
77
|
+
return { api };
|
|
89
78
|
}
|
|
90
79
|
|
|
91
|
-
export async function
|
|
92
|
-
|
|
80
|
+
export async function proveAndVerifyUltraHonk(bytecodePath: string, witnessPath: string, crsPath: string) {
|
|
81
|
+
/* eslint-disable camelcase */
|
|
82
|
+
const { api } = await initUltraHonk(bytecodePath, crsPath);
|
|
93
83
|
try {
|
|
94
|
-
|
|
95
|
-
const bytecode = getBytecode(jsonPath);
|
|
84
|
+
const bytecode = getBytecode(bytecodePath);
|
|
96
85
|
const witness = getWitness(witnessPath);
|
|
97
|
-
const proof = await api.acirCreateProof(acirComposer, new RawBuffer(bytecode), new RawBuffer(witness), isRecursive);
|
|
98
86
|
|
|
99
|
-
|
|
100
|
-
const verified = await api.acirVerifyProof(acirComposer, proof, isRecursive);
|
|
101
|
-
console.log(`verified: ${verified}`);
|
|
87
|
+
const verified = await api.acirProveAndVerifyUltraHonk(bytecode, witness);
|
|
102
88
|
return verified;
|
|
103
89
|
} finally {
|
|
104
90
|
await api.destroy();
|
|
105
91
|
}
|
|
92
|
+
/* eslint-enable camelcase */
|
|
106
93
|
}
|
|
107
94
|
|
|
108
|
-
export async function
|
|
109
|
-
|
|
95
|
+
export async function proveAndVerifyMegaHonk(bytecodePath: string, witnessPath: string, crsPath: string) {
|
|
96
|
+
/* eslint-disable camelcase */
|
|
97
|
+
const { api } = await initUltraHonk(bytecodePath, crsPath);
|
|
110
98
|
try {
|
|
111
|
-
|
|
112
|
-
const bytecode = getBytecode(jsonPath);
|
|
99
|
+
const bytecode = getBytecode(bytecodePath);
|
|
113
100
|
const witness = getWitness(witnessPath);
|
|
114
|
-
const proof = await api.acirCreateProof(acirComposer, new RawBuffer(bytecode), new RawBuffer(witness), isRecursive);
|
|
115
|
-
debug(`done.`);
|
|
116
101
|
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
const verified = await api.acirProveAndVerifyMegaHonk(bytecode, witness);
|
|
103
|
+
return verified;
|
|
119
104
|
} finally {
|
|
120
105
|
await api.destroy();
|
|
121
106
|
}
|
|
107
|
+
/* eslint-enable camelcase */
|
|
122
108
|
}
|
|
123
109
|
|
|
124
|
-
export async function
|
|
125
|
-
const api = await
|
|
110
|
+
export async function gateCountUltra(bytecodePath: string, recursive: boolean, honkRecursion: boolean) {
|
|
111
|
+
const api = await Barretenberg.new({ threads: 1 });
|
|
126
112
|
try {
|
|
127
|
-
|
|
113
|
+
const numberOfGates = await getGatesUltra(bytecodePath, recursive, honkRecursion, api);
|
|
114
|
+
debug(`Number of gates: ${numberOfGates}`);
|
|
115
|
+
// Create an 8-byte buffer and write the number into it.
|
|
116
|
+
// Writing number directly to stdout will result in a variable sized
|
|
117
|
+
// input depending on the size.
|
|
118
|
+
const buffer = Buffer.alloc(8);
|
|
119
|
+
buffer.writeBigInt64LE(BigInt(numberOfGates));
|
|
120
|
+
|
|
121
|
+
process.stdout.write(Uint8Array.from(buffer));
|
|
128
122
|
} finally {
|
|
129
123
|
await api.destroy();
|
|
130
124
|
}
|
|
131
125
|
}
|
|
132
126
|
|
|
133
|
-
export async function
|
|
134
|
-
const { api
|
|
127
|
+
export async function contractUltraHonk(bytecodePath: string, vkPath: string, crsPath: string, outputPath: string) {
|
|
128
|
+
const { api } = await initUltraHonk(bytecodePath, crsPath);
|
|
135
129
|
try {
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
debug(`Creating UltraHonk verifier contract bytecode=${bytecodePath} vk=${vkPath}`);
|
|
131
|
+
const bytecode = getBytecode(bytecodePath);
|
|
132
|
+
const vk = new RawBuffer(readFileSync(vkPath));
|
|
133
|
+
const contract = await api.acirHonkSolidityVerifier(bytecode, vk);
|
|
134
|
+
|
|
135
|
+
if (outputPath === '-') {
|
|
136
|
+
process.stdout.write(contract);
|
|
137
|
+
debug(`Solidity verifier contract written to stdout`);
|
|
138
|
+
} else {
|
|
139
|
+
writeFileSync(outputPath, contract);
|
|
140
|
+
debug(`Solidity verifier contract written to ${outputPath}`);
|
|
141
|
+
}
|
|
140
142
|
} finally {
|
|
141
143
|
await api.destroy();
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
export async function
|
|
146
|
-
|
|
147
|
+
export async function proveUltraHonk(
|
|
148
|
+
bytecodePath: string,
|
|
149
|
+
witnessPath: string,
|
|
150
|
+
crsPath: string,
|
|
151
|
+
vkPath: string,
|
|
152
|
+
outputPath: string,
|
|
153
|
+
options?: UltraHonkBackendOptions,
|
|
154
|
+
) {
|
|
155
|
+
const { api } = await initUltraHonk(bytecodePath, crsPath);
|
|
147
156
|
try {
|
|
148
|
-
|
|
149
|
-
const
|
|
157
|
+
debug(`Creating UltraHonk proof bytecode=${bytecodePath}`);
|
|
158
|
+
const bytecode = getBytecode(bytecodePath);
|
|
159
|
+
const witness = getWitness(witnessPath);
|
|
160
|
+
|
|
161
|
+
const acirProveUltraHonk = options?.keccak
|
|
162
|
+
? api.acirProveUltraKeccakHonk.bind(api)
|
|
163
|
+
: options?.keccakZK
|
|
164
|
+
? api.acirProveUltraKeccakZkHonk.bind(api)
|
|
165
|
+
: options?.starknet
|
|
166
|
+
? api.acirProveUltraStarknetHonk.bind(api)
|
|
167
|
+
: options?.starknetZK
|
|
168
|
+
? api.acirProveUltraStarknetZkHonk.bind(api)
|
|
169
|
+
: api.acirProveUltraZKHonk.bind(api);
|
|
170
|
+
const proof = await acirProveUltraHonk(bytecode, witness, new RawBuffer(readFileSync(vkPath)));
|
|
171
|
+
|
|
150
172
|
if (outputPath === '-') {
|
|
151
|
-
|
|
173
|
+
process.stdout.write(proof);
|
|
174
|
+
debug(`Proof written to stdout`);
|
|
152
175
|
} else {
|
|
153
|
-
writeFileSync(outputPath,
|
|
154
|
-
|
|
176
|
+
writeFileSync(outputPath, proof);
|
|
177
|
+
debug(`Proof written to ${outputPath}`);
|
|
155
178
|
}
|
|
156
179
|
} finally {
|
|
157
180
|
await api.destroy();
|
|
158
181
|
}
|
|
159
182
|
}
|
|
160
183
|
|
|
161
|
-
export async function
|
|
162
|
-
|
|
184
|
+
export async function writeVkUltraHonk(
|
|
185
|
+
bytecodePath: string,
|
|
186
|
+
crsPath: string,
|
|
187
|
+
outputPath: string,
|
|
188
|
+
options?: UltraHonkBackendOptions,
|
|
189
|
+
) {
|
|
190
|
+
const { api } = await initUltraHonk(bytecodePath, crsPath);
|
|
163
191
|
try {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
192
|
+
const bytecode = getBytecode(bytecodePath);
|
|
193
|
+
debug(`Initializing UltraHonk verification key bytecode=${bytecodePath}`);
|
|
194
|
+
|
|
195
|
+
const acirWriteVkUltraHonk = options?.keccak
|
|
196
|
+
? api.acirWriteVkUltraKeccakHonk.bind(api)
|
|
197
|
+
: options?.keccakZK
|
|
198
|
+
? api.acirWriteVkUltraKeccakZkHonk.bind(api)
|
|
199
|
+
: options?.starknet
|
|
200
|
+
? api.acirWriteVkUltraStarknetHonk.bind(api)
|
|
201
|
+
: options?.starknetZK
|
|
202
|
+
? api.acirWriteVkUltraStarknetZkHonk.bind(api)
|
|
203
|
+
: api.acirWriteVkUltraHonk.bind(api);
|
|
204
|
+
const vk = await acirWriteVkUltraHonk(bytecode);
|
|
167
205
|
|
|
168
|
-
debug('initing verification key...');
|
|
169
|
-
const vk = await api.acirGetVerificationKey(acirComposer);
|
|
170
206
|
if (outputPath === '-') {
|
|
171
207
|
process.stdout.write(vk);
|
|
208
|
+
debug(`Verification key written to stdout`);
|
|
172
209
|
} else {
|
|
173
210
|
writeFileSync(outputPath, vk);
|
|
174
|
-
|
|
211
|
+
debug(`Verification key written to ${outputPath}`);
|
|
175
212
|
}
|
|
176
213
|
} finally {
|
|
177
214
|
await api.destroy();
|
|
178
215
|
}
|
|
179
216
|
}
|
|
180
217
|
|
|
181
|
-
export async function
|
|
182
|
-
|
|
183
|
-
|
|
218
|
+
export async function verifyUltraHonk(
|
|
219
|
+
proofPath: string,
|
|
220
|
+
vkPath: string,
|
|
221
|
+
crsPath: string,
|
|
222
|
+
options?: UltraHonkBackendOptions,
|
|
223
|
+
) {
|
|
224
|
+
const { api } = await initLite(crsPath);
|
|
184
225
|
try {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
226
|
+
const acirVerifyUltraHonk = options?.keccak
|
|
227
|
+
? api.acirVerifyUltraKeccakHonk.bind(api)
|
|
228
|
+
: options?.keccakZK
|
|
229
|
+
? api.acirVerifyUltraKeccakZkHonk.bind(api)
|
|
230
|
+
: options?.starknet
|
|
231
|
+
? api.acirVerifyUltraStarknetHonk.bind(api)
|
|
232
|
+
: options?.starknetZK
|
|
233
|
+
? api.acirVerifyUltraStarknetZkHonk.bind(api)
|
|
234
|
+
: api.acirVerifyUltraZKHonk.bind(api);
|
|
235
|
+
const verified = await acirVerifyUltraHonk(
|
|
236
|
+
Uint8Array.from(readFileSync(proofPath)),
|
|
237
|
+
new RawBuffer(readFileSync(vkPath)),
|
|
190
238
|
);
|
|
191
239
|
|
|
192
|
-
|
|
193
|
-
|
|
240
|
+
debug(`Verification ${verified ? 'successful' : 'failed'}`);
|
|
241
|
+
return verified;
|
|
242
|
+
} finally {
|
|
243
|
+
await api.destroy();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export async function proofAsFieldsUltraHonk(proofPath: string, outputPath: string, crsPath: string) {
|
|
248
|
+
const { api } = await initLite(crsPath);
|
|
249
|
+
try {
|
|
250
|
+
debug(`Outputting UltraHonk proof as vector of fields proof=${proofPath}`);
|
|
251
|
+
const proofAsFields = await api.acirProofAsFieldsUltraHonk(Uint8Array.from(readFileSync(proofPath)));
|
|
252
|
+
const jsonProofAsFields = JSON.stringify(proofAsFields.map(f => f.toString()));
|
|
253
|
+
|
|
254
|
+
if (outputPath === '-') {
|
|
255
|
+
process.stdout.write(jsonProofAsFields);
|
|
256
|
+
debug(`Proof as fields written to stdout`);
|
|
257
|
+
} else {
|
|
258
|
+
writeFileSync(outputPath, jsonProofAsFields);
|
|
259
|
+
debug(`Proof as fields written to ${outputPath}`);
|
|
260
|
+
}
|
|
194
261
|
} finally {
|
|
195
262
|
await api.destroy();
|
|
196
263
|
}
|
|
197
264
|
}
|
|
198
265
|
|
|
199
|
-
export async function
|
|
200
|
-
const { api
|
|
266
|
+
export async function vkAsFieldsUltraHonk(vkPath: string, vkeyOutputPath: string, crsPath: string) {
|
|
267
|
+
const { api } = await initLite(crsPath);
|
|
201
268
|
|
|
202
269
|
try {
|
|
203
|
-
debug(
|
|
204
|
-
await api.
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
270
|
+
debug(`Serializing vk byte array into field elements vk=${vkPath}`);
|
|
271
|
+
const vkAsFields = await api.acirVkAsFieldsUltraHonk(new RawBuffer(readFileSync(vkPath)));
|
|
272
|
+
const jsonVKAsFields = JSON.stringify(vkAsFields.map(f => f.toString()));
|
|
273
|
+
|
|
274
|
+
if (vkeyOutputPath === '-') {
|
|
275
|
+
process.stdout.write(jsonVKAsFields);
|
|
276
|
+
debug(`Verification key as fields written to stdout`);
|
|
277
|
+
} else {
|
|
278
|
+
writeFileSync(vkeyOutputPath, jsonVKAsFields);
|
|
279
|
+
debug(`Verification key as fields written to ${vkeyOutputPath}`);
|
|
280
|
+
}
|
|
209
281
|
} finally {
|
|
210
282
|
await api.destroy();
|
|
211
283
|
}
|
|
212
284
|
}
|
|
213
285
|
|
|
214
|
-
const program = new Command();
|
|
286
|
+
const program = new Command('bb');
|
|
215
287
|
|
|
216
288
|
program.option('-v, --verbose', 'enable verbose logging', false);
|
|
289
|
+
program.option('-c, --crs-path <path>', 'set crs path', './crs');
|
|
217
290
|
|
|
218
291
|
function handleGlobalOptions() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
292
|
+
initLogger({ useStdErr: true, level: program.opts().verbose ? 'debug' : 'info' });
|
|
293
|
+
debug = createDebugLogger('bb');
|
|
294
|
+
return { crsPath: program.opts().crsPath };
|
|
222
295
|
}
|
|
223
296
|
|
|
297
|
+
const deprecatedCommandError = () => async () => {
|
|
298
|
+
console.error(
|
|
299
|
+
`Error: UltraPlonk is now deprecated (see https://github.com/AztecProtocol/barretenberg/issues/1377). Use UltraHonk!`,
|
|
300
|
+
);
|
|
301
|
+
process.exit(1);
|
|
302
|
+
};
|
|
303
|
+
|
|
224
304
|
program
|
|
225
305
|
.command('prove_and_verify')
|
|
226
|
-
.description('Generate a proof and verify it. Process exits with success or failure code.')
|
|
227
|
-
.option('-
|
|
228
|
-
.option('-
|
|
229
|
-
.option('-
|
|
230
|
-
.action(
|
|
231
|
-
|
|
232
|
-
|
|
306
|
+
.description('Generate a proof and verify it. Process exits with success or failure code. [DEPRECATED]')
|
|
307
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
308
|
+
.option('-r, --recursive', 'Whether to use a SNARK friendly proof', false)
|
|
309
|
+
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
|
|
310
|
+
.action(deprecatedCommandError());
|
|
311
|
+
|
|
312
|
+
program
|
|
313
|
+
.command('prove_and_verify_ultra_honk')
|
|
314
|
+
.description('Generate an UltraHonk proof and verify it. Process exits with success or failure code.')
|
|
315
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
316
|
+
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
|
|
317
|
+
.action(async ({ bytecodePath, witnessPath }) => {
|
|
318
|
+
const { crsPath } = handleGlobalOptions();
|
|
319
|
+
const result = await proveAndVerifyUltraHonk(bytecodePath, witnessPath, crsPath);
|
|
320
|
+
process.exit(result ? 0 : 1);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
program
|
|
324
|
+
.command('prove_and_verify_mega_honk')
|
|
325
|
+
.description('Generate a MegaHonk proof and verify it. Process exits with success or failure code.')
|
|
326
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
327
|
+
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
|
|
328
|
+
.action(async ({ bytecodePath, witnessPath }) => {
|
|
329
|
+
const { crsPath } = handleGlobalOptions();
|
|
330
|
+
const result = await proveAndVerifyMegaHonk(bytecodePath, witnessPath, crsPath);
|
|
233
331
|
process.exit(result ? 0 : 1);
|
|
234
332
|
});
|
|
235
333
|
|
|
236
334
|
program
|
|
237
335
|
.command('prove')
|
|
238
|
-
.description('Generate a proof and write it to a file.')
|
|
239
|
-
.option('-
|
|
240
|
-
.option('-
|
|
241
|
-
.option('-
|
|
336
|
+
.description('Generate a proof and write it to a file. [DEPRECATED]')
|
|
337
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
338
|
+
.option('-r, --recursive', 'Create a SNARK friendly proof', false)
|
|
339
|
+
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
|
|
242
340
|
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
243
|
-
.action(
|
|
244
|
-
handleGlobalOptions();
|
|
245
|
-
await prove(jsonPath, witnessPath, recursive, outputPath);
|
|
246
|
-
});
|
|
341
|
+
.action(deprecatedCommandError());
|
|
247
342
|
|
|
248
343
|
program
|
|
249
344
|
.command('gates')
|
|
250
|
-
.description('Print gate count to standard output.')
|
|
251
|
-
.option('-
|
|
252
|
-
.
|
|
345
|
+
.description('Print Ultra Builder gate count to standard output.')
|
|
346
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
347
|
+
.option('-r, --recursive', 'Create a SNARK friendly proof', false)
|
|
348
|
+
.option('-hr, --honk-recursion', 'Specify whether to use UltraHonk recursion', false)
|
|
349
|
+
.action(async ({ bytecodePath, recursive, honkRecursion: honkRecursion }) => {
|
|
253
350
|
handleGlobalOptions();
|
|
254
|
-
await
|
|
351
|
+
await gateCountUltra(bytecodePath, recursive, honkRecursion);
|
|
255
352
|
});
|
|
256
353
|
|
|
257
354
|
program
|
|
258
355
|
.command('verify')
|
|
259
|
-
.description('Verify a proof. Process exists with success or failure code.')
|
|
356
|
+
.description('Verify a proof. Process exists with success or failure code. [DEPRECATED]')
|
|
260
357
|
.requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
|
|
261
|
-
.option('-r, --recursive', 'prove using recursive prover', false)
|
|
262
358
|
.requiredOption('-k, --vk <path>', 'path to a verification key. avoids recomputation.')
|
|
263
|
-
.action(
|
|
264
|
-
handleGlobalOptions();
|
|
265
|
-
const result = await verify(proofPath, recursive, vk);
|
|
266
|
-
process.exit(result ? 0 : 1);
|
|
267
|
-
});
|
|
359
|
+
.action(deprecatedCommandError());
|
|
268
360
|
|
|
269
361
|
program
|
|
270
362
|
.command('contract')
|
|
363
|
+
.description('Output solidity verification key contract. [DEPRECATED]')
|
|
364
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
365
|
+
.option('-o, --output-path <path>', 'Specify the path to write the contract', './target/contract.sol')
|
|
366
|
+
.requiredOption('-k, --vk-path <path>', 'Path to a verification key. avoids recomputation.')
|
|
367
|
+
.action(deprecatedCommandError());
|
|
368
|
+
|
|
369
|
+
program
|
|
370
|
+
.command('contract_ultra_honk')
|
|
271
371
|
.description('Output solidity verification key contract.')
|
|
272
|
-
.option('-
|
|
273
|
-
.option('-o, --output-path <path>', 'Specify the path to write the contract', '
|
|
274
|
-
.requiredOption('-k, --vk <path>', '
|
|
275
|
-
.action(async ({ outputPath,
|
|
276
|
-
handleGlobalOptions();
|
|
277
|
-
await
|
|
372
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
373
|
+
.option('-o, --output-path <path>', 'Specify the path to write the contract', './target/contract.sol')
|
|
374
|
+
.requiredOption('-k, --vk-path <path>', 'Path to a verification key.')
|
|
375
|
+
.action(async ({ bytecodePath, outputPath, vkPath }) => {
|
|
376
|
+
const { crsPath } = handleGlobalOptions();
|
|
377
|
+
await contractUltraHonk(bytecodePath, vkPath, crsPath, outputPath);
|
|
278
378
|
});
|
|
279
379
|
|
|
280
380
|
program
|
|
281
381
|
.command('write_vk')
|
|
382
|
+
.description('Output verification key. [DEPRECATED]')
|
|
383
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
384
|
+
.option('-r, --recursive', 'Create a SNARK friendly proof', false)
|
|
385
|
+
.option('-o, --output-path <path>', 'Specify the path to write the key')
|
|
386
|
+
.action(deprecatedCommandError());
|
|
387
|
+
|
|
388
|
+
program
|
|
389
|
+
.command('write_pk')
|
|
390
|
+
.description('Output proving key. [DEPRECATED]')
|
|
391
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
392
|
+
.option('-r, --recursive', 'Create a SNARK friendly proof', false)
|
|
393
|
+
.requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
|
|
394
|
+
.action(deprecatedCommandError());
|
|
395
|
+
|
|
396
|
+
program
|
|
397
|
+
.command('proof_as_fields')
|
|
398
|
+
.description('Return the proof as fields elements. [DEPRECATED]')
|
|
399
|
+
.requiredOption('-p, --proof-path <path>', 'Specify the proof path')
|
|
400
|
+
.requiredOption('-k, --vk-path <path>', 'Path to verification key.')
|
|
401
|
+
.requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the proof fields')
|
|
402
|
+
.action(deprecatedCommandError());
|
|
403
|
+
|
|
404
|
+
program
|
|
405
|
+
.command('vk_as_fields')
|
|
406
|
+
.description(
|
|
407
|
+
'Return the verification key represented as fields elements. Also return the verification key hash. [DEPRECATED]',
|
|
408
|
+
)
|
|
409
|
+
.requiredOption('-k, --vk-path <path>', 'Path to verification key.')
|
|
410
|
+
.requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the verification key fields and key hash')
|
|
411
|
+
.action(deprecatedCommandError());
|
|
412
|
+
|
|
413
|
+
program
|
|
414
|
+
.command('prove_ultra_honk')
|
|
415
|
+
.description('Generate a proof and write it to a file.')
|
|
416
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
417
|
+
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
|
|
418
|
+
.option('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
|
|
419
|
+
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
420
|
+
.action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
|
|
421
|
+
const { crsPath } = handleGlobalOptions();
|
|
422
|
+
debug(`Creating UltraHonk proof bytecodePath=${bytecodePath}, witnessPath=${witnessPath}, vkPath=${vkPath}`);
|
|
423
|
+
await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
program
|
|
427
|
+
.command('prove_ultra_keccak_honk')
|
|
428
|
+
.description('Generate a proof and write it to a file.')
|
|
429
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
430
|
+
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
|
|
431
|
+
.option('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
|
|
432
|
+
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
433
|
+
.action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
|
|
434
|
+
const { crsPath } = handleGlobalOptions();
|
|
435
|
+
await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath, { keccak: true });
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
program
|
|
439
|
+
.command('prove_ultra_starknet_honk')
|
|
440
|
+
.description('Generate a proof and write it to a file.')
|
|
441
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
442
|
+
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
|
|
443
|
+
.option('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
|
|
444
|
+
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
445
|
+
.action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
|
|
446
|
+
const { crsPath } = handleGlobalOptions();
|
|
447
|
+
await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath, { starknet: true });
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
program
|
|
451
|
+
.command('write_vk_ultra_honk')
|
|
282
452
|
.description('Output verification key.')
|
|
283
|
-
.option('-
|
|
453
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
284
454
|
.requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
|
|
285
|
-
.action(async ({
|
|
286
|
-
handleGlobalOptions();
|
|
287
|
-
|
|
455
|
+
.action(async ({ bytecodePath, outputPath }) => {
|
|
456
|
+
const { crsPath } = handleGlobalOptions();
|
|
457
|
+
debug(`Writing verification key to ${outputPath}`);
|
|
458
|
+
await writeVkUltraHonk(bytecodePath, crsPath, outputPath);
|
|
288
459
|
});
|
|
289
460
|
|
|
290
461
|
program
|
|
291
|
-
.command('
|
|
462
|
+
.command('write_vk_ultra_keccak_honk')
|
|
463
|
+
.description('Output verification key.')
|
|
464
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
465
|
+
.requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
|
|
466
|
+
.action(async ({ bytecodePath, outputPath }) => {
|
|
467
|
+
const { crsPath } = handleGlobalOptions();
|
|
468
|
+
await writeVkUltraHonk(bytecodePath, crsPath, outputPath, { keccak: true });
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
program
|
|
472
|
+
.command('write_vk_ultra_starknet_honk')
|
|
473
|
+
.description('Output verification key.')
|
|
474
|
+
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
475
|
+
.requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
|
|
476
|
+
.action(async ({ bytecodePath, outputPath }) => {
|
|
477
|
+
const { crsPath } = handleGlobalOptions();
|
|
478
|
+
await writeVkUltraHonk(bytecodePath, crsPath, outputPath, { starknet: true });
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
program
|
|
482
|
+
.command('verify_ultra_honk')
|
|
483
|
+
.description('Verify a proof. Process exists with success or failure code.')
|
|
484
|
+
.requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
|
|
485
|
+
.requiredOption('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
|
|
486
|
+
.action(async ({ proofPath, vkPath }) => {
|
|
487
|
+
const { crsPath } = handleGlobalOptions();
|
|
488
|
+
const result = await verifyUltraHonk(proofPath, vkPath, crsPath);
|
|
489
|
+
process.exit(result ? 0 : 1);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
program
|
|
493
|
+
.command('verify_ultra_keccak_honk')
|
|
494
|
+
.description('Verify a proof. Process exists with success or failure code.')
|
|
495
|
+
.requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
|
|
496
|
+
.requiredOption('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
|
|
497
|
+
.action(async ({ proofPath, vkPath }) => {
|
|
498
|
+
const { crsPath } = handleGlobalOptions();
|
|
499
|
+
const result = await verifyUltraHonk(proofPath, vkPath, crsPath, { keccak: true });
|
|
500
|
+
process.exit(result ? 0 : 1);
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
program
|
|
504
|
+
.command('verify_ultra_starknet_honk')
|
|
505
|
+
.description('Verify a proof. Process exists with success or failure code.')
|
|
506
|
+
.requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
|
|
507
|
+
.requiredOption('-k, --vk <path>', 'path to a verification key. avoids recomputation.')
|
|
508
|
+
.action(async ({ proofPath, vk }) => {
|
|
509
|
+
const { crsPath } = handleGlobalOptions();
|
|
510
|
+
const result = await verifyUltraHonk(proofPath, vk, crsPath, { starknet: true });
|
|
511
|
+
process.exit(result ? 0 : 1);
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
program
|
|
515
|
+
.command('proof_as_fields_honk')
|
|
292
516
|
.description('Return the proof as fields elements')
|
|
293
517
|
.requiredOption('-p, --proof-path <path>', 'Specify the proof path')
|
|
294
|
-
.requiredOption('-n, --num-public-inputs <number>', 'Specify the number of public inputs')
|
|
295
518
|
.requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the proof fields')
|
|
296
|
-
.action(async ({ proofPath,
|
|
297
|
-
handleGlobalOptions();
|
|
298
|
-
await
|
|
519
|
+
.action(async ({ proofPath, outputPath }) => {
|
|
520
|
+
const { crsPath } = handleGlobalOptions();
|
|
521
|
+
await proofAsFieldsUltraHonk(proofPath, outputPath, crsPath);
|
|
299
522
|
});
|
|
300
523
|
|
|
301
524
|
program
|
|
302
|
-
.command('
|
|
303
|
-
.description('Return the
|
|
304
|
-
.requiredOption('-
|
|
305
|
-
.requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the verification key fields
|
|
306
|
-
.action(async ({
|
|
307
|
-
handleGlobalOptions();
|
|
308
|
-
await
|
|
525
|
+
.command('vk_as_fields_ultra_honk')
|
|
526
|
+
.description('Return the verification key represented as fields elements.')
|
|
527
|
+
.requiredOption('-k, --vk-path <path>', 'Path to verification key.')
|
|
528
|
+
.requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the verification key fields.')
|
|
529
|
+
.action(async ({ vkPath, outputPath }) => {
|
|
530
|
+
const { crsPath } = handleGlobalOptions();
|
|
531
|
+
await vkAsFieldsUltraHonk(vkPath, outputPath, crsPath);
|
|
309
532
|
});
|
|
310
533
|
|
|
311
534
|
program.name('bb.js').parse(process.argv);
|