@arcium-hq/client 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -99,13 +99,17 @@ type HashFunction = {
99
99
  capacity: number;
100
100
  };
101
101
  /**
102
- * Field type for Curve25519 base field.
102
+ * Field type.
103
103
  */
104
104
  type FpField = IField<bigint>;
105
105
  /**
106
106
  * Curve25519 base field as an IField instance.
107
107
  */
108
108
  declare const CURVE25519_BASE_FIELD: FpField;
109
+ /**
110
+ * Curve25519 scalar field as an IField instance.
111
+ */
112
+ declare const CURVE25519_SCALAR_FIELD: FpField;
109
113
  /**
110
114
  * Description and parameters for the Rescue cipher or hash function, including round constants, MDS matrix, and key schedule.
111
115
  * See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
@@ -152,14 +156,14 @@ declare function toVec(data: bigint[]): bigint[][];
152
156
  * The Rescue cipher in Counter (CTR) mode, with a fixed block size m = 5.
153
157
  * See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
154
158
  */
155
- declare class RescueCipher {
159
+ declare class RescueCipherCommon {
156
160
  desc: RescueDesc;
157
161
  /**
158
- * Constructs a RescueCipher instance using a shared secret.
162
+ * Constructs a RescueCipherCommon instance using a shared secret.
159
163
  * The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
160
164
  * @param sharedSecret - The shared secret to derive the cipher key from.
161
165
  */
162
- constructor(sharedSecret: Uint8Array);
166
+ constructor(sharedSecret: Uint8Array, field: FpField);
163
167
  /**
164
168
  * Encrypts the plaintext vector in Counter (CTR) mode (raw, returns bigints).
165
169
  * @param plaintext - The array of plaintext bigints to encrypt.
@@ -192,6 +196,62 @@ declare class RescueCipher {
192
196
  decrypt(ciphertext: number[][], nonce: Uint8Array): bigint[];
193
197
  }
194
198
 
199
+ /**
200
+ * The Rescue cipher over Curve25519's base field in Counter (CTR) mode, with a fixed block size m = 5.
201
+ * See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
202
+ */
203
+ declare class RescueCipher {
204
+ cipher: RescueCipherCommon;
205
+ /**
206
+ * Constructs a RescueCipher instance using a shared secret.
207
+ * The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
208
+ * @param sharedSecret - The shared secret to derive the cipher key from.
209
+ */
210
+ constructor(sharedSecret: Uint8Array);
211
+ /**
212
+ * Encrypts the plaintext vector in Counter (CTR) mode and serializes each block.
213
+ * @param plaintext - The array of plaintext bigints to encrypt.
214
+ * @param nonce - A 16-byte nonce for CTR mode.
215
+ * @returns The ciphertext as an array of arrays of numbers (each 32 bytes).
216
+ */
217
+ encrypt(plaintext: bigint[], nonce: Uint8Array): number[][];
218
+ /**
219
+ * Deserializes and decrypts the ciphertext vector in Counter (CTR) mode.
220
+ * @param ciphertext - The array of arrays of numbers (each 32 bytes) to decrypt.
221
+ * @param nonce - A 16-byte nonce for CTR mode.
222
+ * @returns The decrypted plaintext as an array of bigints.
223
+ */
224
+ decrypt(ciphertext: number[][], nonce: Uint8Array): bigint[];
225
+ }
226
+
227
+ /**
228
+ * The Rescue cipher over Curve25519's scalar field in Counter (CTR) mode, with a fixed block size m = 5.
229
+ * See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
230
+ */
231
+ declare class CSplRescueCipher {
232
+ cipher: RescueCipherCommon;
233
+ /**
234
+ * Constructs a RescueCipher instance using a shared secret.
235
+ * The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
236
+ * @param sharedSecret - The shared secret to derive the cipher key from.
237
+ */
238
+ constructor(sharedSecret: Uint8Array);
239
+ /**
240
+ * Encrypts the plaintext vector in Counter (CTR) mode and serializes each block.
241
+ * @param plaintext - The array of plaintext bigints to encrypt.
242
+ * @param nonce - A 16-byte nonce for CTR mode.
243
+ * @returns The ciphertext as an array of arrays of numbers (each 32 bytes).
244
+ */
245
+ encrypt(plaintext: bigint[], nonce: Uint8Array): number[][];
246
+ /**
247
+ * Deserializes and decrypts the ciphertext vector in Counter (CTR) mode.
248
+ * @param ciphertext - The array of arrays of numbers (each 32 bytes) to decrypt.
249
+ * @param nonce - A 16-byte nonce for CTR mode.
250
+ * @returns The decrypted plaintext as an array of bigints.
251
+ */
252
+ decrypt(ciphertext: number[][], nonce: Uint8Array): bigint[];
253
+ }
254
+
195
255
  /**
196
256
  * The Rescue-Prime hash function, as described in https://eprint.iacr.org/2020/1143.pdf, offering 256 bits
197
257
  * of security against collision, preimage and second-preimage attacks for any field of size at least 102 bits.
@@ -205,7 +265,7 @@ declare class RescuePrimeHash {
205
265
  /**
206
266
  * Constructs a RescuePrimeHash instance with rate = 7 and capacity = 5.
207
267
  */
208
- constructor();
268
+ constructor(field: FpField);
209
269
  /**
210
270
  * Computes the Rescue-Prime hash of a message, with padding as described in Algorithm 2 of the paper.
211
271
  * @param message - The input message as an array of bigints.
@@ -396,7 +456,7 @@ type Arcium = {
396
456
  "address": "Arcj82pX7HxYKLR92qvgZUAd7vGS1k4hQvAFcPATFdEQ";
397
457
  "metadata": {
398
458
  "name": "arcium";
399
- "version": "0.6.1";
459
+ "version": "0.6.3";
400
460
  "spec": "0.1.0";
401
461
  "description": "The Arcium program";
402
462
  };
@@ -1484,6 +1544,10 @@ type Arcium = {
1484
1544
  {
1485
1545
  "name": "mxeProgram";
1486
1546
  "type": "pubkey";
1547
+ },
1548
+ {
1549
+ "name": "outputLenBytes";
1550
+ "type": "u32";
1487
1551
  }
1488
1552
  ];
1489
1553
  },
@@ -1569,18 +1633,24 @@ type Arcium = {
1569
1633
  {
1570
1634
  "kind": "const";
1571
1635
  "value": [
1572
- 109,
1636
+ 77,
1573
1637
  120,
1574
1638
  101,
1575
- 95,
1576
- 114,
1639
+ 82,
1577
1640
  101,
1578
1641
  99,
1579
1642
  111,
1580
1643
  118,
1581
1644
  101,
1582
1645
  114,
1583
- 121
1646
+ 121,
1647
+ 65,
1648
+ 99,
1649
+ 99,
1650
+ 111,
1651
+ 117,
1652
+ 110,
1653
+ 116
1584
1654
  ];
1585
1655
  },
1586
1656
  {
@@ -2251,6 +2321,55 @@ type Arcium = {
2251
2321
  }
2252
2322
  ];
2253
2323
  };
2324
+ },
2325
+ {
2326
+ "name": "compDefRaw";
2327
+ "docs": [
2328
+ "At least the first raw circuit account must exist before finalizing"
2329
+ ];
2330
+ "pda": {
2331
+ "seeds": [
2332
+ {
2333
+ "kind": "const";
2334
+ "value": [
2335
+ 67,
2336
+ 111,
2337
+ 109,
2338
+ 112,
2339
+ 117,
2340
+ 116,
2341
+ 97,
2342
+ 116,
2343
+ 105,
2344
+ 111,
2345
+ 110,
2346
+ 68,
2347
+ 101,
2348
+ 102,
2349
+ 105,
2350
+ 110,
2351
+ 105,
2352
+ 116,
2353
+ 105,
2354
+ 111,
2355
+ 110,
2356
+ 82,
2357
+ 97,
2358
+ 119
2359
+ ];
2360
+ },
2361
+ {
2362
+ "kind": "account";
2363
+ "path": "compDefAcc";
2364
+ },
2365
+ {
2366
+ "kind": "const";
2367
+ "value": [
2368
+ 0
2369
+ ];
2370
+ }
2371
+ ];
2372
+ };
2254
2373
  }
2255
2374
  ];
2256
2375
  "args": [
@@ -2345,18 +2464,24 @@ type Arcium = {
2345
2464
  {
2346
2465
  "kind": "const";
2347
2466
  "value": [
2348
- 109,
2467
+ 77,
2349
2468
  120,
2350
2469
  101,
2351
- 95,
2352
- 114,
2470
+ 82,
2353
2471
  101,
2354
2472
  99,
2355
2473
  111,
2356
2474
  118,
2357
2475
  101,
2358
2476
  114,
2359
- 121
2477
+ 121,
2478
+ 65,
2479
+ 99,
2480
+ 99,
2481
+ 111,
2482
+ 117,
2483
+ 110,
2484
+ 116
2360
2485
  ];
2361
2486
  },
2362
2487
  {
@@ -2700,18 +2825,24 @@ type Arcium = {
2700
2825
  {
2701
2826
  "kind": "const";
2702
2827
  "value": [
2703
- 109,
2828
+ 77,
2704
2829
  120,
2705
2830
  101,
2706
- 95,
2707
- 114,
2831
+ 82,
2708
2832
  101,
2709
2833
  99,
2710
2834
  111,
2711
2835
  118,
2712
2836
  101,
2713
2837
  114,
2714
- 121
2838
+ 121,
2839
+ 65,
2840
+ 99,
2841
+ 99,
2842
+ 111,
2843
+ 117,
2844
+ 110,
2845
+ 116
2715
2846
  ];
2716
2847
  },
2717
2848
  {
@@ -3814,18 +3945,24 @@ type Arcium = {
3814
3945
  {
3815
3946
  "kind": "const";
3816
3947
  "value": [
3817
- 109,
3948
+ 77,
3818
3949
  120,
3819
3950
  101,
3820
- 95,
3821
- 114,
3951
+ 82,
3822
3952
  101,
3823
3953
  99,
3824
3954
  111,
3825
3955
  118,
3826
3956
  101,
3827
3957
  114,
3828
- 121
3958
+ 121,
3959
+ 65,
3960
+ 99,
3961
+ 99,
3962
+ 111,
3963
+ 117,
3964
+ 110,
3965
+ 116
3829
3966
  ];
3830
3967
  },
3831
3968
  {
@@ -3987,18 +4124,24 @@ type Arcium = {
3987
4124
  {
3988
4125
  "kind": "const";
3989
4126
  "value": [
3990
- 109,
4127
+ 77,
3991
4128
  120,
3992
4129
  101,
3993
- 95,
3994
- 114,
4130
+ 82,
3995
4131
  101,
3996
4132
  99,
3997
4133
  111,
3998
4134
  118,
3999
4135
  101,
4000
4136
  114,
4001
- 121
4137
+ 121,
4138
+ 65,
4139
+ 99,
4140
+ 99,
4141
+ 111,
4142
+ 117,
4143
+ 110,
4144
+ 116
4002
4145
  ];
4003
4146
  },
4004
4147
  {
@@ -6154,18 +6297,24 @@ type Arcium = {
6154
6297
  {
6155
6298
  "kind": "const";
6156
6299
  "value": [
6157
- 109,
6300
+ 77,
6158
6301
  120,
6159
6302
  101,
6160
- 95,
6161
- 114,
6303
+ 82,
6162
6304
  101,
6163
6305
  99,
6164
6306
  111,
6165
6307
  118,
6166
6308
  101,
6167
6309
  114,
6168
- 121
6310
+ 121,
6311
+ 65,
6312
+ 99,
6313
+ 99,
6314
+ 111,
6315
+ 117,
6316
+ 110,
6317
+ 116
6169
6318
  ];
6170
6319
  },
6171
6320
  {
@@ -7394,18 +7543,24 @@ type Arcium = {
7394
7543
  {
7395
7544
  "kind": "const";
7396
7545
  "value": [
7397
- 109,
7546
+ 77,
7398
7547
  120,
7399
7548
  101,
7400
- 95,
7401
- 114,
7549
+ 82,
7402
7550
  101,
7403
7551
  99,
7404
7552
  111,
7405
7553
  118,
7406
7554
  101,
7407
7555
  114,
7408
- 121
7556
+ 121,
7557
+ 65,
7558
+ 99,
7559
+ 99,
7560
+ 111,
7561
+ 117,
7562
+ 110,
7563
+ 116
7409
7564
  ];
7410
7565
  },
7411
7566
  {
@@ -8518,6 +8673,11 @@ type Arcium = {
8518
8673
  "code": 6713;
8519
8674
  "name": "backupClusterNotSet";
8520
8675
  "msg": "Backup MXE cluster is not set";
8676
+ },
8677
+ {
8678
+ "code": 6714;
8679
+ "name": "shareAlreadySubmitted";
8680
+ "msg": "Share already submitted";
8521
8681
  }
8522
8682
  ];
8523
8683
  "types": [
@@ -10378,17 +10538,11 @@ type Arcium = {
10378
10538
  "kind": "struct";
10379
10539
  "fields": [
10380
10540
  {
10381
- "name": "bitmap";
10541
+ "name": "keyRecoveryFinalizeOffset";
10382
10542
  "docs": [
10383
- "Bitmap tracking which peers have uploaded their shares.",
10384
- "Bit index corresponds to the index in the original MXE's recovery_peers array."
10543
+ "The computation offset for the queued key_recovery_finalize circuit."
10385
10544
  ];
10386
- "type": {
10387
- "array": [
10388
- "u8",
10389
- 13
10390
- ];
10391
- };
10545
+ "type": "u64";
10392
10546
  },
10393
10547
  {
10394
10548
  "name": "shares";
@@ -10414,52 +10568,32 @@ type Arcium = {
10414
10568
  };
10415
10569
  },
10416
10570
  {
10417
- "name": "isFinalized";
10418
- "docs": [
10419
- "Whether the recovery has been finalized (threshold met and marked ready)."
10420
- ];
10421
- "type": "u8";
10571
+ "name": "originalMxePubkey";
10572
+ "type": "pubkey";
10422
10573
  },
10423
10574
  {
10424
- "name": "padding1";
10425
- "docs": [
10426
- "Padding for u64 alignment (need 5 bytes to align key_recovery_final_offset at 8-byte",
10427
- "boundary)"
10428
- ];
10429
- "type": {
10430
- "array": [
10431
- "u8",
10432
- 2
10433
- ];
10434
- };
10575
+ "name": "backupMxePubkey";
10576
+ "type": "pubkey";
10435
10577
  },
10436
10578
  {
10437
- "name": "keyRecoveryFinalizeOffset";
10579
+ "name": "isFinalized";
10438
10580
  "docs": [
10439
- "The computation offset for the queued key_recovery_finalize circuit."
10581
+ "Whether the recovery has been finalized (threshold met and marked ready)."
10440
10582
  ];
10441
- "type": "u64";
10583
+ "type": "u8";
10442
10584
  },
10443
10585
  {
10444
10586
  "name": "padding2";
10445
10587
  "docs": [
10446
- "Padding to ensure struct size is multiple of 8 (for zero_copy alignment after bump field)"
10588
+ "Padding to ensure struct size is u64 aligned (6 bytes)"
10447
10589
  ];
10448
10590
  "type": {
10449
10591
  "array": [
10450
10592
  "u8",
10451
- 7
10593
+ 6
10452
10594
  ];
10453
10595
  };
10454
10596
  },
10455
- {
10456
- "name": "originalMxePubkey";
10457
- "type": "pubkey";
10458
- },
10459
- {
10460
- "name": "backupMxePubkey";
10461
- "type": "pubkey";
10462
- },
10463
10597
  {
10464
10598
  "name": "bump";
10465
10599
  "type": "u8";
@@ -11670,5 +11804,5 @@ declare function getRecoveryClusterAccAddress(mxeProgramId: PublicKey): PublicKe
11670
11804
  */
11671
11805
  declare function getMxeRecoveryAccAddress(backupMxeProgramId: PublicKey, originalMxeProgramId: PublicKey): PublicKey;
11672
11806
 
11673
- export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, ArcisModule, ArcisType, ArcisValueField, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, IntegerInfo, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, createPacker, deserializeLE, finalizeKeyRecoveryExecution, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, getMxeRecoveryAccAddress, getRecoveryClusterAccAddress, initKeyRecoveryExecution, initMxePart1, initMxePart2, isNullRef, positiveModulo, queueKeyRecoveryInit, randMatrix, recoverMxe, serializeLE, sha256, submitKeyRecoveryShare, toVec, uploadCircuit };
11807
+ export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, ArcisModule, ArcisType, ArcisValueField, CSplRescueCipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, IntegerInfo, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, createPacker, deserializeLE, finalizeKeyRecoveryExecution, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, getMxeRecoveryAccAddress, getRecoveryClusterAccAddress, initKeyRecoveryExecution, initMxePart1, initMxePart2, isNullRef, positiveModulo, queueKeyRecoveryInit, randMatrix, recoverMxe, serializeLE, sha256, submitKeyRecoveryShare, toVec, uploadCircuit };
11674
11808
  export type { Arcium as ArciumIdlType, ArciumLocalEnv, ComputationErrorType, ComputationReference, ExecutingPoolAccount, FieldInfo, FpField, MempoolAccount, MempoolPriorityFeeStats, Packer };