@private.me/xbind 1.3.0 → 1.3.5

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 (68) hide show
  1. package/README.md +2 -2
  2. package/dist-standalone/_deps/crypto/base64.js +183 -170
  3. package/dist-standalone/_deps/crypto/cjs/base64.js +653 -91
  4. package/dist-standalone/_deps/crypto/cjs/errors.js +658 -102
  5. package/dist-standalone/_deps/crypto/cjs/hmac.js +468 -66
  6. package/dist-standalone/_deps/crypto/cjs/index.js +848 -82
  7. package/dist-standalone/_deps/crypto/cjs/package.json +1 -0
  8. package/dist-standalone/_deps/crypto/cjs/padding.js +504 -50
  9. package/dist-standalone/_deps/crypto/cjs/share-header.js +369 -65
  10. package/dist-standalone/_deps/crypto/cjs/shares.js +865 -143
  11. package/dist-standalone/_deps/crypto/cjs/tlv.js +1005 -183
  12. package/dist-standalone/_deps/crypto/cjs/uuid.js +437 -55
  13. package/dist-standalone/_deps/crypto/cjs/verify.js +414 -24
  14. package/dist-standalone/_deps/crypto/cjs/xorida.js +888 -186
  15. package/dist-standalone/_deps/crypto/errors.js +179 -89
  16. package/dist-standalone/_deps/crypto/hmac.js +129 -61
  17. package/dist-standalone/_deps/crypto/index.js +140 -40
  18. package/dist-standalone/_deps/crypto/padding.js +151 -45
  19. package/dist-standalone/_deps/crypto/share-header.js +89 -60
  20. package/dist-standalone/_deps/crypto/shares.js +280 -133
  21. package/dist-standalone/_deps/crypto/tlv.js +348 -179
  22. package/dist-standalone/_deps/crypto/uuid.js +130 -50
  23. package/dist-standalone/_deps/crypto/verify.js +71 -15
  24. package/dist-standalone/_deps/crypto/xorida.js +332 -181
  25. package/dist-standalone/_deps/shared/cjs/errors.js +572 -208
  26. package/dist-standalone/_deps/shared/cjs/index.js +443 -85
  27. package/dist-standalone/_deps/shared/cjs/types.js +284 -57
  28. package/dist-standalone/_deps/shared/errors.js +192 -199
  29. package/dist-standalone/_deps/shared/index.js +48 -51
  30. package/dist-standalone/_deps/shared/types.js +56 -57
  31. package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -1
  32. package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +1 -1
  33. package/dist-standalone/_deps/ux-helpers/cjs/progress.js +1 -1
  34. package/dist-standalone/_deps/ux-helpers/cjs/search.js +1 -1
  35. package/dist-standalone/_deps/ux-helpers/errors.js +1 -1
  36. package/dist-standalone/_deps/ux-helpers/pagination.js +1 -1
  37. package/dist-standalone/_deps/ux-helpers/progress.js +1 -1
  38. package/dist-standalone/_deps/ux-helpers/search.js +1 -1
  39. package/dist-standalone/_deps/xchange/auto-accept.js +1 -1
  40. package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -1
  41. package/dist-standalone/_deps/xchange/cjs/errors.js +1 -1
  42. package/dist-standalone/_deps/xchange/cjs/index.js +1 -1
  43. package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -1
  44. package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -1
  45. package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -1
  46. package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -1
  47. package/dist-standalone/_deps/xchange/errors.js +1 -1
  48. package/dist-standalone/_deps/xchange/index.js +1 -1
  49. package/dist-standalone/_deps/xchange/invite-client.js +1 -1
  50. package/dist-standalone/_deps/xchange/lazy-init.js +1 -1
  51. package/dist-standalone/_deps/xchange/trust-integration.js +1 -1
  52. package/dist-standalone/_deps/xchange/xchange.js +1 -1
  53. package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -1
  54. package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -1
  55. package/dist-standalone/_deps/xregistry/cjs/index.js +1 -1
  56. package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -1
  57. package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -1
  58. package/dist-standalone/_deps/xregistry/cjs/types.js +1 -1
  59. package/dist-standalone/_deps/xregistry/discovery.js +1 -1
  60. package/dist-standalone/_deps/xregistry/errors.js +1 -1
  61. package/dist-standalone/_deps/xregistry/index.js +1 -1
  62. package/dist-standalone/_deps/xregistry/registry.js +1 -1
  63. package/dist-standalone/_deps/xregistry/schema.js +1 -1
  64. package/dist-standalone/_deps/xregistry/types.js +1 -1
  65. package/dist-standalone/cjs/identity.js +2 -3
  66. package/dist-standalone/identity.js +2 -3
  67. package/package.json +2 -1
  68. package/share1.dat +0 -0
