@aztec/bb.js 2.0.3-rc.8 → 2.0.3-zkpassport

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.
@@ -0,0 +1,164 @@
1
+ // AUTOGENERATED FILE - DO NOT EDIT
2
+
3
+ import { BarretenbergWasmMainWorker } from "../../barretenberg_wasm/barretenberg_wasm_main/index.js";
4
+ import { Decoder, Encoder } from 'msgpackr';
5
+ import { BbApiBase, CircuitComputeVk, CircuitComputeVkResponse, CircuitInfoResponse, CircuitInput, CircuitInputNoVK, CircuitProve, CircuitProveResponse, CircuitStats, CircuitVerify, CircuitVerifyResponse, CircuitWriteSolidityVerifier, CircuitWriteSolidityVerifierResponse, ClientIVCProof, ClientIvcAccumulate, ClientIvcAccumulateResponse, ClientIvcCheckPrecomputedVk, ClientIvcCheckPrecomputedVkResponse, ClientIvcComputeIvcVk, ClientIvcComputeIvcVkResponse, ClientIvcComputeStandaloneVk, ClientIvcComputeStandaloneVkResponse, ClientIvcLoad, ClientIvcLoadResponse, ClientIvcProve, ClientIvcProveResponse, ClientIvcStart, ClientIvcStartResponse, ClientIvcStats, ClientIvcStatsResponse, ClientIvcVerify, ClientIvcVerifyResponse, ECCVMProof, Fr, GoblinProof, ProofSystemSettings, Uint256T, VkAsFields, VkAsFieldsResponse, fromCircuitComputeVk, fromCircuitProve, fromCircuitStats, fromCircuitVerify, fromCircuitWriteSolidityVerifier, fromClientIvcAccumulate, fromClientIvcCheckPrecomputedVk, fromClientIvcComputeIvcVk, fromClientIvcComputeStandaloneVk, fromClientIvcLoad, fromClientIvcProve, fromClientIvcStart, fromClientIvcStats, fromClientIvcVerify, fromVkAsFields, toCircuitComputeVkResponse, toCircuitInfoResponse, toCircuitProveResponse, toCircuitVerifyResponse, toCircuitWriteSolidityVerifierResponse, toClientIvcAccumulateResponse, toClientIvcCheckPrecomputedVkResponse, toClientIvcComputeIvcVkResponse, toClientIvcComputeStandaloneVkResponse, toClientIvcLoadResponse, toClientIvcProveResponse, toClientIvcStartResponse, toClientIvcStatsResponse, toClientIvcVerifyResponse, toVkAsFieldsResponse } from './api_types.js';
6
+
7
+ async function msgpackCall(wasm: BarretenbergWasmMainWorker, cbind: string, input: any[]) { const inputBuffer = new Encoder({ useRecords: false }).pack(input); const encodedResult = await wasm.cbindCall(cbind, inputBuffer); return new Decoder({ useRecords: false }).unpack(encodedResult);}
8
+ export class AsyncApi implements BbApiBase {
9
+ constructor(protected wasm: BarretenbergWasmMainWorker) {}
10
+
11
+ circuitProve(command: CircuitProve): Promise<CircuitProveResponse> {
12
+ const msgpackCommand = fromCircuitProve(command);
13
+ return msgpackCall(this.wasm, 'bbapi', [["CircuitProve", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
14
+ if (variantName !== 'CircuitProveResponse') {
15
+ throw new Error(`Expected variant name 'CircuitProveResponse' but got '${variantName}'`);
16
+ }
17
+ return toCircuitProveResponse(result);
18
+ });
19
+ }
20
+
21
+ circuitComputeVk(command: CircuitComputeVk): Promise<CircuitComputeVkResponse> {
22
+ const msgpackCommand = fromCircuitComputeVk(command);
23
+ return msgpackCall(this.wasm, 'bbapi', [["CircuitComputeVk", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
24
+ if (variantName !== 'CircuitComputeVkResponse') {
25
+ throw new Error(`Expected variant name 'CircuitComputeVkResponse' but got '${variantName}'`);
26
+ }
27
+ return toCircuitComputeVkResponse(result);
28
+ });
29
+ }
30
+
31
+ circuitStats(command: CircuitStats): Promise<CircuitInfoResponse> {
32
+ const msgpackCommand = fromCircuitStats(command);
33
+ return msgpackCall(this.wasm, 'bbapi', [["CircuitStats", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
34
+ if (variantName !== 'CircuitInfoResponse') {
35
+ throw new Error(`Expected variant name 'CircuitInfoResponse' but got '${variantName}'`);
36
+ }
37
+ return toCircuitInfoResponse(result);
38
+ });
39
+ }
40
+
41
+ circuitVerify(command: CircuitVerify): Promise<CircuitVerifyResponse> {
42
+ const msgpackCommand = fromCircuitVerify(command);
43
+ return msgpackCall(this.wasm, 'bbapi', [["CircuitVerify", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
44
+ if (variantName !== 'CircuitVerifyResponse') {
45
+ throw new Error(`Expected variant name 'CircuitVerifyResponse' but got '${variantName}'`);
46
+ }
47
+ return toCircuitVerifyResponse(result);
48
+ });
49
+ }
50
+
51
+ clientIvcComputeStandaloneVk(command: ClientIvcComputeStandaloneVk): Promise<ClientIvcComputeStandaloneVkResponse> {
52
+ const msgpackCommand = fromClientIvcComputeStandaloneVk(command);
53
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcComputeStandaloneVk", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
54
+ if (variantName !== 'ClientIvcComputeStandaloneVkResponse') {
55
+ throw new Error(`Expected variant name 'ClientIvcComputeStandaloneVkResponse' but got '${variantName}'`);
56
+ }
57
+ return toClientIvcComputeStandaloneVkResponse(result);
58
+ });
59
+ }
60
+
61
+ clientIvcComputeIvcVk(command: ClientIvcComputeIvcVk): Promise<ClientIvcComputeIvcVkResponse> {
62
+ const msgpackCommand = fromClientIvcComputeIvcVk(command);
63
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcComputeIvcVk", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
64
+ if (variantName !== 'ClientIvcComputeIvcVkResponse') {
65
+ throw new Error(`Expected variant name 'ClientIvcComputeIvcVkResponse' but got '${variantName}'`);
66
+ }
67
+ return toClientIvcComputeIvcVkResponse(result);
68
+ });
69
+ }
70
+
71
+ clientIvcStart(command: ClientIvcStart): Promise<ClientIvcStartResponse> {
72
+ const msgpackCommand = fromClientIvcStart(command);
73
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcStart", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
74
+ if (variantName !== 'ClientIvcStartResponse') {
75
+ throw new Error(`Expected variant name 'ClientIvcStartResponse' but got '${variantName}'`);
76
+ }
77
+ return toClientIvcStartResponse(result);
78
+ });
79
+ }
80
+
81
+ clientIvcLoad(command: ClientIvcLoad): Promise<ClientIvcLoadResponse> {
82
+ const msgpackCommand = fromClientIvcLoad(command);
83
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcLoad", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
84
+ if (variantName !== 'ClientIvcLoadResponse') {
85
+ throw new Error(`Expected variant name 'ClientIvcLoadResponse' but got '${variantName}'`);
86
+ }
87
+ return toClientIvcLoadResponse(result);
88
+ });
89
+ }
90
+
91
+ clientIvcAccumulate(command: ClientIvcAccumulate): Promise<ClientIvcAccumulateResponse> {
92
+ const msgpackCommand = fromClientIvcAccumulate(command);
93
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcAccumulate", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
94
+ if (variantName !== 'ClientIvcAccumulateResponse') {
95
+ throw new Error(`Expected variant name 'ClientIvcAccumulateResponse' but got '${variantName}'`);
96
+ }
97
+ return toClientIvcAccumulateResponse(result);
98
+ });
99
+ }
100
+
101
+ clientIvcProve(command: ClientIvcProve): Promise<ClientIvcProveResponse> {
102
+ const msgpackCommand = fromClientIvcProve(command);
103
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcProve", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
104
+ if (variantName !== 'ClientIvcProveResponse') {
105
+ throw new Error(`Expected variant name 'ClientIvcProveResponse' but got '${variantName}'`);
106
+ }
107
+ return toClientIvcProveResponse(result);
108
+ });
109
+ }
110
+
111
+ clientIvcVerify(command: ClientIvcVerify): Promise<ClientIvcVerifyResponse> {
112
+ const msgpackCommand = fromClientIvcVerify(command);
113
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcVerify", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
114
+ if (variantName !== 'ClientIvcVerifyResponse') {
115
+ throw new Error(`Expected variant name 'ClientIvcVerifyResponse' but got '${variantName}'`);
116
+ }
117
+ return toClientIvcVerifyResponse(result);
118
+ });
119
+ }
120
+
121
+ vkAsFields(command: VkAsFields): Promise<VkAsFieldsResponse> {
122
+ const msgpackCommand = fromVkAsFields(command);
123
+ return msgpackCall(this.wasm, 'bbapi', [["VkAsFields", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
124
+ if (variantName !== 'VkAsFieldsResponse') {
125
+ throw new Error(`Expected variant name 'VkAsFieldsResponse' but got '${variantName}'`);
126
+ }
127
+ return toVkAsFieldsResponse(result);
128
+ });
129
+ }
130
+
131
+ circuitWriteSolidityVerifier(command: CircuitWriteSolidityVerifier): Promise<CircuitWriteSolidityVerifierResponse> {
132
+ const msgpackCommand = fromCircuitWriteSolidityVerifier(command);
133
+ return msgpackCall(this.wasm, 'bbapi', [["CircuitWriteSolidityVerifier", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
134
+ if (variantName !== 'CircuitWriteSolidityVerifierResponse') {
135
+ throw new Error(`Expected variant name 'CircuitWriteSolidityVerifierResponse' but got '${variantName}'`);
136
+ }
137
+ return toCircuitWriteSolidityVerifierResponse(result);
138
+ });
139
+ }
140
+
141
+ clientIvcCheckPrecomputedVk(command: ClientIvcCheckPrecomputedVk): Promise<ClientIvcCheckPrecomputedVkResponse> {
142
+ const msgpackCommand = fromClientIvcCheckPrecomputedVk(command);
143
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcCheckPrecomputedVk", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
144
+ if (variantName !== 'ClientIvcCheckPrecomputedVkResponse') {
145
+ throw new Error(`Expected variant name 'ClientIvcCheckPrecomputedVkResponse' but got '${variantName}'`);
146
+ }
147
+ return toClientIvcCheckPrecomputedVkResponse(result);
148
+ });
149
+ }
150
+
151
+ clientIvcStats(command: ClientIvcStats): Promise<ClientIvcStatsResponse> {
152
+ const msgpackCommand = fromClientIvcStats(command);
153
+ return msgpackCall(this.wasm, 'bbapi', [["ClientIvcStats", msgpackCommand]]).then(([variantName, result]: [string, any]) => {
154
+ if (variantName !== 'ClientIvcStatsResponse') {
155
+ throw new Error(`Expected variant name 'ClientIvcStatsResponse' but got '${variantName}'`);
156
+ }
157
+ return toClientIvcStatsResponse(result);
158
+ });
159
+ }
160
+
161
+ destroy(): Promise<void> {
162
+ return this.wasm.destroy();
163
+ }
164
+ }
@@ -0,0 +1,269 @@
1
+ // AUTOGENERATED FILE - DO NOT EDIT
2
+
3
+ import { spawn, ChildProcess } from 'child_process';
4
+ import { Decoder, Encoder } from 'msgpackr';
5
+ import { BbApiBase, CircuitComputeVk, CircuitComputeVkResponse, CircuitInfoResponse, CircuitInput, CircuitInputNoVK, CircuitProve, CircuitProveResponse, CircuitStats, CircuitVerify, CircuitVerifyResponse, CircuitWriteSolidityVerifier, CircuitWriteSolidityVerifierResponse, ClientIVCProof, ClientIvcAccumulate, ClientIvcAccumulateResponse, ClientIvcCheckPrecomputedVk, ClientIvcCheckPrecomputedVkResponse, ClientIvcComputeIvcVk, ClientIvcComputeIvcVkResponse, ClientIvcComputeStandaloneVk, ClientIvcComputeStandaloneVkResponse, ClientIvcLoad, ClientIvcLoadResponse, ClientIvcProve, ClientIvcProveResponse, ClientIvcStart, ClientIvcStartResponse, ClientIvcStats, ClientIvcStatsResponse, ClientIvcVerify, ClientIvcVerifyResponse, ECCVMProof, Fr, GoblinProof, ProofSystemSettings, Uint256T, VkAsFields, VkAsFieldsResponse, fromCircuitComputeVk, fromCircuitProve, fromCircuitStats, fromCircuitVerify, fromCircuitWriteSolidityVerifier, fromClientIvcAccumulate, fromClientIvcCheckPrecomputedVk, fromClientIvcComputeIvcVk, fromClientIvcComputeStandaloneVk, fromClientIvcLoad, fromClientIvcProve, fromClientIvcStart, fromClientIvcStats, fromClientIvcVerify, fromVkAsFields, toCircuitComputeVkResponse, toCircuitInfoResponse, toCircuitProveResponse, toCircuitVerifyResponse, toCircuitWriteSolidityVerifierResponse, toClientIvcAccumulateResponse, toClientIvcCheckPrecomputedVkResponse, toClientIvcComputeIvcVkResponse, toClientIvcComputeStandaloneVkResponse, toClientIvcLoadResponse, toClientIvcProveResponse, toClientIvcStartResponse, toClientIvcStatsResponse, toClientIvcVerifyResponse, toVkAsFieldsResponse } from './api_types.js';
6
+
7
+ interface NativeApiRequest {
8
+ resolve: (value: any) => void;
9
+ reject: (error: any) => void;
10
+ }
11
+
12
+ class StreamBuffer {
13
+ private buffer = Buffer.alloc(0);
14
+ private expectedLength: number | null = null;
15
+
16
+ addData(data: Buffer): Buffer[] {
17
+ // Create buffer to grow as needed
18
+ const newBuffer = Buffer.allocUnsafe(this.buffer.length + data.length);
19
+ this.buffer.copy(newBuffer, 0);
20
+ data.copy(newBuffer, this.buffer.length);
21
+ this.buffer = newBuffer;
22
+
23
+ const messages: Buffer[] = [];
24
+
25
+ while (true) {
26
+ if (this.expectedLength === null) {
27
+ if (this.buffer.length < 4) break;
28
+ this.expectedLength = this.buffer.readUInt32LE(0);
29
+ this.buffer = this.buffer.subarray(4);
30
+ }
31
+
32
+ if (this.buffer.length < this.expectedLength) break;
33
+
34
+ // Extract complete message
35
+ const messageBuffer = this.buffer.subarray(0, this.expectedLength);
36
+ messages.push(messageBuffer);
37
+ this.buffer = this.buffer.subarray(this.expectedLength);
38
+ this.expectedLength = null;
39
+ }
40
+
41
+ return messages;
42
+ }
43
+ }
44
+
45
+ export class NativeApi implements BbApiBase {
46
+ private decoder = new Decoder({ useRecords: false });
47
+ private encoder = new Encoder({ useRecords: false });
48
+ private pendingRequests: NativeApiRequest[] = [];
49
+
50
+ private constructor(private proc: ChildProcess) {}
51
+
52
+ static async new(bbPath = 'bb', logger = console.log): Promise<NativeApi> {
53
+ const proc = spawn(bbPath, ['msgpack', 'run'], {
54
+ stdio: ['pipe', 'pipe', 'pipe'],
55
+ });
56
+
57
+ if (!proc.stdout || !proc.stdin) {
58
+ throw new Error('Failed to initialize bb process');
59
+ }
60
+
61
+ const api = new NativeApi(proc);
62
+ const streamBuffer = new StreamBuffer();
63
+
64
+ proc.stdout.on('data', (data: Buffer) => {
65
+ const messages = streamBuffer.addData(data);
66
+
67
+ for (const messageBuffer of messages) {
68
+ const pendingRequest = api.pendingRequests.shift();
69
+ if (!pendingRequest) {
70
+ throw new Error('Received response without a pending request');
71
+ }
72
+
73
+ try {
74
+ const decoded = api.decoder.decode(messageBuffer);
75
+ if (!Array.isArray(decoded) || decoded.length !== 2) {
76
+ throw new Error(`Invalid response format: ${JSON.stringify(decoded)}`);
77
+ }
78
+ const [variantName, result] = decoded;
79
+ pendingRequest.resolve([variantName, result]);
80
+ } catch (error) {
81
+ pendingRequest.reject(error);
82
+ break;
83
+ }
84
+ }
85
+ });
86
+
87
+ proc.stderr.on('data', (data: Buffer) => {
88
+ logger(data.toString().trim());
89
+ });
90
+
91
+ proc.on('error', err => {
92
+ throw new Error(err.message);
93
+ });
94
+ return api;
95
+ }
96
+
97
+ private sendCommand(command: any): Promise<any> {
98
+ return new Promise((resolve, reject) => {
99
+ this.pendingRequests.push({ resolve, reject });
100
+ const encoded = this.encoder.encode(command);
101
+
102
+ // Write length prefix (4 bytes, little-endian)
103
+ const lengthBuffer = Buffer.allocUnsafe(4);
104
+ lengthBuffer.writeUInt32LE(encoded.length, 0);
105
+
106
+ // Write length prefix followed by the encoded data
107
+ this.proc.stdin!.write(lengthBuffer);
108
+ this.proc.stdin!.write(encoded);
109
+ });
110
+ }
111
+
112
+ async close(): Promise<void> {
113
+ this.proc.kill();
114
+ }
115
+
116
+ destroy(): Promise<void> {
117
+ return this.close();
118
+ }
119
+
120
+ circuitProve(command: CircuitProve): Promise<CircuitProveResponse> {
121
+ const msgpackCommand = fromCircuitProve(command);
122
+ return this.sendCommand(['CircuitProve', msgpackCommand]).then(([variantName, result]: [string, any]) => {
123
+ if (variantName !== 'CircuitProveResponse') {
124
+ throw new Error(`Expected variant name 'CircuitProveResponse' but got '${variantName}'`);
125
+ }
126
+ return toCircuitProveResponse(result);
127
+ });
128
+ }
129
+
130
+ circuitComputeVk(command: CircuitComputeVk): Promise<CircuitComputeVkResponse> {
131
+ const msgpackCommand = fromCircuitComputeVk(command);
132
+ return this.sendCommand(['CircuitComputeVk', msgpackCommand]).then(([variantName, result]: [string, any]) => {
133
+ if (variantName !== 'CircuitComputeVkResponse') {
134
+ throw new Error(`Expected variant name 'CircuitComputeVkResponse' but got '${variantName}'`);
135
+ }
136
+ return toCircuitComputeVkResponse(result);
137
+ });
138
+ }
139
+
140
+ circuitStats(command: CircuitStats): Promise<CircuitInfoResponse> {
141
+ const msgpackCommand = fromCircuitStats(command);
142
+ return this.sendCommand(['CircuitStats', msgpackCommand]).then(([variantName, result]: [string, any]) => {
143
+ if (variantName !== 'CircuitInfoResponse') {
144
+ throw new Error(`Expected variant name 'CircuitInfoResponse' but got '${variantName}'`);
145
+ }
146
+ return toCircuitInfoResponse(result);
147
+ });
148
+ }
149
+
150
+ circuitVerify(command: CircuitVerify): Promise<CircuitVerifyResponse> {
151
+ const msgpackCommand = fromCircuitVerify(command);
152
+ return this.sendCommand(['CircuitVerify', msgpackCommand]).then(([variantName, result]: [string, any]) => {
153
+ if (variantName !== 'CircuitVerifyResponse') {
154
+ throw new Error(`Expected variant name 'CircuitVerifyResponse' but got '${variantName}'`);
155
+ }
156
+ return toCircuitVerifyResponse(result);
157
+ });
158
+ }
159
+
160
+ clientIvcComputeStandaloneVk(command: ClientIvcComputeStandaloneVk): Promise<ClientIvcComputeStandaloneVkResponse> {
161
+ const msgpackCommand = fromClientIvcComputeStandaloneVk(command);
162
+ return this.sendCommand(['ClientIvcComputeStandaloneVk', msgpackCommand]).then(([variantName, result]: [string, any]) => {
163
+ if (variantName !== 'ClientIvcComputeStandaloneVkResponse') {
164
+ throw new Error(`Expected variant name 'ClientIvcComputeStandaloneVkResponse' but got '${variantName}'`);
165
+ }
166
+ return toClientIvcComputeStandaloneVkResponse(result);
167
+ });
168
+ }
169
+
170
+ clientIvcComputeIvcVk(command: ClientIvcComputeIvcVk): Promise<ClientIvcComputeIvcVkResponse> {
171
+ const msgpackCommand = fromClientIvcComputeIvcVk(command);
172
+ return this.sendCommand(['ClientIvcComputeIvcVk', msgpackCommand]).then(([variantName, result]: [string, any]) => {
173
+ if (variantName !== 'ClientIvcComputeIvcVkResponse') {
174
+ throw new Error(`Expected variant name 'ClientIvcComputeIvcVkResponse' but got '${variantName}'`);
175
+ }
176
+ return toClientIvcComputeIvcVkResponse(result);
177
+ });
178
+ }
179
+
180
+ clientIvcStart(command: ClientIvcStart): Promise<ClientIvcStartResponse> {
181
+ const msgpackCommand = fromClientIvcStart(command);
182
+ return this.sendCommand(['ClientIvcStart', msgpackCommand]).then(([variantName, result]: [string, any]) => {
183
+ if (variantName !== 'ClientIvcStartResponse') {
184
+ throw new Error(`Expected variant name 'ClientIvcStartResponse' but got '${variantName}'`);
185
+ }
186
+ return toClientIvcStartResponse(result);
187
+ });
188
+ }
189
+
190
+ clientIvcLoad(command: ClientIvcLoad): Promise<ClientIvcLoadResponse> {
191
+ const msgpackCommand = fromClientIvcLoad(command);
192
+ return this.sendCommand(['ClientIvcLoad', msgpackCommand]).then(([variantName, result]: [string, any]) => {
193
+ if (variantName !== 'ClientIvcLoadResponse') {
194
+ throw new Error(`Expected variant name 'ClientIvcLoadResponse' but got '${variantName}'`);
195
+ }
196
+ return toClientIvcLoadResponse(result);
197
+ });
198
+ }
199
+
200
+ clientIvcAccumulate(command: ClientIvcAccumulate): Promise<ClientIvcAccumulateResponse> {
201
+ const msgpackCommand = fromClientIvcAccumulate(command);
202
+ return this.sendCommand(['ClientIvcAccumulate', msgpackCommand]).then(([variantName, result]: [string, any]) => {
203
+ if (variantName !== 'ClientIvcAccumulateResponse') {
204
+ throw new Error(`Expected variant name 'ClientIvcAccumulateResponse' but got '${variantName}'`);
205
+ }
206
+ return toClientIvcAccumulateResponse(result);
207
+ });
208
+ }
209
+
210
+ clientIvcProve(command: ClientIvcProve): Promise<ClientIvcProveResponse> {
211
+ const msgpackCommand = fromClientIvcProve(command);
212
+ return this.sendCommand(['ClientIvcProve', msgpackCommand]).then(([variantName, result]: [string, any]) => {
213
+ if (variantName !== 'ClientIvcProveResponse') {
214
+ throw new Error(`Expected variant name 'ClientIvcProveResponse' but got '${variantName}'`);
215
+ }
216
+ return toClientIvcProveResponse(result);
217
+ });
218
+ }
219
+
220
+ clientIvcVerify(command: ClientIvcVerify): Promise<ClientIvcVerifyResponse> {
221
+ const msgpackCommand = fromClientIvcVerify(command);
222
+ return this.sendCommand(['ClientIvcVerify', msgpackCommand]).then(([variantName, result]: [string, any]) => {
223
+ if (variantName !== 'ClientIvcVerifyResponse') {
224
+ throw new Error(`Expected variant name 'ClientIvcVerifyResponse' but got '${variantName}'`);
225
+ }
226
+ return toClientIvcVerifyResponse(result);
227
+ });
228
+ }
229
+
230
+ vkAsFields(command: VkAsFields): Promise<VkAsFieldsResponse> {
231
+ const msgpackCommand = fromVkAsFields(command);
232
+ return this.sendCommand(['VkAsFields', msgpackCommand]).then(([variantName, result]: [string, any]) => {
233
+ if (variantName !== 'VkAsFieldsResponse') {
234
+ throw new Error(`Expected variant name 'VkAsFieldsResponse' but got '${variantName}'`);
235
+ }
236
+ return toVkAsFieldsResponse(result);
237
+ });
238
+ }
239
+
240
+ circuitWriteSolidityVerifier(command: CircuitWriteSolidityVerifier): Promise<CircuitWriteSolidityVerifierResponse> {
241
+ const msgpackCommand = fromCircuitWriteSolidityVerifier(command);
242
+ return this.sendCommand(['CircuitWriteSolidityVerifier', msgpackCommand]).then(([variantName, result]: [string, any]) => {
243
+ if (variantName !== 'CircuitWriteSolidityVerifierResponse') {
244
+ throw new Error(`Expected variant name 'CircuitWriteSolidityVerifierResponse' but got '${variantName}'`);
245
+ }
246
+ return toCircuitWriteSolidityVerifierResponse(result);
247
+ });
248
+ }
249
+
250
+ clientIvcCheckPrecomputedVk(command: ClientIvcCheckPrecomputedVk): Promise<ClientIvcCheckPrecomputedVkResponse> {
251
+ const msgpackCommand = fromClientIvcCheckPrecomputedVk(command);
252
+ return this.sendCommand(['ClientIvcCheckPrecomputedVk', msgpackCommand]).then(([variantName, result]: [string, any]) => {
253
+ if (variantName !== 'ClientIvcCheckPrecomputedVkResponse') {
254
+ throw new Error(`Expected variant name 'ClientIvcCheckPrecomputedVkResponse' but got '${variantName}'`);
255
+ }
256
+ return toClientIvcCheckPrecomputedVkResponse(result);
257
+ });
258
+ }
259
+
260
+ clientIvcStats(command: ClientIvcStats): Promise<ClientIvcStatsResponse> {
261
+ const msgpackCommand = fromClientIvcStats(command);
262
+ return this.sendCommand(['ClientIvcStats', msgpackCommand]).then(([variantName, result]: [string, any]) => {
263
+ if (variantName !== 'ClientIvcStatsResponse') {
264
+ throw new Error(`Expected variant name 'ClientIvcStatsResponse' but got '${variantName}'`);
265
+ }
266
+ return toClientIvcStatsResponse(result);
267
+ });
268
+ }
269
+ }
@@ -0,0 +1,149 @@
1
+ // AUTOGENERATED FILE - DO NOT EDIT
2
+
3
+ import { BarretenbergWasmMain } from "../../barretenberg_wasm/barretenberg_wasm_main/index.js";
4
+ import { Decoder, Encoder } from 'msgpackr';
5
+ import { BbApiBase, CircuitComputeVk, CircuitComputeVkResponse, CircuitInfoResponse, CircuitInput, CircuitInputNoVK, CircuitProve, CircuitProveResponse, CircuitStats, CircuitVerify, CircuitVerifyResponse, CircuitWriteSolidityVerifier, CircuitWriteSolidityVerifierResponse, ClientIVCProof, ClientIvcAccumulate, ClientIvcAccumulateResponse, ClientIvcCheckPrecomputedVk, ClientIvcCheckPrecomputedVkResponse, ClientIvcComputeIvcVk, ClientIvcComputeIvcVkResponse, ClientIvcComputeStandaloneVk, ClientIvcComputeStandaloneVkResponse, ClientIvcLoad, ClientIvcLoadResponse, ClientIvcProve, ClientIvcProveResponse, ClientIvcStart, ClientIvcStartResponse, ClientIvcStats, ClientIvcStatsResponse, ClientIvcVerify, ClientIvcVerifyResponse, ECCVMProof, Fr, GoblinProof, ProofSystemSettings, Uint256T, VkAsFields, VkAsFieldsResponse, fromCircuitComputeVk, fromCircuitProve, fromCircuitStats, fromCircuitVerify, fromCircuitWriteSolidityVerifier, fromClientIvcAccumulate, fromClientIvcCheckPrecomputedVk, fromClientIvcComputeIvcVk, fromClientIvcComputeStandaloneVk, fromClientIvcLoad, fromClientIvcProve, fromClientIvcStart, fromClientIvcStats, fromClientIvcVerify, fromVkAsFields, toCircuitComputeVkResponse, toCircuitInfoResponse, toCircuitProveResponse, toCircuitVerifyResponse, toCircuitWriteSolidityVerifierResponse, toClientIvcAccumulateResponse, toClientIvcCheckPrecomputedVkResponse, toClientIvcComputeIvcVkResponse, toClientIvcComputeStandaloneVkResponse, toClientIvcLoadResponse, toClientIvcProveResponse, toClientIvcStartResponse, toClientIvcStatsResponse, toClientIvcVerifyResponse, toVkAsFieldsResponse } from './api_types.js';
6
+
7
+ function msgpackCall(wasm: BarretenbergWasmMain, cbind: string, input: any[]) { const inputBuffer = new Encoder({ useRecords: false }).pack(input); const encodedResult = wasm.cbindCall(cbind, inputBuffer); return new Decoder({ useRecords: false }).unpack(encodedResult);}
8
+ export class SyncApi {
9
+ constructor(protected wasm: BarretenbergWasmMain) {}
10
+
11
+ circuitProve(command: CircuitProve): CircuitProveResponse {
12
+ const msgpackCommand = fromCircuitProve(command);
13
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["CircuitProve", msgpackCommand]]);
14
+ if (variantName !== 'CircuitProveResponse') {
15
+ throw new Error(`Expected variant name 'CircuitProveResponse' but got '${variantName}'`);
16
+ }
17
+ return toCircuitProveResponse(result);
18
+ }
19
+
20
+ circuitComputeVk(command: CircuitComputeVk): CircuitComputeVkResponse {
21
+ const msgpackCommand = fromCircuitComputeVk(command);
22
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["CircuitComputeVk", msgpackCommand]]);
23
+ if (variantName !== 'CircuitComputeVkResponse') {
24
+ throw new Error(`Expected variant name 'CircuitComputeVkResponse' but got '${variantName}'`);
25
+ }
26
+ return toCircuitComputeVkResponse(result);
27
+ }
28
+
29
+ circuitStats(command: CircuitStats): CircuitInfoResponse {
30
+ const msgpackCommand = fromCircuitStats(command);
31
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["CircuitStats", msgpackCommand]]);
32
+ if (variantName !== 'CircuitInfoResponse') {
33
+ throw new Error(`Expected variant name 'CircuitInfoResponse' but got '${variantName}'`);
34
+ }
35
+ return toCircuitInfoResponse(result);
36
+ }
37
+
38
+ circuitVerify(command: CircuitVerify): CircuitVerifyResponse {
39
+ const msgpackCommand = fromCircuitVerify(command);
40
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["CircuitVerify", msgpackCommand]]);
41
+ if (variantName !== 'CircuitVerifyResponse') {
42
+ throw new Error(`Expected variant name 'CircuitVerifyResponse' but got '${variantName}'`);
43
+ }
44
+ return toCircuitVerifyResponse(result);
45
+ }
46
+
47
+ clientIvcComputeStandaloneVk(command: ClientIvcComputeStandaloneVk): ClientIvcComputeStandaloneVkResponse {
48
+ const msgpackCommand = fromClientIvcComputeStandaloneVk(command);
49
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcComputeStandaloneVk", msgpackCommand]]);
50
+ if (variantName !== 'ClientIvcComputeStandaloneVkResponse') {
51
+ throw new Error(`Expected variant name 'ClientIvcComputeStandaloneVkResponse' but got '${variantName}'`);
52
+ }
53
+ return toClientIvcComputeStandaloneVkResponse(result);
54
+ }
55
+
56
+ clientIvcComputeIvcVk(command: ClientIvcComputeIvcVk): ClientIvcComputeIvcVkResponse {
57
+ const msgpackCommand = fromClientIvcComputeIvcVk(command);
58
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcComputeIvcVk", msgpackCommand]]);
59
+ if (variantName !== 'ClientIvcComputeIvcVkResponse') {
60
+ throw new Error(`Expected variant name 'ClientIvcComputeIvcVkResponse' but got '${variantName}'`);
61
+ }
62
+ return toClientIvcComputeIvcVkResponse(result);
63
+ }
64
+
65
+ clientIvcStart(command: ClientIvcStart): ClientIvcStartResponse {
66
+ const msgpackCommand = fromClientIvcStart(command);
67
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcStart", msgpackCommand]]);
68
+ if (variantName !== 'ClientIvcStartResponse') {
69
+ throw new Error(`Expected variant name 'ClientIvcStartResponse' but got '${variantName}'`);
70
+ }
71
+ return toClientIvcStartResponse(result);
72
+ }
73
+
74
+ clientIvcLoad(command: ClientIvcLoad): ClientIvcLoadResponse {
75
+ const msgpackCommand = fromClientIvcLoad(command);
76
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcLoad", msgpackCommand]]);
77
+ if (variantName !== 'ClientIvcLoadResponse') {
78
+ throw new Error(`Expected variant name 'ClientIvcLoadResponse' but got '${variantName}'`);
79
+ }
80
+ return toClientIvcLoadResponse(result);
81
+ }
82
+
83
+ clientIvcAccumulate(command: ClientIvcAccumulate): ClientIvcAccumulateResponse {
84
+ const msgpackCommand = fromClientIvcAccumulate(command);
85
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcAccumulate", msgpackCommand]]);
86
+ if (variantName !== 'ClientIvcAccumulateResponse') {
87
+ throw new Error(`Expected variant name 'ClientIvcAccumulateResponse' but got '${variantName}'`);
88
+ }
89
+ return toClientIvcAccumulateResponse(result);
90
+ }
91
+
92
+ clientIvcProve(command: ClientIvcProve): ClientIvcProveResponse {
93
+ const msgpackCommand = fromClientIvcProve(command);
94
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcProve", msgpackCommand]]);
95
+ if (variantName !== 'ClientIvcProveResponse') {
96
+ throw new Error(`Expected variant name 'ClientIvcProveResponse' but got '${variantName}'`);
97
+ }
98
+ return toClientIvcProveResponse(result);
99
+ }
100
+
101
+ clientIvcVerify(command: ClientIvcVerify): ClientIvcVerifyResponse {
102
+ const msgpackCommand = fromClientIvcVerify(command);
103
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcVerify", msgpackCommand]]);
104
+ if (variantName !== 'ClientIvcVerifyResponse') {
105
+ throw new Error(`Expected variant name 'ClientIvcVerifyResponse' but got '${variantName}'`);
106
+ }
107
+ return toClientIvcVerifyResponse(result);
108
+ }
109
+
110
+ vkAsFields(command: VkAsFields): VkAsFieldsResponse {
111
+ const msgpackCommand = fromVkAsFields(command);
112
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["VkAsFields", msgpackCommand]]);
113
+ if (variantName !== 'VkAsFieldsResponse') {
114
+ throw new Error(`Expected variant name 'VkAsFieldsResponse' but got '${variantName}'`);
115
+ }
116
+ return toVkAsFieldsResponse(result);
117
+ }
118
+
119
+ circuitWriteSolidityVerifier(command: CircuitWriteSolidityVerifier): CircuitWriteSolidityVerifierResponse {
120
+ const msgpackCommand = fromCircuitWriteSolidityVerifier(command);
121
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["CircuitWriteSolidityVerifier", msgpackCommand]]);
122
+ if (variantName !== 'CircuitWriteSolidityVerifierResponse') {
123
+ throw new Error(`Expected variant name 'CircuitWriteSolidityVerifierResponse' but got '${variantName}'`);
124
+ }
125
+ return toCircuitWriteSolidityVerifierResponse(result);
126
+ }
127
+
128
+ clientIvcCheckPrecomputedVk(command: ClientIvcCheckPrecomputedVk): ClientIvcCheckPrecomputedVkResponse {
129
+ const msgpackCommand = fromClientIvcCheckPrecomputedVk(command);
130
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcCheckPrecomputedVk", msgpackCommand]]);
131
+ if (variantName !== 'ClientIvcCheckPrecomputedVkResponse') {
132
+ throw new Error(`Expected variant name 'ClientIvcCheckPrecomputedVkResponse' but got '${variantName}'`);
133
+ }
134
+ return toClientIvcCheckPrecomputedVkResponse(result);
135
+ }
136
+
137
+ clientIvcStats(command: ClientIvcStats): ClientIvcStatsResponse {
138
+ const msgpackCommand = fromClientIvcStats(command);
139
+ const [variantName, result] = msgpackCall(this.wasm, 'bbapi', [["ClientIvcStats", msgpackCommand]]);
140
+ if (variantName !== 'ClientIvcStatsResponse') {
141
+ throw new Error(`Expected variant name 'ClientIvcStatsResponse' but got '${variantName}'`);
142
+ }
143
+ return toClientIvcStatsResponse(result);
144
+ }
145
+
146
+ destroy(): Promise<void> {
147
+ return this.wasm.destroy();
148
+ }
149
+ }