@aztec/bb-prover 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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 +7 -6
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +38 -15
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +9 -17
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +74 -165
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/honk.d.ts +2 -2
- package/dest/honk.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/instrumentation.d.ts +3 -3
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +21 -43
- package/dest/prover/client/bb_private_kernel_prover.d.ts +12 -6
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +38 -7
- 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 +9 -9
- package/dest/prover/proof_utils.d.ts.map +1 -1
- package/dest/prover/proof_utils.js +42 -25
- package/dest/prover/server/bb_prover.d.ts +27 -50
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +478 -182
- 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 +37 -25
- 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 +24 -34
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +506 -85
- 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 +1 -20
- package/dest/verifier/bb_verifier.d.ts +3 -5
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +23 -28
- package/dest/verifier/index.d.ts +2 -2
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -1
- package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/{queued_ivc_verifier.js → queued_chonk_verifier.js} +10 -41
- package/package.json +23 -23
- package/src/avm_proving_tests/avm_proving_tester.ts +49 -35
- package/src/bb/execute.ts +50 -148
- package/src/honk.ts +1 -1
- package/src/instrumentation.ts +22 -45
- package/src/prover/client/bb_private_kernel_prover.ts +50 -10
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/proof_utils.ts +53 -31
- package/src/prover/server/bb_prover.ts +252 -324
- package/src/test/delay_values.ts +38 -24
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +229 -155
- package/src/test/test_verifier.ts +8 -0
- package/src/verification_key/verification_key_data.ts +1 -26
- package/src/verifier/bb_verifier.ts +33 -36
- package/src/verifier/index.ts +1 -1
- package/src/verifier/{queued_ivc_verifier.ts → queued_chonk_verifier.ts} +10 -41
- 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 -48
- 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/dest/stats.d.ts +0 -4
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -45
- package/dest/verifier/queued_ivc_verifier.d.ts +0 -15
- package/dest/verifier/queued_ivc_verifier.d.ts.map +0 -1
- 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 -60
- package/src/prover/client/wasm/bundle.ts +0 -11
- package/src/prover/client/wasm/lazy.ts +0 -11
- package/src/stats.ts +0 -47
|
@@ -1,41 +1,59 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CHONK_PROOF_LENGTH,
|
|
3
|
+
HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE,
|
|
2
4
|
IPA_CLAIM_SIZE,
|
|
3
5
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
4
6
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
7
|
PAIRING_POINTS_SIZE,
|
|
6
8
|
ULTRA_KECCAK_PROOF_LENGTH,
|
|
7
9
|
} from '@aztec/constants';
|
|
8
|
-
import { Fr } from '@aztec/foundation/
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
10
|
-
import {
|
|
12
|
+
import { ChonkProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
11
13
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
12
14
|
|
|
13
15
|
import assert from 'assert';
|
|
14
16
|
import { promises as fs } from 'fs';
|
|
15
17
|
import * as path from 'path';
|
|
16
18
|
|
|
17
|
-
import {
|
|
19
|
+
import { PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/execute.js';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
|
-
* Create a
|
|
22
|
+
* Create a ChonkProof proof file.
|
|
21
23
|
*
|
|
22
24
|
* @param directory the directory to read the proof from.
|
|
23
|
-
* @returns the encapsulated
|
|
25
|
+
* @returns the encapsulated chonk proof
|
|
24
26
|
*/
|
|
25
|
-
export async function
|
|
26
|
-
const
|
|
27
|
-
|
|
27
|
+
export async function readChonkProofFromOutputDirectory(directory: string) {
|
|
28
|
+
const proofFilename = path.join(directory, PROOF_FILENAME);
|
|
29
|
+
const binaryProof = await fs.readFile(proofFilename);
|
|
30
|
+
const proofFields = splitBufferIntoFields(binaryProof);
|
|
31
|
+
return new ChonkProofWithPublicInputs(proofFields);
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
|
-
* Serialize a
|
|
35
|
+
* Serialize a ChonkProof to a proof file.
|
|
32
36
|
*
|
|
33
|
-
* @param proof the
|
|
37
|
+
* @param proof the ChonkProof from object
|
|
34
38
|
* @param directory the directory to write in
|
|
35
39
|
*/
|
|
36
|
-
export async function
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
export async function writeChonkProofToPath(chonkProof: ChonkProofWithPublicInputs, outputPath: string) {
|
|
41
|
+
// NB: Don't use chonkProof.toBuffer here because it will include the proof length.
|
|
42
|
+
const fieldsBuf = Buffer.concat(chonkProof.fieldsWithPublicInputs.map(field => field.toBuffer()));
|
|
43
|
+
await fs.writeFile(outputPath, fieldsBuf);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getNumCustomPublicInputs(proofLength: number, vkData: VerificationKeyData) {
|
|
47
|
+
let numPublicInputs = vkData.numPublicInputs;
|
|
48
|
+
if (proofLength == CHONK_PROOF_LENGTH) {
|
|
49
|
+
numPublicInputs -= HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE;
|
|
50
|
+
} else {
|
|
51
|
+
numPublicInputs -= PAIRING_POINTS_SIZE;
|
|
52
|
+
if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
|
|
53
|
+
numPublicInputs -= IPA_CLAIM_SIZE;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return numPublicInputs;
|
|
39
57
|
}
|
|
40
58
|
|
|
41
59
|
function splitBufferIntoFields(buffer: Buffer): Fr[] {
|
|
@@ -46,43 +64,47 @@ function splitBufferIntoFields(buffer: Buffer): Fr[] {
|
|
|
46
64
|
return fields;
|
|
47
65
|
}
|
|
48
66
|
|
|
49
|
-
export async function
|
|
50
|
-
|
|
67
|
+
export async function readProofsFromOutputDirectory<PROOF_LENGTH extends number>(
|
|
68
|
+
directory: string,
|
|
51
69
|
vkData: VerificationKeyData,
|
|
52
70
|
proofLength: PROOF_LENGTH,
|
|
53
71
|
logger: Logger,
|
|
54
72
|
): Promise<RecursiveProof<PROOF_LENGTH>> {
|
|
55
|
-
const publicInputsFilename = path.join(filePath, PUBLIC_INPUTS_FILENAME);
|
|
56
|
-
const proofFilename = path.join(filePath, PROOF_FILENAME);
|
|
57
|
-
|
|
58
|
-
const [binaryPublicInputs, binaryProof] = await Promise.all([
|
|
59
|
-
fs.readFile(publicInputsFilename),
|
|
60
|
-
fs.readFile(proofFilename),
|
|
61
|
-
]);
|
|
62
|
-
|
|
63
|
-
const fieldsWithoutPublicInputs = splitBufferIntoFields(binaryProof);
|
|
64
|
-
|
|
65
|
-
let numPublicInputs = vkData.numPublicInputs - PAIRING_POINTS_SIZE;
|
|
66
73
|
assert(
|
|
67
|
-
proofLength ==
|
|
74
|
+
proofLength == CHONK_PROOF_LENGTH ||
|
|
75
|
+
proofLength == NESTED_RECURSIVE_PROOF_LENGTH ||
|
|
68
76
|
proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH ||
|
|
69
77
|
proofLength == ULTRA_KECCAK_PROOF_LENGTH,
|
|
70
78
|
`Proof length must be one of the expected proof lengths, received ${proofLength}`,
|
|
71
79
|
);
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
|
|
81
|
+
const publicInputsFilename = path.join(directory, PUBLIC_INPUTS_FILENAME);
|
|
82
|
+
const proofFilename = path.join(directory, PROOF_FILENAME);
|
|
83
|
+
|
|
84
|
+
// Handle CHONK separately because bb outputs the proof fields with public inputs for CHONK.
|
|
85
|
+
const isChonk = proofLength == CHONK_PROOF_LENGTH;
|
|
86
|
+
|
|
87
|
+
const [binaryPublicInputs, binaryProof] = await Promise.all([
|
|
88
|
+
isChonk ? Buffer.alloc(0) : fs.readFile(publicInputsFilename),
|
|
89
|
+
fs.readFile(proofFilename),
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
const numPublicInputs = getNumCustomPublicInputs(proofLength, vkData);
|
|
93
|
+
let fieldsWithoutPublicInputs = splitBufferIntoFields(binaryProof);
|
|
94
|
+
if (isChonk) {
|
|
95
|
+
fieldsWithoutPublicInputs = fieldsWithoutPublicInputs.slice(numPublicInputs);
|
|
74
96
|
}
|
|
75
97
|
|
|
76
98
|
assert(
|
|
77
99
|
fieldsWithoutPublicInputs.length == proofLength,
|
|
78
|
-
`Proof length mismatch: ${fieldsWithoutPublicInputs.length} != ${proofLength}`,
|
|
100
|
+
`Proof fields length mismatch: ${fieldsWithoutPublicInputs.length} != ${proofLength}`,
|
|
79
101
|
);
|
|
80
102
|
|
|
81
103
|
// Concat binary public inputs and binary proof
|
|
82
104
|
// This buffer will have the form: [binary public inputs, binary proof]
|
|
83
105
|
const binaryProofWithPublicInputs = Buffer.concat([binaryPublicInputs, binaryProof]);
|
|
84
106
|
logger.debug(
|
|
85
|
-
`Circuit path: ${
|
|
107
|
+
`Circuit path: ${directory}, proof fields length: ${fieldsWithoutPublicInputs.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}`,
|
|
86
108
|
);
|
|
87
109
|
return new RecursiveProof(
|
|
88
110
|
fieldsWithoutPublicInputs,
|