@@ -1,148 +1,295 @@
1
- /**
2
- * High-level share creation and reconstruction API.
3
- *
4
- * Sender pipeline: serialize (TLV) → pad (PKCS#7) → HMAC (sign) → split (XorIDA)
5
- * Receiver pipeline: reconstruct (XorIDA) → verify (HMAC) → unpad (PKCS#7) → deserialize (TLV)
6
- */
7
- import { ok, err } from"../shared/index.js";
8
- import { serializeMessage, deserializeMessage } from './tlv.js';
9
- import { pkcs7Pad, pkcs7Unpad } from './padding.js';
10
- import { generateHMAC, verifyHMAC } from './hmac.js';
11
- import { splitXorIDA, reconstructXorIDA, nextOddPrime } from './xorida.js';
1
+ (function (_0x54f50e, _0x47046d) {
2
+ const a17_0x14eb00 = {
3
+ _0x45a251: 0x6b,
4
+ _0x2b2a91: 0x76,
5
+ _0xac70e1: 0x91,
6
+ _0x5b77ad: 0x7b,
7
+ _0x228a8a: 0x8d,
8
+ _0x291c61: 0x96
9
+ }, _0x2be85f = a17_0x39d7, _0x5926bb = _0x54f50e();
10
+ while (!![]) {
11
+ try {
12
+ const _0x48cd75 = parseInt(_0x2be85f(0x72)) / 0x1 * (parseInt(_0x2be85f(a17_0x14eb00._0x45a251)) / 0x2) + -parseInt(_0x2be85f(a17_0x14eb00._0x2b2a91)) / 0x3 * (-parseInt(_0x2be85f(a17_0x14eb00._0xac70e1)) / 0x4) + parseInt(_0x2be85f(0x7a)) / 0x5 + -parseInt(_0x2be85f(0x8f)) / 0x6 + -parseInt(_0x2be85f(a17_0x14eb00._0x5b77ad)) / 0x7 + parseInt(_0x2be85f(a17_0x14eb00._0x228a8a)) / 0x8 * (-parseInt(_0x2be85f(0x93)) / 0x9) + parseInt(_0x2be85f(a17_0x14eb00._0x291c61)) / 0xa;
13
+ if (_0x48cd75 === _0x47046d)
14
+ break;
15
+ else
16
+ _0x5926bb['push'](_0x5926bb['shift']());
17
+ } catch (_0x2f9244) {
18
+ _0x5926bb['push'](_0x5926bb['shift']());
19
+ }
20
+ }
21
+ }(a17_0x5768, 0x2ae90));
22
+ import {
23
+ ok,
24
+ err
25
+ } from"../shared/index.js";
26
+ function a17_0x39d7(_0x4e448e, _0x1c8fc7) {
27
+ _0x4e448e = _0x4e448e - 0x65;
28
+ const _0x5768a2 = a17_0x5768();
29
+ let _0x39d7ef = _0x5768a2[_0x4e448e];
30
+ if (a17_0x39d7['qneHFf'] === undefined) {
31
+ var _0x49dcab = function (_0x300447) {
32
+ const _0x14bf49 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';
33
+ let _0x3308ce = '', _0x359ee8 = '';
34
+ for (let _0xc6d664 = 0x0, _0x1eca43, _0x143197, _0x42dba4 = 0x0; _0x143197 = _0x300447['charAt'](_0x42dba4++); ~_0x143197 && (_0x1eca43 = _0xc6d664 % 0x4 ? _0x1eca43 * 0x40 + _0x143197 : _0x143197, _0xc6d664++ % 0x4) ? _0x3308ce += String['fromCharCode'](0xff & _0x1eca43 >> (-0x2 * _0xc6d664 & 0x6)) : 0x0) {
35
+ _0x143197 = _0x14bf49['indexOf'](_0x143197);
36
+ }
37
+ for (let _0x354340 = 0x0, _0x438e7e = _0x3308ce['length']; _0x354340 < _0x438e7e; _0x354340++) {
38
+ _0x359ee8 += '%' + ('00' + _0x3308ce['charCodeAt'](_0x354340)['toString'](0x10))['slice'](-0x2);
39
+ }
40
+ return decodeURIComponent(_0x359ee8);
41
+ };
42
+ a17_0x39d7['VKDRWr'] = _0x49dcab, a17_0x39d7['IryBnf'] = {}, a17_0x39d7['qneHFf'] = !![];
43
+ }
44
+ const _0xf34aa8 = _0x5768a2[0x0], _0x1868b4 = _0x4e448e + _0xf34aa8, _0xa1bbf = a17_0x39d7['IryBnf'][_0x1868b4];
45
+ return !_0xa1bbf ? (_0x39d7ef = a17_0x39d7['VKDRWr'](_0x39d7ef), a17_0x39d7['IryBnf'][_0x1868b4] = _0x39d7ef) : _0x39d7ef = _0xa1bbf, _0x39d7ef;
46
+ }
47
+ function a17_0x5768() {
48
+ const _0x51e45b = [
49
+ 'BgvUz3rO',
50
+ 'qK5NyKy',
51
+ 'Dg1Ss0G',
52
+ 'zgf0yq',
53
+ 'se1bq19gquLmvvjf',
54
+ 'mZqXndjkqNb6s1q',
55
+ 'qxL4uee',
56
+ 'rLDfD1u',
57
+ 'rgvZzxjPywXPEMf0Aw9UigzHAwXLzdOG',
58
+ 'rxnIsMy',
59
+ 'ig91DcbVzIbYyw5NzsbBmcWG',
60
+ 'Dg9mB3DLCKnHC2u',
61
+ 'mtfNBwDhtNO',
62
+ 'Aw5KzxG',
63
+ 'B1LHuvK',
64
+ 'ihnOyxjLCYWGz290ia',
65
+ 'm3PLCNvbCa',
66
+ 'DgHYzxnOB2XK',
67
+ 'B1bXtuW',
68
+ 'C2XPy2u',
69
+ 'nZG4odmWDhjgB0ry',
70
+ 'mtu4nZi2nfjPDgPWvG',
71
+ 'BwvZC2fNzq',
72
+ 'AgfZ',
73
+ 'vvvjrf9nsvnnqvrdsa',
74
+ 'Ag1Hy0TLEq',
75
+ 'DMfSDwu',
76
+ 'DNDcuhi',
77
+ 'su5tvuzgsunjru5ux1niqvjfuW',
78
+ 'u2HHCMuGAw5KzxGG',
79
+ 'uhHYyK0',
80
+ 'DhjPBq',
81
+ 'tMvLzca',
82
+ 'rhvWBgLJyxrLihnOyxjLigLUzgv4ia',
83
+ 'ywrK',
84
+ 'v1PyquW',
85
+ 'qwXJu2C',
86
+ 'Cw5gufy',
87
+ 'sgTJCLK',
88
+ 'mtyWq1vtyKD2',
89
+ 'DxvPza',
90
+ 'mte3mte1og1mAfbesa',
91
+ 'tM8GC2HHCMvZihbYB3zPzgvK',
92
+ 'mte2mtCWnerywe9hBW',
93
+ 'zevoC2S',
94
+ 'oda3otnxyvvnwNC',
95
+ 'ENrVuvy',
96
+ 'rLbRufO',
97
+ 'mtqXmJCYmgLmAKHxvq',
98
+ 'zxjYB3i',
99
+ 'su5wquXjrf9jtKrfwa',
100
+ 'Dg90ywXtAgfYzxm',
101
+ 'u2HHCMvZigHHDMuGAw5JB25ZAxn0zw50ig4VAYb2ywX1zxm',
102
+ 'su5wquXjrf9tsefsrvm'
103
+ ];
104
+ a17_0x5768 = function () {
105
+ return _0x51e45b;
106
+ };
107
+ return a17_0x5768();
108
+ }
109
+ import {
110
+ serializeMessage,
111
+ deserializeMessage
112
+ } from './tlv.js';
113
+ import {
114
+ pkcs7Pad,
115
+ pkcs7Unpad
116
+ } from './padding.js';
117
+ import {
118
+ generateHMAC,
119
+ verifyHMAC
120
+ } from './hmac.js';
121
+ import {
122
+ splitXorIDA,
123
+ reconstructXorIDA,
124
+ nextOddPrime
125
+ } from './xorida.js';
12
126
  import { generateUUID } from './uuid.js';
