@reclaimprotocol/attestor-core 5.0.3 → 5.0.4

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.
Files changed (122) hide show
  1. package/LICENSE +660 -660
  2. package/browser/resources/attestor-browser.min.mjs +31 -31
  3. package/lib/avs/abis/avsDirectoryABI.js +340 -0
  4. package/lib/avs/abis/delegationABI.js +1 -0
  5. package/lib/avs/abis/registryABI.js +725 -0
  6. package/lib/avs/client/create-claim-on-avs.js +138 -0
  7. package/lib/avs/config.js +20 -0
  8. package/lib/avs/contracts/ReclaimServiceManager.js +1 -0
  9. package/lib/avs/contracts/common.js +1 -0
  10. package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +1169 -0
  11. package/lib/avs/contracts/factories/index.js +4 -0
  12. package/lib/avs/contracts/index.js +2 -0
  13. package/lib/avs/types/index.js +1 -0
  14. package/lib/avs/utils/contracts.js +33 -0
  15. package/lib/avs/utils/register.js +78 -0
  16. package/lib/avs/utils/tasks.js +40 -0
  17. package/lib/client/create-claim.js +433 -0
  18. package/lib/client/index.js +3 -0
  19. package/lib/client/tunnels/make-rpc-tcp-tunnel.js +51 -0
  20. package/lib/client/tunnels/make-rpc-tls-tunnel.js +131 -0
  21. package/lib/client/utils/attestor-pool.js +25 -0
  22. package/lib/client/utils/client-socket.js +98 -0
  23. package/lib/client/utils/message-handler.js +87 -0
  24. package/lib/config/index.d.ts +2 -2
  25. package/lib/config/index.js +44 -0
  26. package/lib/external-rpc/benchmark.js +69 -0
  27. package/lib/external-rpc/event-bus.js +14 -0
  28. package/lib/external-rpc/handle-incoming-msg.js +233 -0
  29. package/lib/external-rpc/index.js +101 -54
  30. package/lib/external-rpc/jsc-polyfills/1.js +82 -0
  31. package/lib/external-rpc/jsc-polyfills/2.js +20 -0
  32. package/lib/external-rpc/jsc-polyfills/event.js +14 -0
  33. package/lib/external-rpc/jsc-polyfills/index.js +2 -0
  34. package/lib/external-rpc/jsc-polyfills/ws.js +81 -0
  35. package/lib/external-rpc/setup-browser.js +33 -0
  36. package/lib/external-rpc/setup-jsc.js +22 -0
  37. package/lib/external-rpc/types.js +1 -0
  38. package/lib/external-rpc/utils.js +100 -0
  39. package/lib/external-rpc/zk.js +63 -0
  40. package/lib/index.js +121 -72
  41. package/lib/mechain/abis/governanceABI.js +458 -0
  42. package/lib/mechain/abis/taskABI.js +509 -0
  43. package/lib/mechain/client/create-claim-on-mechain.js +28 -0
  44. package/lib/mechain/client/index.js +1 -0
  45. package/lib/mechain/constants/index.js +3 -0
  46. package/lib/mechain/index.js +2 -0
  47. package/lib/mechain/types/index.js +1 -0
  48. package/lib/proto/api.d.ts +2 -0
  49. package/lib/proto/api.js +4273 -0
  50. package/lib/proto/tee-bundle.js +1316 -0
  51. package/lib/providers/http/index.js +658 -0
  52. package/lib/providers/http/patch-parse5-tree.js +33 -0
  53. package/lib/providers/http/utils.js +324 -0
  54. package/lib/providers/index.js +4 -0
  55. package/lib/scripts/fetch-ec2-metadata.d.ts +1 -0
  56. package/lib/server/create-server.js +103 -0
  57. package/lib/server/handlers/claimTeeBundle.js +252 -0
  58. package/lib/server/handlers/claimTunnel.js +73 -0
  59. package/lib/server/handlers/completeClaimOnChain.js +22 -0
  60. package/lib/server/handlers/createClaimOnChain.js +26 -0
  61. package/lib/server/handlers/createTaskOnMechain.js +47 -0
  62. package/lib/server/handlers/createTunnel.js +93 -0
  63. package/lib/server/handlers/disconnectTunnel.js +5 -0
  64. package/lib/server/handlers/fetchCertificateBytes.js +41 -0
  65. package/lib/server/handlers/index.js +22 -0
  66. package/lib/server/handlers/init.js +32 -0
  67. package/lib/server/handlers/toprf.js +16 -0
  68. package/lib/server/index.js +4 -0
  69. package/lib/server/socket.js +109 -0
  70. package/lib/server/tunnels/make-tcp-tunnel.js +177 -0
  71. package/lib/server/utils/apm.js +36 -0
  72. package/lib/server/utils/assert-valid-claim-request.d.ts +1 -1
  73. package/lib/server/utils/assert-valid-claim-request.js +204 -0
  74. package/lib/server/utils/config-env.js +4 -0
  75. package/lib/server/utils/dns.js +18 -0
  76. package/lib/server/utils/gcp-attestation.js +289 -0
  77. package/lib/server/utils/generics.d.ts +1 -0
  78. package/lib/server/utils/generics.js +51 -0
  79. package/lib/server/utils/iso.js +256 -0
  80. package/lib/server/utils/keep-alive.js +38 -0
  81. package/lib/server/utils/nitro-attestation.js +325 -0
  82. package/lib/server/utils/process-handshake.js +215 -0
  83. package/lib/server/utils/proxy-session.js +6 -0
  84. package/lib/server/utils/tee-oprf-mpc-verification.js +90 -0
  85. package/lib/server/utils/tee-oprf-verification.js +174 -0
  86. package/lib/server/utils/tee-transcript-reconstruction.js +187 -0
  87. package/lib/server/utils/tee-verification.js +421 -0
  88. package/lib/server/utils/validation.js +38 -0
  89. package/lib/types/bgp.js +1 -0
  90. package/lib/types/claims.js +1 -0
  91. package/lib/types/client.js +1 -0
  92. package/lib/types/general.js +1 -0
  93. package/lib/types/handlers.js +1 -0
  94. package/lib/types/index.js +10 -0
  95. package/lib/types/providers.d.ts +1 -0
  96. package/lib/types/providers.gen.js +10 -0
  97. package/lib/types/providers.js +1 -0
  98. package/lib/types/rpc.js +1 -0
  99. package/lib/types/signatures.js +1 -0
  100. package/lib/types/tunnel.js +1 -0
  101. package/lib/types/zk.js +1 -0
  102. package/lib/utils/auth.js +59 -0
  103. package/lib/utils/b64-json.js +17 -0
  104. package/lib/utils/bgp-listener.js +119 -0
  105. package/lib/utils/claims.js +99 -0
  106. package/lib/utils/env.js +15 -0
  107. package/lib/utils/error.js +50 -0
  108. package/lib/utils/generics.js +317 -0
  109. package/lib/utils/http-parser.d.ts +2 -1
  110. package/lib/utils/http-parser.js +246 -0
  111. package/lib/utils/index.js +13 -0
  112. package/lib/utils/logger.js +91 -0
  113. package/lib/utils/prepare-packets.js +62 -0
  114. package/lib/utils/redactions.js +148 -0
  115. package/lib/utils/retries.js +24 -0
  116. package/lib/utils/signatures/eth.js +29 -0
  117. package/lib/utils/signatures/index.js +7 -0
  118. package/lib/utils/socket-base.js +90 -0
  119. package/lib/utils/tls.js +58 -0
  120. package/lib/utils/ws.js +22 -0
  121. package/lib/utils/zk.js +577 -0
  122. package/package.json +3 -2
