@arcium-hq/client 0.8.4 → 0.9.0

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.cjs CHANGED
@@ -34,9 +34,9 @@ var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
34
34
  */
35
35
  const CURVE25519_SCALAR_FIELD_MODULUS = ed25519.ed25519.CURVE.n;
36
36
  /**
37
- * Generates a random value within the field bound by q.
38
- * @param q - The upper bound (exclusive) for the random value.
39
- * @returns A random bigint value between 0 and q-1.
37
+ * Generate a random value within the field bound by q.
38
+ * @param q - Upper bound (exclusive) for the random value.
39
+ * @returns Random bigint value between 0 and q-1.
40
40
  */
41
41
  function generateRandomFieldElem(q) {
42
42
  const byteLength = (q.toString(2).length + 7) >> 3;
@@ -48,19 +48,19 @@ function generateRandomFieldElem(q) {
48
48
  return r;
49
49
  }
50
50
  /**
51
- * Computes the positive modulo of a over m.
52
- * @param a - The dividend.
53
- * @param m - The modulus.
54
- * @returns The positive remainder of a mod m.
51
+ * Compute the positive modulo of a over m.
52
+ * @param a - Dividend.
53
+ * @param m - Modulus.
54
+ * @returns Positive remainder of a mod m.
55
55
  */
56
56
  function positiveModulo(a, m) {
57
57
  return ((a % m) + m) % m;
58
58
  }
59
59
  /**
60
- * Serializes a bigint to a little-endian Uint8Array of the specified length.
61
- * @param val - The bigint value to serialize.
62
- * @param lengthInBytes - The desired length of the output array.
63
- * @returns The serialized value as a Uint8Array.
60
+ * Serialize a bigint to a little-endian Uint8Array of the specified length.
61
+ * @param val - Bigint value to serialize.
62
+ * @param lengthInBytes - Desired length of the output array.
63
+ * @returns Serialized value as a Uint8Array.
64
64
  * @throws Error if the value is too large for the specified length.
65
65
  */
66
66
  function serializeLE(val, lengthInBytes) {
@@ -76,9 +76,9 @@ function serializeLE(val, lengthInBytes) {
76
76
  return result;
77
77
  }
78
78
  /**
79
- * Deserializes a little-endian Uint8Array to a bigint.
80
- * @param bytes - The Uint8Array to deserialize.
81
- * @returns The deserialized bigint value.
79
+ * Deserialize a little-endian Uint8Array to a bigint.
80
+ * @param bytes - Uint8Array to deserialize.
81
+ * @returns Deserialized bigint value.
82
82
  */
83
83
  function deserializeLE(bytes) {
84
84
  let result = BigInt(0);
@@ -89,9 +89,9 @@ function deserializeLE(bytes) {
89
89
  }
90
90
  // GENERAL
91
91
  /**
92
- * Computes the SHA-256 hash of an array of Uint8Arrays.
93
- * @param byteArrays - The arrays to hash.
94
- * @returns The SHA-256 hash as a Buffer.
92
+ * Compute the SHA-256 hash of an array of Uint8Arrays.
93
+ * @param byteArrays - Arrays to hash.
94
+ * @returns SHA-256 hash as a Buffer.
95
95
  */
96
96
  function sha256(byteArrays) {
97
97
  const hash = crypto.createHash('sha256');
@@ -102,10 +102,10 @@ function sha256(byteArrays) {
102
102
  }
103
103
 
104
104
  /**
105
- * Converts a bigint to an array of bits (least significant to most significant, in 2's complement representation).
106
- * @param x - The bigint to convert.
107
- * @param binSize - The number of bits to use in the representation.
108
- * @returns An array of booleans representing the bits of x.
105
+ * Convert a bigint to an array of bits (least significant to most significant, in 2's complement representation).
106
+ * @param x - Bigint to convert.
107
+ * @param binSize - Number of bits to use in the representation.
108
+ * @returns Array of booleans representing the bits of x.
109
109
  */
110
110
  function toBinLE(x, binSize) {
111
111
  const res = [];
@@ -115,9 +115,9 @@ function toBinLE(x, binSize) {
115
115
  return res;
116
116
  }
117
117
  /**
118
- * Converts an array of bits (least significant to most significant, in 2's complement representation) to a bigint.
119
- * @param xBin - The array of bits to convert.
120
- * @returns The bigint represented by the bit array.
118
+ * Convert an array of bits (least significant to most significant, in 2's complement representation) to a bigint.
119
+ * @param xBin - Array of bits to convert.
120
+ * @returns Bigint represented by the bit array.
121
121
  */
122
122
  function fromBinLE(xBin) {
123
123
  let res = 0n;
@@ -128,11 +128,11 @@ function fromBinLE(xBin) {
128
128
  }
129
129
  /**
130
130
  * Binary adder between x and y (assumes xBin and yBin are of the same length and large enough to represent the sum).
131
- * @param xBin - The first operand as a bit array.
132
- * @param yBin - The second operand as a bit array.
133
- * @param carryIn - The initial carry-in value.
134
- * @param binSize - The number of bits to use in the operation.
135
- * @returns The sum as a bit array.
131
+ * @param xBin - First operand as a bit array.
132
+ * @param yBin - Second operand as a bit array.
133
+ * @param carryIn - Initial carry-in value.
134
+ * @param binSize - Number of bits to use in the operation.
135
+ * @returns Sum as a bit array.
136
136
  */
137
137
  function adder(xBin, yBin, carryIn, binSize) {
138
138
  const res = [];
@@ -150,10 +150,10 @@ function adder(xBin, yBin, carryIn, binSize) {
150
150
  }
151
151
  /**
152
152
  * Constant-time addition of two bigints, using 2's complement representation.
153
- * @param x - The first operand.
154
- * @param y - The second operand.
155
- * @param binSize - The number of bits to use in the operation.
156
- * @returns The sum as a bigint.
153
+ * @param x - First operand.
154
+ * @param y - Second operand.
155
+ * @param binSize - Number of bits to use in the operation.
156
+ * @returns Sum as a bigint.
157
157
  */
158
158
  function ctAdd(x, y, binSize) {
159
159
  const resBin = adder(toBinLE(x, binSize), toBinLE(y, binSize), false, binSize);
@@ -161,10 +161,10 @@ function ctAdd(x, y, binSize) {
161
161
  }
162
162
  /**
163
163
  * Constant-time subtraction of two bigints, using 2's complement representation.
164
- * @param x - The first operand.
165
- * @param y - The second operand.
166
- * @param binSize - The number of bits to use in the operation.
167
- * @returns The difference as a bigint.
164
+ * @param x - First operand.
165
+ * @param y - Second operand.
166
+ * @param binSize - Number of bits to use in the operation.
167
+ * @returns Difference as a bigint.
168
168
  */
169
169
  function ctSub(x, y, binSize) {
170
170
  const yBin = toBinLE(y, binSize);
@@ -176,9 +176,9 @@ function ctSub(x, y, binSize) {
176
176
  return fromBinLE(resBin);
177
177
  }
178
178
  /**
179
- * Returns the sign bit of a bigint in constant time.
180
- * @param x - The bigint to check.
181
- * @param binSize - The bit position to check (typically the highest bit).
179
+ * Return the sign bit of a bigint in constant time.
180
+ * @param x - Bigint to check.
181
+ * @param binSize - Bit position to check (typically the highest bit).
182
182
  * @returns True if the sign bit is set, false otherwise.
183
183
  */
184
184
  function ctSignBit(x, binSize) {
@@ -186,9 +186,9 @@ function ctSignBit(x, binSize) {
186
186
  }
187
187
  /**
188
188
  * Constant-time less-than comparison for two bigints.
189
- * @param x - The first operand.
190
- * @param y - The second operand.
191
- * @param binSize - The number of bits to use in the operation.
189
+ * @param x - First operand.
190
+ * @param y - Second operand.
191
+ * @param binSize - Number of bits to use in the operation.
192
192
  * @returns True if x < y, false otherwise.
193
193
  */
194
194
  function ctLt(x, y, binSize) {
@@ -196,21 +196,21 @@ function ctLt(x, y, binSize) {
196
196
  }
197
197
  /**
198
198
  * Constant-time select between two bigints based on a boolean condition.
199
- * @param b - The condition; if true, select x, otherwise select y.
200
- * @param x - The value to select if b is true.
201
- * @param y - The value to select if b is false.
202
- * @param binSize - The number of bits to use in the operation.
203
- * @returns The selected bigint.
199
+ * @param b - Condition; if true, select x, otherwise select y.
200
+ * @param x - Value to select if b is true.
201
+ * @param y - Value to select if b is false.
202
+ * @param binSize - Number of bits to use in the operation.
203
+ * @returns Selected bigint.
204
204
  */
205
205
  function ctSelect(b, x, y, binSize) {
206
206
  return ctAdd(y, BigInt(b) * (ctSub(x, y, binSize)), binSize);
207
207
  }
208
208
  /**
209
- * Checks if a bigint fits in the range -2^binSize <= x < 2^binSize.
209
+ * Check if a bigint fits in the range -2^binSize <= x < 2^binSize.
210
210
  * Not constant-time for arbitrary x, but is constant-time for all inputs for which the function returns true.
211
211
  * If you assert your inputs satisfy verifyBinSize(x, binSize), you need not care about the non constant-timeness of this function.
212
- * @param x - The bigint to check.
213
- * @param binSize - The number of bits to use in the check.
212
+ * @param x - Bigint to check.
213
+ * @param binSize - Number of bits to use in the check.
214
214
  * @returns True if x fits in the range, false otherwise.
215
215
  */
216
216
  function verifyBinSize(x, binSize) {
@@ -219,8 +219,8 @@ function verifyBinSize(x, binSize) {
219
219
  }
220
220
 
221
221
  /**
222
- * Checks if code is running in a browser environment.
223
- * @returns true if window object exists, false otherwise
222
+ * Check if code is running in a browser environment.
223
+ * @returns true if window object exists, false otherwise.
224
224
  */
225
225
  function isBrowser() {
226
226
  return (
@@ -229,8 +229,8 @@ function isBrowser() {
229
229
  }
230
230
  /**
231
231
  * Conditionally logs a message if logging is enabled.
232
- * @param log - Whether to output the log
233
- * @param args - Arguments to pass to console.log
232
+ * @param log - Whether to output the log.
233
+ * @param args - Arguments to pass to console.log.
234
234
  */
235
235
  function optionalLog(log, ...args) {
236
236
  if (log) {
@@ -239,10 +239,10 @@ function optionalLog(log, ...args) {
239
239
  }
240
240
  }
241
241
  /**
242
- * Calculates the minimum number of bits needed to represent a value.
242
+ * Calculate the minimum number of bits needed to represent a value.
243
243
  * Formula: floor(log2(max)) + 1 for unsigned, +1 for signed, +1 for diff of two negatives.
244
- * @param max - The bigint value to measure
245
- * @returns Number of bits required
244
+ * @param max - Bigint value to measure.
245
+ * @returns Number of bits required.
246
246
  */
247
247
  function getBinSize(max) {
248
248
  // floor(log2(max)) + 1 to represent unsigned elements, a +1 for signed elements
@@ -254,11 +254,11 @@ function getBinSize(max) {
254
254
  */
255
255
  const DOUBLE_PRECISION_MANTISSA = 52;
256
256
  /**
257
- * Encodes a value as a bigint suitable for Rescue encryption, handling booleans, bigints, and numbers.
257
+ * Encode a value as a bigint suitable for Rescue encryption, handling booleans, bigints, and numbers.
258
258
  * The encoding is performed in constant-time to avoid leaking information through timing side-channels.
259
259
  * Throws if the value is out of the supported range for the field.
260
- * @param v - The value to encode (bigint, number, or boolean).
261
- * @returns The encoded value as a bigint.
260
+ * @param v - Value to encode (bigint, number, or boolean).
261
+ * @returns Encoded value as a bigint.
262
262
  */
263
263
  function encodeAsRescueEncryptable(v) {
264
264
  if (typeof v === 'boolean') {
@@ -282,10 +282,10 @@ function encodeAsRescueEncryptable(v) {
282
282
  throw new Error('Invalid type to convert from number to bigint');
283
283
  }
284
284
  /**
285
- * Decodes a Rescue-decrypted value back to a signed bigint.
286
- * Handles the conversion from field element representation to signed integer.
287
- * @param v - The decrypted field element value
288
- * @returns The decoded signed bigint value
285
+ * Decode a Rescue-decrypted value back to a signed bigint.
286
+ * Handle the conversion from field element representation to signed integer.
287
+ * @param v - Decrypted field element value.
288
+ * @returns Decoded signed bigint value.
289
289
  */
290
290
  function decodeRescueDecryptedToBigInt(v) {
291
291
  const twoInv = (CURVE25519_BASE_FIELD.ORDER + 1n) / 2n;
@@ -294,19 +294,19 @@ function decodeRescueDecryptedToBigInt(v) {
294
294
  return ctSelect(isLtTwoInv, v, ctSub(v, CURVE25519_BASE_FIELD.ORDER, binSize), binSize);
295
295
  }
296
296
  /**
297
- * Decodes a Rescue-decrypted value back to a JavaScript number.
298
- * Converts from field element representation to a floating-point number.
299
- * @param v - The decrypted field element value
300
- * @returns The decoded number value
297
+ * Decode a Rescue-decrypted value back to a JavaScript number.
298
+ * Convert from field element representation to a floating-point number.
299
+ * @param v - Decrypted field element value.
300
+ * @returns Decoded number value.
301
301
  */
302
302
  function decodeRescueDecryptedToNumber(v) {
303
303
  const vSigned = decodeRescueDecryptedToBigInt(v);
304
304
  return Number(vSigned) * 2 ** -DOUBLE_PRECISION_MANTISSA;
305
305
  }
306
306
  /**
307
- * Checks if a computation reference is null (all zeros).
308
- * @param ref - The computation reference to check
309
- * @returns true if the reference is null, false otherwise
307
+ * Check if a computation reference is null (all zeros).
308
+ * @param ref - Computation reference to check.
309
+ * @returns true if the reference is null, false otherwise.
310
310
  */
311
311
  function isNullRef(ref) {
312
312
  const bigZero = new anchor__namespace.BN(0);
@@ -315,7 +315,9 @@ function isNullRef(ref) {
315
315
  }
316
316
 
317
317
  /**
318
- * Matrix class over FpField. Data is row-major.
318
+ * Matrix operations for MPC field arithmetic.
319
+ * Used internally by Rescue cipher. Not part of public API.
320
+ * @internal
319
321
  */
320
322
  class Matrix {
321
323
  field;
@@ -433,8 +435,8 @@ class Matrix {
433
435
  return new Matrix(this.field, data);
434
436
  }
435
437
  /**
436
- * computs the determinant using gaus elimination
437
- * matches the determinant implementation in arcis
438
+ * Compute the determinant using Gauss elimination.
439
+ * Match the determinant implementation in Arcis.
438
440
  */
439
441
  det() {
440
442
  // Ensure the matrix is square
@@ -484,6 +486,10 @@ class Matrix {
484
486
  return true;
485
487
  }
486
488
  }
489
+ /**
490
+ * Generate random matrix for testing.
491
+ * @internal
492
+ */
487
493
  function randMatrix(field, nrows, ncols) {
488
494
  const data = [];
489
495
  for (let i = 0; i < nrows; ++i) {
@@ -529,10 +535,10 @@ class RescueDesc {
529
535
  // The round keys, needed for encryption and decryption.
530
536
  roundKeys;
531
537
  /**
532
- * Constructs a RescueDesc for a given field and mode (cipher or hash).
533
- * Initializes round constants, MDS matrix, and key schedule.
534
- * @param field - The field to use (e.g., CURVE25519_BASE_FIELD).
535
- * @param mode - The mode: block cipher or hash function.
538
+ * Construct a RescueDesc for a given field and mode (cipher or hash).
539
+ * Initialize round constants, MDS matrix, and key schedule.
540
+ * @param field - Field to use (e.g., CURVE25519_BASE_FIELD).
541
+ * @param mode - Mode: block cipher or hash function.
536
542
  */
537
543
  constructor(field, mode) {
538
544
  this.field = field;
@@ -580,9 +586,9 @@ class RescueDesc {
580
586
  }
581
587
  }
582
588
  /**
583
- * Samples round constants for the Rescue permutation, using SHAKE256.
584
- * @param nRounds - The number of rounds.
585
- * @returns An array of round constant matrices.
589
+ * Sample round constants for the Rescue permutation, using SHAKE256.
590
+ * @param nRounds - Number of rounds.
591
+ * @returns Array of round constant matrices.
586
592
  */
587
593
  sampleConstants(nRounds) {
588
594
  const field = this.field;
@@ -658,28 +664,28 @@ class RescueDesc {
658
664
  }
659
665
  }
660
666
  /**
661
- * Applies the Rescue permutation to a state matrix.
662
- * @param state - The input state matrix.
663
- * @returns The permuted state matrix.
667
+ * Apply the Rescue permutation to a state matrix.
668
+ * @param state - Input state matrix.
669
+ * @returns Permuted state matrix.
664
670
  */
665
671
  permute(state) {
666
672
  return rescuePermutation(this.mode, this.alpha, this.alphaInverse, this.mdsMat, this.roundKeys, state)[2 * this.nRounds];
667
673
  }
668
674
  /**
669
- * Applies the inverse Rescue permutation to a state matrix.
670
- * @param state - The input state matrix.
671
- * @returns The inverse-permuted state matrix.
675
+ * Apply the inverse Rescue permutation to a state matrix.
676
+ * @param state - Input state matrix.
677
+ * @returns Inverse-permuted state matrix.
672
678
  */
673
679
  permuteInverse(state) {
674
680
  return rescuePermutationInverse(this.mode, this.alpha, this.alphaInverse, this.mdsMatInverse, this.roundKeys, state)[2 * this.nRounds];
675
681
  }
676
682
  }
677
683
  /**
678
- * Finds the smallest prime alpha that does not divide p-1, and computes its inverse modulo p-1.
684
+ * Find the smallest prime alpha that does not divide p-1, and compute its inverse modulo p-1.
679
685
  * The alpha parameter is used in the Rescue permutation for exponentiation operations.
680
- * @param p - The field modulus (prime number)
681
- * @returns A tuple [alpha, alphaInverse] where alpha is the prime and alphaInverse is its modular inverse
682
- * @throws Error if no suitable prime alpha is found
686
+ * @param p - Field modulus (prime number).
687
+ * @returns Tuple [alpha, alphaInverse] where alpha is the prime and alphaInverse is its modular inverse.
688
+ * @throws Error if no suitable prime alpha is found.
683
689
  */
684
690
  function getAlphaAndInverse(p) {
685
691
  const pMinusOne = p - 1n;
@@ -697,14 +703,14 @@ function getAlphaAndInverse(p) {
697
703
  return [alpha, alphaInverse];
698
704
  }
699
705
  /**
700
- * Calculates the number of rounds required for the Rescue permutation based on security analysis.
706
+ * Calculate the number of rounds required for the Rescue permutation based on security analysis.
701
707
  * The number of rounds is determined by analyzing resistance to differential and algebraic attacks.
702
708
  * See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287 for the security analysis.
703
- * @param p - The field modulus
704
- * @param mode - The Rescue mode (cipher or hash)
705
- * @param alpha - The prime alpha parameter
706
- * @param m - The state size (block size for cipher, total size for hash)
707
- * @returns The number of rounds (will be doubled for the full permutation)
709
+ * @param p - Field modulus.
710
+ * @param mode - Rescue mode (cipher or hash).
711
+ * @param alpha - Prime alpha parameter.
712
+ * @param m - State size (block size for cipher, total size for hash).
713
+ * @returns Number of rounds (will be doubled for the full permutation).
708
714
  */
709
715
  function getNRounds(p, mode, alpha, m) {
710
716
  function dcon(n) {
@@ -751,12 +757,12 @@ function getNRounds(p, mode, alpha, m) {
751
757
  }
752
758
  }
753
759
  /**
754
- * Builds a Cauchy matrix for use as an MDS (Maximum Distance Separable) matrix.
760
+ * Build a Cauchy matrix for use as an MDS (Maximum Distance Separable) matrix.
755
761
  * A Cauchy matrix is guaranteed to be invertible and provides optimal diffusion properties.
756
762
  * The matrix is constructed using the formula: M[i][j] = 1/(i + j) for i, j in [1, size].
757
- * @param field - The finite field over which to construct the matrix
758
- * @param size - The size of the square matrix
759
- * @returns A Cauchy matrix of the specified size
763
+ * @param field - Finite field over which to construct the matrix.
764
+ * @param size - Size of the square matrix.
765
+ * @returns Cauchy matrix of the specified size.
760
766
  */
761
767
  function buildCauchy(field, size) {
762
768
  const data = [];
@@ -770,11 +776,11 @@ function buildCauchy(field, size) {
770
776
  return new Matrix(field, data);
771
777
  }
772
778
  /**
773
- * Builds the inverse of a Cauchy matrix for use as the inverse MDS matrix.
779
+ * Build the inverse of a Cauchy matrix for use as the inverse MDS matrix.
774
780
  * The inverse is computed using a closed-form formula for Cauchy matrix inversion.
775
- * @param field - The finite field over which to construct the matrix
776
- * @param size - The size of the square matrix
777
- * @returns The inverse of the Cauchy matrix
781
+ * @param field - Finite field over which to construct the matrix.
782
+ * @param size - Size of the square matrix.
783
+ * @returns Inverse of the Cauchy matrix.
778
784
  */
779
785
  function buildInverseCauchy(field, size) {
780
786
  function product(arr) {
@@ -831,16 +837,16 @@ function exponentForOdd(mode, alpha, alphaInverse) {
831
837
  }
832
838
  /**
833
839
  * Core Rescue permutation function implementing the cryptographic primitive.
834
- * Applies alternating rounds of exponentiation and MDS matrix multiplication with round keys.
840
+ * Apply alternating rounds of exponentiation and MDS matrix multiplication with round keys.
835
841
  * The permutation alternates between using alpha and alphaInverse as exponents based on round parity.
836
842
  * This is the fundamental building block for both Rescue cipher and Rescue-Prime hash.
837
- * @param mode - The Rescue mode (cipher or hash) determining exponent selection
838
- * @param alpha - The prime exponent for even rounds
839
- * @param alphaInverse - The inverse exponent for odd rounds
840
- * @param mdsMat - The Maximum Distance Separable matrix for diffusion
841
- * @param subkeys - Array of round key matrices
842
- * @param state - The initial state matrix to permute
843
- * @returns Array of all intermediate states during the permutation
843
+ * @param mode - Rescue mode (cipher or hash) determining exponent selection.
844
+ * @param alpha - Prime exponent for even rounds.
845
+ * @param alphaInverse - Inverse exponent for odd rounds.
846
+ * @param mdsMat - Maximum Distance Separable matrix for diffusion.
847
+ * @param subkeys - Array of round key matrices.
848
+ * @param state - Initial state matrix to permute.
849
+ * @returns Array of all intermediate states during the permutation.
844
850
  */
845
851
  function rescuePermutation(mode, alpha, alphaInverse, mdsMat, subkeys, state) {
846
852
  const exponentEven = exponentForEven(mode, alpha, alphaInverse);
@@ -897,7 +903,7 @@ class RescuePrimeHash {
897
903
  rate;
898
904
  digestLength;
899
905
  /**
900
- * Constructs a RescuePrimeHash instance with rate = 7 and capacity = 5.
906
+ * Construct a RescuePrimeHash instance with rate = 7 and capacity = 5.
901
907
  */
902
908
  constructor(field) {
903
909
  this.desc = new RescueDesc(field, { kind: 'hash', m: 12, capacity: 5 });
@@ -911,9 +917,9 @@ class RescuePrimeHash {
911
917
  // The security level is thus of the order of 256 bits for any field of size at least 102 bits.
912
918
  // The rate and capacity are chosen to achieve minimal number of rounds 8.
913
919
  /**
914
- * Computes the Rescue-Prime hash of a message, with padding as described in Algorithm 2 of the paper.
915
- * @param message - The input message as an array of bigints.
916
- * @returns The hash output as an array of bigints (length = digestLength).
920
+ * Compute the Rescue-Prime hash of a message, with padding as described in Algorithm 2 of the paper.
921
+ * @param message - Input message as an array of bigints.
922
+ * @returns Hash output as an array of bigints (length = digestLength).
917
923
  */
918
924
  digest(message) {
919
925
  // Create a copy and pad message to avoid mutating input parameter
@@ -957,9 +963,9 @@ const RESCUE_CIPHER_BLOCK_SIZE = 5;
957
963
  class RescueCipherCommon {
958
964
  desc;
959
965
  /**
960
- * Constructs a RescueCipherCommon instance using a shared secret.
966
+ * Construct a RescueCipherCommon instance using a shared secret.
961
967
  * The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
962
- * @param sharedSecret - The shared secret to derive the cipher key from.
968
+ * @param sharedSecret - Shared secret to derive the cipher key from.
963
969
  */
964
970
  constructor(sharedSecret, field) {
965
971
  if (sharedSecret.length != 32) {
@@ -993,10 +999,10 @@ class RescueCipherCommon {
993
999
  this.desc = new RescueDesc(field, { kind: 'cipher', key: rescueKey });
994
1000
  }
995
1001
  /**
996
- * Encrypts the plaintext vector in Counter (CTR) mode (raw, returns bigints).
997
- * @param plaintext - The array of plaintext bigints to encrypt.
998
- * @param nonce - A 16-byte nonce for CTR mode.
999
- * @returns The ciphertext as an array of bigints.
1002
+ * Encrypt the plaintext vector in Counter (CTR) mode (raw, returns bigints).
1003
+ * @param plaintext - Array of plaintext bigints to encrypt.
1004
+ * @param nonce - 16-byte nonce for CTR mode.
1005
+ * @returns Ciphertext as an array of bigints.
1000
1006
  * @throws Error if the nonce is not 16 bytes long.
1001
1007
  */
1002
1008
  encrypt_raw(plaintext, nonce) {
@@ -1032,19 +1038,19 @@ class RescueCipherCommon {
1032
1038
  return ciphertext;
1033
1039
  }
1034
1040
  /**
1035
- * Encrypts the plaintext vector in Counter (CTR) mode and serializes each block.
1036
- * @param plaintext - The array of plaintext bigints to encrypt.
1037
- * @param nonce - A 16-byte nonce for CTR mode.
1038
- * @returns The ciphertext as an array of arrays of numbers (each 32 bytes).
1041
+ * Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
1042
+ * @param plaintext - Array of plaintext bigints to encrypt.
1043
+ * @param nonce - 16-byte nonce for CTR mode.
1044
+ * @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
1039
1045
  */
1040
1046
  encrypt(plaintext, nonce) {
1041
1047
  return this.encrypt_raw(plaintext, nonce).map((c) => Array.from(serializeLE(c, 32)));
1042
1048
  }
1043
1049
  /**
1044
- * Decrypts the ciphertext vector in Counter (CTR) mode (raw, expects bigints).
1045
- * @param ciphertext - The array of ciphertext bigints to decrypt.
1046
- * @param nonce - A 16-byte nonce for CTR mode.
1047
- * @returns The decrypted plaintext as an array of bigints.
1050
+ * Decrypt the ciphertext vector in Counter (CTR) mode (raw, expects bigints).
1051
+ * @param ciphertext - Array of ciphertext bigints to decrypt.
1052
+ * @param nonce - 16-byte nonce for CTR mode.
1053
+ * @returns Decrypted plaintext as an array of bigints.
1048
1054
  * @throws Error if the nonce is not 16 bytes long.
1049
1055
  */
1050
1056
  decrypt_raw(ciphertext, nonce) {
@@ -1077,10 +1083,10 @@ class RescueCipherCommon {
1077
1083
  return decrypted;
1078
1084
  }
1079
1085
  /**
1080
- * Deserializes and decrypts the ciphertext vector in Counter (CTR) mode.
1081
- * @param ciphertext - The array of arrays of numbers (each 32 bytes) to decrypt.
1082
- * @param nonce - A 16-byte nonce for CTR mode.
1083
- * @returns The decrypted plaintext as an array of bigints.
1086
+ * Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
1087
+ * @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
1088
+ * @param nonce - 16-byte nonce for CTR mode.
1089
+ * @returns Decrypted plaintext as an array of bigints.
1084
1090
  */
1085
1091
  decrypt(ciphertext, nonce) {
1086
1092
  return this.decrypt_raw(ciphertext.map((c) => {
@@ -1092,10 +1098,10 @@ class RescueCipherCommon {
1092
1098
  }
1093
1099
  }
1094
1100
  /**
1095
- * Generates the counter values for Rescue cipher CTR mode.
1096
- * @param nonce - The initial nonce as a bigint.
1097
- * @param nBlocks - The number of blocks to generate counters for.
1098
- * @returns An array of counter values as bigints.
1101
+ * Generate the counter values for Rescue cipher CTR mode.
1102
+ * @param nonce - Initial nonce as a bigint.
1103
+ * @param nBlocks - Number of blocks to generate counters for.
1104
+ * @returns Array of counter values as bigints.
1099
1105
  */
1100
1106
  function getCounter(nonce, nBlocks) {
1101
1107
  const counter = [];
@@ -1117,27 +1123,27 @@ function getCounter(nonce, nBlocks) {
1117
1123
  class RescueCipher {
1118
1124
  cipher;
1119
1125
  /**
1120
- * Constructs a RescueCipher instance using a shared secret.
1126
+ * Construct a RescueCipher instance using a shared secret.
1121
1127
  * The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
1122
- * @param sharedSecret - The shared secret to derive the cipher key from.
1128
+ * @param sharedSecret - Shared secret to derive the cipher key from.
1123
1129
  */
1124
1130
  constructor(sharedSecret) {
1125
1131
  this.cipher = new RescueCipherCommon(sharedSecret, CURVE25519_BASE_FIELD);
1126
1132
  }
1127
1133
  /**
1128
- * Encrypts the plaintext vector in Counter (CTR) mode and serializes each block.
1129
- * @param plaintext - The array of plaintext bigints to encrypt.
1130
- * @param nonce - A 16-byte nonce for CTR mode.
1131
- * @returns The ciphertext as an array of arrays of numbers (each 32 bytes).
1134
+ * Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
1135
+ * @param plaintext - Array of plaintext bigints to encrypt.
1136
+ * @param nonce - 16-byte nonce for CTR mode.
1137
+ * @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
1132
1138
  */
1133
1139
  encrypt(plaintext, nonce) {
1134
1140
  return this.cipher.encrypt(plaintext, nonce);
1135
1141
  }
1136
1142
  /**
1137
- * Deserializes and decrypts the ciphertext vector in Counter (CTR) mode.
1138
- * @param ciphertext - The array of arrays of numbers (each 32 bytes) to decrypt.
1139
- * @param nonce - A 16-byte nonce for CTR mode.
1140
- * @returns The decrypted plaintext as an array of bigints.
1143
+ * Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
1144
+ * @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
1145
+ * @param nonce - 16-byte nonce for CTR mode.
1146
+ * @returns Decrypted plaintext as an array of bigints.
1141
1147
  */
1142
1148
  decrypt(ciphertext, nonce) {
1143
1149
  return this.cipher.decrypt(ciphertext, nonce);
@@ -1151,27 +1157,27 @@ class RescueCipher {
1151
1157
  class CSplRescueCipher {
1152
1158
  cipher;
1153
1159
  /**
1154
- * Constructs a RescueCipher instance using a shared secret.
1160
+ * Construct a CSplRescueCipher instance using a shared secret.
1155
1161
  * The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
1156
- * @param sharedSecret - The shared secret to derive the cipher key from.
1162
+ * @param sharedSecret - Shared secret to derive the cipher key from.
1157
1163
  */
1158
1164
  constructor(sharedSecret) {
1159
1165
  this.cipher = new RescueCipherCommon(sharedSecret, CURVE25519_SCALAR_FIELD);
1160
1166
  }
1161
1167
  /**
1162
- * Encrypts the plaintext vector in Counter (CTR) mode and serializes each block.
1163
- * @param plaintext - The array of plaintext bigints to encrypt.
1164
- * @param nonce - A 16-byte nonce for CTR mode.
1165
- * @returns The ciphertext as an array of arrays of numbers (each 32 bytes).
1168
+ * Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
1169
+ * @param plaintext - Array of plaintext bigints to encrypt.
1170
+ * @param nonce - 16-byte nonce for CTR mode.
1171
+ * @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
1166
1172
  */
1167
1173
  encrypt(plaintext, nonce) {
1168
1174
  return this.cipher.encrypt(plaintext, nonce);
1169
1175
  }
1170
1176
  /**
1171
- * Deserializes and decrypts the ciphertext vector in Counter (CTR) mode.
1172
- * @param ciphertext - The array of arrays of numbers (each 32 bytes) to decrypt.
1173
- * @param nonce - A 16-byte nonce for CTR mode.
1174
- * @returns The decrypted plaintext as an array of bigints.
1177
+ * Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
1178
+ * @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
1179
+ * @param nonce - 16-byte nonce for CTR mode.
1180
+ * @returns Decrypted plaintext as an array of bigints.
1175
1181
  */
1176
1182
  decrypt(ciphertext, nonce) {
1177
1183
  return this.cipher.decrypt(ciphertext, nonce);
@@ -1225,10 +1231,10 @@ function ed25519_pow_2_252_3(x) {
1225
1231
  // Fp.sqrt(Fp.neg(1))
1226
1232
  const ED25519_SQRT_M1 = /* @__PURE__ */ BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');
1227
1233
  /**
1228
- * Clamps a 32-byte scalar as required by the Ed25519 signature scheme.
1234
+ * Clamp a 32-byte scalar as required by the Ed25519 signature scheme.
1229
1235
  * See: https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.5
1230
- * @param bytes - The 32-byte scalar to clamp.
1231
- * @returns The clamped scalar as a Uint8Array.
1236
+ * @param bytes - 32-byte scalar to clamp.
1237
+ * @returns Clamped scalar as a Uint8Array.
1232
1238
  */
1233
1239
  function adjustScalarBytes(bytes) {
1234
1240
  const clamped = bytes;
@@ -1239,7 +1245,7 @@ function adjustScalarBytes(bytes) {
1239
1245
  }
1240
1246
  /**
1241
1247
  * Helper function for decompression, calculating √(u/v).
1242
- * @returns An object with isValid and value.
1248
+ * @returns Object with isValid and value.
1243
1249
  */
1244
1250
  function uvRatio(u, v) {
1245
1251
  const P = ed25519.ed25519.CURVE.Fp.ORDER;
@@ -1275,10 +1281,10 @@ class AesCtrCipher {
1275
1281
  key;
1276
1282
  keyBits;
1277
1283
  /**
1278
- * Constructs an AES cipher instance using a shared secret.
1284
+ * Construct an AES cipher instance using a shared secret.
1279
1285
  * The key is derived using SHA3-256.
1280
- * @param sharedSecret - The shared secret to derive the AES key from.
1281
- * @param keyBits - The AES key size in bits (128, 192, or 256).
1286
+ * @param sharedSecret - Shared secret to derive the AES key from.
1287
+ * @param keyBits - AES key size in bits (128, 192, or 256).
1282
1288
  */
1283
1289
  constructor(sharedSecret, keyBits) {
1284
1290
  this.keyBits = keyBits;
@@ -1303,10 +1309,10 @@ class AesCtrCipher {
1303
1309
  this.key = new Uint8Array(hasher.digest()).slice(0, KEY_BYTES[keyBits]);
1304
1310
  }
1305
1311
  /**
1306
- * Encrypts the plaintext array in Counter (CTR) mode.
1307
- * @param plaintext - The data to encrypt.
1308
- * @param nonce - An 8-byte nonce for CTR mode.
1309
- * @returns The encrypted ciphertext as a Uint8Array.
1312
+ * Encrypt the plaintext array in Counter (CTR) mode.
1313
+ * @param plaintext - Data to encrypt.
1314
+ * @param nonce - 8-byte nonce for CTR mode.
1315
+ * @returns Encrypted ciphertext as a Uint8Array.
1310
1316
  * @throws Error if the nonce is not 8 bytes long.
1311
1317
  */
1312
1318
  encrypt(plaintext, nonce) {
@@ -1319,10 +1325,10 @@ class AesCtrCipher {
1319
1325
  return new Uint8Array(ciphertext);
1320
1326
  }
1321
1327
  /**
1322
- * Decrypts the ciphertext array in Counter (CTR) mode.
1323
- * @param ciphertext - The data to decrypt.
1324
- * @param nonce - An 8-byte nonce for CTR mode.
1325
- * @returns The decrypted plaintext as a Uint8Array.
1328
+ * Decrypt the ciphertext array in Counter (CTR) mode.
1329
+ * @param ciphertext - Data to decrypt.
1330
+ * @param nonce - 8-byte nonce for CTR mode.
1331
+ * @returns Decrypted plaintext as a Uint8Array.
1326
1332
  * @throws Error if the nonce is not 8 bytes long.
1327
1333
  */
1328
1334
  decrypt(ciphertext, nonce) {
@@ -1342,9 +1348,9 @@ class AesCtrCipher {
1342
1348
  */
1343
1349
  class Aes128Cipher extends AesCtrCipher {
1344
1350
  /**
1345
- * Constructs an AES-128 cipher instance using a shared secret.
1351
+ * Construct an AES-128 cipher instance using a shared secret.
1346
1352
  * The key is derived using SHA3-256.
1347
- * @param sharedSecret - The shared secret to derive the AES key from.
1353
+ * @param sharedSecret - Shared secret to derive the AES key from.
1348
1354
  */
1349
1355
  constructor(sharedSecret) {
1350
1356
  super(sharedSecret, 128);
@@ -1357,9 +1363,9 @@ class Aes128Cipher extends AesCtrCipher {
1357
1363
  */
1358
1364
  class Aes192Cipher extends AesCtrCipher {
1359
1365
  /**
1360
- * Constructs an AES-192 cipher instance using a shared secret.
1366
+ * Construct an AES-192 cipher instance using a shared secret.
1361
1367
  * The key is derived using SHA3-256.
1362
- * @param sharedSecret - The shared secret to derive the AES key from.
1368
+ * @param sharedSecret - Shared secret to derive the AES key from.
1363
1369
  */
1364
1370
  constructor(sharedSecret) {
1365
1371
  super(sharedSecret, 192);
@@ -1372,18 +1378,26 @@ class Aes192Cipher extends AesCtrCipher {
1372
1378
  */
1373
1379
  class Aes256Cipher extends AesCtrCipher {
1374
1380
  /**
1375
- * Constructs an AES-256 cipher instance using a shared secret.
1381
+ * Construct an AES-256 cipher instance using a shared secret.
1376
1382
  * The key is derived using SHA3-256.
1377
- * @param sharedSecret - The shared secret to derive the AES key from.
1383
+ * @param sharedSecret - Shared secret to derive the AES key from.
1378
1384
  */
1379
1385
  constructor(sharedSecret) {
1380
1386
  super(sharedSecret, 256);
1381
1387
  }
1382
1388
  }
1383
1389
 
1390
+ /**
1391
+ * Size descriptor for a single field in circuit packing.
1392
+ * A "full" field occupies an entire slot; partial fields are bin-packed together.
1393
+ * @internal
1394
+ */
1384
1395
  class DataSize {
1396
+ /** Whether this field occupies a full slot. */
1385
1397
  isFull;
1398
+ /** Bit width of the field (0 if full). */
1386
1399
  size;
1400
+ /** Original index in the fields array. */
1387
1401
  index;
1388
1402
  constructor(index, size) {
1389
1403
  const isUndefined = size === undefined;
@@ -1403,8 +1417,14 @@ function sortDataSizes(arr) {
1403
1417
  return left.index - right.index;
1404
1418
  });
1405
1419
  }
1420
+ /**
1421
+ * Packed location of a field within the slot array.
1422
+ * @internal
1423
+ */
1406
1424
  class PackLocation {
1425
+ /** Slot index in the packed array. */
1407
1426
  index;
1427
+ /** Bit offset within the slot. */
1408
1428
  offset;
1409
1429
  constructor(index, offset) {
1410
1430
  this.index = index;
@@ -1463,6 +1483,12 @@ function packing(maxSize, arr) {
1463
1483
  return [nPacks, res];
1464
1484
  }
1465
1485
  const ARCIS_PACKING_SIZE = 214;
1486
+ /**
1487
+ * Pack field sizes into minimum slots using the Arcium packing size (214 bits).
1488
+ * @param arr - Array of field size descriptors.
1489
+ * @returns Tuple of [total slot count, pack location for each input field].
1490
+ * @internal
1491
+ */
1466
1492
  function arcisPacking(arr) {
1467
1493
  return packing(ARCIS_PACKING_SIZE, arr);
1468
1494
  }
@@ -1479,6 +1505,10 @@ var ArcisValueKind;
1479
1505
  ArcisValueKind[ArcisValueKind["Float"] = 3] = "Float";
1480
1506
  ArcisValueKind[ArcisValueKind["Pubkey"] = 4] = "Pubkey";
1481
1507
  })(ArcisValueKind || (ArcisValueKind = {}));
1508
+ /**
1509
+ * Integer type metadata. Used internally by packer.
1510
+ * @internal
1511
+ */
1482
1512
  class IntegerInfo {
1483
1513
  signed;
1484
1514
  width;
@@ -1501,6 +1531,10 @@ class IntegerInfo {
1501
1531
  return (this.signed ? "i" : "u") + this.width;
1502
1532
  }
1503
1533
  }
1534
+ /**
1535
+ * Runtime field representation. Used internally by packer.
1536
+ * @internal
1537
+ */
1504
1538
  class ArcisValueField {
1505
1539
  name;
1506
1540
  kind;
@@ -1676,6 +1710,10 @@ class ArcisValueField {
1676
1710
  }
1677
1711
  }
1678
1712
  }
1713
+ /**
1714
+ * Type container for pack/unpack operations. Used internally by packer.
1715
+ * @internal
1716
+ */
1679
1717
  class ArcisType {
1680
1718
  name;
1681
1719
  fields;
@@ -1720,11 +1758,21 @@ class ArcisType {
1720
1758
  }
1721
1759
  }
1722
1760
 
1761
+ /**
1762
+ * Container for circuit type definitions.
1763
+ * Loaded from generated JSON files by build tools -- not typically used directly.
1764
+ * @internal
1765
+ */
1723
1766
  class ArcisModule {
1767
+ /** Map of type name to parsed ArcisType. */
1724
1768
  types;
1725
1769
  constructor(types) {
1726
1770
  this.types = types;
1727
1771
  }
1772
+ /**
1773
+ * Parse module from JSON object (as produced by the Arcium compiler).
1774
+ * @param json - Raw JSON object with type name keys.
1775
+ */
1728
1776
  static fromJson(json) {
1729
1777
  const typedJson = json;
1730
1778
  const res = {};
@@ -1733,6 +1781,10 @@ class ArcisModule {
1733
1781
  }
1734
1782
  return new ArcisModule(res);
1735
1783
  }
1784
+ /**
1785
+ * Load module from a JSON file on disk.
1786
+ * @param path - Absolute or relative path to the JSON file.
1787
+ */
1736
1788
  static loadFromFile(path) {
1737
1789
  const file = fs.readFileSync(path);
1738
1790
  const json = JSON.parse(file.toString());
@@ -1779,10 +1831,33 @@ function groupUnpackedValues(values, fieldNames) {
1779
1831
  return result;
1780
1832
  }
1781
1833
  /**
1782
- * Creates a type-safe packer from field definitions.
1783
- * Use `as const` on the fields array for compile-time field name validation.
1784
- * @param fields - Field definitions from generated code.
1785
- * @param typeName - Type name for debugging.
1834
+ * Create a type-safe packer from field definitions.
1835
+ *
1836
+ * Use `as const` on the fields array to enable compile-time field name validation.
1837
+ *
1838
+ * @param fields - Array of {@link FieldInfo} objects defining each field's name and type.
1839
+ * @param typeName - Optional name for debugging (default: 'Packer').
1840
+ * @returns Packer instance with pack() and unpack() methods.
1841
+ * @throws TypeError if field types don't match expected values during pack/unpack.
1842
+ * @throws RangeError if array index is out of bounds.
1843
+ *
1844
+ * @example
1845
+ * import { createPacker } from '@arcium-hq/client';
1846
+ *
1847
+ * // Define fields matching your circuit's input type
1848
+ * const fields = [
1849
+ * { name: 'a', type: { Integer: { signed: false, width: 32 } } },
1850
+ * { name: 'b', type: { Integer: { signed: false, width: 32 } } },
1851
+ * ] as const;
1852
+ *
1853
+ * // Create packer with explicit input/output types
1854
+ * const packer = createPacker<{ a: number; b: number }, { a: bigint; b: bigint }>(fields);
1855
+ *
1856
+ * // Pack values for circuit input
1857
+ * const packed = packer.pack({ a: 10, b: 20 });
1858
+ *
1859
+ * // Unpack circuit output (from decrypted computation result)
1860
+ * const result = packer.unpack(decryptedOutput);
1786
1861
  */
1787
1862
  function createPacker(fields, typeName = 'Packer') {
1788
1863
  const arcisFields = fields.map(f => ArcisValueField.fromFieldInfo(f));
@@ -1809,7 +1884,7 @@ function createPacker(fields, typeName = 'Packer') {
1809
1884
  var address = "Arcj82pX7HxYKLR92qvgZUAd7vGS1k4hQvAFcPATFdEQ";
1810
1885
  var metadata = {
1811
1886
  name: "arcium",
1812
- version: "0.8.4",
1887
+ version: "0.9.0",
1813
1888
  spec: "0.1.0",
1814
1889
  description: "The Arcium program"
1815
1890
  };
@@ -1939,6 +2014,167 @@ var instructions = [
1939
2014
  }
1940
2015
  ]
1941
2016
  },
2017
+ {
2018
+ name: "add_permissioned_recovery_peers",
2019
+ docs: [
2020
+ "Add permissioned recovery peers"
2021
+ ],
2022
+ discriminator: [
2023
+ 190,
2024
+ 177,
2025
+ 28,
2026
+ 28,
2027
+ 204,
2028
+ 131,
2029
+ 176,
2030
+ 251
2031
+ ],
2032
+ accounts: [
2033
+ {
2034
+ name: "signer",
2035
+ writable: true,
2036
+ signer: true
2037
+ },
2038
+ {
2039
+ name: "permissioned_recovery_peers_acc",
2040
+ writable: true,
2041
+ pda: {
2042
+ seeds: [
2043
+ {
2044
+ kind: "const",
2045
+ value: [
2046
+ 80,
2047
+ 101,
2048
+ 114,
2049
+ 109,
2050
+ 105,
2051
+ 115,
2052
+ 115,
2053
+ 105,
2054
+ 111,
2055
+ 110,
2056
+ 101,
2057
+ 100,
2058
+ 82,
2059
+ 101,
2060
+ 99,
2061
+ 111,
2062
+ 118,
2063
+ 101,
2064
+ 114,
2065
+ 121,
2066
+ 80,
2067
+ 101,
2068
+ 101,
2069
+ 114,
2070
+ 115,
2071
+ 65,
2072
+ 99,
2073
+ 99,
2074
+ 111,
2075
+ 117,
2076
+ 110,
2077
+ 116
2078
+ ]
2079
+ }
2080
+ ]
2081
+ }
2082
+ },
2083
+ {
2084
+ name: "program_data",
2085
+ pda: {
2086
+ seeds: [
2087
+ {
2088
+ kind: "const",
2089
+ value: [
2090
+ 146,
2091
+ 111,
2092
+ 9,
2093
+ 170,
2094
+ 109,
2095
+ 72,
2096
+ 125,
2097
+ 226,
2098
+ 216,
2099
+ 140,
2100
+ 55,
2101
+ 106,
2102
+ 22,
2103
+ 29,
2104
+ 7,
2105
+ 127,
2106
+ 176,
2107
+ 129,
2108
+ 11,
2109
+ 19,
2110
+ 35,
2111
+ 107,
2112
+ 124,
2113
+ 118,
2114
+ 71,
2115
+ 160,
2116
+ 112,
2117
+ 40,
2118
+ 3,
2119
+ 250,
2120
+ 93,
2121
+ 137
2122
+ ]
2123
+ }
2124
+ ],
2125
+ program: {
2126
+ kind: "const",
2127
+ value: [
2128
+ 2,
2129
+ 168,
2130
+ 246,
2131
+ 145,
2132
+ 78,
2133
+ 136,
2134
+ 161,
2135
+ 176,
2136
+ 226,
2137
+ 16,
2138
+ 21,
2139
+ 62,
2140
+ 247,
2141
+ 99,
2142
+ 174,
2143
+ 43,
2144
+ 0,
2145
+ 194,
2146
+ 185,
2147
+ 61,
2148
+ 22,
2149
+ 193,
2150
+ 36,
2151
+ 210,
2152
+ 192,
2153
+ 83,
2154
+ 122,
2155
+ 16,
2156
+ 4,
2157
+ 128,
2158
+ 0,
2159
+ 0
2160
+ ]
2161
+ }
2162
+ }
2163
+ },
2164
+ {
2165
+ name: "system_program",
2166
+ address: "11111111111111111111111111111111"
2167
+ }
2168
+ ],
2169
+ args: [
2170
+ {
2171
+ name: "peers",
2172
+ type: {
2173
+ vec: "pubkey"
2174
+ }
2175
+ }
2176
+ ]
2177
+ },
1942
2178
  {
1943
2179
  name: "bump_epoch_cluster",
1944
2180
  discriminator: [
@@ -3191,16 +3427,19 @@ var instructions = [
3191
3427
  ]
3192
3428
  },
3193
3429
  {
3194
- name: "deactivate_arx",
3430
+ name: "close_permissioned_recovery_peers_account",
3431
+ docs: [
3432
+ "Close the permissioned recovery peers account"
3433
+ ],
3195
3434
  discriminator: [
3196
- 117,
3197
- 244,
3198
- 137,
3199
- 148,
3200
- 25,
3435
+ 55,
3436
+ 55,
3437
+ 184,
3438
+ 150,
3439
+ 82,
3201
3440
  190,
3202
- 175,
3203
- 164
3441
+ 205,
3442
+ 92
3204
3443
  ],
3205
3444
  accounts: [
3206
3445
  {
@@ -3209,42 +3448,38 @@ var instructions = [
3209
3448
  signer: true
3210
3449
  },
3211
3450
  {
3212
- name: "arx_node_acc",
3451
+ name: "permissioned_recovery_peers_acc",
3213
3452
  writable: true,
3214
3453
  pda: {
3215
3454
  seeds: [
3216
3455
  {
3217
3456
  kind: "const",
3218
3457
  value: [
3219
- 65,
3458
+ 80,
3459
+ 101,
3220
3460
  114,
3221
- 120,
3222
- 78,
3461
+ 109,
3462
+ 105,
3463
+ 115,
3464
+ 115,
3465
+ 105,
3223
3466
  111,
3467
+ 110,
3468
+ 101,
3224
3469
  100,
3225
- 101
3226
- ]
3227
- },
3228
- {
3229
- kind: "arg",
3230
- path: "_node_offset"
3231
- }
3232
- ]
3233
- }
3234
- },
3235
- {
3236
- name: "clock",
3237
- writable: true,
3238
- pda: {
3239
- seeds: [
3240
- {
3241
- kind: "const",
3242
- value: [
3243
- 67,
3244
- 108,
3245
- 111,
3470
+ 82,
3471
+ 101,
3246
3472
  99,
3247
- 107,
3473
+ 111,
3474
+ 118,
3475
+ 101,
3476
+ 114,
3477
+ 121,
3478
+ 80,
3479
+ 101,
3480
+ 101,
3481
+ 114,
3482
+ 115,
3248
3483
  65,
3249
3484
  99,
3250
3485
  99,
@@ -3258,50 +3493,206 @@ var instructions = [
3258
3493
  }
3259
3494
  },
3260
3495
  {
3261
- name: "cluster_acc",
3262
- optional: true,
3496
+ name: "program_data",
3263
3497
  pda: {
3264
3498
  seeds: [
3265
3499
  {
3266
3500
  kind: "const",
3267
3501
  value: [
3268
- 67,
3269
- 108,
3270
- 117,
3271
- 115,
3272
- 116,
3273
- 101,
3274
- 114
3502
+ 146,
3503
+ 111,
3504
+ 9,
3505
+ 170,
3506
+ 109,
3507
+ 72,
3508
+ 125,
3509
+ 226,
3510
+ 216,
3511
+ 140,
3512
+ 55,
3513
+ 106,
3514
+ 22,
3515
+ 29,
3516
+ 7,
3517
+ 127,
3518
+ 176,
3519
+ 129,
3520
+ 11,
3521
+ 19,
3522
+ 35,
3523
+ 107,
3524
+ 124,
3525
+ 118,
3526
+ 71,
3527
+ 160,
3528
+ 112,
3529
+ 40,
3530
+ 3,
3531
+ 250,
3532
+ 93,
3533
+ 137
3275
3534
  ]
3276
- },
3277
- {
3278
- kind: "account",
3279
- path: "arx_node_acc"
3280
3535
  }
3281
- ]
3282
- }
3283
- }
3284
- ],
3285
- args: [
3286
- {
3287
- name: "node_offset",
3288
- type: "u32"
3289
- }
3290
- ]
3291
- },
3292
- {
3293
- name: "deactivate_cluster",
3294
- discriminator: [
3295
- 13,
3296
- 42,
3297
- 182,
3298
- 159,
3299
- 184,
3300
- 10,
3301
- 212,
3302
- 178
3303
- ],
3304
- accounts: [
3536
+ ],
3537
+ program: {
3538
+ kind: "const",
3539
+ value: [
3540
+ 2,
3541
+ 168,
3542
+ 246,
3543
+ 145,
3544
+ 78,
3545
+ 136,
3546
+ 161,
3547
+ 176,
3548
+ 226,
3549
+ 16,
3550
+ 21,
3551
+ 62,
3552
+ 247,
3553
+ 99,
3554
+ 174,
3555
+ 43,
3556
+ 0,
3557
+ 194,
3558
+ 185,
3559
+ 61,
3560
+ 22,
3561
+ 193,
3562
+ 36,
3563
+ 210,
3564
+ 192,
3565
+ 83,
3566
+ 122,
3567
+ 16,
3568
+ 4,
3569
+ 128,
3570
+ 0,
3571
+ 0
3572
+ ]
3573
+ }
3574
+ }
3575
+ },
3576
+ {
3577
+ name: "system_program",
3578
+ address: "11111111111111111111111111111111"
3579
+ }
3580
+ ],
3581
+ args: [
3582
+ ]
3583
+ },
3584
+ {
3585
+ name: "deactivate_arx",
3586
+ discriminator: [
3587
+ 117,
3588
+ 244,
3589
+ 137,
3590
+ 148,
3591
+ 25,
3592
+ 190,
3593
+ 175,
3594
+ 164
3595
+ ],
3596
+ accounts: [
3597
+ {
3598
+ name: "signer",
3599
+ writable: true,
3600
+ signer: true
3601
+ },
3602
+ {
3603
+ name: "arx_node_acc",
3604
+ writable: true,
3605
+ pda: {
3606
+ seeds: [
3607
+ {
3608
+ kind: "const",
3609
+ value: [
3610
+ 65,
3611
+ 114,
3612
+ 120,
3613
+ 78,
3614
+ 111,
3615
+ 100,
3616
+ 101
3617
+ ]
3618
+ },
3619
+ {
3620
+ kind: "arg",
3621
+ path: "_node_offset"
3622
+ }
3623
+ ]
3624
+ }
3625
+ },
3626
+ {
3627
+ name: "clock",
3628
+ writable: true,
3629
+ pda: {
3630
+ seeds: [
3631
+ {
3632
+ kind: "const",
3633
+ value: [
3634
+ 67,
3635
+ 108,
3636
+ 111,
3637
+ 99,
3638
+ 107,
3639
+ 65,
3640
+ 99,
3641
+ 99,
3642
+ 111,
3643
+ 117,
3644
+ 110,
3645
+ 116
3646
+ ]
3647
+ }
3648
+ ]
3649
+ }
3650
+ },
3651
+ {
3652
+ name: "cluster_acc",
3653
+ optional: true,
3654
+ pda: {
3655
+ seeds: [
3656
+ {
3657
+ kind: "const",
3658
+ value: [
3659
+ 67,
3660
+ 108,
3661
+ 117,
3662
+ 115,
3663
+ 116,
3664
+ 101,
3665
+ 114
3666
+ ]
3667
+ },
3668
+ {
3669
+ kind: "account",
3670
+ path: "arx_node_acc"
3671
+ }
3672
+ ]
3673
+ }
3674
+ }
3675
+ ],
3676
+ args: [
3677
+ {
3678
+ name: "node_offset",
3679
+ type: "u32"
3680
+ }
3681
+ ]
3682
+ },
3683
+ {
3684
+ name: "deactivate_cluster",
3685
+ discriminator: [
3686
+ 13,
3687
+ 42,
3688
+ 182,
3689
+ 159,
3690
+ 184,
3691
+ 10,
3692
+ 212,
3693
+ 178
3694
+ ],
3695
+ accounts: [
3305
3696
  {
3306
3697
  name: "authority",
3307
3698
  writable: true,
@@ -6338,16 +6729,19 @@ var instructions = [
6338
6729
  ]
6339
6730
  },
6340
6731
  {
6341
- name: "init_raw_circuit_acc",
6732
+ name: "init_permissioned_recovery_peers_account",
6733
+ docs: [
6734
+ "Initialize the permissioned recovery peers account"
6735
+ ],
6342
6736
  discriminator: [
6343
- 16,
6344
- 228,
6345
- 193,
6346
- 228,
6347
- 93,
6348
- 231,
6349
- 58,
6350
- 4
6737
+ 23,
6738
+ 147,
6739
+ 149,
6740
+ 121,
6741
+ 218,
6742
+ 173,
6743
+ 81,
6744
+ 117
6351
6745
  ],
6352
6746
  accounts: [
6353
6747
  {
@@ -6356,33 +6750,38 @@ var instructions = [
6356
6750
  signer: true
6357
6751
  },
6358
6752
  {
6359
- name: "comp_def_acc",
6753
+ name: "permissioned_recovery_peers_acc",
6754
+ writable: true,
6360
6755
  pda: {
6361
6756
  seeds: [
6362
6757
  {
6363
6758
  kind: "const",
6364
6759
  value: [
6365
- 67,
6366
- 111,
6760
+ 80,
6761
+ 101,
6762
+ 114,
6367
6763
  109,
6368
- 112,
6369
- 117,
6370
- 116,
6371
- 97,
6372
- 116,
6764
+ 105,
6765
+ 115,
6766
+ 115,
6373
6767
  105,
6374
6768
  111,
6375
6769
  110,
6376
- 68,
6377
6770
  101,
6378
- 102,
6379
- 105,
6380
- 110,
6381
- 105,
6382
- 116,
6383
- 105,
6771
+ 100,
6772
+ 82,
6773
+ 101,
6774
+ 99,
6384
6775
  111,
6385
- 110,
6776
+ 118,
6777
+ 101,
6778
+ 114,
6779
+ 121,
6780
+ 80,
6781
+ 101,
6782
+ 101,
6783
+ 114,
6784
+ 115,
6386
6785
  65,
6387
6786
  99,
6388
6787
  99,
@@ -6391,56 +6790,203 @@ var instructions = [
6391
6790
  110,
6392
6791
  116
6393
6792
  ]
6394
- },
6395
- {
6396
- kind: "arg",
6397
- path: "_mxe_program"
6398
- },
6399
- {
6400
- kind: "arg",
6401
- path: "_comp_offset"
6402
6793
  }
6403
6794
  ]
6404
6795
  }
6405
6796
  },
6406
6797
  {
6407
- name: "comp_def_raw",
6408
- writable: true,
6798
+ name: "program_data",
6409
6799
  pda: {
6410
6800
  seeds: [
6411
6801
  {
6412
6802
  kind: "const",
6413
6803
  value: [
6414
- 67,
6804
+ 146,
6415
6805
  111,
6806
+ 9,
6807
+ 170,
6416
6808
  109,
6809
+ 72,
6810
+ 125,
6811
+ 226,
6812
+ 216,
6813
+ 140,
6814
+ 55,
6815
+ 106,
6816
+ 22,
6817
+ 29,
6818
+ 7,
6819
+ 127,
6820
+ 176,
6821
+ 129,
6822
+ 11,
6823
+ 19,
6824
+ 35,
6825
+ 107,
6826
+ 124,
6827
+ 118,
6828
+ 71,
6829
+ 160,
6417
6830
  112,
6418
- 117,
6419
- 116,
6420
- 97,
6421
- 116,
6422
- 105,
6423
- 111,
6424
- 110,
6425
- 68,
6426
- 101,
6427
- 102,
6428
- 105,
6429
- 110,
6430
- 105,
6431
- 116,
6432
- 105,
6433
- 111,
6434
- 110,
6435
- 82,
6436
- 97,
6437
- 119
6831
+ 40,
6832
+ 3,
6833
+ 250,
6834
+ 93,
6835
+ 137
6438
6836
  ]
6439
- },
6440
- {
6441
- kind: "account",
6442
- path: "comp_def_acc"
6443
- },
6837
+ }
6838
+ ],
6839
+ program: {
6840
+ kind: "const",
6841
+ value: [
6842
+ 2,
6843
+ 168,
6844
+ 246,
6845
+ 145,
6846
+ 78,
6847
+ 136,
6848
+ 161,
6849
+ 176,
6850
+ 226,
6851
+ 16,
6852
+ 21,
6853
+ 62,
6854
+ 247,
6855
+ 99,
6856
+ 174,
6857
+ 43,
6858
+ 0,
6859
+ 194,
6860
+ 185,
6861
+ 61,
6862
+ 22,
6863
+ 193,
6864
+ 36,
6865
+ 210,
6866
+ 192,
6867
+ 83,
6868
+ 122,
6869
+ 16,
6870
+ 4,
6871
+ 128,
6872
+ 0,
6873
+ 0
6874
+ ]
6875
+ }
6876
+ }
6877
+ },
6878
+ {
6879
+ name: "system_program",
6880
+ address: "11111111111111111111111111111111"
6881
+ }
6882
+ ],
6883
+ args: [
6884
+ ]
6885
+ },
6886
+ {
6887
+ name: "init_raw_circuit_acc",
6888
+ discriminator: [
6889
+ 16,
6890
+ 228,
6891
+ 193,
6892
+ 228,
6893
+ 93,
6894
+ 231,
6895
+ 58,
6896
+ 4
6897
+ ],
6898
+ accounts: [
6899
+ {
6900
+ name: "signer",
6901
+ writable: true,
6902
+ signer: true
6903
+ },
6904
+ {
6905
+ name: "comp_def_acc",
6906
+ pda: {
6907
+ seeds: [
6908
+ {
6909
+ kind: "const",
6910
+ value: [
6911
+ 67,
6912
+ 111,
6913
+ 109,
6914
+ 112,
6915
+ 117,
6916
+ 116,
6917
+ 97,
6918
+ 116,
6919
+ 105,
6920
+ 111,
6921
+ 110,
6922
+ 68,
6923
+ 101,
6924
+ 102,
6925
+ 105,
6926
+ 110,
6927
+ 105,
6928
+ 116,
6929
+ 105,
6930
+ 111,
6931
+ 110,
6932
+ 65,
6933
+ 99,
6934
+ 99,
6935
+ 111,
6936
+ 117,
6937
+ 110,
6938
+ 116
6939
+ ]
6940
+ },
6941
+ {
6942
+ kind: "arg",
6943
+ path: "_mxe_program"
6944
+ },
6945
+ {
6946
+ kind: "arg",
6947
+ path: "_comp_offset"
6948
+ }
6949
+ ]
6950
+ }
6951
+ },
6952
+ {
6953
+ name: "comp_def_raw",
6954
+ writable: true,
6955
+ pda: {
6956
+ seeds: [
6957
+ {
6958
+ kind: "const",
6959
+ value: [
6960
+ 67,
6961
+ 111,
6962
+ 109,
6963
+ 112,
6964
+ 117,
6965
+ 116,
6966
+ 97,
6967
+ 116,
6968
+ 105,
6969
+ 111,
6970
+ 110,
6971
+ 68,
6972
+ 101,
6973
+ 102,
6974
+ 105,
6975
+ 110,
6976
+ 105,
6977
+ 116,
6978
+ 105,
6979
+ 111,
6980
+ 110,
6981
+ 82,
6982
+ 97,
6983
+ 119
6984
+ ]
6985
+ },
6986
+ {
6987
+ kind: "account",
6988
+ path: "comp_def_acc"
6989
+ },
6444
6990
  {
6445
6991
  kind: "arg",
6446
6992
  path: "_raw_circuit_index"
@@ -6522,6 +7068,50 @@ var instructions = [
6522
7068
  ]
6523
7069
  }
6524
7070
  },
7071
+ {
7072
+ name: "permissioned_recovery_peers_acc",
7073
+ pda: {
7074
+ seeds: [
7075
+ {
7076
+ kind: "const",
7077
+ value: [
7078
+ 80,
7079
+ 101,
7080
+ 114,
7081
+ 109,
7082
+ 105,
7083
+ 115,
7084
+ 115,
7085
+ 105,
7086
+ 111,
7087
+ 110,
7088
+ 101,
7089
+ 100,
7090
+ 82,
7091
+ 101,
7092
+ 99,
7093
+ 111,
7094
+ 118,
7095
+ 101,
7096
+ 114,
7097
+ 121,
7098
+ 80,
7099
+ 101,
7100
+ 101,
7101
+ 114,
7102
+ 115,
7103
+ 65,
7104
+ 99,
7105
+ 99,
7106
+ 111,
7107
+ 117,
7108
+ 110,
7109
+ 116
7110
+ ]
7111
+ }
7112
+ ]
7113
+ }
7114
+ },
6525
7115
  {
6526
7116
  name: "system_program",
6527
7117
  address: "11111111111111111111111111111111"
@@ -6533,7 +7123,7 @@ var instructions = [
6533
7123
  type: "u32"
6534
7124
  },
6535
7125
  {
6536
- name: "authority",
7126
+ name: "signer",
6537
7127
  type: "pubkey"
6538
7128
  },
6539
7129
  {
@@ -7508,6 +8098,32 @@ var instructions = [
7508
8098
  writable: true,
7509
8099
  signer: true
7510
8100
  },
8101
+ {
8102
+ name: "mxe",
8103
+ pda: {
8104
+ seeds: [
8105
+ {
8106
+ kind: "const",
8107
+ value: [
8108
+ 77,
8109
+ 88,
8110
+ 69,
8111
+ 65,
8112
+ 99,
8113
+ 99,
8114
+ 111,
8115
+ 117,
8116
+ 110,
8117
+ 116
8118
+ ]
8119
+ },
8120
+ {
8121
+ kind: "arg",
8122
+ path: "_mxe_program"
8123
+ }
8124
+ ]
8125
+ }
8126
+ },
7511
8127
  {
7512
8128
  name: "comp",
7513
8129
  writable: true,
@@ -7537,8 +8153,9 @@ var instructions = [
7537
8153
  ]
7538
8154
  },
7539
8155
  {
7540
- kind: "arg",
7541
- path: "_mxe_program"
8156
+ kind: "account",
8157
+ path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
8158
+ account: "MXEAccount"
7542
8159
  },
7543
8160
  {
7544
8161
  kind: "arg",
@@ -7547,6 +8164,32 @@ var instructions = [
7547
8164
  ]
7548
8165
  }
7549
8166
  },
8167
+ {
8168
+ name: "executing_pool",
8169
+ writable: true,
8170
+ pda: {
8171
+ seeds: [
8172
+ {
8173
+ kind: "const",
8174
+ value: [
8175
+ 69,
8176
+ 120,
8177
+ 101,
8178
+ 99,
8179
+ 112,
8180
+ 111,
8181
+ 111,
8182
+ 108
8183
+ ]
8184
+ },
8185
+ {
8186
+ kind: "account",
8187
+ path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
8188
+ account: "MXEAccount"
8189
+ }
8190
+ ]
8191
+ }
8192
+ },
7550
8193
  {
7551
8194
  name: "pool_account",
7552
8195
  writable: true,
@@ -7663,26 +8306,225 @@ var instructions = [
7663
8306
  99,
7664
8307
  99,
7665
8308
  111,
7666
- 117,
7667
- 110,
7668
- 116
8309
+ 117,
8310
+ 110,
8311
+ 116
8312
+ ]
8313
+ },
8314
+ {
8315
+ kind: "arg",
8316
+ path: "_mxe_program"
8317
+ }
8318
+ ]
8319
+ }
8320
+ },
8321
+ {
8322
+ name: "recovery_cluster_acc",
8323
+ pda: {
8324
+ seeds: [
8325
+ {
8326
+ kind: "const",
8327
+ value: [
8328
+ 82,
8329
+ 101,
8330
+ 99,
8331
+ 111,
8332
+ 118,
8333
+ 101,
8334
+ 114,
8335
+ 121,
8336
+ 67,
8337
+ 108,
8338
+ 117,
8339
+ 115,
8340
+ 116,
8341
+ 101,
8342
+ 114,
8343
+ 65,
8344
+ 99,
8345
+ 99,
8346
+ 111,
8347
+ 117,
8348
+ 110,
8349
+ 116
8350
+ ]
8351
+ },
8352
+ {
8353
+ kind: "arg",
8354
+ path: "_mxe_program"
8355
+ }
8356
+ ]
8357
+ }
8358
+ },
8359
+ {
8360
+ name: "mxe_program"
8361
+ }
8362
+ ],
8363
+ args: [
8364
+ {
8365
+ name: "mxe_program",
8366
+ type: "pubkey"
8367
+ }
8368
+ ]
8369
+ },
8370
+ {
8371
+ name: "remove_permissioned_recovery_peers",
8372
+ docs: [
8373
+ "Remove permissioned recovery peers"
8374
+ ],
8375
+ discriminator: [
8376
+ 246,
8377
+ 123,
8378
+ 224,
8379
+ 196,
8380
+ 110,
8381
+ 208,
8382
+ 85,
8383
+ 6
8384
+ ],
8385
+ accounts: [
8386
+ {
8387
+ name: "signer",
8388
+ writable: true,
8389
+ signer: true
8390
+ },
8391
+ {
8392
+ name: "permissioned_recovery_peers_acc",
8393
+ writable: true,
8394
+ pda: {
8395
+ seeds: [
8396
+ {
8397
+ kind: "const",
8398
+ value: [
8399
+ 80,
8400
+ 101,
8401
+ 114,
8402
+ 109,
8403
+ 105,
8404
+ 115,
8405
+ 115,
8406
+ 105,
8407
+ 111,
8408
+ 110,
8409
+ 101,
8410
+ 100,
8411
+ 82,
8412
+ 101,
8413
+ 99,
8414
+ 111,
8415
+ 118,
8416
+ 101,
8417
+ 114,
8418
+ 121,
8419
+ 80,
8420
+ 101,
8421
+ 101,
8422
+ 114,
8423
+ 115,
8424
+ 65,
8425
+ 99,
8426
+ 99,
8427
+ 111,
8428
+ 117,
8429
+ 110,
8430
+ 116
8431
+ ]
8432
+ }
8433
+ ]
8434
+ }
8435
+ },
8436
+ {
8437
+ name: "program_data",
8438
+ pda: {
8439
+ seeds: [
8440
+ {
8441
+ kind: "const",
8442
+ value: [
8443
+ 146,
8444
+ 111,
8445
+ 9,
8446
+ 170,
8447
+ 109,
8448
+ 72,
8449
+ 125,
8450
+ 226,
8451
+ 216,
8452
+ 140,
8453
+ 55,
8454
+ 106,
8455
+ 22,
8456
+ 29,
8457
+ 7,
8458
+ 127,
8459
+ 176,
8460
+ 129,
8461
+ 11,
8462
+ 19,
8463
+ 35,
8464
+ 107,
8465
+ 124,
8466
+ 118,
8467
+ 71,
8468
+ 160,
8469
+ 112,
8470
+ 40,
8471
+ 3,
8472
+ 250,
8473
+ 93,
8474
+ 137
7669
8475
  ]
7670
- },
7671
- {
7672
- kind: "arg",
7673
- path: "_mxe_program"
7674
8476
  }
7675
- ]
8477
+ ],
8478
+ program: {
8479
+ kind: "const",
8480
+ value: [
8481
+ 2,
8482
+ 168,
8483
+ 246,
8484
+ 145,
8485
+ 78,
8486
+ 136,
8487
+ 161,
8488
+ 176,
8489
+ 226,
8490
+ 16,
8491
+ 21,
8492
+ 62,
8493
+ 247,
8494
+ 99,
8495
+ 174,
8496
+ 43,
8497
+ 0,
8498
+ 194,
8499
+ 185,
8500
+ 61,
8501
+ 22,
8502
+ 193,
8503
+ 36,
8504
+ 210,
8505
+ 192,
8506
+ 83,
8507
+ 122,
8508
+ 16,
8509
+ 4,
8510
+ 128,
8511
+ 0,
8512
+ 0
8513
+ ]
8514
+ }
7676
8515
  }
7677
8516
  },
7678
8517
  {
7679
- name: "mxe_program"
8518
+ name: "system_program",
8519
+ address: "11111111111111111111111111111111"
7680
8520
  }
7681
8521
  ],
7682
8522
  args: [
7683
8523
  {
7684
- name: "mxe_program",
7685
- type: "pubkey"
8524
+ name: "peers",
8525
+ type: {
8526
+ vec: "pubkey"
8527
+ }
7686
8528
  }
7687
8529
  ]
7688
8530
  },
@@ -7764,6 +8606,44 @@ var instructions = [
7764
8606
  ]
7765
8607
  }
7766
8608
  },
8609
+ {
8610
+ name: "recovery_cluster_acc",
8611
+ pda: {
8612
+ seeds: [
8613
+ {
8614
+ kind: "const",
8615
+ value: [
8616
+ 82,
8617
+ 101,
8618
+ 99,
8619
+ 111,
8620
+ 118,
8621
+ 101,
8622
+ 114,
8623
+ 121,
8624
+ 67,
8625
+ 108,
8626
+ 117,
8627
+ 115,
8628
+ 116,
8629
+ 101,
8630
+ 114,
8631
+ 65,
8632
+ 99,
8633
+ 99,
8634
+ 111,
8635
+ 117,
8636
+ 110,
8637
+ 116
8638
+ ]
8639
+ },
8640
+ {
8641
+ kind: "arg",
8642
+ path: "_original_mxe_program"
8643
+ }
8644
+ ]
8645
+ }
8646
+ },
7767
8647
  {
7768
8648
  name: "mxe_recovery_account",
7769
8649
  writable: true,
@@ -8377,6 +9257,7 @@ var instructions = [
8377
9257
  docs: [
8378
9258
  "Cluster to set for the MXE."
8379
9259
  ],
9260
+ writable: true,
8380
9261
  pda: {
8381
9262
  seeds: [
8382
9263
  {
@@ -8490,6 +9371,66 @@ var instructions = [
8490
9371
  }
8491
9372
  ]
8492
9373
  },
9374
+ {
9375
+ name: "set_cluster_td_info",
9376
+ discriminator: [
9377
+ 182,
9378
+ 126,
9379
+ 92,
9380
+ 101,
9381
+ 25,
9382
+ 252,
9383
+ 84,
9384
+ 180
9385
+ ],
9386
+ accounts: [
9387
+ {
9388
+ name: "authority",
9389
+ writable: true,
9390
+ signer: true
9391
+ },
9392
+ {
9393
+ name: "cluster_acc",
9394
+ writable: true,
9395
+ pda: {
9396
+ seeds: [
9397
+ {
9398
+ kind: "const",
9399
+ value: [
9400
+ 67,
9401
+ 108,
9402
+ 117,
9403
+ 115,
9404
+ 116,
9405
+ 101,
9406
+ 114
9407
+ ]
9408
+ },
9409
+ {
9410
+ kind: "arg",
9411
+ path: "_id"
9412
+ }
9413
+ ]
9414
+ }
9415
+ }
9416
+ ],
9417
+ args: [
9418
+ {
9419
+ name: "cluster_id",
9420
+ type: "u32"
9421
+ },
9422
+ {
9423
+ name: "td_info",
9424
+ type: {
9425
+ option: {
9426
+ defined: {
9427
+ name: "NodeMetadata"
9428
+ }
9429
+ }
9430
+ }
9431
+ }
9432
+ ]
9433
+ },
8493
9434
  {
8494
9435
  name: "set_mxe_keys",
8495
9436
  discriminator: [
@@ -9590,6 +10531,19 @@ var accounts = [
9590
10531
  117
9591
10532
  ]
9592
10533
  },
10534
+ {
10535
+ name: "PermissionedRecoveryPeersAccount",
10536
+ discriminator: [
10537
+ 113,
10538
+ 236,
10539
+ 217,
10540
+ 203,
10541
+ 251,
10542
+ 98,
10543
+ 36,
10544
+ 240
10545
+ ]
10546
+ },
9593
10547
  {
9594
10548
  name: "RecoveryClusterAccount",
9595
10549
  discriminator: [
@@ -10018,6 +10972,11 @@ var errors = [
10018
10972
  name: "ClusterNotReady",
10019
10973
  msg: "Cluster is not ready"
10020
10974
  },
10975
+ {
10976
+ code: 6508,
10977
+ name: "BlsPubkeyNotSet",
10978
+ msg: "Bls pubkey not set"
10979
+ },
10021
10980
  {
10022
10981
  code: 6600,
10023
10982
  name: "SerializationFailed",
@@ -10133,15 +11092,25 @@ var errors = [
10133
11092
  name: "NoFeesToClaim",
10134
11093
  msg: "No fees available to claim"
10135
11094
  },
11095
+ {
11096
+ code: 6623,
11097
+ name: "RecoveryPeerOffsetZero",
11098
+ msg: "Recovery peer offset is zero"
11099
+ },
11100
+ {
11101
+ code: 6624,
11102
+ name: "InvalidDomainSeparator",
11103
+ msg: "Invalid domain separator"
11104
+ },
10136
11105
  {
10137
11106
  code: 6700,
10138
- name: "MxeNotInRecoveryState",
10139
- msg: "MXE is not in recovery state"
11107
+ name: "MxeNotInMigrationState",
11108
+ msg: "MXE is not in migration state"
10140
11109
  },
10141
11110
  {
10142
11111
  code: 6701,
10143
- name: "MxeAlreadyInRecovery",
10144
- msg: "MXE is already in recovery state"
11112
+ name: "MxeAlreadyInMigration",
11113
+ msg: "MXE is already in migration state"
10145
11114
  },
10146
11115
  {
10147
11116
  code: 6702,
@@ -10215,8 +11184,33 @@ var errors = [
10215
11184
  },
10216
11185
  {
10217
11186
  code: 6716,
10218
- name: "MxeInRecoveryState",
10219
- msg: "MXE is in recovery state, cannot queue new computations"
11187
+ name: "MxeInMigrationState",
11188
+ msg: "MXE is in migration state, cannot queue new computations"
11189
+ },
11190
+ {
11191
+ code: 6717,
11192
+ name: "PermissionedRecoveryPeersNotDistinct",
11193
+ msg: "Permissioned recovery peers to add must be distinct"
11194
+ },
11195
+ {
11196
+ code: 6718,
11197
+ name: "TooManyPermissionedRecoveryPeers",
11198
+ msg: "Too many permissioned recovery peers to add"
11199
+ },
11200
+ {
11201
+ code: 6719,
11202
+ name: "RemoveNonExistingPermissionedRecoveryPeers",
11203
+ msg: "Can only remove existing permissioned recovery peers"
11204
+ },
11205
+ {
11206
+ code: 6720,
11207
+ name: "UnauthorizedRecoveryPeerCreation",
11208
+ msg: "Unauthorized to create recovery peer on mainnet"
11209
+ },
11210
+ {
11211
+ code: 6721,
11212
+ name: "CompilationWithoutMainnetFeatureFlag",
11213
+ msg: "Program must be compiled with the \\mainnet\\ feature flag."
10220
11214
  }
10221
11215
  ];
10222
11216
  var types = [
@@ -11203,7 +12197,16 @@ var types = [
11203
12197
  name: "AcccountAccessInfo"
11204
12198
  }
11205
12199
  },
11206
- 12
12200
+ 13
12201
+ ]
12202
+ }
12203
+ },
12204
+ {
12205
+ name: "_padding",
12206
+ type: {
12207
+ array: [
12208
+ "u8",
12209
+ 6
11207
12210
  ]
11208
12211
  }
11209
12212
  }
@@ -11377,6 +12380,12 @@ var types = [
11377
12380
  }
11378
12381
  }
11379
12382
  ]
12383
+ },
12384
+ {
12385
+ name: "TrustedDealer"
12386
+ },
12387
+ {
12388
+ name: "OutputTooLarge"
11380
12389
  }
11381
12390
  ]
11382
12391
  }
@@ -11498,6 +12507,14 @@ var types = [
11498
12507
  {
11499
12508
  name: "mxe_program_id",
11500
12509
  type: "pubkey"
12510
+ },
12511
+ {
12512
+ name: "execution_status",
12513
+ type: {
12514
+ defined: {
12515
+ name: "ExecutionStatus"
12516
+ }
12517
+ }
11501
12518
  }
11502
12519
  ]
11503
12520
  }
@@ -11579,9 +12596,6 @@ var types = [
11579
12596
  },
11580
12597
  {
11581
12598
  name: "NoPubkeysSet"
11582
- },
11583
- {
11584
- name: "AccountNotFound"
11585
12599
  }
11586
12600
  ]
11587
12601
  }
@@ -11874,7 +12888,7 @@ var types = [
11874
12888
  {
11875
12889
  name: "status",
11876
12890
  docs: [
11877
- "The status of this MXE (Active or Recovery)."
12891
+ "The status of this MXE (Active or Migration)."
11878
12892
  ],
11879
12893
  type: {
11880
12894
  defined: {
@@ -12178,7 +13192,7 @@ var types = [
12178
13192
  name: "Active"
12179
13193
  },
12180
13194
  {
12181
- name: "Recovery"
13195
+ name: "Migration"
12182
13196
  }
12183
13197
  ]
12184
13198
  }
@@ -12471,6 +13485,38 @@ var types = [
12471
13485
  ]
12472
13486
  }
12473
13487
  },
13488
+ {
13489
+ name: "PermissionedRecoveryPeersAccount",
13490
+ docs: [
13491
+ "Account for tracking permissioned recovery peers - needed until we have staking."
13492
+ ],
13493
+ serialization: "bytemuck",
13494
+ repr: {
13495
+ kind: "c"
13496
+ },
13497
+ type: {
13498
+ kind: "struct",
13499
+ fields: [
13500
+ {
13501
+ name: "permissioned_peers",
13502
+ docs: [
13503
+ "DO NOT PUT ANYTHING ELSE BEFORE THE PERMISSIONED_PEERS FIELD, IT'S EXPECTED TO BE AT",
13504
+ "OFFSET 8."
13505
+ ],
13506
+ type: {
13507
+ array: [
13508
+ "pubkey",
13509
+ 25
13510
+ ]
13511
+ }
13512
+ },
13513
+ {
13514
+ name: "bump",
13515
+ type: "u8"
13516
+ }
13517
+ ]
13518
+ }
13519
+ },
12474
13520
  {
12475
13521
  name: "QueueComputationEvent",
12476
13522
  type: {
@@ -12634,6 +13680,18 @@ var types = [
12634
13680
  ]
12635
13681
  }
12636
13682
  },
13683
+ {
13684
+ name: "peer_offset",
13685
+ docs: [
13686
+ "DO NOT PUT ANYTHING ELSE BEFORE THE PEER_OFFSET FIELD, IT'S EXPECTED TO BE AT OFFSET 72."
13687
+ ],
13688
+ type: {
13689
+ array: [
13690
+ "u8",
13691
+ 4
13692
+ ]
13693
+ }
13694
+ },
12637
13695
  {
12638
13696
  name: "bump",
12639
13697
  type: "u8"
@@ -13126,62 +14184,62 @@ const ARCIUM_IDL = (arcium ?? ARCIUM_IDL_MODULE);
13126
14184
  const ARCIUM_ADDR = ARCIUM_IDL.address;
13127
14185
 
13128
14186
  /**
13129
- * Seed for ClockAccount PDA
14187
+ * Seed for ClockAccount PDA.
13130
14188
  * @constant {string}
13131
14189
  */
13132
14190
  const CLOCK_ACC_SEED = 'ClockAccount';
13133
14191
  /**
13134
- * Seed for FeePool PDA
14192
+ * Seed for FeePool PDA.
13135
14193
  * @constant {string}
13136
14194
  */
13137
14195
  const POOL_ACC_SEED = 'FeePool';
13138
14196
  /**
13139
- * Seed for ComputationAccount PDA
14197
+ * Seed for ComputationAccount PDA.
13140
14198
  * @constant {string}
13141
14199
  */
13142
14200
  const COMPUTATION_ACC_SEED = 'ComputationAccount';
13143
14201
  /**
13144
- * Seed for Mempool PDA
14202
+ * Seed for Mempool PDA.
13145
14203
  * @constant {string}
13146
14204
  */
13147
14205
  const MEMPOOL_ACC_SEED = 'Mempool';
13148
14206
  /**
13149
- * Seed for ExecutingPoolAccount PDA
14207
+ * Seed for ExecutingPoolAccount PDA.
13150
14208
  * @constant {string}
13151
14209
  */
13152
14210
  const EXEC_POOL_ACC_SEED = 'Execpool';
13153
14211
  /**
13154
- * Seed for ClusterAccount PDA
14212
+ * Seed for ClusterAccount PDA.
13155
14213
  * @constant {string}
13156
14214
  */
13157
14215
  const CLUSTER_ACC_SEED = 'Cluster';
13158
14216
  /**
13159
- * Seed for ArxNodeAccount PDA
14217
+ * Seed for ArxNodeAccount PDA.
13160
14218
  * @constant {string}
13161
14219
  */
13162
14220
  const ARX_NODE_ACC_SEED = 'ArxNode';
13163
14221
  /**
13164
- * Seed for MXE Account PDA
14222
+ * Seed for MXE Account PDA.
13165
14223
  * @constant {string}
13166
14224
  */
13167
14225
  const MXE_ACCOUNT_SEED = 'MXEAccount';
13168
14226
  /**
13169
- * Seed for CompDefAccount PDA
14227
+ * Seed for CompDefAccount PDA.
13170
14228
  * @constant {string}
13171
14229
  */
13172
14230
  const COMP_DEF_ACC_SEED = 'ComputationDefinitionAccount';
13173
14231
  /**
13174
- * Seed for RecoveryClusterAccount PDA
14232
+ * Seed for RecoveryClusterAccount PDA.
13175
14233
  * @constant {string}
13176
14234
  */
13177
14235
  const RECOVERY_CLUSTER_ACC_SEED = 'RecoveryClusterAccount';
13178
14236
  /**
13179
- * Seed for MxeRecoveryAccount PDA
14237
+ * Seed for MxeRecoveryAccount PDA.
13180
14238
  * @constant {string}
13181
14239
  */
13182
14240
  const MXE_RECOVERY_ACC_SEED = 'MxeRecoveryAccount';
13183
14241
  /**
13184
- * Seed for ComputationDefinitionRaw PDA
14242
+ * Seed for ComputationDefinitionRaw PDA.
13185
14243
  * @constant {string}
13186
14244
  */
13187
14245
  const RAW_CIRCUIT_ACC_SEED = 'ComputationDefinitionRaw';
@@ -13201,7 +14259,7 @@ const MAX_UPLOAD_PER_TX_BYTES = 814;
13201
14259
  */
13202
14260
  const MAX_ACCOUNT_SIZE = 10485760;
13203
14261
  /**
13204
- * Maximum number of arcium embiggen instructions allowed in a single transaction (due to compute unit limits).
14262
+ * Maximum number of Arcium embiggen instructions allowed in a single transaction (due to compute unit limits).
13205
14263
  * @constant {number}
13206
14264
  */
13207
14265
  const MAX_EMBIGGEN_IX_PER_TX = 18;
@@ -13222,17 +14280,17 @@ const OFFSET_BUFFER_SIZE = 4;
13222
14280
  const COMP_DEF_OFFSET_SIZE = 4;
13223
14281
 
13224
14282
  /**
13225
- * Returns the public key of the deployed Arcium program on Solana.
13226
- * @returns The Arcium program's public key.
14283
+ * Return the public key of the deployed Arcium program on Solana.
14284
+ * @returns Arcium program's public key.
13227
14285
  */
13228
14286
  function getArciumProgramId() {
13229
14287
  return new anchor__namespace.web3.PublicKey(ARCIUM_ADDR);
13230
14288
  }
13231
14289
  /**
13232
- * Derives the computation account address for a given cluster and computation offset.
13233
- * @param clusterOffset - The offset of the cluster this computation will be executed by.
13234
- * @param computationOffset - The computation offset as an anchor.BN.
13235
- * @returns The derived computation account public key.
14290
+ * Derive the computation account address for a given cluster and computation offset.
14291
+ * @param clusterOffset - Offset of the cluster this computation will be executed by.
14292
+ * @param computationOffset - Computation offset as an anchor.BN.
14293
+ * @returns Derived computation account public key.
13236
14294
  */
13237
14295
  function getComputationAccAddress(clusterOffset, computationOffset) {
13238
14296
  const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
@@ -13241,9 +14299,9 @@ function getComputationAccAddress(clusterOffset, computationOffset) {
13241
14299
  return generateArciumPDAFrom(seeds)[0];
13242
14300
  }
13243
14301
  /**
13244
- * Derives the mempool account address for a given cluster.
13245
- * @param clusterOffset - The offset of the cluster.
13246
- * @returns The derived mempool account public key.
14302
+ * Derive the mempool account address for a given cluster.
14303
+ * @param clusterOffset - Offset of the cluster.
14304
+ * @returns Derived mempool account public key.
13247
14305
  */
13248
14306
  function getMempoolAccAddress(clusterOffset) {
13249
14307
  const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
@@ -13252,9 +14310,9 @@ function getMempoolAccAddress(clusterOffset) {
13252
14310
  return generateArciumPDAFrom(seeds)[0];
13253
14311
  }
13254
14312
  /**
13255
- * Derives the executing pool account address for a given cluster.
13256
- * @param clusterOffset - The offset of the cluster.
13257
- * @returns The derived executing pool account public key.
14313
+ * Derive the executing pool account address for a given cluster.
14314
+ * @param clusterOffset - Offset of the cluster.
14315
+ * @returns Derived executing pool account public key.
13258
14316
  */
13259
14317
  function getExecutingPoolAccAddress(clusterOffset) {
13260
14318
  const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
@@ -13263,25 +14321,25 @@ function getExecutingPoolAccAddress(clusterOffset) {
13263
14321
  return generateArciumPDAFrom(seeds)[0];
13264
14322
  }
13265
14323
  /**
13266
- * Derives the fee pool account address.
13267
- * @returns The derived fee pool account public key.
14324
+ * Derive the fee pool account address.
14325
+ * @returns Derived fee pool account public key.
13268
14326
  */
13269
14327
  function getFeePoolAccAddress() {
13270
14328
  const seeds = [Buffer.from(POOL_ACC_SEED)];
13271
14329
  return generateArciumPDAFrom(seeds)[0];
13272
14330
  }
13273
14331
  /**
13274
- * Derives the clock account address.
13275
- * @returns The derived clock account public key.
14332
+ * Derive the clock account address.
14333
+ * @returns Derived clock account public key.
13276
14334
  */
13277
14335
  function getClockAccAddress() {
13278
14336
  const seeds = [Buffer.from(CLOCK_ACC_SEED)];
13279
14337
  return generateArciumPDAFrom(seeds)[0];
13280
14338
  }
13281
14339
  /**
13282
- * Derives the cluster account address for a given offset.
13283
- * @param clusterOffset - The cluster offset as a number.
13284
- * @returns The derived cluster account public key.
14340
+ * Derive the cluster account address for a given offset.
14341
+ * @param clusterOffset - Cluster offset as a number.
14342
+ * @returns Derived cluster account public key.
13285
14343
  */
13286
14344
  function getClusterAccAddress(clusterOffset) {
13287
14345
  const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
@@ -13290,9 +14348,9 @@ function getClusterAccAddress(clusterOffset) {
13290
14348
  return generateArciumPDAFrom(seeds)[0];
13291
14349
  }
13292
14350
  /**
13293
- * Derives the ArxNode account address for a given offset.
13294
- * @param nodeOffset - The ArxNode offset as a number.
13295
- * @returns The derived ArxNode account public key.
14351
+ * Derive the ArxNode account address for a given offset.
14352
+ * @param nodeOffset - ArxNode offset as a number.
14353
+ * @returns Derived ArxNode account public key.
13296
14354
  */
13297
14355
  function getArxNodeAccAddress(nodeOffset) {
13298
14356
  const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
@@ -13301,19 +14359,19 @@ function getArxNodeAccAddress(nodeOffset) {
13301
14359
  return generateArciumPDAFrom(seeds)[0];
13302
14360
  }
13303
14361
  /**
13304
- * Derives the MXE account address for a given MXE program ID.
13305
- * @param mxeProgramId - The public key of the MXE program.
13306
- * @returns The derived MXE account public key.
14362
+ * Derive the MXE account address for a given MXE program ID.
14363
+ * @param mxeProgramId - Public key of the MXE program.
14364
+ * @returns Derived MXE account public key.
13307
14365
  */
13308
14366
  function getMXEAccAddress(mxeProgramId) {
13309
14367
  const seeds = [Buffer.from(MXE_ACCOUNT_SEED), mxeProgramId.toBuffer()];
13310
14368
  return generateArciumPDAFrom(seeds)[0];
13311
14369
  }
13312
14370
  /**
13313
- * Derives the computation definition account address for a given MXE program ID and offset.
13314
- * @param mxeProgramId - The public key of the MXE program.
13315
- * @param compDefOffset - The computation definition offset as a number.
13316
- * @returns The derived computation definition account public key.
14371
+ * Derive the computation definition account address for a given MXE program ID and offset.
14372
+ * @param mxeProgramId - Public key of the MXE program.
14373
+ * @param compDefOffset - Computation definition offset as a number.
14374
+ * @returns Derived computation definition account public key.
13317
14375
  */
13318
14376
  function getCompDefAccAddress(mxeProgramId, compDefOffset) {
13319
14377
  const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
@@ -13322,19 +14380,19 @@ function getCompDefAccAddress(mxeProgramId, compDefOffset) {
13322
14380
  return generateArciumPDAFrom(seeds)[0];
13323
14381
  }
13324
14382
  /**
13325
- * Derives the recovery cluster account address for a given MXE program ID.
13326
- * @param mxeProgramId - The public key of the MXE program.
13327
- * @returns The derived recovery cluster account public key.
14383
+ * Derive the recovery cluster account address for a given MXE program ID.
14384
+ * @param mxeProgramId - Public key of the MXE program.
14385
+ * @returns Derived recovery cluster account public key.
13328
14386
  */
13329
14387
  function getRecoveryClusterAccAddress(mxeProgramId) {
13330
14388
  const seeds = [Buffer.from(RECOVERY_CLUSTER_ACC_SEED), mxeProgramId.toBuffer()];
13331
14389
  return generateArciumPDAFrom(seeds)[0];
13332
14390
  }
13333
14391
  /**
13334
- * Derives the MXE recovery account address for a key recovery session.
13335
- * @param backupMxeProgramId - The public key of the backup MXE program that will take over.
13336
- * @param originalMxeProgramId - The public key of the original MXE program being recovered.
13337
- * @returns The derived MXE recovery account public key.
14392
+ * Derive the MXE recovery account address for a key recovery session.
14393
+ * @param backupMxeProgramId - Public key of the backup MXE program that will take over.
14394
+ * @param originalMxeProgramId - Public key of the original MXE program being recovered.
14395
+ * @returns Derived MXE recovery account public key.
13338
14396
  */
13339
14397
  function getMxeRecoveryAccAddress(backupMxeProgramId, originalMxeProgramId) {
13340
14398
  const seeds = [
@@ -13345,10 +14403,10 @@ function getMxeRecoveryAccAddress(backupMxeProgramId, originalMxeProgramId) {
13345
14403
  return generateArciumPDAFrom(seeds)[0];
13346
14404
  }
13347
14405
  /**
13348
- * Derives the raw circuit account address for a given computation definition and index.
13349
- * @param compDefPubkey - The public key of the computation definition account.
13350
- * @param rawCircuitIndex - The index of the raw circuit account (0-based).
13351
- * @returns The derived raw circuit account public key.
14406
+ * Derive the raw circuit account address for a given computation definition and index.
14407
+ * @param compDefPubkey - Public key of the computation definition account.
14408
+ * @param rawCircuitIndex - Index of the raw circuit account (0-based).
14409
+ * @returns Derived raw circuit account public key.
13352
14410
  */
13353
14411
  function getRawCircuitAccAddress(compDefPubkey, rawCircuitIndex) {
13354
14412
  const seeds = [
@@ -13359,10 +14417,10 @@ function getRawCircuitAccAddress(compDefPubkey, rawCircuitIndex) {
13359
14417
  return generateArciumPDAFrom(seeds)[0];
13360
14418
  }
13361
14419
  /**
13362
- * Derives the address lookup table address for an MXE program.
13363
- * @param mxeProgramId - The public key of the MXE program.
13364
- * @param lutOffset - The index of the lookup table, to be fetched from the mxe account.
13365
- * @returns The derived address lookup table public key.
14420
+ * Derive the address lookup table address for an MXE program.
14421
+ * @param mxeProgramId - Public key of the MXE program.
14422
+ * @param lutOffset - Index of the lookup table, to be fetched from the mxe account.
14423
+ * @returns Derived address lookup table public key.
13366
14424
  */
13367
14425
  function getLookupTableAddress(mxeProgramId, lutOffset) {
13368
14426
  const mxeAccount = getMXEAccAddress(mxeProgramId);
@@ -13371,9 +14429,9 @@ function getLookupTableAddress(mxeProgramId, lutOffset) {
13371
14429
  return web3_js.PublicKey.findProgramAddressSync(seeds, web3_js.AddressLookupTableProgram.programId)[0];
13372
14430
  }
13373
14431
  /**
13374
- * Generates a program-derived address (PDA) from the provided seeds and the Arcium program ID.
13375
- * @param seeds - An array of Buffer seeds used for PDA derivation.
13376
- * @returns A tuple containing the derived public key and the bump seed.
14432
+ * Generate a program-derived address (PDA) from the provided seeds and the Arcium program ID.
14433
+ * @param seeds - Array of Buffer seeds used for PDA derivation.
14434
+ * @returns Tuple containing the derived public key and the bump seed.
13377
14435
  */
13378
14436
  function generateArciumPDAFrom(seeds) {
13379
14437
  const programId = getArciumProgramId();
@@ -13481,10 +14539,10 @@ const EXECPOOL_DISCRIMINATOR_MAP = {
13481
14539
  [LARGE_EXECPOOL_DISCRIMINATOR.toString()]: LARGE_EXECPOOL_ACC_NAME,
13482
14540
  };
13483
14541
  /**
13484
- * Fetches and decodes the mempool account info for any mempool account size.
13485
- * @param provider - The Anchor provider to use for fetching accounts.
13486
- * @param mempoolAccPubkey - The public key of the mempool account.
13487
- * @returns The decoded mempool account info.
14542
+ * Fetch and decode the mempool account info for any mempool account size.
14543
+ * @param provider - Anchor provider to use for fetching accounts.
14544
+ * @param mempoolAccPubkey - Public key of the mempool account.
14545
+ * @returns Decoded mempool account info.
13488
14546
  * @throws Error if the account cannot be fetched or the discriminator is unknown.
13489
14547
  */
13490
14548
  async function getMempoolAccInfo(provider, mempoolAccPubkey) {
@@ -13501,10 +14559,10 @@ async function getMempoolAccInfo(provider, mempoolAccPubkey) {
13501
14559
  return program.coder.accounts.decode(accName, accData.data);
13502
14560
  }
13503
14561
  /**
13504
- * Fetches and decodes the executing pool account info for any pool size.
13505
- * @param provider - The Anchor provider to use for fetching accounts.
13506
- * @param executingPoolAccPubkey - The public key of the executing pool account.
13507
- * @returns The decoded executing pool account info.
14562
+ * Fetch and decode the executing pool account info for any pool size.
14563
+ * @param provider - Anchor provider to use for fetching accounts.
14564
+ * @param executingPoolAccPubkey - Public key of the executing pool account.
14565
+ * @returns Decoded executing pool account info.
13508
14566
  * @throws Error if the account cannot be fetched or the discriminator is unknown.
13509
14567
  */
13510
14568
  async function getExecutingPoolAccInfo(provider, executingPoolAccPubkey) {
@@ -13521,10 +14579,10 @@ async function getExecutingPoolAccInfo(provider, executingPoolAccPubkey) {
13521
14579
  return program.coder.accounts.decode(accName, accData.data);
13522
14580
  }
13523
14581
  /**
13524
- * Returns all computation references in the mempool for a given account.
14582
+ * Return all computation references in the mempool for a given account.
13525
14583
  * Only non-stake computations are included.
13526
- * @param arciumProgram - The Anchor program instance.
13527
- * @param address - The public key of the mempool account.
14584
+ * @param arciumProgram - Anchor program instance.
14585
+ * @param address - Public key of the mempool account.
13528
14586
  * @returns Array of ComputationReference objects.
13529
14587
  */
13530
14588
  async function getComputationsInMempool(arciumProgram, address) {
@@ -13555,9 +14613,9 @@ async function getComputationsInMempool(arciumProgram, address) {
13555
14613
  .filter((ref) => !isNullRef(ref));
13556
14614
  }
13557
14615
  /**
13558
- * Calculates priority fee statistics for computations in a mempool.
13559
- * @param arciumProgram - The Anchor program instance.
13560
- * @param mempoolAddress - The public key of the mempool account.
14616
+ * Calculate priority fee statistics for computations in a mempool.
14617
+ * @param arciumProgram - Anchor program instance.
14618
+ * @param mempoolAddress - Public key of the mempool account.
13561
14619
  * @returns Priority fee statistics (mean, median, min, max, count).
13562
14620
  */
13563
14621
  async function getMempoolPriorityFeeStats(arciumProgram, mempoolAddress) {
@@ -13582,11 +14640,11 @@ async function getMempoolPriorityFeeStats(arciumProgram, mempoolAddress) {
13582
14640
  };
13583
14641
  }
13584
14642
  /**
13585
- * Helper function to fetch a specific utility key from the MXE account.
13586
- * @param provider - The Anchor provider to use for fetching accounts.
13587
- * @param mxeProgramId - The public key of the MXE program.
13588
- * @param field - The field name to extract ('x25519Pubkey' or 'ed25519VerifyingKey').
13589
- * @returns The utility key as a Uint8Array, or null if not set.
14643
+ * Fetch a specific utility key from the MXE account.
14644
+ * @param provider - Anchor provider to use for fetching accounts.
14645
+ * @param mxeProgramId - Public key of the MXE program.
14646
+ * @param field - Field name to extract ('x25519Pubkey' or 'ed25519VerifyingKey').
14647
+ * @returns Utility key as a Uint8Array, or null if not set.
13590
14648
  */
13591
14649
  async function getMXEUtilityKey(provider, mxeProgramId, field) {
13592
14650
  const program = getArciumProgram(provider);
@@ -13605,28 +14663,28 @@ async function getMXEUtilityKey(provider, mxeProgramId, field) {
13605
14663
  return null;
13606
14664
  }
13607
14665
  /**
13608
- * Fetches and extracts the MXE X25519 public key from the MXE account.
13609
- * @param provider - The Anchor provider to use for fetching accounts.
13610
- * @param mxeProgramId - The public key of the MXE program.
13611
- * @returns The MXE's X25519 public key as a Uint8Array, or null if not set.
14666
+ * Fetch and extract the MXE X25519 public key from the MXE account.
14667
+ * @param provider - Anchor provider to use for fetching accounts.
14668
+ * @param mxeProgramId - Public key of the MXE program.
14669
+ * @returns MXE's X25519 public key as a Uint8Array, or null if not set.
13612
14670
  */
13613
14671
  async function getMXEPublicKey(provider, mxeProgramId) {
13614
14672
  return getMXEUtilityKey(provider, mxeProgramId, 'x25519Pubkey');
13615
14673
  }
13616
14674
  /**
13617
- * Fetches and extracts the MXE arcis Ed25519 verifying key from the MXE account.
13618
- * @param provider - The Anchor provider to use for fetching accounts.
13619
- * @param mxeProgramId - The public key of the MXE program.
13620
- * @returns The MXE's arcis Ed25519 verifying key as a Uint8Array, or null if not set.
14675
+ * Fetch and extract the MXE arcis Ed25519 verifying key from the MXE account.
14676
+ * @param provider - Anchor provider to use for fetching accounts.
14677
+ * @param mxeProgramId - Public key of the MXE program.
14678
+ * @returns MXE's arcis Ed25519 verifying key as a Uint8Array, or null if not set.
13621
14679
  */
13622
14680
  async function getMXEArcisEd25519VerifyingKey(provider, mxeProgramId) {
13623
14681
  return getMXEUtilityKey(provider, mxeProgramId, 'ed25519VerifyingKey');
13624
14682
  }
13625
14683
  /**
13626
- * Determines the current state of a circuit based on its on-chain configuration.
14684
+ * Determine the current state of a circuit based on its on-chain configuration.
13627
14685
  * @internal Called internally by `uploadCircuit` - most users don't need this directly.
13628
- * @param circuitSource - The circuitSource field from ComputationDefinitionAccount.
13629
- * @returns The current state of the circuit.
14686
+ * @param circuitSource - circuitSource field from ComputationDefinitionAccount.
14687
+ * @returns Current state of the circuit.
13630
14688
  */
13631
14689
  function getCircuitState(circuitSource) {
13632
14690
  if (!('onChain' in circuitSource) || !circuitSource.onChain) {
@@ -13638,14 +14696,15 @@ function getCircuitState(circuitSource) {
13638
14696
  return 'OnchainPending';
13639
14697
  }
13640
14698
  /**
13641
- * Uploads a circuit to the blockchain, splitting it into multiple accounts if necessary.
13642
- * @param provider - The Anchor provider to use for transactions.
13643
- * @param circuitName - The name of the circuit.
13644
- * @param mxeProgramId - The public key of the MXE program.
13645
- * @param rawCircuit - The raw circuit data as a Uint8Array.
14699
+ * Upload a circuit to the blockchain, splitting it into multiple accounts if necessary.
14700
+ * @param provider - Anchor provider to use for transactions.
14701
+ * @param circuitName - Name of the circuit.
14702
+ * @param mxeProgramId - Public key of the MXE program.
14703
+ * @param rawCircuit - Raw circuit data as a Uint8Array.
13646
14704
  * @param logging - Whether to log progress (default: true).
13647
- * @param chunkSize - The number of upload transactions to send in parallel (default: 500).
13648
- * @returns An array of transaction signatures for all upload and finalize transactions.
14705
+ * @param chunkSize - Number of upload transactions to send in parallel (default: 500).
14706
+ * @param confirmOptions - Transaction confirmation options.
14707
+ * @returns Array of transaction signatures for all upload and finalize transactions.
13649
14708
  */
13650
14709
  async function uploadCircuit(provider, circuitName, mxeProgramId, rawCircuit, logging = true, chunkSize = 500, confirmOptions) {
13651
14710
  const compDefAccInfo = getCompDefAccInfo(circuitName, mxeProgramId);
@@ -13669,6 +14728,14 @@ async function uploadCircuit(provider, circuitName, mxeProgramId, rawCircuit, lo
13669
14728
  sigs.push(await signAndSendWithBlockhash(provider, finalizeCompDefTx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions));
13670
14729
  return sigs;
13671
14730
  }
14731
+ /**
14732
+ * Queue a key recovery initialization for an MXE on a given cluster.
14733
+ * @param provider - Anchor provider for signing and sending.
14734
+ * @param clusterOffset - Cluster offset to recover keys from.
14735
+ * @param mxeProgramId - Public key of the MXE program.
14736
+ * @param confirmOptions - Transaction confirmation options.
14737
+ * @returns Array of transaction signatures.
14738
+ */
13672
14739
  async function queueKeyRecoveryInit(provider, clusterOffset, mxeProgramId, confirmOptions) {
13673
14740
  const program = getArciumProgram(provider);
13674
14741
  const sigs = [];
@@ -13683,11 +14750,11 @@ async function queueKeyRecoveryInit(provider, clusterOffset, mxeProgramId, confi
13683
14750
  return sigs;
13684
14751
  }
13685
14752
  /**
13686
- * Builds a transaction to finalize a computation definition.
13687
- * @param provider - The Anchor provider to use for transactions.
13688
- * @param compDefOffset - The offset of the computation definition.
13689
- * @param mxeProgramId - The public key of the MXE program.
13690
- * @returns The transaction to finalize the computation definition.
14753
+ * Build a transaction to finalize a computation definition.
14754
+ * @param provider - Anchor provider to use for transactions.
14755
+ * @param compDefOffset - Offset of the computation definition.
14756
+ * @param mxeProgramId - Public key of the MXE program.
14757
+ * @returns Transaction to finalize the computation definition.
13691
14758
  */
13692
14759
  async function buildFinalizeCompDefTx(provider, compDefOffset, mxeProgramId) {
13693
14760
  const program = getArciumProgram(provider);
@@ -13805,35 +14872,35 @@ async function signAndSendWithBlockhash(provider, tx, block, confirmOptions) {
13805
14872
  return provider.sendAndConfirm(tx, [], confirmOptions || { commitment: 'confirmed' });
13806
14873
  }
13807
14874
  /**
13808
- * Returns the base seed for an Arcium account, given its name.
13809
- * @param accName - The name of the account.
13810
- * @returns The base seed as a Uint8Array.
14875
+ * Return the base seed for an Arcium account, given its name.
14876
+ * @param accName - Name of the account.
14877
+ * @returns Base seed as a Uint8Array.
13811
14878
  */
13812
14879
  function getArciumAccountBaseSeed(accName) {
13813
14880
  return Buffer.from(accName, 'utf-8');
13814
14881
  }
13815
14882
  /**
13816
- * Computes the offset for a computation definition account, based on the circuit name.
13817
- * @param circuitName - The name of the circuit.
13818
- * @returns The offset as a 4-byte Uint8Array.
14883
+ * Compute the offset for a computation definition account, based on the circuit name.
14884
+ * @param circuitName - Name of the circuit.
14885
+ * @returns Offset as a 4-byte Uint8Array.
13819
14886
  */
13820
14887
  function getCompDefAccOffset(circuitName) {
13821
14888
  const hash = new Uint8Array(sha256([Buffer.from(circuitName, 'utf-8')]));
13822
14889
  return hash.slice(0, COMP_DEF_OFFSET_SIZE);
13823
14890
  }
13824
14891
  /**
13825
- * Returns an Anchor program instance for the Arcium program.
13826
- * @param provider - The Anchor provider to use.
13827
- * @returns The Anchor program instance for Arcium.
14892
+ * Return an Anchor program instance for the Arcium program.
14893
+ * @param provider - Anchor provider to use.
14894
+ * @returns Anchor program instance for Arcium.
13828
14895
  */
13829
14896
  function getArciumProgram(provider) {
13830
14897
  return new anchor.Program(ARCIUM_IDL, provider);
13831
14898
  }
13832
14899
  /**
13833
- * Returns the public key and offset for a computation definition account, given the circuit name and MXE program ID.
13834
- * @param circuitName - The name of the circuit.
13835
- * @param mxeProgramId - The public key of the MXE program.
13836
- * @returns An object containing the public key and offset for the computation definition account.
14900
+ * Return the public key and offset for a computation definition account, given the circuit name and MXE program ID.
14901
+ * @param circuitName - Name of the circuit.
14902
+ * @param mxeProgramId - Public key of the MXE program.
14903
+ * @returns Object containing the public key and offset for the computation definition account.
13837
14904
  */
13838
14905
  function getCompDefAccInfo(circuitName, mxeProgramId) {
13839
14906
  const offset = getCompDefAccOffset(circuitName);
@@ -13841,20 +14908,21 @@ function getCompDefAccInfo(circuitName, mxeProgramId) {
13841
14908
  return { pubkey: pda, offset: Buffer.from(offset).readUInt32LE(0) };
13842
14909
  }
13843
14910
  /**
13844
- * Returns the PDA for a computation definition account, given the program ID, MXE program ID, and offset.
13845
- * @param arciumProgramId - The public key of the Arcium program.
13846
- * @param mxeProgramId - The public key of the MXE program.
13847
- * @param offset - The offset as a Uint8Array.
13848
- * @returns The PDA for the computation definition account.
14911
+ * Return the PDA for a computation definition account, given the program ID, MXE program ID, and offset.
14912
+ * @param arciumProgramId - Public key of the Arcium program.
14913
+ * @param mxeProgramId - Public key of the MXE program.
14914
+ * @param offset - Offset as a Uint8Array.
14915
+ * @returns PDA for the computation definition account.
13849
14916
  */
13850
14917
  function getCompDefAccPDA(arciumProgramId, mxeProgramId, offset) {
13851
14918
  return anchor__namespace.web3.PublicKey.findProgramAddressSync([Buffer.from(COMP_DEF_ACC_SEED, 'utf-8'), mxeProgramId.toBuffer(), offset], arciumProgramId)[0];
13852
14919
  }
13853
14920
  /**
13854
- * Sets an MXE to Recovery status, initiating the key recovery process.
13855
- * @param provider - The Anchor provider to use for transactions.
13856
- * @param mxeProgramId - The public key of the MXE program to recover.
13857
- * @returns The transaction signature.
14921
+ * Set an MXE to Recovery status, initiating the key recovery process.
14922
+ * @param provider - Anchor provider to use for transactions.
14923
+ * @param mxeProgramId - Public key of the MXE program to recover.
14924
+ * @param confirmOptions - Transaction confirmation options.
14925
+ * @returns Transaction signature.
13858
14926
  */
13859
14927
  async function recoverMxe(provider, mxeProgramId, confirmOptions) {
13860
14928
  const program = getArciumProgram(provider);
@@ -13868,13 +14936,14 @@ async function recoverMxe(provider, mxeProgramId, confirmOptions) {
13868
14936
  return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
13869
14937
  }
13870
14938
  /**
13871
- * Initializes key recovery execution by creating the MxeRecoveryAccount and
14939
+ * Initialize key recovery execution by creating the MxeRecoveryAccount and
13872
14940
  * registering the key_recovery_final computation definition on the backup MXE.
13873
14941
  * This is split into two parts due to Solana's 10KB per-instruction allocation limit.
13874
- * @param provider - The Anchor provider to use for transactions.
13875
- * @param originalMxeProgramId - The public key of the original MXE program being recovered.
13876
- * @param backupMxeProgramId - The public key of the backup MXE program that will take over.
13877
- * @returns The transaction signature from part2.
14942
+ * @param provider - Anchor provider to use for transactions.
14943
+ * @param originalMxeProgramId - Public key of the original MXE program being recovered.
14944
+ * @param backupMxeProgramId - Public key of the backup MXE program that will take over.
14945
+ * @param confirmOptions - Transaction confirmation options.
14946
+ * @returns Transaction signature from part2.
13878
14947
  */
13879
14948
  async function initKeyRecoveryExecution(provider, originalMxeProgramId, backupMxeProgramId, confirmOptions) {
13880
14949
  // Part 1: Create MxeRecoveryAccount with partial size
@@ -13901,16 +14970,17 @@ async function initKeyRecoveryExecution(provider, originalMxeProgramId, backupMx
13901
14970
  return signAndSendWithBlockhash(provider, tx2, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
13902
14971
  }
13903
14972
  /**
13904
- * Submits a re-encrypted key recovery share from a recovery peer.
14973
+ * Submit a re-encrypted key recovery share from a recovery peer.
13905
14974
  * Recovery peers must decrypt shares using their x25519 private key and re-encrypt
13906
14975
  * them for the backup MXE before submission.
13907
- * @param provider - The Anchor provider to use for transactions.
13908
- * @param originalMxeProgramId - The public key of the original MXE program being recovered.
13909
- * @param backupMxeProgramId - The public key of the backup MXE program.
13910
- * @param peerOffset - The offset of the recovery peer.
13911
- * @param peerIndex - The index of this peer in the recovery peers list.
13912
- * @param share - The re-encrypted share: 5 field elements of 32 bytes each (160 bytes total).
13913
- * @returns The transaction signature.
14976
+ * @param provider - Anchor provider to use for transactions.
14977
+ * @param originalMxeProgramId - Public key of the original MXE program being recovered.
14978
+ * @param backupMxeProgramId - Public key of the backup MXE program.
14979
+ * @param peerOffset - Offset of the recovery peer.
14980
+ * @param peerIndex - Index of this peer in the recovery peers list.
14981
+ * @param share - Re-encrypted share: 5 field elements of 32 bytes each (160 bytes total).
14982
+ * @param confirmOptions - Transaction confirmation options.
14983
+ * @returns Transaction signature.
13914
14984
  */
13915
14985
  async function submitKeyRecoveryShare(provider, originalMxeProgramId, backupMxeProgramId, peerOffset, peerIndex, share, confirmOptions) {
13916
14986
  const program = getArciumProgram(provider);
@@ -13935,14 +15005,15 @@ async function submitKeyRecoveryShare(provider, originalMxeProgramId, backupMxeP
13935
15005
  return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
13936
15006
  }
13937
15007
  /**
13938
- * Finalizes key recovery execution after the submission threshold is met.
15008
+ * Finalize key recovery execution after the submission threshold is met.
13939
15009
  * This queues the key_recovery_finalize MPC computation on the backup cluster.
13940
- * @param provider - The Anchor provider to use for transactions.
13941
- * @param originalMxeProgramId - The public key of the original MXE program being recovered.
13942
- * @param backupMxeProgramId - The public key of the backup MXE program.
13943
- * @param clusterOffset - The cluster offset where the backup MXE is deployed.
13944
- * @param keyRecoveryFinalizeOffset - The computation offset for the key_recovery_finalize computation.
13945
- * @returns The transaction signature.
15010
+ * @param provider - Anchor provider to use for transactions.
15011
+ * @param originalMxeProgramId - Public key of the original MXE program being recovered.
15012
+ * @param backupMxeProgramId - Public key of the backup MXE program.
15013
+ * @param clusterOffset - Cluster offset where the backup MXE is deployed.
15014
+ * @param keyRecoveryFinalizeOffset - Computation offset for the key_recovery_finalize computation.
15015
+ * @param confirmOptions - Transaction confirmation options.
15016
+ * @returns Transaction signature.
13946
15017
  */
13947
15018
  async function finalizeKeyRecoveryExecution(provider, originalMxeProgramId, backupMxeProgramId, clusterOffset, keyRecoveryFinalizeOffset, confirmOptions) {
13948
15019
  const program = getArciumProgram(provider);
@@ -13961,12 +15032,13 @@ async function finalizeKeyRecoveryExecution(provider, originalMxeProgramId, back
13961
15032
  return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
13962
15033
  }
13963
15034
  /**
13964
- * Initializes an MXE (part 1). Due to Solana's 10KB per-instruction allocation limit,
15035
+ * Initialize an MXE (part 1). Due to Solana's 10KB per-instruction allocation limit,
13965
15036
  * this only partially allocates recovery_cluster_acc.
13966
15037
  * Call initMxePart2 afterwards to finish allocation and add keygen to mempool.
13967
- * @param provider - The Anchor provider to use for transactions.
13968
- * @param mxeProgramId - The public key to use as the MXE program ID.
13969
- * @returns The transaction signature.
15038
+ * @param provider - Anchor provider to use for transactions.
15039
+ * @param mxeProgramId - Public key to use as the MXE program ID.
15040
+ * @param confirmOptions - Transaction confirmation options.
15041
+ * @returns Transaction signature.
13970
15042
  */
13971
15043
  async function initMxePart1(provider, mxeProgramId, confirmOptions) {
13972
15044
  const program = getArciumProgram(provider);
@@ -13980,17 +15052,19 @@ async function initMxePart1(provider, mxeProgramId, confirmOptions) {
13980
15052
  return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
13981
15053
  }
13982
15054
  /**
13983
- * Finishes MXE initialization (part 2).
13984
- * Reallocates recovery_cluster_acc to full size, initializes recovery_peers,
13985
- * and adds the keygen computation to the mempool.
13986
- * @param provider - The Anchor provider to use for transactions.
13987
- * @param clusterOffset - The cluster offset to associate with the MXE.
13988
- * @param mxeProgramId - The public key to use as the MXE program ID.
15055
+ * Finish MXE initialization (part 2).
15056
+ * Reallocate recovery_cluster_acc to full size, initialize recovery_peers,
15057
+ * and add the keygen computation to the mempool.
15058
+ * @param provider - Anchor provider to use for transactions.
15059
+ * @param clusterOffset - Cluster offset to associate with the MXE.
15060
+ * @param mxeProgramId - Public key to use as the MXE program ID.
13989
15061
  * @param recoveryPeers - Array of 100 node offsets for recovery peers (0 for unused slots).
13990
- * @param keygenOffset - The computation offset for the keygen computation.
13991
- * @param keyRecoveryInitOffset - The computation offset for the key_recovery_init computation.
15062
+ * @param keygenOffset - Computation offset for the keygen computation.
15063
+ * @param keyRecoveryInitOffset - Computation offset for the key_recovery_init computation.
15064
+ * @param lutOffset - Lookup table offset for the MXE's address lookup table.
13992
15065
  * @param mxeAuthority - Optional authority for the MXE (defaults to provider.publicKey).
13993
- * @returns The transaction signature.
15066
+ * @param confirmOptions - Transaction confirmation options.
15067
+ * @returns Transaction signature.
13994
15068
  */
13995
15069
  async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers, keygenOffset, keyRecoveryInitOffset, lutOffset, mxeAuthority, confirmOptions) {
13996
15070
  const program = getArciumProgram(provider);
@@ -14016,9 +15090,9 @@ async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers
14016
15090
  }
14017
15091
 
14018
15092
  /**
14019
- * Reads local Arcium environment information from environment variables.
15093
+ * Read local Arcium environment information from environment variables.
14020
15094
  * Only available in Node.js and when testing locally.
14021
- * @returns The local Arcium environment configuration.
15095
+ * @returns Local Arcium environment configuration.
14022
15096
  * @throws Error if called in a browser or if required environment variables are missing or invalid.
14023
15097
  */
14024
15098
  function getArciumEnv() {
@@ -14030,8 +15104,14 @@ function getArciumEnv() {
14030
15104
  if (isNaN(arciumClusterOffset)) {
14031
15105
  throw new Error('ARCIUM_CLUSTER_OFFSET environment variable is not set or is invalid (NaN).');
14032
15106
  }
15107
+ const arciumBackupClusterOffset = process.env.ARCIUM_BACKUP_CLUSTER_OFFSET;
15108
+ const arciumBackupClusterOffsetNumber = Number(arciumBackupClusterOffset);
15109
+ if (typeof arciumBackupClusterOffset !== 'undefined' && isNaN(arciumBackupClusterOffsetNumber)) {
15110
+ throw new Error('ARCIUM_BACKUP_CLUSTER_OFFSET environment variable is invalid (NaN).');
15111
+ }
14033
15112
  return {
14034
15113
  arciumClusterOffset,
15114
+ arciumBackupClusterOffset: arciumBackupClusterOffsetNumber,
14035
15115
  };
14036
15116
  }
14037
15117
  catch (e) {
@@ -14039,38 +15119,78 @@ function getArciumEnv() {
14039
15119
  }
14040
15120
  }
14041
15121
 
15122
+ const POLL_INTERVAL_MS = 500;
14042
15123
  /**
14043
- * Waits for the finalization of a computation by listening for the finalizeComputationEvent.
14044
- * Resolves with the transaction signature once the computation is finalized.
14045
- * @param provider - The Anchor provider to use for event listening.
14046
- * @param computationOffset - The offset of the computation to wait for.
14047
- * @param mxeProgramId - The public key of the MXE program.
14048
- * @param commitment - (Optional) The desired finality/commitment level (default: 'confirmed').
14049
- * @returns The transaction signature of the finalization event.
15124
+ * Wait for a computation to finalize by polling the computation account
15125
+ * status via HTTP RPC. Does not use WebSocket subscriptions.
15126
+ *
15127
+ * Polls every 500ms (same as Agave's send_and_confirm_transaction_with_config).
15128
+ * Return the most recent transaction signature on the computation account
15129
+ * once finalization is detected.
15130
+ *
15131
+ * @param provider - Anchor provider.
15132
+ * @param computationOffset - Computation offset to wait for.
15133
+ * @param mxeProgramId - MXE program public key.
15134
+ * @param commitment - Commitment level for RPC calls (default: 'confirmed').
15135
+ * @param timeoutMs - Maximum wait time in milliseconds (default: 120000).
15136
+ * @returns Transaction signature from the finalization.
15137
+ * @throws Error if the MXE account has no cluster assigned.
15138
+ * @throws Error if the computation does not finalize within timeoutMs.
14050
15139
  */
14051
- async function awaitComputationFinalization(provider, computationOffset, mxeProgramId, commitment = 'confirmed') {
15140
+ async function awaitComputationFinalization(provider, computationOffset, mxeProgramId, commitment = 'confirmed', timeoutMs = 120_000) {
15141
+ const conn = provider.connection;
14052
15142
  const arciumProgram = getArciumProgram(provider);
14053
- const eventListener = new anchor.EventManager(arciumProgram.programId, provider, arciumProgram.coder);
14054
- const finalizeComp = await awaitEvent(eventListener, 'finalizeComputationEvent', (e) => mxeProgramId.equals(e.mxeProgramId) && e.computationOffset.eq(computationOffset), commitment);
14055
- return finalizeComp.sig;
14056
- }
14057
- /**
14058
- * Waits for a specific event to occur, matching a custom check, and returns the event and its signature.
14059
- * @param eventListener - The EventManager instance to use for listening.
14060
- * @param eventName - The name of the event to listen for.
14061
- * @param eventCheck - A predicate function to check if the event matches the desired criteria.
14062
- * @param commitment - (Optional) The desired finality/commitment level (default: 'confirmed').
14063
- * @returns An object containing the event and its transaction signature.
14064
- */
14065
- async function awaitEvent(eventListener, eventName, eventCheck, commitment = 'confirmed') {
14066
- const foundEvent = await new Promise((res) => {
14067
- const listenerId = eventListener.addEventListener(eventName, (event, _slot, signature) => {
14068
- if (eventCheck(event))
14069
- res([event, signature, listenerId]);
14070
- }, commitment);
14071
- });
14072
- await eventListener.removeEventListener(foundEvent[2]);
14073
- return { event: foundEvent[0], sig: foundEvent[1] };
15143
+ // Derive computation account PDA (requires clusterOffset from MXE account)
15144
+ const mxeAccAddress = getMXEAccAddress(mxeProgramId);
15145
+ const mxeAcc = await arciumProgram.account.mxeAccount.fetch(mxeAccAddress, commitment);
15146
+ if (mxeAcc.cluster === null) {
15147
+ throw new Error('MXE account has no cluster assigned');
15148
+ }
15149
+ const compAccAddress = getComputationAccAddress(mxeAcc.cluster, computationOffset);
15150
+ const startTime = Date.now();
15151
+ let lastStatus = 'unknown';
15152
+ let rpcErrorCount = 0;
15153
+ let lastError;
15154
+ while (Date.now() - startTime < timeoutMs) {
15155
+ let compAcc;
15156
+ try {
15157
+ // eslint-disable-next-line no-await-in-loop
15158
+ compAcc = await arciumProgram.account.computationAccount.fetchNullable(compAccAddress, commitment);
15159
+ }
15160
+ catch (e) {
15161
+ rpcErrorCount++;
15162
+ lastError = e instanceof Error ? e.message : String(e);
15163
+ // eslint-disable-next-line no-await-in-loop
15164
+ await new Promise((r) => {
15165
+ setTimeout(r, POLL_INTERVAL_MS);
15166
+ });
15167
+ continue;
15168
+ }
15169
+ if (compAcc !== null && 'finalized' in compAcc.status) {
15170
+ lastStatus = 'finalized';
15171
+ for (let sigRetry = 0; sigRetry < 10; sigRetry++) {
15172
+ // eslint-disable-next-line no-await-in-loop
15173
+ const sigs = await conn.getSignaturesForAddress(compAccAddress, { limit: 1 }, commitment);
15174
+ if (sigs.length > 0)
15175
+ return sigs[0].signature;
15176
+ // eslint-disable-next-line no-await-in-loop
15177
+ await new Promise((r) => {
15178
+ setTimeout(r, POLL_INTERVAL_MS);
15179
+ });
15180
+ }
15181
+ throw new Error('Computation finalized but transaction signature not indexed after retries.');
15182
+ }
15183
+ if (compAcc !== null)
15184
+ lastStatus = 'queued';
15185
+ // eslint-disable-next-line no-await-in-loop
15186
+ await new Promise((r) => {
15187
+ setTimeout(r, POLL_INTERVAL_MS);
15188
+ });
15189
+ }
15190
+ const timeoutMsg = `Computation did not finalize within ${timeoutMs}ms (status: ${lastStatus})`;
15191
+ throw rpcErrorCount > 0
15192
+ ? new Error(timeoutMsg, { cause: new Error(`${rpcErrorCount} RPC errors, last: ${lastError}`) })
15193
+ : new Error(timeoutMsg);
14074
15194
  }
14075
15195
 
14076
15196
  Object.defineProperty(exports, "x25519", {