@aztec-labs/bb-prover 6.0.0-nightly.20260829
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 +27 -0
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -0
- package/dest/avm_proving_tests/avm_proving_tester.js +236 -0
- package/dest/bb/bb_js_backend.d.ts +196 -0
- package/dest/bb/bb_js_backend.d.ts.map +1 -0
- package/dest/bb/bb_js_backend.js +385 -0
- package/dest/bb/bb_js_debug.d.ts +52 -0
- package/dest/bb/bb_js_debug.d.ts.map +1 -0
- package/dest/bb/bb_js_debug.js +176 -0
- package/dest/bb/cli.d.ts +12 -0
- package/dest/bb/cli.d.ts.map +1 -0
- package/dest/bb/cli.js +19 -0
- package/dest/bb/file_names.d.ts +4 -0
- package/dest/bb/file_names.d.ts.map +1 -0
- package/dest/bb/file_names.js +5 -0
- package/dest/bb/index.d.ts +3 -0
- package/dest/bb/index.d.ts.map +1 -0
- package/dest/bb/index.js +16 -0
- package/dest/config.d.ts +31 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +1 -0
- package/dest/honk.d.ts +13 -0
- package/dest/honk.d.ts.map +1 -0
- package/dest/honk.js +20 -0
- package/dest/index.d.ts +10 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +8 -0
- package/dest/instrumentation.d.ts +47 -0
- package/dest/instrumentation.d.ts.map +1 -0
- package/dest/instrumentation.js +76 -0
- package/dest/prover/client/bb_private_kernel_prover.d.ts +54 -0
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/client/bb_private_kernel_prover.js +205 -0
- 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 +3 -0
- package/dest/prover/index.d.ts.map +1 -0
- package/dest/prover/index.js +2 -0
- package/dest/prover/proof_utils.d.ts +29 -0
- package/dest/prover/proof_utils.d.ts.map +1 -0
- package/dest/prover/proof_utils.js +95 -0
- package/dest/prover/server/bb_prover.d.ts +88 -0
- package/dest/prover/server/bb_prover.d.ts.map +1 -0
- package/dest/prover/server/bb_prover.js +823 -0
- package/dest/test/delay_values.d.ts +4 -0
- package/dest/test/delay_values.d.ts.map +1 -0
- package/dest/test/delay_values.js +37 -0
- package/dest/test/index.d.ts +4 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +3 -0
- package/dest/test/test_circuit_prover.d.ts +64 -0
- package/dest/test/test_circuit_prover.d.ts.map +1 -0
- package/dest/test/test_circuit_prover.js +576 -0
- package/dest/test/test_verifier.d.ts +9 -0
- package/dest/test/test_verifier.d.ts.map +1 -0
- package/dest/test/test_verifier.js +27 -0
- package/dest/verification_key/verification_key_data.d.ts +8 -0
- package/dest/verification_key/verification_key_data.d.ts.map +1 -0
- package/dest/verification_key/verification_key_data.js +19 -0
- package/dest/verifier/batch_chonk_verifier.d.ts +57 -0
- package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/batch_chonk_verifier.js +389 -0
- package/dest/verifier/bb_verifier.d.ts +21 -0
- package/dest/verifier/bb_verifier.d.ts.map +1 -0
- package/dest/verifier/bb_verifier.js +193 -0
- package/dest/verifier/index.d.ts +4 -0
- package/dest/verifier/index.d.ts.map +1 -0
- package/dest/verifier/index.js +3 -0
- package/dest/verifier/queued_chonk_verifier.d.ts +26 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/queued_chonk_verifier.js +102 -0
- package/package.json +113 -0
- package/src/avm_proving_tests/avm_proving_tester.ts +235 -0
- package/src/bb/bb_js_backend.ts +442 -0
- package/src/bb/bb_js_debug.ts +227 -0
- package/src/bb/cli.ts +31 -0
- package/src/bb/file_names.ts +6 -0
- package/src/bb/index.ts +22 -0
- package/src/config.ts +31 -0
- package/src/honk.ts +35 -0
- package/src/index.ts +10 -0
- package/src/instrumentation.ts +119 -0
- package/src/prover/client/bb_private_kernel_prover.ts +531 -0
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/index.ts +2 -0
- package/src/prover/proof_utils.ts +154 -0
- package/src/prover/server/bb_prover.ts +658 -0
- package/src/test/delay_values.ts +41 -0
- package/src/test/index.ts +3 -0
- package/src/test/test_circuit_prover.ts +424 -0
- package/src/test/test_verifier.ts +20 -0
- package/src/verification_key/verification_key_data.ts +24 -0
- package/src/verifier/batch_chonk_verifier.ts +420 -0
- package/src/verifier/bb_verifier.ts +130 -0
- package/src/verifier/index.ts +3 -0
- package/src/verifier/queued_chonk_verifier.ts +108 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
|
+
}
|
|
373
|
+
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _initProto;
|
|
374
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH } from '@aztec-labs/constants';
|
|
375
|
+
import { createLogger } from '@aztec-labs/foundation/log';
|
|
376
|
+
import { sleep } from '@aztec-labs/foundation/sleep';
|
|
377
|
+
import { Timer } from '@aztec-labs/foundation/timer';
|
|
378
|
+
import { convertBlockMergeRollupOutputsFromWitnessMap, convertBlockMergeRollupPrivateInputsToWitnessMap, convertBlockRootNoTxsRollupOutputsFromWitnessMap, convertBlockRootNoTxsRollupPrivateInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap, convertBlockRootRollupPrivateInputsToWitnessMap, convertBlockRootSingleTxRollupOutputsFromWitnessMap, convertBlockRootSingleTxRollupPrivateInputsToWitnessMap, convertCheckpointMergeRollupOutputsFromWitnessMap, convertCheckpointMergeRollupPrivateInputsToWitnessMap, convertCheckpointPaddingRollupOutputsFromWitnessMap, convertCheckpointPaddingRollupPrivateInputsToWitnessMap, convertCheckpointRootRollupOutputsFromWitnessMap, convertCheckpointRootRollupPrivateInputsToWitnessMap, convertCheckpointRootSingleBlockRollupOutputsFromWitnessMap, convertCheckpointRootSingleBlockRollupPrivateInputsToWitnessMap, convertInboxParityOutputsFromWitnessMap, convertInboxParityPrivateInputsToWitnessMap, convertPrivateTxBaseRollupOutputsFromWitnessMap, convertPrivateTxBaseRollupPrivateInputsToWitnessMap, convertPublicTxBaseRollupOutputsFromWitnessMap, convertPublicTxBaseRollupPrivateInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertRootRollupPrivateInputsToWitnessMap, convertTxMergeRollupOutputsFromWitnessMap, convertTxMergeRollupPrivateInputsToWitnessMap, foreignCallHandler, getSimulatedServerCircuitArtifact, inboxParityArtifactForSize } from '@aztec-labs/noir-protocol-circuits-types/server';
|
|
379
|
+
import { ProtocolCircuitVks } from '@aztec-labs/noir-protocol-circuits-types/server/vks';
|
|
380
|
+
import { mapProtocolArtifactNameToCircuitName } from '@aztec-labs/noir-protocol-circuits-types/types';
|
|
381
|
+
import { WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec-labs/simulator/server';
|
|
382
|
+
import { makePublicInputsAndRecursiveProof } from '@aztec-labs/stdlib/interfaces/server';
|
|
383
|
+
import { ProvingRequestType, makeEmptyRecursiveProof, makeRecursiveProof } from '@aztec-labs/stdlib/proofs';
|
|
384
|
+
import { PublicChonkVerifierPublicInputs } from '@aztec-labs/stdlib/rollup';
|
|
385
|
+
import { getTelemetryClient, trackSpan } from '@aztec-labs/telemetry-client';
|
|
386
|
+
import { ProverInstrumentation } from '../instrumentation.js';
|
|
387
|
+
import { PROOF_DELAY_MS, WITGEN_DELAY_MS } from './delay_values.js';
|
|
388
|
+
_dec = trackSpan('TestCircuitProver.getInboxParityProof'), _dec1 = trackSpan('TestCircuitProver.getPrivateTxBaseRollupProof'), _dec2 = trackSpan('TestCircuitProver.getPublicTxBaseRollupProof'), _dec3 = trackSpan('TestCircuitProver.getTxMergeRollupProof'), _dec4 = trackSpan('TestCircuitProver.getBlockRootNoTxsRollupProof'), _dec5 = trackSpan('TestCircuitProver.getBlockRootRollupProof'), _dec6 = trackSpan('TestCircuitProver.getBlockRootSingleTxRollupProof'), _dec7 = trackSpan('TestCircuitProver.getBlockMergeRollupProof'), _dec8 = trackSpan('TestCircuitProver.getCheckpointRootRollupProof'), _dec9 = trackSpan('TestCircuitProver.getCheckpointRootSingleBlockRollupProof'), _dec10 = trackSpan('TestCircuitProver.getCheckpointPaddingRollupProof'), _dec11 = trackSpan('TestCircuitProver.getCheckpointMergeRollupProof'), _dec12 = trackSpan('TestCircuitProver.getRootRollupProof');
|
|
389
|
+
/**
|
|
390
|
+
* A class for use in testing situations (e2e, unit test, etc) and temporarily for assembling a block in the sequencer.
|
|
391
|
+
* Simulates circuits using the most efficient method and performs no proving.
|
|
392
|
+
*/ export class TestCircuitProver {
|
|
393
|
+
simulator;
|
|
394
|
+
opts;
|
|
395
|
+
static{
|
|
396
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
397
|
+
[
|
|
398
|
+
_dec,
|
|
399
|
+
2,
|
|
400
|
+
"getInboxParityProof"
|
|
401
|
+
],
|
|
402
|
+
[
|
|
403
|
+
_dec1,
|
|
404
|
+
2,
|
|
405
|
+
"getPrivateTxBaseRollupProof"
|
|
406
|
+
],
|
|
407
|
+
[
|
|
408
|
+
_dec2,
|
|
409
|
+
2,
|
|
410
|
+
"getPublicTxBaseRollupProof"
|
|
411
|
+
],
|
|
412
|
+
[
|
|
413
|
+
_dec3,
|
|
414
|
+
2,
|
|
415
|
+
"getTxMergeRollupProof"
|
|
416
|
+
],
|
|
417
|
+
[
|
|
418
|
+
_dec4,
|
|
419
|
+
2,
|
|
420
|
+
"getBlockRootNoTxsRollupProof"
|
|
421
|
+
],
|
|
422
|
+
[
|
|
423
|
+
_dec5,
|
|
424
|
+
2,
|
|
425
|
+
"getBlockRootRollupProof"
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
_dec6,
|
|
429
|
+
2,
|
|
430
|
+
"getBlockRootSingleTxRollupProof"
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
_dec7,
|
|
434
|
+
2,
|
|
435
|
+
"getBlockMergeRollupProof"
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
_dec8,
|
|
439
|
+
2,
|
|
440
|
+
"getCheckpointRootRollupProof"
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
_dec9,
|
|
444
|
+
2,
|
|
445
|
+
"getCheckpointRootSingleBlockRollupProof"
|
|
446
|
+
],
|
|
447
|
+
[
|
|
448
|
+
_dec10,
|
|
449
|
+
2,
|
|
450
|
+
"getCheckpointPaddingRollupProof"
|
|
451
|
+
],
|
|
452
|
+
[
|
|
453
|
+
_dec11,
|
|
454
|
+
2,
|
|
455
|
+
"getCheckpointMergeRollupProof"
|
|
456
|
+
],
|
|
457
|
+
[
|
|
458
|
+
_dec12,
|
|
459
|
+
2,
|
|
460
|
+
"getRootRollupProof"
|
|
461
|
+
]
|
|
462
|
+
], []));
|
|
463
|
+
}
|
|
464
|
+
wasmSimulator;
|
|
465
|
+
instrumentation;
|
|
466
|
+
logger;
|
|
467
|
+
constructor(simulator, opts = {
|
|
468
|
+
proverTestDelayType: 'fixed',
|
|
469
|
+
proverTestDelayMs: 0
|
|
470
|
+
}, telemetry = getTelemetryClient()){
|
|
471
|
+
this.simulator = simulator;
|
|
472
|
+
this.opts = opts;
|
|
473
|
+
this.wasmSimulator = (_initProto(this), new WASMSimulatorWithBlobs());
|
|
474
|
+
this.logger = createLogger('bb-prover:test-prover');
|
|
475
|
+
this.instrumentation = new ProverInstrumentation(telemetry, 'TestCircuitProver');
|
|
476
|
+
}
|
|
477
|
+
get tracer() {
|
|
478
|
+
return this.instrumentation.tracer;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Simulates the base parity circuit from its inputs.
|
|
482
|
+
* @param inputs - Inputs to the circuit.
|
|
483
|
+
* @returns The public inputs of the parity circuit.
|
|
484
|
+
*/ getInboxParityProof(inputs) {
|
|
485
|
+
return this.applyDelay(ProvingRequestType.INBOX_PARITY, ()=>this.simulate(inputs, inboxParityArtifactForSize(inputs.size), RECURSIVE_PROOF_LENGTH, convertInboxParityPrivateInputsToWitnessMap, (outputs)=>convertInboxParityOutputsFromWitnessMap(outputs, inputs.size)));
|
|
486
|
+
}
|
|
487
|
+
getPublicChonkVerifierProof(inputs) {
|
|
488
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_CHONK_VERIFIER, ()=>makePublicInputsAndRecursiveProof(new PublicChonkVerifierPublicInputs(inputs.hidingKernelProofData.publicInputs, inputs.proverId), makeEmptyRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), ProtocolCircuitVks.PublicChonkVerifier));
|
|
489
|
+
}
|
|
490
|
+
getPrivateTxBaseRollupProof(inputs) {
|
|
491
|
+
return this.applyDelay(ProvingRequestType.PRIVATE_TX_BASE_ROLLUP, ()=>this.simulate(inputs, 'PrivateTxBaseRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertPrivateTxBaseRollupPrivateInputsToWitnessMap, convertPrivateTxBaseRollupOutputsFromWitnessMap));
|
|
492
|
+
}
|
|
493
|
+
getPublicTxBaseRollupProof(inputs) {
|
|
494
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_TX_BASE_ROLLUP, ()=>this.simulate(inputs, 'PublicTxBaseRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertPublicTxBaseRollupPrivateInputsToWitnessMap, convertPublicTxBaseRollupOutputsFromWitnessMap));
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Simulates the merge rollup circuit from its inputs.
|
|
498
|
+
* @param input - Inputs to the circuit.
|
|
499
|
+
* @returns The public inputs as outputs of the simulation.
|
|
500
|
+
*/ getTxMergeRollupProof(input) {
|
|
501
|
+
return this.applyDelay(ProvingRequestType.TX_MERGE_ROLLUP, ()=>this.simulate(input, 'TxMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertTxMergeRollupPrivateInputsToWitnessMap, convertTxMergeRollupOutputsFromWitnessMap));
|
|
502
|
+
}
|
|
503
|
+
getBlockRootNoTxsRollupProof(input) {
|
|
504
|
+
return this.applyDelay(ProvingRequestType.BLOCK_ROOT_NO_TXS_ROLLUP, ()=>this.simulate(input, 'BlockRootNoTxsRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootNoTxsRollupPrivateInputsToWitnessMap, convertBlockRootNoTxsRollupOutputsFromWitnessMap));
|
|
505
|
+
}
|
|
506
|
+
getBlockRootRollupProof(input) {
|
|
507
|
+
return this.applyDelay(ProvingRequestType.BLOCK_ROOT_ROLLUP, ()=>this.simulate(input, 'BlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootRollupPrivateInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap));
|
|
508
|
+
}
|
|
509
|
+
async getBlockRootSingleTxRollupProof(input) {
|
|
510
|
+
return await this.applyDelay(ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP, ()=>this.simulate(input, 'BlockRootSingleTxRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootSingleTxRollupPrivateInputsToWitnessMap, convertBlockRootSingleTxRollupOutputsFromWitnessMap));
|
|
511
|
+
}
|
|
512
|
+
getBlockMergeRollupProof(input) {
|
|
513
|
+
return this.applyDelay(ProvingRequestType.BLOCK_MERGE_ROLLUP, ()=>this.simulate(input, 'BlockMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockMergeRollupPrivateInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap));
|
|
514
|
+
}
|
|
515
|
+
getCheckpointRootRollupProof(input) {
|
|
516
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_ROOT_ROLLUP, ()=>this.simulate(input, 'CheckpointRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointRootRollupPrivateInputsToWitnessMap, convertCheckpointRootRollupOutputsFromWitnessMap));
|
|
517
|
+
}
|
|
518
|
+
getCheckpointRootSingleBlockRollupProof(input) {
|
|
519
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP, ()=>this.simulate(input, 'CheckpointRootSingleBlockRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointRootSingleBlockRollupPrivateInputsToWitnessMap, convertCheckpointRootSingleBlockRollupOutputsFromWitnessMap));
|
|
520
|
+
}
|
|
521
|
+
getCheckpointPaddingRollupProof(input) {
|
|
522
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_PADDING_ROLLUP, ()=>this.simulate(input, 'CheckpointPaddingRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointPaddingRollupPrivateInputsToWitnessMap, convertCheckpointPaddingRollupOutputsFromWitnessMap));
|
|
523
|
+
}
|
|
524
|
+
getCheckpointMergeRollupProof(input) {
|
|
525
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_MERGE_ROLLUP, ()=>this.simulate(input, 'CheckpointMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointMergeRollupPrivateInputsToWitnessMap, convertCheckpointMergeRollupOutputsFromWitnessMap));
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Simulates the root rollup circuit from its inputs.
|
|
529
|
+
* @param input - Inputs to the circuit.
|
|
530
|
+
* @returns The public inputs as outputs of the simulation.
|
|
531
|
+
*/ getRootRollupProof(input) {
|
|
532
|
+
return this.applyDelay(ProvingRequestType.ROOT_ROLLUP, ()=>this.simulate(input, 'RootRollupArtifact', NESTED_RECURSIVE_PROOF_LENGTH, convertRootRollupPrivateInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap));
|
|
533
|
+
}
|
|
534
|
+
getAvmProof(_inputs) {
|
|
535
|
+
// We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
|
|
536
|
+
// We just return an empty proof.
|
|
537
|
+
this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
|
|
538
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_VM, ()=>makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS));
|
|
539
|
+
}
|
|
540
|
+
async applyDelay(type, fn) {
|
|
541
|
+
const timer = new Timer();
|
|
542
|
+
const res = await fn();
|
|
543
|
+
const duration = timer.ms();
|
|
544
|
+
if (this.opts.proverTestDelayType === 'fixed') {
|
|
545
|
+
await sleep(Math.max(0, (this.opts.proverTestDelayMs ?? 0) - duration));
|
|
546
|
+
} else if (this.opts.proverTestDelayType === 'realistic') {
|
|
547
|
+
const delay = WITGEN_DELAY_MS[type] + PROOF_DELAY_MS[type];
|
|
548
|
+
await sleep(Math.max(0, delay * (this.opts.proverTestDelayFactor ?? 1) - duration));
|
|
549
|
+
}
|
|
550
|
+
return res;
|
|
551
|
+
}
|
|
552
|
+
// Not implemented for test circuits
|
|
553
|
+
verifyProof(_1, _2) {
|
|
554
|
+
return Promise.reject(new Error('Method not implemented.'));
|
|
555
|
+
}
|
|
556
|
+
async simulate(input, artifactName, proofLength, convertInput, convertOutput) {
|
|
557
|
+
const timer = new Timer();
|
|
558
|
+
const witnessMap = convertInput(input, true);
|
|
559
|
+
const circuitName = mapProtocolArtifactNameToCircuitName(artifactName);
|
|
560
|
+
let witness;
|
|
561
|
+
if ([
|
|
562
|
+
'CheckpointRootRollupArtifact',
|
|
563
|
+
'CheckpointRootSingleBlockRollupArtifact'
|
|
564
|
+
].includes(artifactName) || this.simulator == undefined) {
|
|
565
|
+
// TODO(#10323): Native ACVM simulator does not support foreign call handler so we use the wasm simulator
|
|
566
|
+
// when simulating checkpoint root rollup circuits or when the native ACVM simulator is not provided.
|
|
567
|
+
witness = (await this.wasmSimulator.executeProtocolCircuit(witnessMap, getSimulatedServerCircuitArtifact(artifactName), foreignCallHandler)).witness;
|
|
568
|
+
} else {
|
|
569
|
+
witness = (await this.simulator.executeProtocolCircuit(witnessMap, getSimulatedServerCircuitArtifact(artifactName), undefined)).witness;
|
|
570
|
+
}
|
|
571
|
+
const result = convertOutput(witness, true);
|
|
572
|
+
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
573
|
+
emitCircuitSimulationStats(circuitName, timer.ms(), input.toBuffer().length, result.toBuffer().length, this.logger);
|
|
574
|
+
return makePublicInputsAndRecursiveProof(result, makeRecursiveProof(proofLength), ProtocolCircuitVks[artifactName]);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec-labs/stdlib/interfaces/server';
|
|
2
|
+
import type { Tx } from '@aztec-labs/stdlib/tx';
|
|
3
|
+
export declare class TestCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
4
|
+
private verificationDelayMs?;
|
|
5
|
+
constructor(verificationDelayMs?: number | undefined);
|
|
6
|
+
verifyProof(_tx: Tx): Promise<IVCProofVerificationResult>;
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF92ZXJpZmllci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvdGVzdF92ZXJpZmllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSw2QkFBNkIsRUFBRSwwQkFBMEIsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBQ3RILE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRWhELHFCQUFhLG1CQUFvQixZQUFXLDZCQUE2QjtJQUMzRCxPQUFPLENBQUMsbUJBQW1CLENBQUM7SUFBeEMsWUFBb0IsbUJBQW1CLENBQUMsb0JBQVEsRUFBSTtJQUNwRCxXQUFXLENBQUMsR0FBRyxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsMEJBQTBCLENBQUMsQ0FTeEQ7SUFFTSxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUUzQjtDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test_verifier.d.ts","sourceRoot":"","sources":["../../src/test/test_verifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACtH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAEhD,qBAAa,mBAAoB,YAAW,6BAA6B;IAC3D,OAAO,CAAC,mBAAmB,CAAC;IAAxC,YAAoB,mBAAmB,CAAC,oBAAQ,EAAI;IACpD,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CASxD;IAEM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class TestCircuitVerifier {
|
|
2
|
+
verificationDelayMs;
|
|
3
|
+
constructor(verificationDelayMs){
|
|
4
|
+
this.verificationDelayMs = verificationDelayMs;
|
|
5
|
+
}
|
|
6
|
+
verifyProof(_tx) {
|
|
7
|
+
if (this.verificationDelayMs !== undefined && this.verificationDelayMs > 0) {
|
|
8
|
+
return new Promise((resolve)=>{
|
|
9
|
+
setTimeout(()=>{
|
|
10
|
+
resolve({
|
|
11
|
+
valid: true,
|
|
12
|
+
durationMs: this.verificationDelayMs,
|
|
13
|
+
totalDurationMs: this.verificationDelayMs
|
|
14
|
+
});
|
|
15
|
+
}, this.verificationDelayMs);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return Promise.resolve({
|
|
19
|
+
valid: true,
|
|
20
|
+
durationMs: 0,
|
|
21
|
+
totalDurationMs: 0
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
stop() {
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VerificationKeyData } from '@aztec-labs/stdlib/vks';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the verification key data stored at the specified location and parses into a VerificationKeyData
|
|
4
|
+
* @param vkDirectoryPath - The directory containing the verification key data files
|
|
5
|
+
* @returns The verification key data
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractVkData(vkDirectoryPath: string): Promise<VerificationKeyData>;
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyaWZpY2F0aW9uX2tleV9kYXRhLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpY2F0aW9uX2tleS92ZXJpZmljYXRpb25fa2V5X2RhdGEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUEyQixtQkFBbUIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBTXRGOzs7O0dBSUc7QUFDSCx3QkFBc0IsYUFBYSxDQUFDLGVBQWUsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBVXpGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification_key_data.d.ts","sourceRoot":"","sources":["../../src/verification_key/verification_key_data.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAMtF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAUzF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
|
+
import { BufferReader } from '@aztec-labs/foundation/serialize';
|
|
3
|
+
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec-labs/stdlib/vks';
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { VK_FILENAME } from '../bb/file_names.js';
|
|
7
|
+
/**
|
|
8
|
+
* Reads the verification key data stored at the specified location and parses into a VerificationKeyData
|
|
9
|
+
* @param vkDirectoryPath - The directory containing the verification key data files
|
|
10
|
+
* @returns The verification key data
|
|
11
|
+
*/ export async function extractVkData(vkDirectoryPath) {
|
|
12
|
+
const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
|
|
13
|
+
// Convert binary to field elements (32 bytes per field)
|
|
14
|
+
const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
|
|
15
|
+
const reader = BufferReader.asReader(rawBinary);
|
|
16
|
+
const fields = reader.readArray(numFields, Fr);
|
|
17
|
+
const vkAsFields = await VerificationKeyAsFields.fromKey(fields);
|
|
18
|
+
return new VerificationKeyData(vkAsFields, rawBinary);
|
|
19
|
+
}
|