@@ -0,0 +1,1316 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.5.0
4
+ // protoc v6.31.1
5
+ // source: tee-bundle.proto
6
+ /* eslint-disable */
7
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
+ export const protobufPackage = "teeproto";
9
+ /** Signature wrapper used everywhere */
10
+ export const BodyType = {
11
+ BODY_TYPE_UNSPECIFIED: 0,
12
+ BODY_TYPE_K_OUTPUT: 1,
13
+ BODY_TYPE_T_OUTPUT: 2,
14
+ UNRECOGNIZED: -1,
15
+ };
16
+ export function bodyTypeFromJSON(object) {
17
+ switch (object) {
18
+ case 0:
19
+ case "BODY_TYPE_UNSPECIFIED":
20
+ return BodyType.BODY_TYPE_UNSPECIFIED;
21
+ case 1:
22
+ case "BODY_TYPE_K_OUTPUT":
23
+ return BodyType.BODY_TYPE_K_OUTPUT;
24
+ case 2:
25
+ case "BODY_TYPE_T_OUTPUT":
26
+ return BodyType.BODY_TYPE_T_OUTPUT;
27
+ case -1:
28
+ case "UNRECOGNIZED":
29
+ default:
30
+ return BodyType.UNRECOGNIZED;
31
+ }
32
+ }
33
+ export function bodyTypeToJSON(object) {
34
+ switch (object) {
35
+ case BodyType.BODY_TYPE_UNSPECIFIED:
36
+ return "BODY_TYPE_UNSPECIFIED";
37
+ case BodyType.BODY_TYPE_K_OUTPUT:
38
+ return "BODY_TYPE_K_OUTPUT";
39
+ case BodyType.BODY_TYPE_T_OUTPUT:
40
+ return "BODY_TYPE_T_OUTPUT";
41
+ case BodyType.UNRECOGNIZED:
42
+ default:
43
+ return "UNRECOGNIZED";
44
+ }
45
+ }
46
+ function createBaseRequestRedactionRange() {
47
+ return { start: 0, length: 0, type: "" };
48
+ }
49
+ export const RequestRedactionRange = {
50
+ encode(message, writer = new BinaryWriter()) {
51
+ if (message.start !== 0) {
52
+ writer.uint32(8).int32(message.start);
53
+ }
54
+ if (message.length !== 0) {
55
+ writer.uint32(16).int32(message.length);
56
+ }
57
+ if (message.type !== "") {
58
+ writer.uint32(26).string(message.type);
59
+ }
60
+ return writer;
61
+ },
62
+ decode(input, length) {
63
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
64
+ let end = length === undefined ? reader.len : reader.pos + length;
65
+ const message = createBaseRequestRedactionRange();
66
+ while (reader.pos < end) {
67
+ const tag = reader.uint32();
68
+ switch (tag >>> 3) {
69
+ case 1: {
70
+ if (tag !== 8) {
71
+ break;
72
+ }
73
+ message.start = reader.int32();
74
+ continue;
75
+ }
76
+ case 2: {
77
+ if (tag !== 16) {
78
+ break;
79
+ }
80
+ message.length = reader.int32();
81
+ continue;
82
+ }
83
+ case 3: {
84
+ if (tag !== 26) {
85
+ break;
86
+ }
87
+ message.type = reader.string();
88
+ continue;
89
+ }
90
+ }
91
+ if ((tag & 7) === 4 || tag === 0) {
92
+ break;
93
+ }
94
+ reader.skip(tag & 7);
95
+ }
96
+ return message;
97
+ },
98
+ fromJSON(object) {
99
+ return {
100
+ start: isSet(object.start) ? globalThis.Number(object.start) : 0,
101
+ length: isSet(object.length) ? globalThis.Number(object.length) : 0,
102
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
103
+ };
104
+ },
105
+ toJSON(message) {
106
+ const obj = {};
107
+ if (message.start !== 0) {
108
+ obj.start = Math.round(message.start);
109
+ }
110
+ if (message.length !== 0) {
111
+ obj.length = Math.round(message.length);
112
+ }
113
+ if (message.type !== "") {
114
+ obj.type = message.type;
115
+ }
116
+ return obj;
117
+ },
118
+ create(base) {
119
+ return RequestRedactionRange.fromPartial(base ?? {});
120
+ },
121
+ fromPartial(object) {
122
+ const message = createBaseRequestRedactionRange();
123
+ message.start = object.start ?? 0;
124
+ message.length = object.length ?? 0;
125
+ message.type = object.type ?? "";
126
+ return message;
127
+ },
128
+ };
129
+ function createBaseResponseRedactionRange() {
130
+ return { start: 0, length: 0 };
131
+ }
132
+ export const ResponseRedactionRange = {
133
+ encode(message, writer = new BinaryWriter()) {
134
+ if (message.start !== 0) {
135
+ writer.uint32(8).int32(message.start);
136
+ }
137
+ if (message.length !== 0) {
138
+ writer.uint32(16).int32(message.length);
139
+ }
140
+ return writer;
141
+ },
142
+ decode(input, length) {
143
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
144
+ let end = length === undefined ? reader.len : reader.pos + length;
145
+ const message = createBaseResponseRedactionRange();
146
+ while (reader.pos < end) {
147
+ const tag = reader.uint32();
148
+ switch (tag >>> 3) {
149
+ case 1: {
150
+ if (tag !== 8) {
151
+ break;
152
+ }
153
+ message.start = reader.int32();
154
+ continue;
155
+ }
156
+ case 2: {
157
+ if (tag !== 16) {
158
+ break;
159
+ }
160
+ message.length = reader.int32();
161
+ continue;
162
+ }
163
+ }
164
+ if ((tag & 7) === 4 || tag === 0) {
165
+ break;
166
+ }
167
+ reader.skip(tag & 7);
168
+ }
169
+ return message;
170
+ },
171
+ fromJSON(object) {
172
+ return {
173
+ start: isSet(object.start) ? globalThis.Number(object.start) : 0,
174
+ length: isSet(object.length) ? globalThis.Number(object.length) : 0,
175
+ };
176
+ },
177
+ toJSON(message) {
178
+ const obj = {};
179
+ if (message.start !== 0) {
180
+ obj.start = Math.round(message.start);
181
+ }
182
+ if (message.length !== 0) {
183
+ obj.length = Math.round(message.length);
184
+ }
185
+ return obj;
186
+ },
187
+ create(base) {
188
+ return ResponseRedactionRange.fromPartial(base ?? {});
189
+ },
190
+ fromPartial(object) {
191
+ const message = createBaseResponseRedactionRange();
192
+ message.start = object.start ?? 0;
193
+ message.length = object.length ?? 0;
194
+ return message;
195
+ },
196
+ };
197
+ function createBaseSignedRedactedDecryptionStream() {
198
+ return { redactedStream: new Uint8Array(0), seqNum: 0 };
199
+ }
200
+ export const SignedRedactedDecryptionStream = {
201
+ encode(message, writer = new BinaryWriter()) {
202
+ if (message.redactedStream.length !== 0) {
203
+ writer.uint32(10).bytes(message.redactedStream);
204
+ }
205
+ if (message.seqNum !== 0) {
206
+ writer.uint32(16).uint64(message.seqNum);
207
+ }
208
+ return writer;
209
+ },
210
+ decode(input, length) {
211
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
212
+ let end = length === undefined ? reader.len : reader.pos + length;
213
+ const message = createBaseSignedRedactedDecryptionStream();
214
+ while (reader.pos < end) {
215
+ const tag = reader.uint32();
216
+ switch (tag >>> 3) {
217
+ case 1: {
218
+ if (tag !== 10) {
219
+ break;
220
+ }
221
+ message.redactedStream = reader.bytes();
222
+ continue;
223
+ }
224
+ case 2: {
225
+ if (tag !== 16) {
226
+ break;
227
+ }
228
+ message.seqNum = longToNumber(reader.uint64());
229
+ continue;
230
+ }
231
+ }
232
+ if ((tag & 7) === 4 || tag === 0) {
233
+ break;
234
+ }
235
+ reader.skip(tag & 7);
236
+ }
237
+ return message;
238
+ },
239
+ fromJSON(object) {
240
+ return {
241
+ redactedStream: isSet(object.redactedStream) ? bytesFromBase64(object.redactedStream) : new Uint8Array(0),
242
+ seqNum: isSet(object.seqNum) ? globalThis.Number(object.seqNum) : 0,
243
+ };
244
+ },
245
+ toJSON(message) {
246
+ const obj = {};
247
+ if (message.redactedStream.length !== 0) {
248
+ obj.redactedStream = base64FromBytes(message.redactedStream);
249
+ }
250
+ if (message.seqNum !== 0) {
251
+ obj.seqNum = Math.round(message.seqNum);
252
+ }
253
+ return obj;
254
+ },
255
+ create(base) {
256
+ return SignedRedactedDecryptionStream.fromPartial(base ?? {});
257
+ },
258
+ fromPartial(object) {
259
+ const message = createBaseSignedRedactedDecryptionStream();
260
+ message.redactedStream = object.redactedStream ?? new Uint8Array(0);
261
+ message.seqNum = object.seqNum ?? 0;
262
+ return message;
263
+ },
264
+ };
265
+ function createBaseCertificateInfo() {
266
+ return { commonName: "", issuerCommonName: "", notBeforeUnix: 0, notAfterUnix: 0, dnsNames: [] };
267
+ }
268
+ export const CertificateInfo = {
269
+ encode(message, writer = new BinaryWriter()) {
270
+ if (message.commonName !== "") {
271
+ writer.uint32(10).string(message.commonName);
272
+ }
273
+ if (message.issuerCommonName !== "") {
274
+ writer.uint32(18).string(message.issuerCommonName);
275
+ }
276
+ if (message.notBeforeUnix !== 0) {
277
+ writer.uint32(24).uint64(message.notBeforeUnix);
278
+ }
279
+ if (message.notAfterUnix !== 0) {
280
+ writer.uint32(32).uint64(message.notAfterUnix);
281
+ }
282
+ for (const v of message.dnsNames) {
283
+ writer.uint32(42).string(v);
284
+ }
285
+ return writer;
286
+ },
287
+ decode(input, length) {
288
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
289
+ let end = length === undefined ? reader.len : reader.pos + length;
290
+ const message = createBaseCertificateInfo();
291
+ while (reader.pos < end) {
292
+ const tag = reader.uint32();
293
+ switch (tag >>> 3) {
294
+ case 1: {
295
+ if (tag !== 10) {
296
+ break;
297
+ }
298
+ message.commonName = reader.string();
299
+ continue;
300
+ }
301
+ case 2: {
302
+ if (tag !== 18) {
303
+ break;
304
+ }
305
+ message.issuerCommonName = reader.string();
306
+ continue;
307
+ }
308
+ case 3: {
309
+ if (tag !== 24) {
310
+ break;
311
+ }
312
+ message.notBeforeUnix = longToNumber(reader.uint64());
313
+ continue;
314
+ }
315
+ case 4: {
316
+ if (tag !== 32) {
317
+ break;
318
+ }
319
+ message.notAfterUnix = longToNumber(reader.uint64());
320
+ continue;
321
+ }
322
+ case 5: {
323
+ if (tag !== 42) {
324
+ break;
325
+ }
326
+ message.dnsNames.push(reader.string());
327
+ continue;
328
+ }
329
+ }
330
+ if ((tag & 7) === 4 || tag === 0) {
331
+ break;
332
+ }
333
+ reader.skip(tag & 7);
334
+ }
335
+ return message;
336
+ },
337
+ fromJSON(object) {
338
+ return {
339
+ commonName: isSet(object.commonName) ? globalThis.String(object.commonName) : "",
340
+ issuerCommonName: isSet(object.issuerCommonName) ? globalThis.String(object.issuerCommonName) : "",
341
+ notBeforeUnix: isSet(object.notBeforeUnix) ? globalThis.Number(object.notBeforeUnix) : 0,
342
+ notAfterUnix: isSet(object.notAfterUnix) ? globalThis.Number(object.notAfterUnix) : 0,
343
+ dnsNames: globalThis.Array.isArray(object?.dnsNames) ? object.dnsNames.map((e) => globalThis.String(e)) : [],
344
+ };
345
+ },
346
+ toJSON(message) {
347
+ const obj = {};
348
+ if (message.commonName !== "") {
349
+ obj.commonName = message.commonName;
350
+ }
351
+ if (message.issuerCommonName !== "") {
352
+ obj.issuerCommonName = message.issuerCommonName;
353
+ }
354
+ if (message.notBeforeUnix !== 0) {
355
+ obj.notBeforeUnix = Math.round(message.notBeforeUnix);
356
+ }
357
+ if (message.notAfterUnix !== 0) {
358
+ obj.notAfterUnix = Math.round(message.notAfterUnix);
359
+ }
360
+ if (message.dnsNames?.length) {
361
+ obj.dnsNames = message.dnsNames;
362
+ }
363
+ return obj;
364
+ },
365
+ create(base) {
366
+ return CertificateInfo.fromPartial(base ?? {});
367
+ },
368
+ fromPartial(object) {
369
+ const message = createBaseCertificateInfo();
370
+ message.commonName = object.commonName ?? "";
371
+ message.issuerCommonName = object.issuerCommonName ?? "";
372
+ message.notBeforeUnix = object.notBeforeUnix ?? 0;
373
+ message.notAfterUnix = object.notAfterUnix ?? 0;
374
+ message.dnsNames = object.dnsNames?.map((e) => e) || [];
375
+ return message;
376
+ },
377
+ };
378
+ function createBaseHandshakeSecrets() {
379
+ return { handshakeKey: new Uint8Array(0), handshakeIv: new Uint8Array(0), cipherSuite: 0, algorithm: "" };
380
+ }
381
+ export const HandshakeSecrets = {
382
+ encode(message, writer = new BinaryWriter()) {
383
+ if (message.handshakeKey.length !== 0) {
384
+ writer.uint32(10).bytes(message.handshakeKey);
385
+ }
386
+ if (message.handshakeIv.length !== 0) {
387
+ writer.uint32(18).bytes(message.handshakeIv);
388
+ }
389
+ if (message.cipherSuite !== 0) {
390
+ writer.uint32(24).uint32(message.cipherSuite);
391
+ }
392
+ if (message.algorithm !== "") {
393
+ writer.uint32(34).string(message.algorithm);
394
+ }
395
+ return writer;
396
+ },
397
+ decode(input, length) {
398
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
399
+ let end = length === undefined ? reader.len : reader.pos + length;
400
+ const message = createBaseHandshakeSecrets();
401
+ while (reader.pos < end) {
402
+ const tag = reader.uint32();
403
+ switch (tag >>> 3) {
404
+ case 1: {
405
+ if (tag !== 10) {
406
+ break;
407
+ }
408
+ message.handshakeKey = reader.bytes();
409
+ continue;
410
+ }
411
+ case 2: {
412
+ if (tag !== 18) {
413
+ break;
414
+ }
415
+ message.handshakeIv = reader.bytes();
416
+ continue;
417
+ }
418
+ case 3: {
419
+ if (tag !== 24) {
420
+ break;
421
+ }
422
+ message.cipherSuite = reader.uint32();
423
+ continue;
424
+ }
425
+ case 4: {
426
+ if (tag !== 34) {
427
+ break;
428
+ }
429
+ message.algorithm = reader.string();
430
+ continue;
431
+ }
432
+ }
433
+ if ((tag & 7) === 4 || tag === 0) {
434
+ break;
435
+ }
436
+ reader.skip(tag & 7);
437
+ }
438
+ return message;
439
+ },
440
+ fromJSON(object) {
441
+ return {
442
+ handshakeKey: isSet(object.handshakeKey) ? bytesFromBase64(object.handshakeKey) : new Uint8Array(0),
443
+ handshakeIv: isSet(object.handshakeIv) ? bytesFromBase64(object.handshakeIv) : new Uint8Array(0),
444
+ cipherSuite: isSet(object.cipherSuite) ? globalThis.Number(object.cipherSuite) : 0,
445
+ algorithm: isSet(object.algorithm) ? globalThis.String(object.algorithm) : "",
446
+ };
447
+ },
448
+ toJSON(message) {
449
+ const obj = {};
450
+ if (message.handshakeKey.length !== 0) {
451
+ obj.handshakeKey = base64FromBytes(message.handshakeKey);
452
+ }
453
+ if (message.handshakeIv.length !== 0) {
454
+ obj.handshakeIv = base64FromBytes(message.handshakeIv);
455
+ }
456
+ if (message.cipherSuite !== 0) {
457
+ obj.cipherSuite = Math.round(message.cipherSuite);
458
+ }
459
+ if (message.algorithm !== "") {
460
+ obj.algorithm = message.algorithm;
461
+ }
462
+ return obj;
463
+ },
464
+ create(base) {
465
+ return HandshakeSecrets.fromPartial(base ?? {});
466
+ },
467
+ fromPartial(object) {
468
+ const message = createBaseHandshakeSecrets();
469
+ message.handshakeKey = object.handshakeKey ?? new Uint8Array(0);
470
+ message.handshakeIv = object.handshakeIv ?? new Uint8Array(0);
471
+ message.cipherSuite = object.cipherSuite ?? 0;
472
+ message.algorithm = object.algorithm ?? "";
473
+ return message;
474
+ },
475
+ };
476
+ function createBaseOpening() {
477
+ return { proofStream: new Uint8Array(0) };
478
+ }
479
+ export const Opening = {
480
+ encode(message, writer = new BinaryWriter()) {
481
+ if (message.proofStream.length !== 0) {
482
+ writer.uint32(10).bytes(message.proofStream);
483
+ }
484
+ return writer;
485
+ },
486
+ decode(input, length) {
487
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
488
+ let end = length === undefined ? reader.len : reader.pos + length;
489
+ const message = createBaseOpening();
490
+ while (reader.pos < end) {
491
+ const tag = reader.uint32();
492
+ switch (tag >>> 3) {
493
+ case 1: {
494
+ if (tag !== 10) {
495
+ break;
496
+ }
497
+ message.proofStream = reader.bytes();
498
+ continue;
499
+ }
500
+ }
501
+ if ((tag & 7) === 4 || tag === 0) {
502
+ break;
503
+ }
504
+ reader.skip(tag & 7);
505
+ }
506
+ return message;
507
+ },
508
+ fromJSON(object) {
509
+ return { proofStream: isSet(object.proofStream) ? bytesFromBase64(object.proofStream) : new Uint8Array(0) };
510
+ },
511
+ toJSON(message) {
512
+ const obj = {};
513
+ if (message.proofStream.length !== 0) {
514
+ obj.proofStream = base64FromBytes(message.proofStream);
515
+ }
516
+ return obj;
517
+ },
518
+ create(base) {
519
+ return Opening.fromPartial(base ?? {});
520
+ },
521
+ fromPartial(object) {
522
+ const message = createBaseOpening();
523
+ message.proofStream = object.proofStream ?? new Uint8Array(0);
524
+ return message;
525
+ },
526
+ };
527
+ function createBaseOPRFOutput() {
528
+ return { tlsStart: 0, tlsLength: 0, hashOutput: new Uint8Array(0) };
529
+ }
530
+ export const OPRFOutput = {
531
+ encode(message, writer = new BinaryWriter()) {
532
+ if (message.tlsStart !== 0) {
533
+ writer.uint32(8).int32(message.tlsStart);
534
+ }
535
+ if (message.tlsLength !== 0) {
536
+ writer.uint32(16).int32(message.tlsLength);
537
+ }
538
+ if (message.hashOutput.length !== 0) {
539
+ writer.uint32(26).bytes(message.hashOutput);
540
+ }
541
+ return writer;
542
+ },
543
+ decode(input, length) {
544
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
545
+ let end = length === undefined ? reader.len : reader.pos + length;
546
+ const message = createBaseOPRFOutput();
547
+ while (reader.pos < end) {
548
+ const tag = reader.uint32();
549
+ switch (tag >>> 3) {
550
+ case 1: {
551
+ if (tag !== 8) {
552
+ break;
553
+ }
554
+ message.tlsStart = reader.int32();
555
+ continue;
556
+ }
557
+ case 2: {
558
+ if (tag !== 16) {
559
+ break;
560
+ }
561
+ message.tlsLength = reader.int32();
562
+ continue;
563
+ }
564
+ case 3: {
565
+ if (tag !== 26) {
566
+ break;
567
+ }
568
+ message.hashOutput = reader.bytes();
569
+ continue;
570
+ }
571
+ }
572
+ if ((tag & 7) === 4 || tag === 0) {
573
+ break;
574
+ }
575
+ reader.skip(tag & 7);
576
+ }
577
+ return message;
578
+ },
579
+ fromJSON(object) {
580
+ return {
581
+ tlsStart: isSet(object.tlsStart) ? globalThis.Number(object.tlsStart) : 0,
582
+ tlsLength: isSet(object.tlsLength) ? globalThis.Number(object.tlsLength) : 0,
583
+ hashOutput: isSet(object.hashOutput) ? bytesFromBase64(object.hashOutput) : new Uint8Array(0),
584
+ };
585
+ },
586
+ toJSON(message) {
587
+ const obj = {};
588
+ if (message.tlsStart !== 0) {
589
+ obj.tlsStart = Math.round(message.tlsStart);
590
+ }
591
+ if (message.tlsLength !== 0) {
592
+ obj.tlsLength = Math.round(message.tlsLength);
593
+ }
594
+ if (message.hashOutput.length !== 0) {
595
+ obj.hashOutput = base64FromBytes(message.hashOutput);
596
+ }
597
+ return obj;
598
+ },
599
+ create(base) {
600
+ return OPRFOutput.fromPartial(base ?? {});
601
+ },
602
+ fromPartial(object) {
603
+ const message = createBaseOPRFOutput();
604
+ message.tlsStart = object.tlsStart ?? 0;
605
+ message.tlsLength = object.tlsLength ?? 0;
606
+ message.hashOutput = object.hashOutput ?? new Uint8Array(0);
607
+ return message;
608
+ },
609
+ };
610
+ function createBaseKOutputPayload() {
611
+ return {
612
+ redactedRequest: new Uint8Array(0),
613
+ requestRedactionRanges: [],
614
+ consolidatedResponseKeystream: new Uint8Array(0),
615
+ certificateInfo: undefined,
616
+ responseRedactionRanges: [],
617
+ timestampMs: 0,
618
+ sessionId: "",
619
+ oprfOutputs: [],
620
+ };
621
+ }
622
+ export const KOutputPayload = {
623
+ encode(message, writer = new BinaryWriter()) {
624
+ if (message.redactedRequest.length !== 0) {
625
+ writer.uint32(10).bytes(message.redactedRequest);
626
+ }
627
+ for (const v of message.requestRedactionRanges) {
628
+ RequestRedactionRange.encode(v, writer.uint32(18).fork()).join();
629
+ }
630
+ if (message.consolidatedResponseKeystream.length !== 0) {
631
+ writer.uint32(26).bytes(message.consolidatedResponseKeystream);
632
+ }
633
+ if (message.certificateInfo !== undefined) {
634
+ CertificateInfo.encode(message.certificateInfo, writer.uint32(34).fork()).join();
635
+ }
636
+ for (const v of message.responseRedactionRanges) {
637
+ ResponseRedactionRange.encode(v, writer.uint32(42).fork()).join();
638
+ }
639
+ if (message.timestampMs !== 0) {
640
+ writer.uint32(48).uint64(message.timestampMs);
641
+ }
642
+ if (message.sessionId !== "") {
643
+ writer.uint32(58).string(message.sessionId);
644
+ }
645
+ for (const v of message.oprfOutputs) {
646
+ OPRFOutput.encode(v, writer.uint32(82).fork()).join();
647
+ }
648
+ return writer;
649
+ },
650
+ decode(input, length) {
651
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
652
+ let end = length === undefined ? reader.len : reader.pos + length;
653
+ const message = createBaseKOutputPayload();
654
+ while (reader.pos < end) {
655
+ const tag = reader.uint32();
656
+ switch (tag >>> 3) {
657
+ case 1: {
658
+ if (tag !== 10) {
659
+ break;
660
+ }
661
+ message.redactedRequest = reader.bytes();
662
+ continue;
663
+ }
664
+ case 2: {
665
+ if (tag !== 18) {
666
+ break;
667
+ }
668
+ message.requestRedactionRanges.push(RequestRedactionRange.decode(reader, reader.uint32()));
669
+ continue;
670
+ }
671
+ case 3: {
672
+ if (tag !== 26) {
673
+ break;
674
+ }
675
+ message.consolidatedResponseKeystream = reader.bytes();
676
+ continue;
677
+ }
678
+ case 4: {
679
+ if (tag !== 34) {
680
+ break;
681
+ }
682
+ message.certificateInfo = CertificateInfo.decode(reader, reader.uint32());
683
+ continue;
684
+ }
685
+ case 5: {
686
+ if (tag !== 42) {
687
+ break;
688
+ }
689
+ message.responseRedactionRanges.push(ResponseRedactionRange.decode(reader, reader.uint32()));
690
+ continue;
691
+ }
692
+ case 6: {
693
+ if (tag !== 48) {
694
+ break;
695
+ }
696
+ message.timestampMs = longToNumber(reader.uint64());
697
+ continue;
698
+ }
699
+ case 7: {
700
+ if (tag !== 58) {
701
+ break;
702
+ }
703
+ message.sessionId = reader.string();
704
+ continue;
705
+ }
706
+ case 10: {
707
+ if (tag !== 82) {
708
+ break;
709
+ }
710
+ message.oprfOutputs.push(OPRFOutput.decode(reader, reader.uint32()));
711
+ continue;
712
+ }
713
+ }
714
+ if ((tag & 7) === 4 || tag === 0) {
715
+ break;
716
+ }
717
+ reader.skip(tag & 7);
718
+ }
719
+ return message;
720
+ },
721
+ fromJSON(object) {
722
+ return {
723
+ redactedRequest: isSet(object.redactedRequest) ? bytesFromBase64(object.redactedRequest) : new Uint8Array(0),
724
+ requestRedactionRanges: globalThis.Array.isArray(object?.requestRedactionRanges)
725
+ ? object.requestRedactionRanges.map((e) => RequestRedactionRange.fromJSON(e))
726
+ : [],
727
+ consolidatedResponseKeystream: isSet(object.consolidatedResponseKeystream)
728
+ ? bytesFromBase64(object.consolidatedResponseKeystream)
729
+ : new Uint8Array(0),
730
+ certificateInfo: isSet(object.certificateInfo) ? CertificateInfo.fromJSON(object.certificateInfo) : undefined,
731
+ responseRedactionRanges: globalThis.Array.isArray(object?.responseRedactionRanges)
732
+ ? object.responseRedactionRanges.map((e) => ResponseRedactionRange.fromJSON(e))
733
+ : [],
734
+ timestampMs: isSet(object.timestampMs) ? globalThis.Number(object.timestampMs) : 0,
735
+ sessionId: isSet(object.sessionId) ? globalThis.String(object.sessionId) : "",
736
+ oprfOutputs: globalThis.Array.isArray(object?.oprfOutputs)
737
+ ? object.oprfOutputs.map((e) => OPRFOutput.fromJSON(e))
738
+ : [],
739
+ };
740
+ },
741
+ toJSON(message) {
742
+ const obj = {};
743
+ if (message.redactedRequest.length !== 0) {
744
+ obj.redactedRequest = base64FromBytes(message.redactedRequest);
745
+ }
746
+ if (message.requestRedactionRanges?.length) {
747
+ obj.requestRedactionRanges = message.requestRedactionRanges.map((e) => RequestRedactionRange.toJSON(e));
748
+ }
749
+ if (message.consolidatedResponseKeystream.length !== 0) {
750
+ obj.consolidatedResponseKeystream = base64FromBytes(message.consolidatedResponseKeystream);
751
+ }
752
+ if (message.certificateInfo !== undefined) {
753
+ obj.certificateInfo = CertificateInfo.toJSON(message.certificateInfo);
754
+ }
755
+ if (message.responseRedactionRanges?.length) {
756
+ obj.responseRedactionRanges = message.responseRedactionRanges.map((e) => ResponseRedactionRange.toJSON(e));
757
+ }
758
+ if (message.timestampMs !== 0) {
759
+ obj.timestampMs = Math.round(message.timestampMs);
760
+ }
761
+ if (message.sessionId !== "") {
762
+ obj.sessionId = message.sessionId;
763
+ }
764
+ if (message.oprfOutputs?.length) {
765
+ obj.oprfOutputs = message.oprfOutputs.map((e) => OPRFOutput.toJSON(e));
766
+ }
767
+ return obj;
768
+ },
769
+ create(base) {
770
+ return KOutputPayload.fromPartial(base ?? {});
771
+ },
772
+ fromPartial(object) {
773
+ const message = createBaseKOutputPayload();
774
+ message.redactedRequest = object.redactedRequest ?? new Uint8Array(0);
775
+ message.requestRedactionRanges = object.requestRedactionRanges?.map((e) => RequestRedactionRange.fromPartial(e)) ||
776
+ [];
777
+ message.consolidatedResponseKeystream = object.consolidatedResponseKeystream ?? new Uint8Array(0);
778
+ message.certificateInfo = (object.certificateInfo !== undefined && object.certificateInfo !== null)
779
+ ? CertificateInfo.fromPartial(object.certificateInfo)
780
+ : undefined;
781
+ message.responseRedactionRanges =
782
+ object.responseRedactionRanges?.map((e) => ResponseRedactionRange.fromPartial(e)) || [];
783
+ message.timestampMs = object.timestampMs ?? 0;
784
+ message.sessionId = object.sessionId ?? "";
785
+ message.oprfOutputs = object.oprfOutputs?.map((e) => OPRFOutput.fromPartial(e)) || [];
786
+ return message;
787
+ },
788
+ };
789
+ function createBaseTOutputPayload() {
790
+ return {
791
+ consolidatedResponseCiphertext: new Uint8Array(0),
792
+ requestProofStreams: [],
793
+ timestampMs: 0,
794
+ sessionId: "",
795
+ oprfOutputs: [],
796
+ };
797
+ }
798
+ export const TOutputPayload = {
799
+ encode(message, writer = new BinaryWriter()) {
800
+ if (message.consolidatedResponseCiphertext.length !== 0) {
801
+ writer.uint32(10).bytes(message.consolidatedResponseCiphertext);
802
+ }
803
+ for (const v of message.requestProofStreams) {
804
+ writer.uint32(18).bytes(v);
805
+ }
806
+ if (message.timestampMs !== 0) {
807
+ writer.uint32(24).uint64(message.timestampMs);
808
+ }
809
+ if (message.sessionId !== "") {
810
+ writer.uint32(34).string(message.sessionId);
811
+ }
812
+ for (const v of message.oprfOutputs) {
813
+ OPRFOutput.encode(v, writer.uint32(82).fork()).join();
814
+ }
815
+ return writer;
816
+ },
817
+ decode(input, length) {
818
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
819
+ let end = length === undefined ? reader.len : reader.pos + length;
820
+ const message = createBaseTOutputPayload();
821
+ while (reader.pos < end) {
822
+ const tag = reader.uint32();
823
+ switch (tag >>> 3) {
824
+ case 1: {
825
+ if (tag !== 10) {
826
+ break;
827
+ }
828
+ message.consolidatedResponseCiphertext = reader.bytes();
829
+ continue;
830
+ }
831
+ case 2: {
832
+ if (tag !== 18) {
833
+ break;
834
+ }
835
+ message.requestProofStreams.push(reader.bytes());
836
+ continue;
837
+ }
838
+ case 3: {
839
+ if (tag !== 24) {
840
+ break;
841
+ }
842
+ message.timestampMs = longToNumber(reader.uint64());
843
+ continue;
844
+ }
845
+ case 4: {
846
+ if (tag !== 34) {
847
+ break;
848
+ }
849
+ message.sessionId = reader.string();
850
+ continue;
851
+ }
852
+ case 10: {
853
+ if (tag !== 82) {
854
+ break;
855
+ }
856
+ message.oprfOutputs.push(OPRFOutput.decode(reader, reader.uint32()));
857
+ continue;
858
+ }
859
+ }
860
+ if ((tag & 7) === 4 || tag === 0) {
861
+ break;
862
+ }
863
+ reader.skip(tag & 7);
864
+ }
865
+ return message;
866
+ },
867
+ fromJSON(object) {
868
+ return {
869
+ consolidatedResponseCiphertext: isSet(object.consolidatedResponseCiphertext)
870
+ ? bytesFromBase64(object.consolidatedResponseCiphertext)
871
+ : new Uint8Array(0),
872
+ requestProofStreams: globalThis.Array.isArray(object?.requestProofStreams)
873
+ ? object.requestProofStreams.map((e) => bytesFromBase64(e))
874
+ : [],
875
+ timestampMs: isSet(object.timestampMs) ? globalThis.Number(object.timestampMs) : 0,
876
+ sessionId: isSet(object.sessionId) ? globalThis.String(object.sessionId) : "",
877
+ oprfOutputs: globalThis.Array.isArray(object?.oprfOutputs)
878
+ ? object.oprfOutputs.map((e) => OPRFOutput.fromJSON(e))
879
+ : [],
880
+ };
881
+ },
882
+ toJSON(message) {
883
+ const obj = {};
884
+ if (message.consolidatedResponseCiphertext.length !== 0) {
885
+ obj.consolidatedResponseCiphertext = base64FromBytes(message.consolidatedResponseCiphertext);
886
+ }
887
+ if (message.requestProofStreams?.length) {
888
+ obj.requestProofStreams = message.requestProofStreams.map((e) => base64FromBytes(e));
889
+ }
890
+ if (message.timestampMs !== 0) {
891
+ obj.timestampMs = Math.round(message.timestampMs);
892
+ }
893
+ if (message.sessionId !== "") {
894
+ obj.sessionId = message.sessionId;
895
+ }
896
+ if (message.oprfOutputs?.length) {
897
+ obj.oprfOutputs = message.oprfOutputs.map((e) => OPRFOutput.toJSON(e));
898
+ }
899
+ return obj;
900
+ },
901
+ create(base) {
902
+ return TOutputPayload.fromPartial(base ?? {});
903
+ },
904
+ fromPartial(object) {
905
+ const message = createBaseTOutputPayload();
906
+ message.consolidatedResponseCiphertext = object.consolidatedResponseCiphertext ?? new Uint8Array(0);
907
+ message.requestProofStreams = object.requestProofStreams?.map((e) => e) || [];
908
+ message.timestampMs = object.timestampMs ?? 0;
909
+ message.sessionId = object.sessionId ?? "";
910
+ message.oprfOutputs = object.oprfOutputs?.map((e) => OPRFOutput.fromPartial(e)) || [];
911
+ return message;
912
+ },
913
+ };
914
+ function createBaseAttestationReport() {
915
+ return { type: "", report: new Uint8Array(0) };
916
+ }
917
+ export const AttestationReport = {
918
+ encode(message, writer = new BinaryWriter()) {
919
+ if (message.type !== "") {
920
+ writer.uint32(10).string(message.type);
921
+ }
922
+ if (message.report.length !== 0) {
923
+ writer.uint32(18).bytes(message.report);
924
+ }
925
+ return writer;
926
+ },
927
+ decode(input, length) {
928
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
929
+ let end = length === undefined ? reader.len : reader.pos + length;
930
+ const message = createBaseAttestationReport();
931
+ while (reader.pos < end) {
932
+ const tag = reader.uint32();
933
+ switch (tag >>> 3) {
934
+ case 1: {
935
+ if (tag !== 10) {
936
+ break;
937
+ }
938
+ message.type = reader.string();
939
+ continue;
940
+ }
941
+ case 2: {
942
+ if (tag !== 18) {
943
+ break;
944
+ }
945
+ message.report = reader.bytes();
946
+ continue;
947
+ }
948
+ }
949
+ if ((tag & 7) === 4 || tag === 0) {
950
+ break;
951
+ }
952
+ reader.skip(tag & 7);
953
+ }
954
+ return message;
955
+ },
956
+ fromJSON(object) {
957
+ return {
958
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
959
+ report: isSet(object.report) ? bytesFromBase64(object.report) : new Uint8Array(0),
960
+ };
961
+ },
962
+ toJSON(message) {
963
+ const obj = {};
964
+ if (message.type !== "") {
965
+ obj.type = message.type;
966
+ }
967
+ if (message.report.length !== 0) {
968
+ obj.report = base64FromBytes(message.report);
969
+ }
970
+ return obj;
971
+ },
972
+ create(base) {
973
+ return AttestationReport.fromPartial(base ?? {});
974
+ },
975
+ fromPartial(object) {
976
+ const message = createBaseAttestationReport();
977
+ message.type = object.type ?? "";
978
+ message.report = object.report ?? new Uint8Array(0);
979
+ return message;
980
+ },
981
+ };
982
+ function createBaseSignedMessage() {
983
+ return {
984
+ bodyType: 0,
985
+ body: new Uint8Array(0),
986
+ ethAddress: new Uint8Array(0),
987
+ signature: new Uint8Array(0),
988
+ attestationReport: undefined,
989
+ };
990
+ }
991
+ export const SignedMessage = {
992
+ encode(message, writer = new BinaryWriter()) {
993
+ if (message.bodyType !== 0) {
994
+ writer.uint32(8).int32(message.bodyType);
995
+ }
996
+ if (message.body.length !== 0) {
997
+ writer.uint32(18).bytes(message.body);
998
+ }
999
+ if (message.ethAddress.length !== 0) {
1000
+ writer.uint32(26).bytes(message.ethAddress);
1001
+ }
1002
+ if (message.signature.length !== 0) {
1003
+ writer.uint32(34).bytes(message.signature);
1004
+ }
1005
+ if (message.attestationReport !== undefined) {
1006
+ AttestationReport.encode(message.attestationReport, writer.uint32(42).fork()).join();
1007
+ }
1008
+ return writer;
1009
+ },
1010
+ decode(input, length) {
1011
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1012
+ let end = length === undefined ? reader.len : reader.pos + length;
1013
+ const message = createBaseSignedMessage();
1014
+ while (reader.pos < end) {
1015
+ const tag = reader.uint32();
1016
+ switch (tag >>> 3) {
1017
+ case 1: {
1018
+ if (tag !== 8) {
1019
+ break;
1020
+ }
1021
+ message.bodyType = reader.int32();
1022
+ continue;
1023
+ }
1024
+ case 2: {
1025
+ if (tag !== 18) {
1026
+ break;
1027
+ }
1028
+ message.body = reader.bytes();
1029
+ continue;
1030
+ }
1031
+ case 3: {
1032
+ if (tag !== 26) {
1033
+ break;
1034
+ }
1035
+ message.ethAddress = reader.bytes();
1036
+ continue;
1037
+ }
1038
+ case 4: {
1039
+ if (tag !== 34) {
1040
+ break;
1041
+ }
1042
+ message.signature = reader.bytes();
1043
+ continue;
1044
+ }
1045
+ case 5: {
1046
+ if (tag !== 42) {
1047
+ break;
1048
+ }
1049
+ message.attestationReport = AttestationReport.decode(reader, reader.uint32());
1050
+ continue;
1051
+ }
1052
+ }
1053
+ if ((tag & 7) === 4 || tag === 0) {
1054
+ break;
1055
+ }
1056
+ reader.skip(tag & 7);
1057
+ }
1058
+ return message;
1059
+ },
1060
+ fromJSON(object) {
1061
+ return {
1062
+ bodyType: isSet(object.bodyType) ? bodyTypeFromJSON(object.bodyType) : 0,
1063
+ body: isSet(object.body) ? bytesFromBase64(object.body) : new Uint8Array(0),
1064
+ ethAddress: isSet(object.ethAddress) ? bytesFromBase64(object.ethAddress) : new Uint8Array(0),
1065
+ signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),
1066
+ attestationReport: isSet(object.attestationReport)
1067
+ ? AttestationReport.fromJSON(object.attestationReport)
1068
+ : undefined,
1069
+ };
1070
+ },
1071
+ toJSON(message) {
1072
+ const obj = {};
1073
+ if (message.bodyType !== 0) {
1074
+ obj.bodyType = bodyTypeToJSON(message.bodyType);
1075
+ }
1076
+ if (message.body.length !== 0) {
1077
+ obj.body = base64FromBytes(message.body);
1078
+ }
1079
+ if (message.ethAddress.length !== 0) {
1080
+ obj.ethAddress = base64FromBytes(message.ethAddress);
1081
+ }
1082
+ if (message.signature.length !== 0) {
1083
+ obj.signature = base64FromBytes(message.signature);
1084
+ }
1085
+ if (message.attestationReport !== undefined) {
1086
+ obj.attestationReport = AttestationReport.toJSON(message.attestationReport);
1087
+ }
1088
+ return obj;
1089
+ },
1090
+ create(base) {
1091
+ return SignedMessage.fromPartial(base ?? {});
1092
+ },
1093
+ fromPartial(object) {
1094
+ const message = createBaseSignedMessage();
1095
+ message.bodyType = object.bodyType ?? 0;
1096
+ message.body = object.body ?? new Uint8Array(0);
1097
+ message.ethAddress = object.ethAddress ?? new Uint8Array(0);
1098
+ message.signature = object.signature ?? new Uint8Array(0);
1099
+ message.attestationReport = (object.attestationReport !== undefined && object.attestationReport !== null)
1100
+ ? AttestationReport.fromPartial(object.attestationReport)
1101
+ : undefined;
1102
+ return message;
1103
+ },
1104
+ };
1105
+ function createBaseOPRFVerificationData() {
1106
+ return { streamPos: 0, streamLength: 0, publicSignalsJson: new Uint8Array(0) };
1107
+ }
1108
+ export const OPRFVerificationData = {
1109
+ encode(message, writer = new BinaryWriter()) {
1110
+ if (message.streamPos !== 0) {
1111
+ writer.uint32(8).uint32(message.streamPos);
1112
+ }
1113
+ if (message.streamLength !== 0) {
1114
+ writer.uint32(16).uint32(message.streamLength);
1115
+ }
1116
+ if (message.publicSignalsJson.length !== 0) {
1117
+ writer.uint32(26).bytes(message.publicSignalsJson);
1118
+ }
1119
+ return writer;
1120
+ },
1121
+ decode(input, length) {
1122
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1123
+ let end = length === undefined ? reader.len : reader.pos + length;
1124
+ const message = createBaseOPRFVerificationData();
1125
+ while (reader.pos < end) {
1126
+ const tag = reader.uint32();
1127
+ switch (tag >>> 3) {
1128
+ case 1: {
1129
+ if (tag !== 8) {
1130
+ break;
1131
+ }
1132
+ message.streamPos = reader.uint32();
1133
+ continue;
1134
+ }
1135
+ case 2: {
1136
+ if (tag !== 16) {
1137
+ break;
1138
+ }
1139
+ message.streamLength = reader.uint32();
1140
+ continue;
1141
+ }
1142
+ case 3: {
1143
+ if (tag !== 26) {
1144
+ break;
1145
+ }
1146
+ message.publicSignalsJson = reader.bytes();
1147
+ continue;
1148
+ }
1149
+ }
1150
+ if ((tag & 7) === 4 || tag === 0) {
1151
+ break;
1152
+ }
1153
+ reader.skip(tag & 7);
1154
+ }
1155
+ return message;
1156
+ },
1157
+ fromJSON(object) {
1158
+ return {
1159
+ streamPos: isSet(object.streamPos) ? globalThis.Number(object.streamPos) : 0,
1160
+ streamLength: isSet(object.streamLength) ? globalThis.Number(object.streamLength) : 0,
1161
+ publicSignalsJson: isSet(object.publicSignalsJson)
1162
+ ? bytesFromBase64(object.publicSignalsJson)
1163
+ : new Uint8Array(0),
1164
+ };
1165
+ },
1166
+ toJSON(message) {
1167
+ const obj = {};
1168
+ if (message.streamPos !== 0) {
1169
+ obj.streamPos = Math.round(message.streamPos);
1170
+ }
1171
+ if (message.streamLength !== 0) {
1172
+ obj.streamLength = Math.round(message.streamLength);
1173
+ }
1174
+ if (message.publicSignalsJson.length !== 0) {
1175
+ obj.publicSignalsJson = base64FromBytes(message.publicSignalsJson);
1176
+ }
1177
+ return obj;
1178
+ },
1179
+ create(base) {
1180
+ return OPRFVerificationData.fromPartial(base ?? {});
1181
+ },
1182
+ fromPartial(object) {
1183
+ const message = createBaseOPRFVerificationData();
1184
+ message.streamPos = object.streamPos ?? 0;
1185
+ message.streamLength = object.streamLength ?? 0;
1186
+ message.publicSignalsJson = object.publicSignalsJson ?? new Uint8Array(0);
1187
+ return message;
1188
+ },
1189
+ };
1190
+ function createBaseVerificationBundle() {
1191
+ return { teekSigned: undefined, teetSigned: undefined, oprfVerifications: [] };
1192
+ }
1193
+ export const VerificationBundle = {
1194
+ encode(message, writer = new BinaryWriter()) {
1195
+ if (message.teekSigned !== undefined) {
1196
+ SignedMessage.encode(message.teekSigned, writer.uint32(10).fork()).join();
1197
+ }
1198
+ if (message.teetSigned !== undefined) {
1199
+ SignedMessage.encode(message.teetSigned, writer.uint32(18).fork()).join();
1200
+ }
1201
+ for (const v of message.oprfVerifications) {
1202
+ OPRFVerificationData.encode(v, writer.uint32(26).fork()).join();
1203
+ }
1204
+ return writer;
1205
+ },
1206
+ decode(input, length) {
1207
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1208
+ let end = length === undefined ? reader.len : reader.pos + length;
1209
+ const message = createBaseVerificationBundle();
1210
+ while (reader.pos < end) {
1211
+ const tag = reader.uint32();
1212
+ switch (tag >>> 3) {
1213
+ case 1: {
1214
+ if (tag !== 10) {
1215
+ break;
1216
+ }
1217
+ message.teekSigned = SignedMessage.decode(reader, reader.uint32());
1218
+ continue;
1219
+ }
1220
+ case 2: {
1221
+ if (tag !== 18) {
1222
+ break;
1223
+ }
1224
+ message.teetSigned = SignedMessage.decode(reader, reader.uint32());
1225
+ continue;
1226
+ }
1227
+ case 3: {
1228
+ if (tag !== 26) {
1229
+ break;
1230
+ }
1231
+ message.oprfVerifications.push(OPRFVerificationData.decode(reader, reader.uint32()));
1232
+ continue;
1233
+ }
1234
+ }
1235
+ if ((tag & 7) === 4 || tag === 0) {
1236
+ break;
1237
+ }
1238
+ reader.skip(tag & 7);
1239
+ }
1240
+ return message;
1241
+ },
1242
+ fromJSON(object) {
1243
+ return {
1244
+ teekSigned: isSet(object.teekSigned) ? SignedMessage.fromJSON(object.teekSigned) : undefined,
1245
+ teetSigned: isSet(object.teetSigned) ? SignedMessage.fromJSON(object.teetSigned) : undefined,
1246
+ oprfVerifications: globalThis.Array.isArray(object?.oprfVerifications)
1247
+ ? object.oprfVerifications.map((e) => OPRFVerificationData.fromJSON(e))
1248
+ : [],
1249
+ };
1250
+ },
1251
+ toJSON(message) {
1252
+ const obj = {};
1253
+ if (message.teekSigned !== undefined) {
1254
+ obj.teekSigned = SignedMessage.toJSON(message.teekSigned);
1255
+ }
1256
+ if (message.teetSigned !== undefined) {
1257
+ obj.teetSigned = SignedMessage.toJSON(message.teetSigned);
1258
+ }
1259
+ if (message.oprfVerifications?.length) {
1260
+ obj.oprfVerifications = message.oprfVerifications.map((e) => OPRFVerificationData.toJSON(e));
1261
+ }
1262
+ return obj;
1263
+ },
1264
+ create(base) {
1265
+ return VerificationBundle.fromPartial(base ?? {});
1266
+ },
1267
+ fromPartial(object) {
1268
+ const message = createBaseVerificationBundle();
1269
+ message.teekSigned = (object.teekSigned !== undefined && object.teekSigned !== null)
1270
+ ? SignedMessage.fromPartial(object.teekSigned)
1271
+ : undefined;
1272
+ message.teetSigned = (object.teetSigned !== undefined && object.teetSigned !== null)
1273
+ ? SignedMessage.fromPartial(object.teetSigned)
1274
+ : undefined;
1275
+ message.oprfVerifications = object.oprfVerifications?.map((e) => OPRFVerificationData.fromPartial(e)) || [];
1276
+ return message;
1277
+ },
1278
+ };
1279
+ function bytesFromBase64(b64) {
1280
+ if (globalThis.Buffer) {
1281
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1282
+ }
1283
+ else {
1284
+ const bin = globalThis.atob(b64);
1285
+ const arr = new Uint8Array(bin.length);
1286
+ for (let i = 0; i < bin.length; ++i) {
1287
+ arr[i] = bin.charCodeAt(i);
1288
+ }
1289
+ return arr;
1290
+ }
1291
+ }
1292
+ function base64FromBytes(arr) {
1293
+ if (globalThis.Buffer) {
1294
+ return globalThis.Buffer.from(arr).toString("base64");
1295
+ }
1296
+ else {
1297
+ const bin = [];
1298
+ arr.forEach((byte) => {
1299
+ bin.push(globalThis.String.fromCharCode(byte));
1300
+ });
1301
+ return globalThis.btoa(bin.join(""));
1302
+ }
1303
+ }
1304
+ function longToNumber(int64) {
1305
+ const num = globalThis.Number(int64.toString());
1306
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
1307
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
1308
+ }
1309
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
1310
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
1311
+ }
1312
+ return num;
1313
+ }
1314
+ function isSet(value) {
1315
+ return value !== null && value !== undefined;
1316
+ }