@aztec/bb-prover 0.0.0-test.0 → 0.0.1-commit.21caa21
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 +14 -18
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +130 -79
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +14 -47
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +132 -236
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +3 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/honk.d.ts +3 -3
- package/dest/honk.d.ts.map +1 -1
- package/dest/honk.js +3 -2
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/instrumentation.d.ts +3 -3
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +2 -4
- package/dest/prover/client/bb_private_kernel_prover.d.ts +32 -0
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/{bb_private_kernel_prover.js → client/bb_private_kernel_prover.js} +42 -20
- 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 +8 -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 +8 -0
- package/dest/prover/index.d.ts +3 -4
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/prover/index.js +2 -3
- package/dest/prover/proof_utils.d.ts +19 -0
- package/dest/prover/proof_utils.d.ts.map +1 -0
- package/dest/prover/proof_utils.js +72 -0
- package/dest/prover/server/bb_prover.d.ts +100 -0
- package/dest/prover/server/bb_prover.d.ts.map +1 -0
- package/dest/prover/server/bb_prover.js +339 -0
- 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 +33 -21
- package/dest/test/index.d.ts +1 -1
- package/dest/test/test_circuit_prover.d.ts +25 -34
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +85 -59
- package/dest/test/test_verifier.d.ts +6 -3
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +23 -1
- package/dest/verification_key/verification_key_data.d.ts +7 -1
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +23 -29
- package/dest/verifier/bb_verifier.d.ts +6 -5
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +46 -25
- package/dest/verifier/index.d.ts +2 -1
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- 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_chonk_verifier.js +132 -0
- package/package.json +35 -33
- package/src/avm_proving_tests/avm_proving_tester.ts +210 -104
- package/src/bb/execute.ts +103 -250
- package/src/config.ts +2 -0
- package/src/honk.ts +3 -2
- package/src/index.ts +1 -0
- package/src/instrumentation.ts +2 -4
- package/src/prover/{bb_private_kernel_prover.ts → client/bb_private_kernel_prover.ts} +78 -30
- package/src/prover/client/bundle.ts +11 -0
- package/src/prover/client/lazy.ts +11 -0
- package/src/prover/index.ts +2 -3
- package/src/prover/proof_utils.ts +115 -0
- package/src/prover/server/bb_prover.ts +733 -0
- package/src/test/delay_values.ts +33 -21
- package/src/test/test_circuit_prover.ts +260 -147
- package/src/test/test_verifier.ts +15 -3
- package/src/verification_key/verification_key_data.ts +29 -24
- package/src/verifier/bb_verifier.ts +63 -32
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_chonk_verifier.ts +140 -0
- package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_native_private_kernel_prover.js +0 -69
- package/dest/prover/bb_private_kernel_prover.d.ts +0 -32
- package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.d.ts +0 -120
- package/dest/prover/bb_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.js +0 -423
- package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
- package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.js +0 -43
- package/dest/stats.d.ts +0 -5
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -62
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +0 -46
- package/dest/wasm/bundle.d.ts +0 -6
- package/dest/wasm/bundle.d.ts.map +0 -1
- package/dest/wasm/bundle.js +0 -8
- package/dest/wasm/lazy.d.ts +0 -6
- package/dest/wasm/lazy.d.ts.map +0 -1
- package/dest/wasm/lazy.js +0 -8
- package/src/prover/bb_native_private_kernel_prover.ts +0 -119
- package/src/prover/bb_prover.ts +0 -781
- package/src/prover/client_ivc_proof_utils.ts +0 -42
- package/src/stats.ts +0 -64
- package/src/wasm/bb_wasm_private_kernel_prover.ts +0 -55
- package/src/wasm/bundle.ts +0 -11
- package/src/wasm/lazy.ts +0 -11
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_prover.ts"],"names":[],"mappings":"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"}
|
package/dest/prover/bb_prover.js
DELETED
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
/* eslint-disable require-await */ function _ts_decorate(decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
import { AGGREGATION_OBJECT_LENGTH, AVM_PROOF_LENGTH_IN_FIELDS, IPA_CLAIM_LENGTH, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
|
|
8
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
9
|
-
import { runInDirectory } from '@aztec/foundation/fs';
|
|
10
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
11
|
-
import { BufferReader } from '@aztec/foundation/serialize';
|
|
12
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
13
|
-
import { ServerCircuitArtifacts, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap, convertBlockRootRollupInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap, convertEmptyBlockRootRollupInputsToWitnessMap, convertEmptyBlockRootRollupOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap, convertPrivateBaseRollupInputsToWitnessMap, convertPrivateBaseRollupOutputsFromWitnessMap, convertPublicBaseRollupInputsToWitnessMap, convertPublicBaseRollupOutputsFromWitnessMap, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertSingleTxBlockRootRollupInputsToWitnessMap, convertSingleTxBlockRootRollupOutputsFromWitnessMap } from '@aztec/noir-protocol-circuits-types/server';
|
|
14
|
-
import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
15
|
-
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
16
|
-
import { ProvingError } from '@aztec/stdlib/errors';
|
|
17
|
-
import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
18
|
-
import { Proof, RecursiveProof, makeRecursiveProofFromBinary } from '@aztec/stdlib/proofs';
|
|
19
|
-
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
20
|
-
import { assert } from 'console';
|
|
21
|
-
import crypto from 'crypto';
|
|
22
|
-
import { promises as fs } from 'fs';
|
|
23
|
-
import * as path from 'path';
|
|
24
|
-
import { BB_RESULT, PROOF_FIELDS_FILENAME, PROOF_FILENAME, VK_FILENAME, generateAvmProof, generateProof, generateTubeProof, verifyAvmProof, verifyProof } from '../bb/execute.js';
|
|
25
|
-
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
26
|
-
import { ProverInstrumentation } from '../instrumentation.js';
|
|
27
|
-
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
28
|
-
import { extractAvmVkData, extractVkData } from '../verification_key/verification_key_data.js';
|
|
29
|
-
import { writeToOutputDirectory } from './client_ivc_proof_utils.js';
|
|
30
|
-
const logger = createLogger('bb-prover');
|
|
31
|
-
// All `ServerCircuitArtifact` are recursive.
|
|
32
|
-
const SERVER_CIRCUIT_RECURSIVE = true;
|
|
33
|
-
/**
|
|
34
|
-
* Prover implementation that uses barretenberg native proving
|
|
35
|
-
*/ export class BBNativeRollupProver {
|
|
36
|
-
config;
|
|
37
|
-
instrumentation;
|
|
38
|
-
constructor(config, telemetry){
|
|
39
|
-
this.config = config;
|
|
40
|
-
this.instrumentation = new ProverInstrumentation(telemetry, 'BBNativeRollupProver');
|
|
41
|
-
}
|
|
42
|
-
get tracer() {
|
|
43
|
-
return this.instrumentation.tracer;
|
|
44
|
-
}
|
|
45
|
-
static async new(config, telemetry = getTelemetryClient()) {
|
|
46
|
-
await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
|
|
47
|
-
await fs.mkdir(config.acvmWorkingDirectory, {
|
|
48
|
-
recursive: true
|
|
49
|
-
});
|
|
50
|
-
await fs.access(config.bbBinaryPath, fs.constants.R_OK);
|
|
51
|
-
await fs.mkdir(config.bbWorkingDirectory, {
|
|
52
|
-
recursive: true
|
|
53
|
-
});
|
|
54
|
-
logger.info(`Using native BB at ${config.bbBinaryPath} and working directory ${config.bbWorkingDirectory}`);
|
|
55
|
-
logger.info(`Using native ACVM at ${config.acvmBinaryPath} and working directory ${config.acvmWorkingDirectory}`);
|
|
56
|
-
return new BBNativeRollupProver(config, telemetry);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Simulates the base parity circuit from its inputs.
|
|
60
|
-
* @param inputs - Inputs to the circuit.
|
|
61
|
-
* @returns The public inputs of the parity circuit.
|
|
62
|
-
*/ async getBaseParityProof(inputs) {
|
|
63
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(inputs, 'BaseParityArtifact', RECURSIVE_PROOF_LENGTH, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap);
|
|
64
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('BaseParityArtifact');
|
|
65
|
-
await this.verifyProof('BaseParityArtifact', proof.binaryProof);
|
|
66
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Simulates the root parity circuit from its inputs.
|
|
70
|
-
* @param inputs - Inputs to the circuit.
|
|
71
|
-
* @returns The public inputs of the parity circuit.
|
|
72
|
-
*/ async getRootParityProof(inputs) {
|
|
73
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(inputs, 'RootParityArtifact', NESTED_RECURSIVE_PROOF_LENGTH, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap);
|
|
74
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('RootParityArtifact');
|
|
75
|
-
await this.verifyProof('RootParityArtifact', proof.binaryProof);
|
|
76
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Creates an AVM proof and verifies it.
|
|
80
|
-
* @param inputs - The inputs to the AVM circuit.
|
|
81
|
-
* @returns The proof.
|
|
82
|
-
*/ async getAvmProof(inputs) {
|
|
83
|
-
const proofAndVk = await this.createAvmProof(inputs);
|
|
84
|
-
await this.verifyAvmProof(proofAndVk.proof.binaryProof, proofAndVk.verificationKey);
|
|
85
|
-
return proofAndVk;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Simulates the base rollup circuit from its inputs.
|
|
89
|
-
* @param inputs - Inputs to the circuit.
|
|
90
|
-
* @returns The public inputs as outputs of the simulation.
|
|
91
|
-
*/ async getPrivateBaseRollupProof(inputs) {
|
|
92
|
-
const artifactName = 'PrivateBaseRollupArtifact';
|
|
93
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(inputs, artifactName, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertPrivateBaseRollupInputsToWitnessMap, convertPrivateBaseRollupOutputsFromWitnessMap);
|
|
94
|
-
const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
|
|
95
|
-
await this.verifyProof(artifactName, proof.binaryProof);
|
|
96
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Requests that the public kernel tail circuit be executed and the proof generated
|
|
100
|
-
* @param kernelRequest - The object encapsulating the request for a proof
|
|
101
|
-
* @returns The requested circuit's public inputs and proof
|
|
102
|
-
*/ async getPublicBaseRollupProof(inputs) {
|
|
103
|
-
const artifactName = 'PublicBaseRollupArtifact';
|
|
104
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(inputs, artifactName, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertPublicBaseRollupInputsToWitnessMap, convertPublicBaseRollupOutputsFromWitnessMap);
|
|
105
|
-
const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
|
|
106
|
-
await this.verifyProof(artifactName, proof.binaryProof);
|
|
107
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Simulates the merge rollup circuit from its inputs.
|
|
111
|
-
* @param input - Inputs to the circuit.
|
|
112
|
-
* @returns The public inputs as outputs of the simulation.
|
|
113
|
-
*/ async getMergeRollupProof(input) {
|
|
114
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(input, 'MergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap);
|
|
115
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('MergeRollupArtifact');
|
|
116
|
-
await this.verifyProof('MergeRollupArtifact', proof.binaryProof);
|
|
117
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Simulates the block root rollup circuit from its inputs.
|
|
121
|
-
* @param input - Inputs to the circuit.
|
|
122
|
-
* @returns The public inputs as outputs of the simulation.
|
|
123
|
-
*/ async getBlockRootRollupProof(input) {
|
|
124
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(input, 'BlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootRollupInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap);
|
|
125
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('BlockRootRollupArtifact');
|
|
126
|
-
await this.verifyProof('BlockRootRollupArtifact', proof.binaryProof);
|
|
127
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
128
|
-
}
|
|
129
|
-
async getSingleTxBlockRootRollupProof(input) {
|
|
130
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(input, 'SingleTxBlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertSingleTxBlockRootRollupInputsToWitnessMap, convertSingleTxBlockRootRollupOutputsFromWitnessMap);
|
|
131
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('SingleTxBlockRootRollupArtifact');
|
|
132
|
-
await this.verifyProof('SingleTxBlockRootRollupArtifact', proof.binaryProof);
|
|
133
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Simulates the empty block root rollup circuit from its inputs.
|
|
137
|
-
* @param input - Inputs to the circuit.
|
|
138
|
-
* @returns The public inputs as outputs of the simulation.
|
|
139
|
-
*/ async getEmptyBlockRootRollupProof(input) {
|
|
140
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(input, 'EmptyBlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertEmptyBlockRootRollupInputsToWitnessMap, convertEmptyBlockRootRollupOutputsFromWitnessMap);
|
|
141
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('EmptyBlockRootRollupArtifact');
|
|
142
|
-
await this.verifyProof('EmptyBlockRootRollupArtifact', proof.binaryProof);
|
|
143
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Simulates the block merge rollup circuit from its inputs.
|
|
147
|
-
* @param input - Inputs to the circuit.
|
|
148
|
-
* @returns The public inputs as outputs of the simulation.
|
|
149
|
-
*/ async getBlockMergeRollupProof(input) {
|
|
150
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(input, 'BlockMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap);
|
|
151
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('BlockMergeRollupArtifact');
|
|
152
|
-
await this.verifyProof('BlockMergeRollupArtifact', proof.binaryProof);
|
|
153
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Simulates the root rollup circuit from its inputs.
|
|
157
|
-
* @param input - Inputs to the circuit.
|
|
158
|
-
* @returns The public inputs as outputs of the simulation.
|
|
159
|
-
*/ async getRootRollupProof(input) {
|
|
160
|
-
const { circuitOutput, proof } = await this.createProof(input, 'RootRollupArtifact', convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap);
|
|
161
|
-
const recursiveProof = makeRecursiveProofFromBinary(proof, NESTED_RECURSIVE_PROOF_LENGTH);
|
|
162
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('RootRollupArtifact');
|
|
163
|
-
await this.verifyProof('RootRollupArtifact', proof);
|
|
164
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, recursiveProof, verificationKey);
|
|
165
|
-
}
|
|
166
|
-
async generateProofWithBB(input, circuitType, convertInput, convertOutput, workingDirectory) {
|
|
167
|
-
// Have the ACVM write the partial witness here
|
|
168
|
-
const outputWitnessFile = path.join(workingDirectory, 'partial-witness.gz');
|
|
169
|
-
// Generate the partial witness using the ACVM
|
|
170
|
-
// A further temp directory will be created beneath ours and then cleaned up after the partial witness has been copied to our specified location
|
|
171
|
-
const simulator = new NativeACVMSimulator(this.config.acvmWorkingDirectory, this.config.acvmBinaryPath, outputWitnessFile);
|
|
172
|
-
const artifact = ServerCircuitArtifacts[circuitType];
|
|
173
|
-
logger.debug(`Generating witness data for ${circuitType}`);
|
|
174
|
-
const inputWitness = convertInput(input);
|
|
175
|
-
const timer = new Timer();
|
|
176
|
-
const outputWitness = await simulator.executeProtocolCircuit(inputWitness, artifact);
|
|
177
|
-
const output = convertOutput(outputWitness);
|
|
178
|
-
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
179
|
-
this.instrumentation.recordDuration('witGenDuration', circuitName, timer);
|
|
180
|
-
this.instrumentation.recordSize('witGenInputSize', circuitName, input.toBuffer().length);
|
|
181
|
-
this.instrumentation.recordSize('witGenOutputSize', circuitName, output.toBuffer().length);
|
|
182
|
-
logger.info(`Generated witness`, {
|
|
183
|
-
circuitName,
|
|
184
|
-
duration: timer.ms(),
|
|
185
|
-
inputSize: input.toBuffer().length,
|
|
186
|
-
outputSize: output.toBuffer().length,
|
|
187
|
-
eventName: 'circuit-witness-generation'
|
|
188
|
-
});
|
|
189
|
-
// Now prove the circuit from the generated witness
|
|
190
|
-
logger.debug(`Proving ${circuitType}...`);
|
|
191
|
-
const provingResult = await generateProof(this.config.bbBinaryPath, workingDirectory, circuitType, Buffer.from(artifact.bytecode, 'base64'), SERVER_CIRCUIT_RECURSIVE, outputWitnessFile, getUltraHonkFlavorForCircuit(circuitType), logger.debug);
|
|
192
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
193
|
-
logger.error(`Failed to generate proof for ${circuitType}: ${provingResult.reason}`);
|
|
194
|
-
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
circuitOutput: output,
|
|
198
|
-
provingResult
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
async createProof(input, circuitType, convertInput, convertOutput) {
|
|
202
|
-
const operation = async (bbWorkingDirectory)=>{
|
|
203
|
-
const { provingResult, circuitOutput: output } = await this.generateProofWithBB(input, circuitType, convertInput, convertOutput, bbWorkingDirectory);
|
|
204
|
-
// Read the binary proof
|
|
205
|
-
const rawProof = await fs.readFile(`${provingResult.proofPath}/${PROOF_FILENAME}`);
|
|
206
|
-
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
207
|
-
const proof = new Proof(rawProof, vkData.numPublicInputs);
|
|
208
|
-
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
209
|
-
this.instrumentation.recordDuration('provingDuration', circuitName, provingResult.durationMs);
|
|
210
|
-
this.instrumentation.recordSize('proofSize', circuitName, proof.buffer.length);
|
|
211
|
-
this.instrumentation.recordSize('circuitPublicInputCount', circuitName, vkData.numPublicInputs);
|
|
212
|
-
this.instrumentation.recordSize('circuitSize', circuitName, vkData.circuitSize);
|
|
213
|
-
logger.info(`Generated proof for ${circuitType} in ${Math.ceil(provingResult.durationMs)} ms`, {
|
|
214
|
-
circuitName,
|
|
215
|
-
// does not include reading the proof from disk
|
|
216
|
-
duration: provingResult.durationMs,
|
|
217
|
-
proofSize: proof.buffer.length,
|
|
218
|
-
eventName: 'circuit-proving',
|
|
219
|
-
// circuitOutput is the partial witness that became the input to the proof
|
|
220
|
-
inputSize: output.toBuffer().length,
|
|
221
|
-
circuitSize: vkData.circuitSize,
|
|
222
|
-
numPublicInputs: vkData.numPublicInputs
|
|
223
|
-
});
|
|
224
|
-
return {
|
|
225
|
-
circuitOutput: output,
|
|
226
|
-
proof
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
return await this.runInDirectory(operation);
|
|
230
|
-
}
|
|
231
|
-
async generateAvmProofWithBB(input, workingDirectory) {
|
|
232
|
-
logger.info(`Proving avm-circuit for ${input.functionName}...`);
|
|
233
|
-
const provingResult = await generateAvmProof(this.config.bbBinaryPath, workingDirectory, input, logger);
|
|
234
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
235
|
-
logger.error(`Failed to generate AVM proof for ${input.functionName}: ${provingResult.reason}`);
|
|
236
|
-
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
237
|
-
}
|
|
238
|
-
return provingResult;
|
|
239
|
-
}
|
|
240
|
-
async generateTubeProofWithBB(bbWorkingDirectory, input) {
|
|
241
|
-
logger.debug(`Proving tube...`);
|
|
242
|
-
const hasher = crypto.createHash('sha256');
|
|
243
|
-
hasher.update(input.toBuffer());
|
|
244
|
-
await writeToOutputDirectory(input.clientIVCData, bbWorkingDirectory);
|
|
245
|
-
const provingResult = await generateTubeProof(this.config.bbBinaryPath, bbWorkingDirectory, logger.verbose);
|
|
246
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
247
|
-
logger.error(`Failed to generate proof for tube circuit: ${provingResult.reason}`);
|
|
248
|
-
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
249
|
-
}
|
|
250
|
-
return provingResult;
|
|
251
|
-
}
|
|
252
|
-
async createAvmProof(input) {
|
|
253
|
-
const operation = async (bbWorkingDirectory)=>{
|
|
254
|
-
const provingResult = await this.generateAvmProofWithBB(input, bbWorkingDirectory);
|
|
255
|
-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6773): this VK data format is wrong.
|
|
256
|
-
// In particular, the number of public inputs, etc will be wrong.
|
|
257
|
-
const verificationKey = await extractAvmVkData(provingResult.vkPath);
|
|
258
|
-
const avmProof = await this.readAvmProofAsFields(provingResult.proofPath, verificationKey);
|
|
259
|
-
const circuitType = 'avm-circuit';
|
|
260
|
-
const appCircuitName = 'unknown';
|
|
261
|
-
this.instrumentation.recordAvmDuration('provingDuration', appCircuitName, provingResult.durationMs);
|
|
262
|
-
this.instrumentation.recordAvmSize('proofSize', appCircuitName, avmProof.binaryProof.buffer.length);
|
|
263
|
-
this.instrumentation.recordAvmSize('circuitPublicInputCount', appCircuitName, verificationKey.numPublicInputs);
|
|
264
|
-
this.instrumentation.recordAvmSize('circuitSize', appCircuitName, verificationKey.circuitSize);
|
|
265
|
-
logger.info(`Generated proof for ${circuitType}(${input.functionName}) in ${Math.ceil(provingResult.durationMs)} ms`, {
|
|
266
|
-
circuitName: circuitType,
|
|
267
|
-
appCircuitName: input.functionName,
|
|
268
|
-
// does not include reading the proof from disk
|
|
269
|
-
duration: provingResult.durationMs,
|
|
270
|
-
proofSize: avmProof.binaryProof.buffer.length,
|
|
271
|
-
eventName: 'circuit-proving',
|
|
272
|
-
inputSize: input.serializeWithMessagePack().length,
|
|
273
|
-
circuitSize: verificationKey.circuitSize,
|
|
274
|
-
numPublicInputs: verificationKey.numPublicInputs
|
|
275
|
-
});
|
|
276
|
-
return makeProofAndVerificationKey(avmProof, verificationKey);
|
|
277
|
-
};
|
|
278
|
-
return await this.runInDirectory(operation);
|
|
279
|
-
}
|
|
280
|
-
async getTubeProof(input) {
|
|
281
|
-
const operation = async (bbWorkingDirectory)=>{
|
|
282
|
-
logger.debug(`createTubeProof: ${bbWorkingDirectory}`);
|
|
283
|
-
const provingResult = await this.generateTubeProofWithBB(bbWorkingDirectory, input);
|
|
284
|
-
// Read the proof as fields
|
|
285
|
-
// TODO(AD): this is the only remaining use of extractVkData.
|
|
286
|
-
const tubeVK = await extractVkData(provingResult.vkPath);
|
|
287
|
-
const tubeProof = await this.readProofAsFields(provingResult.proofPath, tubeVK, TUBE_PROOF_LENGTH);
|
|
288
|
-
this.instrumentation.recordDuration('provingDuration', 'tubeCircuit', provingResult.durationMs);
|
|
289
|
-
this.instrumentation.recordSize('proofSize', 'tubeCircuit', tubeProof.binaryProof.buffer.length);
|
|
290
|
-
this.instrumentation.recordSize('circuitPublicInputCount', 'tubeCircuit', tubeVK.numPublicInputs);
|
|
291
|
-
this.instrumentation.recordSize('circuitSize', 'tubeCircuit', tubeVK.circuitSize);
|
|
292
|
-
// Sanity check the tube proof (can be removed later)
|
|
293
|
-
await this.verifyWithKey('ultra_rollup_honk', tubeVK, tubeProof.binaryProof);
|
|
294
|
-
logger.info(`Generated proof for tubeCircuit in ${Math.ceil(provingResult.durationMs)} ms, size: ${tubeProof.proof.length} fields`);
|
|
295
|
-
return makeProofAndVerificationKey(tubeProof, tubeVK);
|
|
296
|
-
};
|
|
297
|
-
return await this.runInDirectory(operation);
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Executes a circuit and returns its outputs and corresponding proof with embedded aggregation object
|
|
301
|
-
* @param witnessMap - The input witness
|
|
302
|
-
* @param circuitType - The type of circuit to be executed
|
|
303
|
-
* @param proofLength - The length of the proof to be generated. This is a dummy parameter to aid in type checking
|
|
304
|
-
* @param convertInput - Function for mapping the input object to a witness map.
|
|
305
|
-
* @param convertOutput - Function for parsing the output witness to it's corresponding object
|
|
306
|
-
* @returns The circuits output object and it's proof
|
|
307
|
-
*/ async createRecursiveProof(input, circuitType, proofLength, convertInput, convertOutput) {
|
|
308
|
-
// this probably is gonna need to call client ivc
|
|
309
|
-
const operation = async (bbWorkingDirectory)=>{
|
|
310
|
-
const { provingResult, circuitOutput: output } = await this.generateProofWithBB(input, circuitType, convertInput, convertOutput, bbWorkingDirectory);
|
|
311
|
-
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
312
|
-
// Read the proof as fields
|
|
313
|
-
const proof = await this.readProofAsFields(provingResult.proofPath, vkData, proofLength);
|
|
314
|
-
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
315
|
-
this.instrumentation.recordDuration('provingDuration', circuitName, provingResult.durationMs);
|
|
316
|
-
this.instrumentation.recordSize('proofSize', circuitName, proof.binaryProof.buffer.length);
|
|
317
|
-
this.instrumentation.recordSize('circuitPublicInputCount', circuitName, vkData.numPublicInputs);
|
|
318
|
-
this.instrumentation.recordSize('circuitSize', circuitName, vkData.circuitSize);
|
|
319
|
-
logger.info(`Generated proof for ${circuitType} in ${Math.ceil(provingResult.durationMs)} ms, size: ${proof.proof.length} fields`, {
|
|
320
|
-
circuitName,
|
|
321
|
-
circuitSize: vkData.circuitSize,
|
|
322
|
-
duration: provingResult.durationMs,
|
|
323
|
-
inputSize: output.toBuffer().length,
|
|
324
|
-
proofSize: proof.binaryProof.buffer.length,
|
|
325
|
-
eventName: 'circuit-proving',
|
|
326
|
-
numPublicInputs: vkData.numPublicInputs
|
|
327
|
-
});
|
|
328
|
-
return {
|
|
329
|
-
circuitOutput: output,
|
|
330
|
-
proof
|
|
331
|
-
};
|
|
332
|
-
};
|
|
333
|
-
return await this.runInDirectory(operation);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Verifies a proof, will generate the verification key if one is not cached internally
|
|
337
|
-
* @param circuitType - The type of circuit whose proof is to be verified
|
|
338
|
-
* @param proof - The proof to be verified
|
|
339
|
-
*/ async verifyProof(circuitType, proof) {
|
|
340
|
-
const verificationKey = this.getVerificationKeyDataForCircuit(circuitType);
|
|
341
|
-
return await this.verifyWithKey(getUltraHonkFlavorForCircuit(circuitType), verificationKey, proof);
|
|
342
|
-
}
|
|
343
|
-
async verifyAvmProof(proof, verificationKey) {
|
|
344
|
-
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath)=>verifyAvmProof(this.config.bbBinaryPath, proofPath, vkPath, logger));
|
|
345
|
-
}
|
|
346
|
-
async verifyWithKey(flavor, verificationKey, proof) {
|
|
347
|
-
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath)=>verifyProof(this.config.bbBinaryPath, proofPath, vkPath, flavor, logger));
|
|
348
|
-
}
|
|
349
|
-
async verifyWithKeyInternal(proof, verificationKey, verificationFunction) {
|
|
350
|
-
const operation = async (bbWorkingDirectory)=>{
|
|
351
|
-
const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
352
|
-
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
353
|
-
await fs.writeFile(proofFileName, proof.buffer);
|
|
354
|
-
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
355
|
-
const result = await verificationFunction(proofFileName, verificationKeyPath);
|
|
356
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
357
|
-
const errorMessage = `Failed to verify proof from key!`;
|
|
358
|
-
throw new ProvingError(errorMessage, result, result.retry);
|
|
359
|
-
}
|
|
360
|
-
logger.info(`Successfully verified proof from key in ${result.durationMs} ms`);
|
|
361
|
-
};
|
|
362
|
-
await this.runInDirectory(operation);
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Returns the verification key data for a circuit.
|
|
366
|
-
* @param circuitType - The type of circuit for which the verification key is required
|
|
367
|
-
* @returns The verification key data
|
|
368
|
-
*/ getVerificationKeyDataForCircuit(circuitType) {
|
|
369
|
-
const vk = ServerCircuitVks[circuitType];
|
|
370
|
-
if (vk === undefined) {
|
|
371
|
-
throw new Error('Could not find VK for server artifact ' + circuitType);
|
|
372
|
-
}
|
|
373
|
-
return vk;
|
|
374
|
-
}
|
|
375
|
-
async readProofAsFields(filePath, vkData, proofLength) {
|
|
376
|
-
const proofFilename = path.join(filePath, PROOF_FILENAME);
|
|
377
|
-
const proofFieldsFilename = path.join(filePath, PROOF_FIELDS_FILENAME);
|
|
378
|
-
const [binaryProof, proofString] = await Promise.all([
|
|
379
|
-
fs.readFile(proofFilename),
|
|
380
|
-
fs.readFile(proofFieldsFilename, {
|
|
381
|
-
encoding: 'utf-8'
|
|
382
|
-
})
|
|
383
|
-
]);
|
|
384
|
-
const json = JSON.parse(proofString);
|
|
385
|
-
let numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
386
|
-
if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
|
|
387
|
-
numPublicInputs -= IPA_CLAIM_LENGTH;
|
|
388
|
-
}
|
|
389
|
-
assert(json.length - numPublicInputs == proofLength, 'Proof length mismatch');
|
|
390
|
-
const fieldsWithoutPublicInputs = json.slice(0, 3).map(Fr.fromHexString).concat(json.slice(3 + numPublicInputs).map(Fr.fromHexString));
|
|
391
|
-
logger.debug(`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProof.length}`);
|
|
392
|
-
return new RecursiveProof(fieldsWithoutPublicInputs, new Proof(binaryProof, numPublicInputs), true, proofLength);
|
|
393
|
-
}
|
|
394
|
-
async readAvmProofAsFields(proofFilename, vkData) {
|
|
395
|
-
const rawProof = await fs.readFile(proofFilename);
|
|
396
|
-
const reader = BufferReader.asReader(rawProof);
|
|
397
|
-
const fields = reader.readArray(rawProof.length / Fr.SIZE_IN_BYTES, Fr);
|
|
398
|
-
const fieldsWithoutPublicCols = fields.slice(-1 * AVM_PROOF_LENGTH_IN_FIELDS);
|
|
399
|
-
const proof = new Proof(rawProof, vkData.numPublicInputs);
|
|
400
|
-
return new RecursiveProof(fieldsWithoutPublicCols, proof, true, AVM_PROOF_LENGTH_IN_FIELDS);
|
|
401
|
-
}
|
|
402
|
-
runInDirectory(fn) {
|
|
403
|
-
return runInDirectory(this.config.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
|
|
404
|
-
logger.error(`Error running operation at ${dir}: ${err}`);
|
|
405
|
-
throw err;
|
|
406
|
-
}), this.config.bbSkipCleanup, logger);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
_ts_decorate([
|
|
410
|
-
trackSpan('BBNativeRollupProver.getBaseParityProof', {
|
|
411
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'base-parity'
|
|
412
|
-
})
|
|
413
|
-
], BBNativeRollupProver.prototype, "getBaseParityProof", null);
|
|
414
|
-
_ts_decorate([
|
|
415
|
-
trackSpan('BBNativeRollupProver.getRootParityProof', {
|
|
416
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'root-parity'
|
|
417
|
-
})
|
|
418
|
-
], BBNativeRollupProver.prototype, "getRootParityProof", null);
|
|
419
|
-
_ts_decorate([
|
|
420
|
-
trackSpan('BBNativeRollupProver.getAvmProof', (inputs)=>({
|
|
421
|
-
[Attributes.APP_CIRCUIT_NAME]: inputs.functionName
|
|
422
|
-
}))
|
|
423
|
-
], BBNativeRollupProver.prototype, "getAvmProof", null);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
|
-
export declare const CLIENT_IVC_VK_FILE_NAME = "vk";
|
|
3
|
-
export declare const CLIENT_IVC_PROOF_FILE_NAME = "proof";
|
|
4
|
-
/**
|
|
5
|
-
* TODO(#7371): eventually remove client_ivc_prove_output_all_msgpack and properly handle these accumulators and VKs
|
|
6
|
-
* Create a ClientIvcProof from the result of client_ivc_prove_output_all or client_ivc_prove_output_all_msgpack
|
|
7
|
-
* @param directory the directory of results
|
|
8
|
-
* @returns the encapsulated client ivc proof
|
|
9
|
-
*/
|
|
10
|
-
export declare function readFromOutputDirectory(directory: string): Promise<ClientIvcProof>;
|
|
11
|
-
/**
|
|
12
|
-
* TODO(#7371): eventually remove client_ivc_prove_output_all_msgpack and properly handle these accumulators and VKs
|
|
13
|
-
* Serialize a ClientIvcProof to the files expected by prove_tube
|
|
14
|
-
*
|
|
15
|
-
* Example usage:
|
|
16
|
-
* await runInDirectory(bbWorkingDirectory, async (dir: string) => {
|
|
17
|
-
* await privateTx.clientIvcProof!.writeToOutputDirectory(bbWorkingDirectory);
|
|
18
|
-
* const result = await generateTubeProof(bbPath, dir, logger.info)
|
|
19
|
-
* expect(result.status).toBe(BB_RESULT.SUCCESS)
|
|
20
|
-
* });
|
|
21
|
-
* @param proof the ClientIvcProof from readFromOutputDirectory
|
|
22
|
-
* @param directory the directory of results
|
|
23
|
-
*/
|
|
24
|
-
export declare function writeToOutputDirectory(clientIvcProof: ClientIvcProof, directory: string): Promise<void>;
|
|
25
|
-
//# sourceMappingURL=client_ivc_proof_utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client_ivc_proof_utils.d.ts","sourceRoot":"","sources":["../../src/prover/client_ivc_proof_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,UAAU,CAAC;AAElD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,MAAM,2BAK9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAO7F"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
|
-
import { promises as fs } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
export const CLIENT_IVC_VK_FILE_NAME = 'vk';
|
|
5
|
-
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
6
|
-
/**
|
|
7
|
-
* TODO(#7371): eventually remove client_ivc_prove_output_all_msgpack and properly handle these accumulators and VKs
|
|
8
|
-
* Create a ClientIvcProof from the result of client_ivc_prove_output_all or client_ivc_prove_output_all_msgpack
|
|
9
|
-
* @param directory the directory of results
|
|
10
|
-
* @returns the encapsulated client ivc proof
|
|
11
|
-
*/ export async function readFromOutputDirectory(directory) {
|
|
12
|
-
const [clientIvcVkBuffer, clientIvcProofBuffer] = await Promise.all([
|
|
13
|
-
CLIENT_IVC_VK_FILE_NAME,
|
|
14
|
-
CLIENT_IVC_PROOF_FILE_NAME
|
|
15
|
-
].map((fileName)=>fs.readFile(join(directory, fileName))));
|
|
16
|
-
return new ClientIvcProof(clientIvcProofBuffer, clientIvcVkBuffer);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* TODO(#7371): eventually remove client_ivc_prove_output_all_msgpack and properly handle these accumulators and VKs
|
|
20
|
-
* Serialize a ClientIvcProof to the files expected by prove_tube
|
|
21
|
-
*
|
|
22
|
-
* Example usage:
|
|
23
|
-
* await runInDirectory(bbWorkingDirectory, async (dir: string) => {
|
|
24
|
-
* await privateTx.clientIvcProof!.writeToOutputDirectory(bbWorkingDirectory);
|
|
25
|
-
* const result = await generateTubeProof(bbPath, dir, logger.info)
|
|
26
|
-
* expect(result.status).toBe(BB_RESULT.SUCCESS)
|
|
27
|
-
* });
|
|
28
|
-
* @param proof the ClientIvcProof from readFromOutputDirectory
|
|
29
|
-
* @param directory the directory of results
|
|
30
|
-
*/ export async function writeToOutputDirectory(clientIvcProof, directory) {
|
|
31
|
-
const { clientIvcProofBuffer, clientIvcVkBuffer } = clientIvcProof;
|
|
32
|
-
const fileData = [
|
|
33
|
-
[
|
|
34
|
-
CLIENT_IVC_PROOF_FILE_NAME,
|
|
35
|
-
clientIvcProofBuffer
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
CLIENT_IVC_VK_FILE_NAME,
|
|
39
|
-
clientIvcVkBuffer
|
|
40
|
-
]
|
|
41
|
-
];
|
|
42
|
-
await Promise.all(fileData.map(([fileName, buffer])=>fs.writeFile(join(directory, fileName), buffer)));
|
|
43
|
-
}
|
package/dest/stats.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
2
|
-
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
3
|
-
export declare function mapProtocolArtifactNameToCircuitName(artifact: ProtocolArtifact): CircuitName;
|
|
4
|
-
export declare function isProtocolArtifactRecursive(artifact: ProtocolArtifact): boolean;
|
|
5
|
-
//# sourceMappingURL=stats.d.ts.map
|
package/dest/stats.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../src/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,gBAAgB,GAAG,WAAW,CAqC5F;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAqB/E"}
|
package/dest/stats.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export function mapProtocolArtifactNameToCircuitName(artifact) {
|
|
2
|
-
switch(artifact){
|
|
3
|
-
case 'BaseParityArtifact':
|
|
4
|
-
return 'base-parity';
|
|
5
|
-
case 'RootParityArtifact':
|
|
6
|
-
return 'root-parity';
|
|
7
|
-
case 'PrivateBaseRollupArtifact':
|
|
8
|
-
return 'private-base-rollup';
|
|
9
|
-
case 'PublicBaseRollupArtifact':
|
|
10
|
-
return 'public-base-rollup';
|
|
11
|
-
case 'MergeRollupArtifact':
|
|
12
|
-
return 'merge-rollup';
|
|
13
|
-
case 'BlockRootRollupArtifact':
|
|
14
|
-
return 'block-root-rollup';
|
|
15
|
-
case 'SingleTxBlockRootRollupArtifact':
|
|
16
|
-
return 'single-tx-block-root-rollup';
|
|
17
|
-
case 'EmptyBlockRootRollupArtifact':
|
|
18
|
-
return 'empty-block-root-rollup';
|
|
19
|
-
case 'BlockMergeRollupArtifact':
|
|
20
|
-
return 'block-merge-rollup';
|
|
21
|
-
case 'RootRollupArtifact':
|
|
22
|
-
return 'root-rollup';
|
|
23
|
-
case 'PrivateKernelInitArtifact':
|
|
24
|
-
return 'private-kernel-init';
|
|
25
|
-
case 'PrivateKernelInnerArtifact':
|
|
26
|
-
return 'private-kernel-inner';
|
|
27
|
-
case 'PrivateKernelTailArtifact':
|
|
28
|
-
return 'private-kernel-tail';
|
|
29
|
-
case 'PrivateKernelTailToPublicArtifact':
|
|
30
|
-
return 'private-kernel-tail-to-public';
|
|
31
|
-
default:
|
|
32
|
-
{
|
|
33
|
-
if (artifact.startsWith('PrivateKernelReset')) {
|
|
34
|
-
return 'private-kernel-reset';
|
|
35
|
-
}
|
|
36
|
-
throw new Error(`Unknown circuit type: ${artifact}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export function isProtocolArtifactRecursive(artifact) {
|
|
41
|
-
switch(artifact){
|
|
42
|
-
case 'BaseParityArtifact':
|
|
43
|
-
case 'RootParityArtifact':
|
|
44
|
-
case 'PrivateBaseRollupArtifact':
|
|
45
|
-
case 'PublicBaseRollupArtifact':
|
|
46
|
-
case 'MergeRollupArtifact':
|
|
47
|
-
case 'BlockRootRollupArtifact':
|
|
48
|
-
case 'SingleTxBlockRootRollupArtifact':
|
|
49
|
-
case 'EmptyBlockRootRollupArtifact':
|
|
50
|
-
case 'BlockMergeRollupArtifact':
|
|
51
|
-
case 'RootRollupArtifact':
|
|
52
|
-
return true;
|
|
53
|
-
default:
|
|
54
|
-
{
|
|
55
|
-
if (artifact.startsWith('PrivateKernel')) {
|
|
56
|
-
// The kernel prover, where these are used, eventually calls `createClientIvcProof`, which is recursive.
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
throw new Error(`Unknown circuit type: ${artifact}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
|
|
4
|
-
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
5
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
6
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
7
|
-
import { BBPrivateKernelProver } from '../prover/bb_private_kernel_prover.js';
|
|
8
|
-
export declare abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
9
|
-
protected artifactProvider: ArtifactProvider;
|
|
10
|
-
protected simulationProvider: SimulationProvider;
|
|
11
|
-
private threads;
|
|
12
|
-
protected log: import("@aztec/foundation/log").Logger;
|
|
13
|
-
constructor(artifactProvider: ArtifactProvider, simulationProvider: SimulationProvider, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
14
|
-
createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof>;
|
|
15
|
-
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=bb_wasm_private_kernel_prover.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bb_wasm_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/wasm/bb_wasm_private_kernel_prover.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,8BAAsB,yBAA0B,SAAQ,qBAAqB;cAEtD,gBAAgB,EAAE,gBAAgB;cAClC,kBAAkB,EAAE,kBAAkB;IACzD,OAAO,CAAC,OAAO;cACI,GAAG;gBAHH,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,EACjD,OAAO,GAAE,MAAU,EACR,GAAG,yCAAiC;IAKnC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAmB1F,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAY3G"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { AztecClientBackend } from '@aztec/bb.js';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
5
|
-
import { serializeWitness } from '@noir-lang/noirc_abi';
|
|
6
|
-
import { ungzip } from 'pako';
|
|
7
|
-
import { BBPrivateKernelProver } from '../prover/bb_private_kernel_prover.js';
|
|
8
|
-
export class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
9
|
-
artifactProvider;
|
|
10
|
-
simulationProvider;
|
|
11
|
-
threads;
|
|
12
|
-
log;
|
|
13
|
-
constructor(artifactProvider, simulationProvider, threads = 1, log = createLogger('bb-prover:wasm')){
|
|
14
|
-
super(artifactProvider, simulationProvider, log), this.artifactProvider = artifactProvider, this.simulationProvider = simulationProvider, this.threads = threads, this.log = log;
|
|
15
|
-
}
|
|
16
|
-
async createClientIvcProof(acirs, witnessStack) {
|
|
17
|
-
const timer = new Timer();
|
|
18
|
-
this.log.info(`Generating ClientIVC proof...`);
|
|
19
|
-
const backend = new AztecClientBackend(acirs.map((acir)=>ungzip(acir)), {
|
|
20
|
-
threads: this.threads,
|
|
21
|
-
logger: this.log.verbose,
|
|
22
|
-
wasmPath: process.env.BB_WASM_PATH
|
|
23
|
-
});
|
|
24
|
-
const [proof, vk] = await backend.prove(witnessStack.map((witnessMap)=>ungzip(serializeWitness(witnessMap))));
|
|
25
|
-
await backend.destroy();
|
|
26
|
-
this.log.info(`Generated ClientIVC proof`, {
|
|
27
|
-
eventName: 'client-ivc-proof-generation',
|
|
28
|
-
duration: timer.ms(),
|
|
29
|
-
proofSize: proof.length,
|
|
30
|
-
vkSize: vk.length
|
|
31
|
-
});
|
|
32
|
-
return new ClientIvcProof(Buffer.from(proof), Buffer.from(vk));
|
|
33
|
-
}
|
|
34
|
-
async computeGateCountForCircuit(_bytecode, _circuitName) {
|
|
35
|
-
const backend = new AztecClientBackend([
|
|
36
|
-
ungzip(_bytecode)
|
|
37
|
-
], {
|
|
38
|
-
threads: this.threads,
|
|
39
|
-
logger: this.log.verbose,
|
|
40
|
-
wasmPath: process.env.BB_WASM_PATH
|
|
41
|
-
});
|
|
42
|
-
const gateCount = await backend.gates();
|
|
43
|
-
await backend.destroy();
|
|
44
|
-
return gateCount[0];
|
|
45
|
-
}
|
|
46
|
-
}
|