13
- /**
14
- * Create shares from a XailMessage.
15
- *
16
- * Pipeline: serialize → pad → HMAC → split → package as XailShare[]
17
- *
18
- * @param message - The message to split into shares
19
- * @param n - Total number of shares to produce
20
- * @param k - Threshold: minimum shares needed for reconstruction
21
- * @returns Array of n XailShare objects ready for transport
22
- */
23
- export async function createShares(message, n, k) {
24
- // Ensure UUID is set before serialization so TLV and share headers match.
25
- const uuid = message.uuid || generateUUID();
26
- const messageWithUuid = uuid !== message.uuid ? { ...message, uuid } : message;
27
- // Step 1: Serialize to TLV
28
- const tlvPayload = serializeMessage(messageWithUuid);
29
- // Step 2: Pad to XorIDA block boundary
30
- const p = nextOddPrime(n);
31
- const blockSize = p - 1;
32
- const padded = pkcs7Pad(tlvPayload, blockSize);
33
- // Step 3: HMAC the padded payload
34
- const { key: hmacKey, signature: hmacSignature } = await generateHMAC(padded);
35
- // Step 4: Split via XorIDA
36
- const shareDataArrays = splitXorIDA(padded, n, k);
37
- const shares = shareDataArrays.map((data, index) => ({
38
- uuid,
39
- index,
40
- totalShares: n,
41
- threshold: k,
42
- data,
43
- hmacKey: hmacKey.slice(), // each share carries a copy
44
- hmacSignature: hmacSignature.slice(),
45
- }));
46
- return shares;
127
+ export async function createShares(_0x12f083, _0x2aa019, _0x16003c) {
128
+ const a17_0x336b5f = {
129
+ _0x35a8c1: 0x8e,
130
+ _0x5c8da3: 0x8a
131
+ }, _0x16af96 = a17_0x39d7, _0x341560 = {
132
+ 'dENsk': function (_0x9cb74) {
133
+ return _0x9cb74();
134
+ },
135
+ 'AlcSg': function (_0x460755, _0x247125) {
136
+ return _0x460755 !== _0x247125;
137
+ },
138
+ 'VJYBA': function (_0xc5e449, _0x2792e7) {
139
+ return _0xc5e449 - _0x2792e7;
140
+ }
141
+ }, _0x1dd90b = _0x12f083[_0x16af96(a17_0x336b5f._0x35a8c1)] || _0x341560[_0x16af96(0x92)](generateUUID), _0x328987 = _0x341560[_0x16af96(a17_0x336b5f._0x5c8da3)](_0x1dd90b, _0x12f083[_0x16af96(0x8e)]) ? {
142
+ ..._0x12f083,
143
+ 'uuid': _0x1dd90b
144
+ } : _0x12f083, _0x167138 = serializeMessage(_0x328987), _0x44d756 = nextOddPrime(_0x2aa019), _0x3d07f1 = _0x341560['VJYBA'](_0x44d756, 0x1), _0x16417c = pkcs7Pad(_0x167138, _0x3d07f1), {
145
+ key: _0x51425b,
146
+ signature: _0x3d16e8
147
+ } = await generateHMAC(_0x16417c), _0x3ada4e = splitXorIDA(_0x16417c, _0x2aa019, _0x16003c), _0x5de678 = _0x3ada4e['map']((_0x23d7ab, _0x2e3b15) => ({
148
+ 'uuid': _0x1dd90b,
149
+ 'index': _0x2e3b15,
150
+ 'totalShares': _0x2aa019,
151
+ 'threshold': _0x16003c,
152
+ 'data': _0x23d7ab,
153
+ 'hmacKey': _0x51425b['slice'](),
154
+ 'hmacSignature': _0x3d16e8[_0x16af96(0x79)]()
155
+ }));
156
+ return _0x5de678;
47
157
  }
48
- /**
49
- * Reconstruct a XailMessage from k shares.
50
- *
51
- * Pipeline: validate → reconstruct → verify HMAC → unpad → deserialize
52
- *
53
- * @param shares - Array of k XailShare objects (must share the same UUID)
54
- * @returns Reconstructed message, or ReconstructionError
55
- */
56
- export async function reconstructMessage(shares) {
57
- // Validation: need at least k shares
58
- if (shares.length === 0) {
59
- return err({ code: 'INSUFFICIENT_SHARES', message: 'No shares provided' });
60
- }
61
- const first = shares[0];
62
- const k = first.threshold;
63
- const n = first.totalShares;
64
- if (shares.length < k) {
65
- return err({
66
- code: 'INSUFFICIENT_SHARES',
67
- message: `Need ${k} shares, got ${shares.length}`,
158
+ export async function reconstructMessage(_0x50700b) {
159
+ const a17_0x307403 = {
160
+ _0x227fa2: 0x82,
161
+ _0x53a92f: 0x90,
162
+ _0x48dd5b: 0x81,
163
+ _0x5655f0: 0x89,
164
+ _0x72ed61: 0x77,
165
+ _0x42d942: 0x86,
166
+ _0x3ca728: 0x66,
167
+ _0x19b9cb: 0x6c,
168
+ _0x436e85: 0x99,
169
+ _0x5da107: 0x8b,
170
+ _0xe8fd36: 0x94,
171
+ _0x4e1518: 0x73,
172
+ _0x39343e: 0x74,
173
+ _0x4d2c8e: 0x83,
174
+ _0x42088e: 0x7d,
175
+ _0xc61bdc: 0x87,
176
+ _0x3ba152: 0x73,
177
+ _0xb7c748: 0x8c,
178
+ _0x22cdd6: 0x7f,
179
+ _0x438bb8: 0x67,
180
+ _0x14fa95: 0x6d,
181
+ _0x541ca9: 0x97,
182
+ _0x115255: 0x84,
183
+ _0x2d7bcb: 0x6e,
184
+ _0x42c26c: 0x7c,
185
+ _0x13db04: 0x80,
186
+ _0x1430ea: 0x8e,
187
+ _0x5e493d: 0x85,
188
+ _0x18a6a3: 0x95,
189
+ _0x36f426: 0x80,
190
+ _0x2a98c5: 0x8e
191
+ }, _0x304ca6 = a17_0x39d7, _0x1ca59f = {
192
+ 'pngKV': function (_0x40fd03, _0x350e4b) {
193
+ return _0x40fd03 === _0x350e4b;
194
+ },
195
+ 'vwBPr': function (_0xffccb1, _0x5e5f8a) {
196
+ return _0xffccb1(_0x5e5f8a);
197
+ },
198
+ 'WZXAL': _0x304ca6(a17_0x307403._0x227fa2),
199
+ 'DOcWp': _0x304ca6(a17_0x307403._0x53a92f),
200
+ 'EsbJf': function (_0x55d4b8, _0x1a5cc0) {
201
+ return _0x55d4b8(_0x1a5cc0);
202
+ },
203
+ 'AyxPA': function (_0x2ca239, _0x5701df) {
204
+ return _0x2ca239 !== _0x5701df;
205
+ },
206
+ 'qnFPV': function (_0x2211ec, _0x311599) {
207
+ return _0x2211ec(_0x311599);
208
+ },
209
+ 'tmlKH': 'Shares\x20have\x20different\x20UUIDs',
210
+ 'ztoQV': _0x304ca6(0x65),
211
+ 'oYaQY': function (_0x295f15, _0x131f63) {
212
+ return _0x295f15(_0x131f63);
213
+ },
214
+ 'mQWqQ': 'INVALID_INDEX',
215
+ 'HkcrY': function (_0xbb16dc, _0x54b9c0, _0x1d9934, _0xa609a8, _0xbb1982) {
216
+ return _0xbb16dc(_0x54b9c0, _0x1d9934, _0xa609a8, _0xbb1982);
217
+ },
218
+ 'LooGs': function (_0x3fbb78, _0x116cbe, _0x2f3511, _0x5bb9b1) {
219
+ return _0x3fbb78(_0x116cbe, _0x2f3511, _0x5bb9b1);
220
+ },
221
+ 'BNgbF': _0x304ca6(0x6a),
222
+ 'FWEwU': 'HMAC\x20verification\x20failed\x20—\x20data\x20may\x20be\x20corrupted\x20or\x20tampered',
223
+ 'PxrbM': function (_0x9a4067, _0x3cb2b0) {
224
+ return _0x9a4067(_0x3cb2b0);
225
+ },
226
+ 'oPqML': function (_0x4123d0, _0x43c673) {
227
+ return _0x4123d0 !== _0x43c673;
228
+ },
229
+ 'FPkPZ': _0x304ca6(0x7e),
230
+ 'ltVLV': 'TLV\x20UUID\x20does\x20not\x20match\x20envelope\x20UUID'
231
+ };
232
+ if (_0x1ca59f['pngKV'](_0x50700b['length'], 0x0))
233
+ return _0x1ca59f[_0x304ca6(a17_0x307403._0x48dd5b)](err, {
234
+ 'code': _0x1ca59f[_0x304ca6(a17_0x307403._0x5655f0)],
235
+ 'message': _0x1ca59f['DOcWp']
68
236
  });
69
- }
70
- // Validate consistency
71
- const indices = [];
72
- const indexSet = new Set();
73
- for (const share of shares) {
74
- if (share.uuid !== first.uuid) {
75
- return err({
76
- code: 'INVALID_SHARES',
77
- message: 'Shares have different UUIDs',
237
+ const _0x50731d = _0x50700b[0x0], _0x31ef9c = _0x50731d[_0x304ca6(a17_0x307403._0x72ed61)], _0x22b30b = _0x50731d[_0x304ca6(0x99)];
238
+ if (_0x50700b[_0x304ca6(0x66)] < _0x31ef9c)
239
+ return _0x1ca59f[_0x304ca6(0x6f)](err, {
240
+ 'code': _0x1ca59f['WZXAL'],
241
+ 'message': _0x304ca6(a17_0x307403._0x42d942) + _0x31ef9c + _0x304ca6(0x75) + _0x50700b[_0x304ca6(a17_0x307403._0x3ca728)]
242
+ });
243
+ const _0x5265d9 = [], _0x11c353 = new Set();
244
+ for (const _0xd4d496 of _0x50700b) {
245
+ if (_0x1ca59f[_0x304ca6(a17_0x307403._0x19b9cb)](_0xd4d496['uuid'], _0x50731d[_0x304ca6(0x8e)]))
246
+ return _0x1ca59f[_0x304ca6(0x8b)](err, {
247
+ 'code': _0x304ca6(0x65),
248
+ 'message': _0x1ca59f[_0x304ca6(0x68)]
78
249
  });
79
- }
80
- if (share.totalShares !== n || share.threshold !== k) {
81
- return err({
82
- code: 'INVALID_SHARES',
83
- message: 'Shares have inconsistent n/k values',
250
+ if (_0xd4d496[_0x304ca6(a17_0x307403._0x436e85)] !== _0x22b30b || _0xd4d496['threshold'] !== _0x31ef9c)
251
+ return _0x1ca59f[_0x304ca6(a17_0x307403._0x5da107)](err, {
252
+ 'code': _0x1ca59f[_0x304ca6(a17_0x307403._0xe8fd36)],
253
+ 'message': _0x304ca6(0x9a)
84
254
  });
85
- }
86
- if (share.index < 0 || share.index >= n) {
87
- return err({
88
- code: 'INVALID_INDEX',
89
- message: `Share index ${share.index} out of range [0, ${n})`,
255
+ if (_0xd4d496[_0x304ca6(a17_0x307403._0x4e1518)] < 0x0 || _0xd4d496['index'] >= _0x22b30b)
256
+ return _0x1ca59f[_0x304ca6(a17_0x307403._0x39343e)](err, {
257
+ 'code': _0x1ca59f['mQWqQ'],
258
+ 'message': _0x304ca6(a17_0x307403._0x4d2c8e) + _0xd4d496[_0x304ca6(0x73)] + _0x304ca6(0x70) + _0x22b30b + ')'
90
259
  });
91
- }
92
- if (indexSet.has(share.index)) {
260
+ if (_0x11c353[_0x304ca6(a17_0x307403._0x42088e)](_0xd4d496['index']))
93
261
  return err({
94
- code: 'INVALID_INDEX',
95
- message: `Duplicate share index ${share.index}`,
262
+ 'code': _0x304ca6(0x98),
263
+ 'message': _0x304ca6(a17_0x307403._0xc61bdc) + _0xd4d496[_0x304ca6(0x73)]
96
264
  });
97
- }
98
- indexSet.add(share.index);
99
- indices.push(share.index);
265
+ _0x11c353[_0x304ca6(0x88)](_0xd4d496[_0x304ca6(a17_0x307403._0x3ba152)]), _0x5265d9['push'](_0xd4d496[_0x304ca6(0x73)]);
100
266
  }
101
- // Take first k shares
102
- const usedShares = shares.slice(0, k);
103
- const usedIndices = indices.slice(0, k);
104
- const shareData = usedShares.map((s) => s.data);
105
- // Step 1: Reconstruct padded payload
106
- const padded = reconstructXorIDA(shareData, usedIndices, n, k);
107
- // Step 2: Verify HMAC (before unpadding — fail closed)
108
- const hmacValid = await verifyHMAC(first.hmacKey, padded, first.hmacSignature);
109
- if (!hmacValid) {
267
+ const _0xa43798 = _0x50700b['slice'](0x0, _0x31ef9c), _0x481908 = _0x5265d9['slice'](0x0, _0x31ef9c), _0x365b2a = _0xa43798['map'](_0x32b357 => _0x32b357[_0x304ca6(0x69)]), _0x30f118 = _0x1ca59f[_0x304ca6(a17_0x307403._0xb7c748)](reconstructXorIDA, _0x365b2a, _0x481908, _0x22b30b, _0x31ef9c), _0x3355de = await _0x1ca59f['LooGs'](verifyHMAC, _0x50731d[_0x304ca6(a17_0x307403._0x22cdd6)], _0x30f118, _0x50731d['hmacSignature']);
268
+ if (!_0x3355de)
110
269
  return err({
111
- code: 'HMAC_FAILURE',
112
- message: 'HMAC verification failed — data may be corrupted or tampered',
270
+ 'code': _0x1ca59f[_0x304ca6(a17_0x307403._0x438bb8)],
271
+ 'message': _0x1ca59f[_0x304ca6(a17_0x307403._0x14fa95)]
113
272
  });
114
- }
115
- // Step 3: Unpad
116
- const p = nextOddPrime(n);
117
- const blockSize = p - 1;
118
- const unpadResult = pkcs7Unpad(padded, blockSize);
119
- if (!unpadResult.ok) {
120
- return err({
121
- code: 'HMAC_FAILURE',
122
- message: `Unpadding failed: ${unpadResult.error.message}`,
273
+ const _0x5abd70 = nextOddPrime(_0x22b30b), _0x3889ee = _0x5abd70 - 0x1, _0xde0ec0 = pkcs7Unpad(_0x30f118, _0x3889ee);
274
+ if (!_0xde0ec0['ok'])
275
+ return _0x1ca59f[_0x304ca6(a17_0x307403._0x39343e)](err, {
276
+ 'code': _0x1ca59f['BNgbF'],
277
+ 'message': 'Unpadding\x20failed:\x20' + _0xde0ec0[_0x304ca6(a17_0x307403._0x541ca9)]['message']
123
278
  });
124
- }
125
- // Step 4: Deserialize TLV
126
- const msgResult = deserializeMessage(unpadResult.value);
127
- if (!msgResult.ok) {
279
+ const _0x226190 = _0x1ca59f[_0x304ca6(a17_0x307403._0x115255)](deserializeMessage, _0xde0ec0['value']);
280
+ if (!_0x226190['ok'])
128
281
  return err({
129
- code: 'INVALID_SHARES',
130
- message: `Deserialization failed: ${msgResult.error.message}`,
282
+ 'code': _0x1ca59f[_0x304ca6(0x94)],
283
+ 'message': _0x304ca6(a17_0x307403._0x2d7bcb) + _0x226190['error'][_0x304ca6(a17_0x307403._0x42c26c)]
131
284
  });
132
- }
133
- // UUID cross-check: if the TLV payload contains a UUID, it must match the envelope UUID.
134
- // Normalize both to lowercase+trimmed — bytesToUuid() always returns lowercase,
135
- // but envelope UUIDs from email headers may differ in casing or have whitespace.
136
- const tlvUuid = msgResult.value.uuid;
137
- if (tlvUuid && tlvUuid.toLowerCase().trim() !== first.uuid.toLowerCase().trim()) {
138
- return err({
139
- code: 'UUID_MISMATCH',
140
- message: 'TLV UUID does not match envelope UUID',
285
+ const _0x11b980 = _0x226190[_0x304ca6(a17_0x307403._0x13db04)][_0x304ca6(a17_0x307403._0x1430ea)];
286
+ if (_0x11b980 && _0x1ca59f[_0x304ca6(0x78)](_0x11b980[_0x304ca6(0x71)]()[_0x304ca6(a17_0x307403._0x5e493d)](), _0x50731d['uuid'][_0x304ca6(0x71)]()[_0x304ca6(0x85)]()))
287
+ return _0x1ca59f['PxrbM'](err, {
288
+ 'code': _0x1ca59f[_0x304ca6(a17_0x307403._0x18a6a3)],
289
+ 'message': _0x1ca59f['ltVLV']
141
290
  });
142
- }
143
- // The share headers carry the authoritative UUID (X-Xail-UUID).
144
- // The TLV payload may have a stale or empty UUID if the sender didn't
145
- // pre-populate message.uuid before calling createShares(). Stamp the
146
- // share-header UUID onto the reconstructed message.
147
- return ok({ ...msgResult.value, uuid: first.uuid });
148
- }
291
+ return _0x1ca59f[_0x304ca6(0x6f)](ok, {
292
+ ..._0x226190[_0x304ca6(a17_0x307403._0x36f426)],
293
+ 'uuid': _0x50731d[_0x304ca6(a17_0x307403._0x2a98c5)]
294
+ });
295
+ }