@aztec/bb.js 1.0.0-nightly.20250613 → 1.0.0-nightly.20250615
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/browser/barretenberg/backend.d.ts.map +1 -1
- package/dest/browser/barretenberg/backend.js +13 -13
- package/dest/browser/barretenberg_api/index.d.ts +5 -5
- package/dest/browser/barretenberg_api/index.d.ts.map +1 -1
- package/dest/browser/barretenberg_api/index.js +11 -11
- package/dest/browser/barretenberg_wasm/fetch_code/browser/barretenberg-threads.js +1 -1
- package/dest/browser/barretenberg_wasm/fetch_code/browser/barretenberg.js +1 -1
- package/dest/node/barretenberg/backend.d.ts.map +1 -1
- package/dest/node/barretenberg/backend.js +13 -13
- package/dest/node/barretenberg_api/index.d.ts +5 -5
- package/dest/node/barretenberg_api/index.d.ts.map +1 -1
- package/dest/node/barretenberg_api/index.js +11 -11
- package/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
- package/dest/node/main.d.ts +1 -1
- package/dest/node/main.d.ts.map +1 -1
- package/dest/node/main.js +19 -18
- package/dest/node-cjs/barretenberg/backend.d.ts.map +1 -1
- package/dest/node-cjs/barretenberg/backend.js +13 -13
- package/dest/node-cjs/barretenberg_api/index.d.ts +5 -5
- package/dest/node-cjs/barretenberg_api/index.d.ts.map +1 -1
- package/dest/node-cjs/barretenberg_api/index.js +11 -11
- package/dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
- package/dest/node-cjs/main.d.ts +1 -1
- package/dest/node-cjs/main.d.ts.map +1 -1
- package/dest/node-cjs/main.js +19 -18
- package/package.json +1 -1
- package/src/barretenberg/backend.ts +18 -14
- package/src/barretenberg_api/index.ts +22 -12
- package/src/main.ts +18 -16
|
@@ -92,18 +92,6 @@ export class UltraHonkBackend {
|
|
|
92
92
|
async generateProof(compressedWitness: Uint8Array, options?: UltraHonkBackendOptions): Promise<ProofData> {
|
|
93
93
|
await this.instantiate();
|
|
94
94
|
|
|
95
|
-
const proveUltraHonk = options?.keccak
|
|
96
|
-
? this.api.acirProveUltraKeccakHonk.bind(this.api)
|
|
97
|
-
: options?.keccakZK
|
|
98
|
-
? this.api.acirProveUltraKeccakZkHonk.bind(this.api)
|
|
99
|
-
: options?.starknet
|
|
100
|
-
? this.api.acirProveUltraStarknetHonk.bind(this.api)
|
|
101
|
-
: options?.starknetZK
|
|
102
|
-
? this.api.acirProveUltraStarknetZkHonk.bind(this.api)
|
|
103
|
-
: this.api.acirProveUltraHonk.bind(this.api);
|
|
104
|
-
|
|
105
|
-
const proofWithPublicInputs = await proveUltraHonk(this.acirUncompressedBytecode, ungzip(compressedWitness));
|
|
106
|
-
|
|
107
95
|
// Write VK to get the number of public inputs
|
|
108
96
|
const writeVKUltraHonk = options?.keccak
|
|
109
97
|
? this.api.acirWriteVkUltraKeccakHonk.bind(this.api)
|
|
@@ -115,8 +103,24 @@ export class UltraHonkBackend {
|
|
|
115
103
|
? this.api.acirWriteVkUltraStarknetZkHonk.bind(this.api)
|
|
116
104
|
: this.api.acirWriteVkUltraHonk.bind(this.api);
|
|
117
105
|
|
|
118
|
-
const
|
|
119
|
-
const vkAsFields = await this.api.acirVkAsFieldsUltraHonk(new RawBuffer(
|
|
106
|
+
const vkBuf = await writeVKUltraHonk(this.acirUncompressedBytecode);
|
|
107
|
+
const vkAsFields = await this.api.acirVkAsFieldsUltraHonk(new RawBuffer(vkBuf));
|
|
108
|
+
|
|
109
|
+
const proveUltraHonk = options?.keccak
|
|
110
|
+
? this.api.acirProveUltraKeccakHonk.bind(this.api)
|
|
111
|
+
: options?.keccakZK
|
|
112
|
+
? this.api.acirProveUltraKeccakZkHonk.bind(this.api)
|
|
113
|
+
: options?.starknet
|
|
114
|
+
? this.api.acirProveUltraStarknetHonk.bind(this.api)
|
|
115
|
+
: options?.starknetZK
|
|
116
|
+
? this.api.acirProveUltraStarknetZkHonk.bind(this.api)
|
|
117
|
+
: this.api.acirProveUltraHonk.bind(this.api);
|
|
118
|
+
|
|
119
|
+
const proofWithPublicInputs = await proveUltraHonk(
|
|
120
|
+
this.acirUncompressedBytecode,
|
|
121
|
+
ungzip(compressedWitness),
|
|
122
|
+
new RawBuffer(vkBuf),
|
|
123
|
+
);
|
|
120
124
|
|
|
121
125
|
// Item at index 1 in VK is the number of public inputs
|
|
122
126
|
const publicInputsSizeIndex = 1; // index into VK for numPublicInputs
|
|
@@ -223,7 +223,6 @@ export class BarretenbergApi {
|
|
|
223
223
|
return out as any;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
227
226
|
async acirProveAndVerifyUltraHonk(constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Promise<boolean> {
|
|
228
227
|
const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable);
|
|
229
228
|
const outTypes: OutputType[] = [BoolDeserializer()];
|
|
@@ -384,8 +383,8 @@ export class BarretenbergApi {
|
|
|
384
383
|
return out as any;
|
|
385
384
|
}
|
|
386
385
|
|
|
387
|
-
async acirProveUltraHonk(acirVec: Uint8Array, witnessVec: Uint8Array): Promise<Uint8Array> {
|
|
388
|
-
const inArgs = [acirVec, witnessVec].map(serializeBufferable);
|
|
386
|
+
async acirProveUltraHonk(acirVec: Uint8Array, witnessVec: Uint8Array, vkBuf: Uint8Array): Promise<Uint8Array> {
|
|
387
|
+
const inArgs = [acirVec, witnessVec, vkBuf].map(serializeBufferable);
|
|
389
388
|
const outTypes: OutputType[] = [BufferDeserializer()];
|
|
390
389
|
const result = await this.wasm.callWasmExport(
|
|
391
390
|
'acir_prove_ultra_honk',
|
|
@@ -396,8 +395,8 @@ export class BarretenbergApi {
|
|
|
396
395
|
return out[0];
|
|
397
396
|
}
|
|
398
397
|
|
|
399
|
-
async acirProveUltraKeccakHonk(acirVec: Uint8Array, witnessVec: Uint8Array): Promise<Uint8Array> {
|
|
400
|
-
const inArgs = [acirVec, witnessVec].map(serializeBufferable);
|
|
398
|
+
async acirProveUltraKeccakHonk(acirVec: Uint8Array, witnessVec: Uint8Array, vkBuf: Uint8Array): Promise<Uint8Array> {
|
|
399
|
+
const inArgs = [acirVec, witnessVec, vkBuf].map(serializeBufferable);
|
|
401
400
|
const outTypes: OutputType[] = [BufferDeserializer()];
|
|
402
401
|
const result = await this.wasm.callWasmExport(
|
|
403
402
|
'acir_prove_ultra_keccak_honk',
|
|
@@ -408,8 +407,12 @@ export class BarretenbergApi {
|
|
|
408
407
|
return out[0];
|
|
409
408
|
}
|
|
410
409
|
|
|
411
|
-
async acirProveUltraKeccakZkHonk(
|
|
412
|
-
|
|
410
|
+
async acirProveUltraKeccakZkHonk(
|
|
411
|
+
acirVec: Uint8Array,
|
|
412
|
+
witnessVec: Uint8Array,
|
|
413
|
+
vkBuf: Uint8Array,
|
|
414
|
+
): Promise<Uint8Array> {
|
|
415
|
+
const inArgs = [acirVec, witnessVec, vkBuf].map(serializeBufferable);
|
|
413
416
|
const outTypes: OutputType[] = [BufferDeserializer()];
|
|
414
417
|
const result = await this.wasm.callWasmExport(
|
|
415
418
|
'acir_prove_ultra_keccak_zk_honk',
|
|
@@ -420,8 +423,12 @@ export class BarretenbergApi {
|
|
|
420
423
|
return out[0];
|
|
421
424
|
}
|
|
422
425
|
|
|
423
|
-
async acirProveUltraStarknetHonk(
|
|
424
|
-
|
|
426
|
+
async acirProveUltraStarknetHonk(
|
|
427
|
+
acirVec: Uint8Array,
|
|
428
|
+
witnessVec: Uint8Array,
|
|
429
|
+
vkBuf: Uint8Array,
|
|
430
|
+
): Promise<Uint8Array> {
|
|
431
|
+
const inArgs = [acirVec, witnessVec, vkBuf].map(serializeBufferable);
|
|
425
432
|
const outTypes: OutputType[] = [BufferDeserializer()];
|
|
426
433
|
const result = await this.wasm.callWasmExport(
|
|
427
434
|
'acir_prove_ultra_starknet_honk',
|
|
@@ -432,8 +439,12 @@ export class BarretenbergApi {
|
|
|
432
439
|
return out[0];
|
|
433
440
|
}
|
|
434
441
|
|
|
435
|
-
async acirProveUltraStarknetZkHonk(
|
|
436
|
-
|
|
442
|
+
async acirProveUltraStarknetZkHonk(
|
|
443
|
+
acirVec: Uint8Array,
|
|
444
|
+
witnessVec: Uint8Array,
|
|
445
|
+
vkBuf: Uint8Array,
|
|
446
|
+
): Promise<Uint8Array> {
|
|
447
|
+
const inArgs = [acirVec, witnessVec, vkBuf].map(serializeBufferable);
|
|
437
448
|
const outTypes: OutputType[] = [BufferDeserializer()];
|
|
438
449
|
const result = await this.wasm.callWasmExport(
|
|
439
450
|
'acir_prove_ultra_starknet_zk_honk',
|
|
@@ -819,7 +830,6 @@ export class BarretenbergApiSync {
|
|
|
819
830
|
return out as any;
|
|
820
831
|
}
|
|
821
832
|
|
|
822
|
-
|
|
823
833
|
acirProveAndVerifyUltraHonk(constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): boolean {
|
|
824
834
|
const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable);
|
|
825
835
|
const outTypes: OutputType[] = [BoolDeserializer()];
|
package/src/main.ts
CHANGED
|
@@ -148,6 +148,7 @@ export async function proveUltraHonk(
|
|
|
148
148
|
bytecodePath: string,
|
|
149
149
|
witnessPath: string,
|
|
150
150
|
crsPath: string,
|
|
151
|
+
vkPath: string,
|
|
151
152
|
outputPath: string,
|
|
152
153
|
options?: UltraHonkBackendOptions,
|
|
153
154
|
) {
|
|
@@ -166,7 +167,7 @@ export async function proveUltraHonk(
|
|
|
166
167
|
: options?.starknetZK
|
|
167
168
|
? api.acirProveUltraStarknetZkHonk.bind(api)
|
|
168
169
|
: api.acirProveUltraHonk.bind(api);
|
|
169
|
-
const proof = await acirProveUltraHonk(bytecode, witness);
|
|
170
|
+
const proof = await acirProveUltraHonk(bytecode, witness, new RawBuffer(readFileSync(vkPath)));
|
|
170
171
|
|
|
171
172
|
if (outputPath === '-') {
|
|
172
173
|
process.stdout.write(proof);
|
|
@@ -414,11 +415,12 @@ program
|
|
|
414
415
|
.description('Generate a proof and write it to a file.')
|
|
415
416
|
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
416
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.')
|
|
417
419
|
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
418
|
-
.action(async ({ bytecodePath, witnessPath, outputPath }) => {
|
|
420
|
+
.action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
|
|
419
421
|
const { crsPath } = handleGlobalOptions();
|
|
420
|
-
debug(`Creating UltraHonk proof
|
|
421
|
-
await proveUltraHonk(bytecodePath, witnessPath, crsPath, outputPath);
|
|
422
|
+
debug(`Creating UltraHonk proof bytecodePath=${bytecodePath}, witnessPath=${witnessPath}, vkPath=${vkPath}`);
|
|
423
|
+
await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath);
|
|
422
424
|
});
|
|
423
425
|
|
|
424
426
|
program
|
|
@@ -426,22 +428,23 @@ program
|
|
|
426
428
|
.description('Generate a proof and write it to a file.')
|
|
427
429
|
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
428
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.')
|
|
429
432
|
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
430
|
-
.action(async ({ bytecodePath, witnessPath, outputPath }) => {
|
|
433
|
+
.action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
|
|
431
434
|
const { crsPath } = handleGlobalOptions();
|
|
432
|
-
await proveUltraHonk(bytecodePath, witnessPath, crsPath, outputPath, { keccak: true });
|
|
435
|
+
await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath, { keccak: true });
|
|
433
436
|
});
|
|
434
437
|
|
|
435
438
|
program
|
|
436
439
|
.command('prove_ultra_starknet_honk')
|
|
437
440
|
.description('Generate a proof and write it to a file.')
|
|
438
441
|
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
439
|
-
.option('-r, --recursive', 'Create a SNARK friendly proof', false)
|
|
440
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.')
|
|
441
444
|
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
|
|
442
|
-
.action(async ({ bytecodePath, witnessPath, outputPath }) => {
|
|
445
|
+
.action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
|
|
443
446
|
const { crsPath } = handleGlobalOptions();
|
|
444
|
-
await proveUltraHonk(bytecodePath, witnessPath, crsPath, outputPath, { starknet: true });
|
|
447
|
+
await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath, { starknet: true });
|
|
445
448
|
});
|
|
446
449
|
|
|
447
450
|
program
|
|
@@ -469,7 +472,6 @@ program
|
|
|
469
472
|
.command('write_vk_ultra_starknet_honk')
|
|
470
473
|
.description('Output verification key.')
|
|
471
474
|
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
|
|
472
|
-
.option('-r, --recursive', 'Create a SNARK friendly proof', false)
|
|
473
475
|
.requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
|
|
474
476
|
.action(async ({ bytecodePath, outputPath }) => {
|
|
475
477
|
const { crsPath } = handleGlobalOptions();
|
|
@@ -480,10 +482,10 @@ program
|
|
|
480
482
|
.command('verify_ultra_honk')
|
|
481
483
|
.description('Verify a proof. Process exists with success or failure code.')
|
|
482
484
|
.requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
|
|
483
|
-
.requiredOption('-k, --vk <path>', 'path to a verification key. avoids recomputation.')
|
|
484
|
-
.action(async ({ proofPath,
|
|
485
|
+
.requiredOption('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
|
|
486
|
+
.action(async ({ proofPath, vkPath }) => {
|
|
485
487
|
const { crsPath } = handleGlobalOptions();
|
|
486
|
-
const result = await verifyUltraHonk(proofPath,
|
|
488
|
+
const result = await verifyUltraHonk(proofPath, vkPath, crsPath);
|
|
487
489
|
process.exit(result ? 0 : 1);
|
|
488
490
|
});
|
|
489
491
|
|
|
@@ -491,10 +493,10 @@ program
|
|
|
491
493
|
.command('verify_ultra_keccak_honk')
|
|
492
494
|
.description('Verify a proof. Process exists with success or failure code.')
|
|
493
495
|
.requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
|
|
494
|
-
.requiredOption('-k, --vk <path>', 'path to a verification key. avoids recomputation.')
|
|
495
|
-
.action(async ({ proofPath,
|
|
496
|
+
.requiredOption('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
|
|
497
|
+
.action(async ({ proofPath, vkPath }) => {
|
|
496
498
|
const { crsPath } = handleGlobalOptions();
|
|
497
|
-
const result = await verifyUltraHonk(proofPath,
|
|
499
|
+
const result = await verifyUltraHonk(proofPath, vkPath, crsPath, { keccak: true });
|
|
498
500
|
process.exit(result ? 0 : 1);
|
|
499
501
|
});
|
|
500
502
|
|