@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/README.md +7 -4
- package/build/index.cjs +1652 -532
- package/build/index.d.ts +1424 -331
- package/build/index.mjs +1653 -533
- package/package.json +1 -1
package/build/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ export { x25519 } from '@noble/curves/ed25519';
|
|
|
4
4
|
import { shake256, sha3_512 } from '@noble/hashes/sha3';
|
|
5
5
|
import { invert, mod, isNegativeLE, pow2 } from '@noble/curves/abstract/modular';
|
|
6
6
|
import * as anchor from '@coral-xyz/anchor';
|
|
7
|
-
import { Program
|
|
7
|
+
import { Program } from '@coral-xyz/anchor';
|
|
8
8
|
import { randomBytes as randomBytes$1 } from '@noble/hashes/utils';
|
|
9
9
|
import { twistedEdwards } from '@noble/curves/abstract/edwards';
|
|
10
10
|
import fs from 'fs';
|
|
@@ -15,9 +15,9 @@ import { PublicKey, AddressLookupTableProgram } from '@solana/web3.js';
|
|
|
15
15
|
*/
|
|
16
16
|
const CURVE25519_SCALAR_FIELD_MODULUS = ed25519.CURVE.n;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param q -
|
|
20
|
-
* @returns
|
|
18
|
+
* Generate a random value within the field bound by q.
|
|
19
|
+
* @param q - Upper bound (exclusive) for the random value.
|
|
20
|
+
* @returns Random bigint value between 0 and q-1.
|
|
21
21
|
*/
|
|
22
22
|
function generateRandomFieldElem(q) {
|
|
23
23
|
const byteLength = (q.toString(2).length + 7) >> 3;
|
|
@@ -29,19 +29,19 @@ function generateRandomFieldElem(q) {
|
|
|
29
29
|
return r;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @param a -
|
|
34
|
-
* @param m -
|
|
35
|
-
* @returns
|
|
32
|
+
* Compute the positive modulo of a over m.
|
|
33
|
+
* @param a - Dividend.
|
|
34
|
+
* @param m - Modulus.
|
|
35
|
+
* @returns Positive remainder of a mod m.
|
|
36
36
|
*/
|
|
37
37
|
function positiveModulo(a, m) {
|
|
38
38
|
return ((a % m) + m) % m;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param val -
|
|
43
|
-
* @param lengthInBytes -
|
|
44
|
-
* @returns
|
|
41
|
+
* Serialize a bigint to a little-endian Uint8Array of the specified length.
|
|
42
|
+
* @param val - Bigint value to serialize.
|
|
43
|
+
* @param lengthInBytes - Desired length of the output array.
|
|
44
|
+
* @returns Serialized value as a Uint8Array.
|
|
45
45
|
* @throws Error if the value is too large for the specified length.
|
|
46
46
|
*/
|
|
47
47
|
function serializeLE(val, lengthInBytes) {
|
|
@@ -57,9 +57,9 @@ function serializeLE(val, lengthInBytes) {
|
|
|
57
57
|
return result;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param bytes -
|
|
62
|
-
* @returns
|
|
60
|
+
* Deserialize a little-endian Uint8Array to a bigint.
|
|
61
|
+
* @param bytes - Uint8Array to deserialize.
|
|
62
|
+
* @returns Deserialized bigint value.
|
|
63
63
|
*/
|
|
64
64
|
function deserializeLE(bytes) {
|
|
65
65
|
let result = BigInt(0);
|
|
@@ -70,9 +70,9 @@ function deserializeLE(bytes) {
|
|
|
70
70
|
}
|
|
71
71
|
// GENERAL
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @param byteArrays -
|
|
75
|
-
* @returns
|
|
73
|
+
* Compute the SHA-256 hash of an array of Uint8Arrays.
|
|
74
|
+
* @param byteArrays - Arrays to hash.
|
|
75
|
+
* @returns SHA-256 hash as a Buffer.
|
|
76
76
|
*/
|
|
77
77
|
function sha256(byteArrays) {
|
|
78
78
|
const hash = createHash('sha256');
|
|
@@ -83,10 +83,10 @@ function sha256(byteArrays) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @param x -
|
|
88
|
-
* @param binSize -
|
|
89
|
-
* @returns
|
|
86
|
+
* Convert a bigint to an array of bits (least significant to most significant, in 2's complement representation).
|
|
87
|
+
* @param x - Bigint to convert.
|
|
88
|
+
* @param binSize - Number of bits to use in the representation.
|
|
89
|
+
* @returns Array of booleans representing the bits of x.
|
|
90
90
|
*/
|
|
91
91
|
function toBinLE(x, binSize) {
|
|
92
92
|
const res = [];
|
|
@@ -96,9 +96,9 @@ function toBinLE(x, binSize) {
|
|
|
96
96
|
return res;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @param xBin -
|
|
101
|
-
* @returns
|
|
99
|
+
* Convert an array of bits (least significant to most significant, in 2's complement representation) to a bigint.
|
|
100
|
+
* @param xBin - Array of bits to convert.
|
|
101
|
+
* @returns Bigint represented by the bit array.
|
|
102
102
|
*/
|
|
103
103
|
function fromBinLE(xBin) {
|
|
104
104
|
let res = 0n;
|
|
@@ -109,11 +109,11 @@ function fromBinLE(xBin) {
|
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Binary adder between x and y (assumes xBin and yBin are of the same length and large enough to represent the sum).
|
|
112
|
-
* @param xBin -
|
|
113
|
-
* @param yBin -
|
|
114
|
-
* @param carryIn -
|
|
115
|
-
* @param binSize -
|
|
116
|
-
* @returns
|
|
112
|
+
* @param xBin - First operand as a bit array.
|
|
113
|
+
* @param yBin - Second operand as a bit array.
|
|
114
|
+
* @param carryIn - Initial carry-in value.
|
|
115
|
+
* @param binSize - Number of bits to use in the operation.
|
|
116
|
+
* @returns Sum as a bit array.
|
|
117
117
|
*/
|
|
118
118
|
function adder(xBin, yBin, carryIn, binSize) {
|
|
119
119
|
const res = [];
|
|
@@ -131,10 +131,10 @@ function adder(xBin, yBin, carryIn, binSize) {
|
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Constant-time addition of two bigints, using 2's complement representation.
|
|
134
|
-
* @param x -
|
|
135
|
-
* @param y -
|
|
136
|
-
* @param binSize -
|
|
137
|
-
* @returns
|
|
134
|
+
* @param x - First operand.
|
|
135
|
+
* @param y - Second operand.
|
|
136
|
+
* @param binSize - Number of bits to use in the operation.
|
|
137
|
+
* @returns Sum as a bigint.
|
|
138
138
|
*/
|
|
139
139
|
function ctAdd(x, y, binSize) {
|
|
140
140
|
const resBin = adder(toBinLE(x, binSize), toBinLE(y, binSize), false, binSize);
|
|
@@ -142,10 +142,10 @@ function ctAdd(x, y, binSize) {
|
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Constant-time subtraction of two bigints, using 2's complement representation.
|
|
145
|
-
* @param x -
|
|
146
|
-
* @param y -
|
|
147
|
-
* @param binSize -
|
|
148
|
-
* @returns
|
|
145
|
+
* @param x - First operand.
|
|
146
|
+
* @param y - Second operand.
|
|
147
|
+
* @param binSize - Number of bits to use in the operation.
|
|
148
|
+
* @returns Difference as a bigint.
|
|
149
149
|
*/
|
|
150
150
|
function ctSub(x, y, binSize) {
|
|
151
151
|
const yBin = toBinLE(y, binSize);
|
|
@@ -157,9 +157,9 @@ function ctSub(x, y, binSize) {
|
|
|
157
157
|
return fromBinLE(resBin);
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
|
-
*
|
|
161
|
-
* @param x -
|
|
162
|
-
* @param binSize -
|
|
160
|
+
* Return the sign bit of a bigint in constant time.
|
|
161
|
+
* @param x - Bigint to check.
|
|
162
|
+
* @param binSize - Bit position to check (typically the highest bit).
|
|
163
163
|
* @returns True if the sign bit is set, false otherwise.
|
|
164
164
|
*/
|
|
165
165
|
function ctSignBit(x, binSize) {
|
|
@@ -167,9 +167,9 @@ function ctSignBit(x, binSize) {
|
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* Constant-time less-than comparison for two bigints.
|
|
170
|
-
* @param x -
|
|
171
|
-
* @param y -
|
|
172
|
-
* @param binSize -
|
|
170
|
+
* @param x - First operand.
|
|
171
|
+
* @param y - Second operand.
|
|
172
|
+
* @param binSize - Number of bits to use in the operation.
|
|
173
173
|
* @returns True if x < y, false otherwise.
|
|
174
174
|
*/
|
|
175
175
|
function ctLt(x, y, binSize) {
|
|
@@ -177,21 +177,21 @@ function ctLt(x, y, binSize) {
|
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
179
|
* Constant-time select between two bigints based on a boolean condition.
|
|
180
|
-
* @param b -
|
|
181
|
-
* @param x -
|
|
182
|
-
* @param y -
|
|
183
|
-
* @param binSize -
|
|
184
|
-
* @returns
|
|
180
|
+
* @param b - Condition; if true, select x, otherwise select y.
|
|
181
|
+
* @param x - Value to select if b is true.
|
|
182
|
+
* @param y - Value to select if b is false.
|
|
183
|
+
* @param binSize - Number of bits to use in the operation.
|
|
184
|
+
* @returns Selected bigint.
|
|
185
185
|
*/
|
|
186
186
|
function ctSelect(b, x, y, binSize) {
|
|
187
187
|
return ctAdd(y, BigInt(b) * (ctSub(x, y, binSize)), binSize);
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
|
-
*
|
|
190
|
+
* Check if a bigint fits in the range -2^binSize <= x < 2^binSize.
|
|
191
191
|
* Not constant-time for arbitrary x, but is constant-time for all inputs for which the function returns true.
|
|
192
192
|
* If you assert your inputs satisfy verifyBinSize(x, binSize), you need not care about the non constant-timeness of this function.
|
|
193
|
-
* @param x -
|
|
194
|
-
* @param binSize -
|
|
193
|
+
* @param x - Bigint to check.
|
|
194
|
+
* @param binSize - Number of bits to use in the check.
|
|
195
195
|
* @returns True if x fits in the range, false otherwise.
|
|
196
196
|
*/
|
|
197
197
|
function verifyBinSize(x, binSize) {
|
|
@@ -200,8 +200,8 @@ function verifyBinSize(x, binSize) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
|
-
*
|
|
204
|
-
* @returns true if window object exists, false otherwise
|
|
203
|
+
* Check if code is running in a browser environment.
|
|
204
|
+
* @returns true if window object exists, false otherwise.
|
|
205
205
|
*/
|
|
206
206
|
function isBrowser() {
|
|
207
207
|
return (
|
|
@@ -210,8 +210,8 @@ function isBrowser() {
|
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
212
|
* Conditionally logs a message if logging is enabled.
|
|
213
|
-
* @param log - Whether to output the log
|
|
214
|
-
* @param args - Arguments to pass to console.log
|
|
213
|
+
* @param log - Whether to output the log.
|
|
214
|
+
* @param args - Arguments to pass to console.log.
|
|
215
215
|
*/
|
|
216
216
|
function optionalLog(log, ...args) {
|
|
217
217
|
if (log) {
|
|
@@ -220,10 +220,10 @@ function optionalLog(log, ...args) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
|
-
*
|
|
223
|
+
* Calculate the minimum number of bits needed to represent a value.
|
|
224
224
|
* Formula: floor(log2(max)) + 1 for unsigned, +1 for signed, +1 for diff of two negatives.
|
|
225
|
-
* @param max -
|
|
226
|
-
* @returns Number of bits required
|
|
225
|
+
* @param max - Bigint value to measure.
|
|
226
|
+
* @returns Number of bits required.
|
|
227
227
|
*/
|
|
228
228
|
function getBinSize(max) {
|
|
229
229
|
// floor(log2(max)) + 1 to represent unsigned elements, a +1 for signed elements
|
|
@@ -235,11 +235,11 @@ function getBinSize(max) {
|
|
|
235
235
|
*/
|
|
236
236
|
const DOUBLE_PRECISION_MANTISSA = 52;
|
|
237
237
|
/**
|
|
238
|
-
*
|
|
238
|
+
* Encode a value as a bigint suitable for Rescue encryption, handling booleans, bigints, and numbers.
|
|
239
239
|
* The encoding is performed in constant-time to avoid leaking information through timing side-channels.
|
|
240
240
|
* Throws if the value is out of the supported range for the field.
|
|
241
|
-
* @param v -
|
|
242
|
-
* @returns
|
|
241
|
+
* @param v - Value to encode (bigint, number, or boolean).
|
|
242
|
+
* @returns Encoded value as a bigint.
|
|
243
243
|
*/
|
|
244
244
|
function encodeAsRescueEncryptable(v) {
|
|
245
245
|
if (typeof v === 'boolean') {
|
|
@@ -263,10 +263,10 @@ function encodeAsRescueEncryptable(v) {
|
|
|
263
263
|
throw new Error('Invalid type to convert from number to bigint');
|
|
264
264
|
}
|
|
265
265
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* @param v -
|
|
269
|
-
* @returns
|
|
266
|
+
* Decode a Rescue-decrypted value back to a signed bigint.
|
|
267
|
+
* Handle the conversion from field element representation to signed integer.
|
|
268
|
+
* @param v - Decrypted field element value.
|
|
269
|
+
* @returns Decoded signed bigint value.
|
|
270
270
|
*/
|
|
271
271
|
function decodeRescueDecryptedToBigInt(v) {
|
|
272
272
|
const twoInv = (CURVE25519_BASE_FIELD.ORDER + 1n) / 2n;
|
|
@@ -275,19 +275,19 @@ function decodeRescueDecryptedToBigInt(v) {
|
|
|
275
275
|
return ctSelect(isLtTwoInv, v, ctSub(v, CURVE25519_BASE_FIELD.ORDER, binSize), binSize);
|
|
276
276
|
}
|
|
277
277
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
* @param v -
|
|
281
|
-
* @returns
|
|
278
|
+
* Decode a Rescue-decrypted value back to a JavaScript number.
|
|
279
|
+
* Convert from field element representation to a floating-point number.
|
|
280
|
+
* @param v - Decrypted field element value.
|
|
281
|
+
* @returns Decoded number value.
|
|
282
282
|
*/
|
|
283
283
|
function decodeRescueDecryptedToNumber(v) {
|
|
284
284
|
const vSigned = decodeRescueDecryptedToBigInt(v);
|
|
285
285
|
return Number(vSigned) * 2 ** -DOUBLE_PRECISION_MANTISSA;
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
288
|
-
*
|
|
289
|
-
* @param ref -
|
|
290
|
-
* @returns true if the reference is null, false otherwise
|
|
288
|
+
* Check if a computation reference is null (all zeros).
|
|
289
|
+
* @param ref - Computation reference to check.
|
|
290
|
+
* @returns true if the reference is null, false otherwise.
|
|
291
291
|
*/
|
|
292
292
|
function isNullRef(ref) {
|
|
293
293
|
const bigZero = new anchor.BN(0);
|
|
@@ -296,7 +296,9 @@ function isNullRef(ref) {
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
/**
|
|
299
|
-
* Matrix
|
|
299
|
+
* Matrix operations for MPC field arithmetic.
|
|
300
|
+
* Used internally by Rescue cipher. Not part of public API.
|
|
301
|
+
* @internal
|
|
300
302
|
*/
|
|
301
303
|
class Matrix {
|
|
302
304
|
field;
|
|
@@ -414,8 +416,8 @@ class Matrix {
|
|
|
414
416
|
return new Matrix(this.field, data);
|
|
415
417
|
}
|
|
416
418
|
/**
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
+
* Compute the determinant using Gauss elimination.
|
|
420
|
+
* Match the determinant implementation in Arcis.
|
|
419
421
|
*/
|
|
420
422
|
det() {
|
|
421
423
|
// Ensure the matrix is square
|
|
@@ -465,6 +467,10 @@ class Matrix {
|
|
|
465
467
|
return true;
|
|
466
468
|
}
|
|
467
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Generate random matrix for testing.
|
|
472
|
+
* @internal
|
|
473
|
+
*/
|
|
468
474
|
function randMatrix(field, nrows, ncols) {
|
|
469
475
|
const data = [];
|
|
470
476
|
for (let i = 0; i < nrows; ++i) {
|
|
@@ -510,10 +516,10 @@ class RescueDesc {
|
|
|
510
516
|
// The round keys, needed for encryption and decryption.
|
|
511
517
|
roundKeys;
|
|
512
518
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
* @param field -
|
|
516
|
-
* @param mode -
|
|
519
|
+
* Construct a RescueDesc for a given field and mode (cipher or hash).
|
|
520
|
+
* Initialize round constants, MDS matrix, and key schedule.
|
|
521
|
+
* @param field - Field to use (e.g., CURVE25519_BASE_FIELD).
|
|
522
|
+
* @param mode - Mode: block cipher or hash function.
|
|
517
523
|
*/
|
|
518
524
|
constructor(field, mode) {
|
|
519
525
|
this.field = field;
|
|
@@ -561,9 +567,9 @@ class RescueDesc {
|
|
|
561
567
|
}
|
|
562
568
|
}
|
|
563
569
|
/**
|
|
564
|
-
*
|
|
565
|
-
* @param nRounds -
|
|
566
|
-
* @returns
|
|
570
|
+
* Sample round constants for the Rescue permutation, using SHAKE256.
|
|
571
|
+
* @param nRounds - Number of rounds.
|
|
572
|
+
* @returns Array of round constant matrices.
|
|
567
573
|
*/
|
|
568
574
|
sampleConstants(nRounds) {
|
|
569
575
|
const field = this.field;
|
|
@@ -639,28 +645,28 @@ class RescueDesc {
|
|
|
639
645
|
}
|
|
640
646
|
}
|
|
641
647
|
/**
|
|
642
|
-
*
|
|
643
|
-
* @param state -
|
|
644
|
-
* @returns
|
|
648
|
+
* Apply the Rescue permutation to a state matrix.
|
|
649
|
+
* @param state - Input state matrix.
|
|
650
|
+
* @returns Permuted state matrix.
|
|
645
651
|
*/
|
|
646
652
|
permute(state) {
|
|
647
653
|
return rescuePermutation(this.mode, this.alpha, this.alphaInverse, this.mdsMat, this.roundKeys, state)[2 * this.nRounds];
|
|
648
654
|
}
|
|
649
655
|
/**
|
|
650
|
-
*
|
|
651
|
-
* @param state -
|
|
652
|
-
* @returns
|
|
656
|
+
* Apply the inverse Rescue permutation to a state matrix.
|
|
657
|
+
* @param state - Input state matrix.
|
|
658
|
+
* @returns Inverse-permuted state matrix.
|
|
653
659
|
*/
|
|
654
660
|
permuteInverse(state) {
|
|
655
661
|
return rescuePermutationInverse(this.mode, this.alpha, this.alphaInverse, this.mdsMatInverse, this.roundKeys, state)[2 * this.nRounds];
|
|
656
662
|
}
|
|
657
663
|
}
|
|
658
664
|
/**
|
|
659
|
-
*
|
|
665
|
+
* Find the smallest prime alpha that does not divide p-1, and compute its inverse modulo p-1.
|
|
660
666
|
* The alpha parameter is used in the Rescue permutation for exponentiation operations.
|
|
661
|
-
* @param p -
|
|
662
|
-
* @returns
|
|
663
|
-
* @throws Error if no suitable prime alpha is found
|
|
667
|
+
* @param p - Field modulus (prime number).
|
|
668
|
+
* @returns Tuple [alpha, alphaInverse] where alpha is the prime and alphaInverse is its modular inverse.
|
|
669
|
+
* @throws Error if no suitable prime alpha is found.
|
|
664
670
|
*/
|
|
665
671
|
function getAlphaAndInverse(p) {
|
|
666
672
|
const pMinusOne = p - 1n;
|
|
@@ -678,14 +684,14 @@ function getAlphaAndInverse(p) {
|
|
|
678
684
|
return [alpha, alphaInverse];
|
|
679
685
|
}
|
|
680
686
|
/**
|
|
681
|
-
*
|
|
687
|
+
* Calculate the number of rounds required for the Rescue permutation based on security analysis.
|
|
682
688
|
* The number of rounds is determined by analyzing resistance to differential and algebraic attacks.
|
|
683
689
|
* See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287 for the security analysis.
|
|
684
|
-
* @param p -
|
|
685
|
-
* @param mode -
|
|
686
|
-
* @param alpha -
|
|
687
|
-
* @param m -
|
|
688
|
-
* @returns
|
|
690
|
+
* @param p - Field modulus.
|
|
691
|
+
* @param mode - Rescue mode (cipher or hash).
|
|
692
|
+
* @param alpha - Prime alpha parameter.
|
|
693
|
+
* @param m - State size (block size for cipher, total size for hash).
|
|
694
|
+
* @returns Number of rounds (will be doubled for the full permutation).
|
|
689
695
|
*/
|
|
690
696
|
function getNRounds(p, mode, alpha, m) {
|
|
691
697
|
function dcon(n) {
|
|
@@ -732,12 +738,12 @@ function getNRounds(p, mode, alpha, m) {
|
|
|
732
738
|
}
|
|
733
739
|
}
|
|
734
740
|
/**
|
|
735
|
-
*
|
|
741
|
+
* Build a Cauchy matrix for use as an MDS (Maximum Distance Separable) matrix.
|
|
736
742
|
* A Cauchy matrix is guaranteed to be invertible and provides optimal diffusion properties.
|
|
737
743
|
* The matrix is constructed using the formula: M[i][j] = 1/(i + j) for i, j in [1, size].
|
|
738
|
-
* @param field -
|
|
739
|
-
* @param size -
|
|
740
|
-
* @returns
|
|
744
|
+
* @param field - Finite field over which to construct the matrix.
|
|
745
|
+
* @param size - Size of the square matrix.
|
|
746
|
+
* @returns Cauchy matrix of the specified size.
|
|
741
747
|
*/
|
|
742
748
|
function buildCauchy(field, size) {
|
|
743
749
|
const data = [];
|
|
@@ -751,11 +757,11 @@ function buildCauchy(field, size) {
|
|
|
751
757
|
return new Matrix(field, data);
|
|
752
758
|
}
|
|
753
759
|
/**
|
|
754
|
-
*
|
|
760
|
+
* Build the inverse of a Cauchy matrix for use as the inverse MDS matrix.
|
|
755
761
|
* The inverse is computed using a closed-form formula for Cauchy matrix inversion.
|
|
756
|
-
* @param field -
|
|
757
|
-
* @param size -
|
|
758
|
-
* @returns
|
|
762
|
+
* @param field - Finite field over which to construct the matrix.
|
|
763
|
+
* @param size - Size of the square matrix.
|
|
764
|
+
* @returns Inverse of the Cauchy matrix.
|
|
759
765
|
*/
|
|
760
766
|
function buildInverseCauchy(field, size) {
|
|
761
767
|
function product(arr) {
|
|
@@ -812,16 +818,16 @@ function exponentForOdd(mode, alpha, alphaInverse) {
|
|
|
812
818
|
}
|
|
813
819
|
/**
|
|
814
820
|
* Core Rescue permutation function implementing the cryptographic primitive.
|
|
815
|
-
*
|
|
821
|
+
* Apply alternating rounds of exponentiation and MDS matrix multiplication with round keys.
|
|
816
822
|
* The permutation alternates between using alpha and alphaInverse as exponents based on round parity.
|
|
817
823
|
* This is the fundamental building block for both Rescue cipher and Rescue-Prime hash.
|
|
818
|
-
* @param mode -
|
|
819
|
-
* @param alpha -
|
|
820
|
-
* @param alphaInverse -
|
|
821
|
-
* @param mdsMat -
|
|
822
|
-
* @param subkeys - Array of round key matrices
|
|
823
|
-
* @param state -
|
|
824
|
-
* @returns Array of all intermediate states during the permutation
|
|
824
|
+
* @param mode - Rescue mode (cipher or hash) determining exponent selection.
|
|
825
|
+
* @param alpha - Prime exponent for even rounds.
|
|
826
|
+
* @param alphaInverse - Inverse exponent for odd rounds.
|
|
827
|
+
* @param mdsMat - Maximum Distance Separable matrix for diffusion.
|
|
828
|
+
* @param subkeys - Array of round key matrices.
|
|
829
|
+
* @param state - Initial state matrix to permute.
|
|
830
|
+
* @returns Array of all intermediate states during the permutation.
|
|
825
831
|
*/
|
|
826
832
|
function rescuePermutation(mode, alpha, alphaInverse, mdsMat, subkeys, state) {
|
|
827
833
|
const exponentEven = exponentForEven(mode, alpha, alphaInverse);
|
|
@@ -878,7 +884,7 @@ class RescuePrimeHash {
|
|
|
878
884
|
rate;
|
|
879
885
|
digestLength;
|
|
880
886
|
/**
|
|
881
|
-
*
|
|
887
|
+
* Construct a RescuePrimeHash instance with rate = 7 and capacity = 5.
|
|
882
888
|
*/
|
|
883
889
|
constructor(field) {
|
|
884
890
|
this.desc = new RescueDesc(field, { kind: 'hash', m: 12, capacity: 5 });
|
|
@@ -892,9 +898,9 @@ class RescuePrimeHash {
|
|
|
892
898
|
// The security level is thus of the order of 256 bits for any field of size at least 102 bits.
|
|
893
899
|
// The rate and capacity are chosen to achieve minimal number of rounds 8.
|
|
894
900
|
/**
|
|
895
|
-
*
|
|
896
|
-
* @param message -
|
|
897
|
-
* @returns
|
|
901
|
+
* Compute the Rescue-Prime hash of a message, with padding as described in Algorithm 2 of the paper.
|
|
902
|
+
* @param message - Input message as an array of bigints.
|
|
903
|
+
* @returns Hash output as an array of bigints (length = digestLength).
|
|
898
904
|
*/
|
|
899
905
|
digest(message) {
|
|
900
906
|
// Create a copy and pad message to avoid mutating input parameter
|
|
@@ -938,9 +944,9 @@ const RESCUE_CIPHER_BLOCK_SIZE = 5;
|
|
|
938
944
|
class RescueCipherCommon {
|
|
939
945
|
desc;
|
|
940
946
|
/**
|
|
941
|
-
*
|
|
947
|
+
* Construct a RescueCipherCommon instance using a shared secret.
|
|
942
948
|
* The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
|
|
943
|
-
* @param sharedSecret -
|
|
949
|
+
* @param sharedSecret - Shared secret to derive the cipher key from.
|
|
944
950
|
*/
|
|
945
951
|
constructor(sharedSecret, field) {
|
|
946
952
|
if (sharedSecret.length != 32) {
|
|
@@ -974,10 +980,10 @@ class RescueCipherCommon {
|
|
|
974
980
|
this.desc = new RescueDesc(field, { kind: 'cipher', key: rescueKey });
|
|
975
981
|
}
|
|
976
982
|
/**
|
|
977
|
-
*
|
|
978
|
-
* @param plaintext -
|
|
979
|
-
* @param nonce -
|
|
980
|
-
* @returns
|
|
983
|
+
* Encrypt the plaintext vector in Counter (CTR) mode (raw, returns bigints).
|
|
984
|
+
* @param plaintext - Array of plaintext bigints to encrypt.
|
|
985
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
986
|
+
* @returns Ciphertext as an array of bigints.
|
|
981
987
|
* @throws Error if the nonce is not 16 bytes long.
|
|
982
988
|
*/
|
|
983
989
|
encrypt_raw(plaintext, nonce) {
|
|
@@ -1013,19 +1019,19 @@ class RescueCipherCommon {
|
|
|
1013
1019
|
return ciphertext;
|
|
1014
1020
|
}
|
|
1015
1021
|
/**
|
|
1016
|
-
*
|
|
1017
|
-
* @param plaintext -
|
|
1018
|
-
* @param nonce -
|
|
1019
|
-
* @returns
|
|
1022
|
+
* Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
|
|
1023
|
+
* @param plaintext - Array of plaintext bigints to encrypt.
|
|
1024
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
1025
|
+
* @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
|
|
1020
1026
|
*/
|
|
1021
1027
|
encrypt(plaintext, nonce) {
|
|
1022
1028
|
return this.encrypt_raw(plaintext, nonce).map((c) => Array.from(serializeLE(c, 32)));
|
|
1023
1029
|
}
|
|
1024
1030
|
/**
|
|
1025
|
-
*
|
|
1026
|
-
* @param ciphertext -
|
|
1027
|
-
* @param nonce -
|
|
1028
|
-
* @returns
|
|
1031
|
+
* Decrypt the ciphertext vector in Counter (CTR) mode (raw, expects bigints).
|
|
1032
|
+
* @param ciphertext - Array of ciphertext bigints to decrypt.
|
|
1033
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
1034
|
+
* @returns Decrypted plaintext as an array of bigints.
|
|
1029
1035
|
* @throws Error if the nonce is not 16 bytes long.
|
|
1030
1036
|
*/
|
|
1031
1037
|
decrypt_raw(ciphertext, nonce) {
|
|
@@ -1058,10 +1064,10 @@ class RescueCipherCommon {
|
|
|
1058
1064
|
return decrypted;
|
|
1059
1065
|
}
|
|
1060
1066
|
/**
|
|
1061
|
-
*
|
|
1062
|
-
* @param ciphertext -
|
|
1063
|
-
* @param nonce -
|
|
1064
|
-
* @returns
|
|
1067
|
+
* Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
|
|
1068
|
+
* @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
|
|
1069
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
1070
|
+
* @returns Decrypted plaintext as an array of bigints.
|
|
1065
1071
|
*/
|
|
1066
1072
|
decrypt(ciphertext, nonce) {
|
|
1067
1073
|
return this.decrypt_raw(ciphertext.map((c) => {
|
|
@@ -1073,10 +1079,10 @@ class RescueCipherCommon {
|
|
|
1073
1079
|
}
|
|
1074
1080
|
}
|
|
1075
1081
|
/**
|
|
1076
|
-
*
|
|
1077
|
-
* @param nonce -
|
|
1078
|
-
* @param nBlocks -
|
|
1079
|
-
* @returns
|
|
1082
|
+
* Generate the counter values for Rescue cipher CTR mode.
|
|
1083
|
+
* @param nonce - Initial nonce as a bigint.
|
|
1084
|
+
* @param nBlocks - Number of blocks to generate counters for.
|
|
1085
|
+
* @returns Array of counter values as bigints.
|
|
1080
1086
|
*/
|
|
1081
1087
|
function getCounter(nonce, nBlocks) {
|
|
1082
1088
|
const counter = [];
|
|
@@ -1098,27 +1104,27 @@ function getCounter(nonce, nBlocks) {
|
|
|
1098
1104
|
class RescueCipher {
|
|
1099
1105
|
cipher;
|
|
1100
1106
|
/**
|
|
1101
|
-
*
|
|
1107
|
+
* Construct a RescueCipher instance using a shared secret.
|
|
1102
1108
|
* The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
|
|
1103
|
-
* @param sharedSecret -
|
|
1109
|
+
* @param sharedSecret - Shared secret to derive the cipher key from.
|
|
1104
1110
|
*/
|
|
1105
1111
|
constructor(sharedSecret) {
|
|
1106
1112
|
this.cipher = new RescueCipherCommon(sharedSecret, CURVE25519_BASE_FIELD);
|
|
1107
1113
|
}
|
|
1108
1114
|
/**
|
|
1109
|
-
*
|
|
1110
|
-
* @param plaintext -
|
|
1111
|
-
* @param nonce -
|
|
1112
|
-
* @returns
|
|
1115
|
+
* Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
|
|
1116
|
+
* @param plaintext - Array of plaintext bigints to encrypt.
|
|
1117
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
1118
|
+
* @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
|
|
1113
1119
|
*/
|
|
1114
1120
|
encrypt(plaintext, nonce) {
|
|
1115
1121
|
return this.cipher.encrypt(plaintext, nonce);
|
|
1116
1122
|
}
|
|
1117
1123
|
/**
|
|
1118
|
-
*
|
|
1119
|
-
* @param ciphertext -
|
|
1120
|
-
* @param nonce -
|
|
1121
|
-
* @returns
|
|
1124
|
+
* Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
|
|
1125
|
+
* @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
|
|
1126
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
1127
|
+
* @returns Decrypted plaintext as an array of bigints.
|
|
1122
1128
|
*/
|
|
1123
1129
|
decrypt(ciphertext, nonce) {
|
|
1124
1130
|
return this.cipher.decrypt(ciphertext, nonce);
|
|
@@ -1132,27 +1138,27 @@ class RescueCipher {
|
|
|
1132
1138
|
class CSplRescueCipher {
|
|
1133
1139
|
cipher;
|
|
1134
1140
|
/**
|
|
1135
|
-
*
|
|
1141
|
+
* Construct a CSplRescueCipher instance using a shared secret.
|
|
1136
1142
|
* The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
|
|
1137
|
-
* @param sharedSecret -
|
|
1143
|
+
* @param sharedSecret - Shared secret to derive the cipher key from.
|
|
1138
1144
|
*/
|
|
1139
1145
|
constructor(sharedSecret) {
|
|
1140
1146
|
this.cipher = new RescueCipherCommon(sharedSecret, CURVE25519_SCALAR_FIELD);
|
|
1141
1147
|
}
|
|
1142
1148
|
/**
|
|
1143
|
-
*
|
|
1144
|
-
* @param plaintext -
|
|
1145
|
-
* @param nonce -
|
|
1146
|
-
* @returns
|
|
1149
|
+
* Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
|
|
1150
|
+
* @param plaintext - Array of plaintext bigints to encrypt.
|
|
1151
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
1152
|
+
* @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
|
|
1147
1153
|
*/
|
|
1148
1154
|
encrypt(plaintext, nonce) {
|
|
1149
1155
|
return this.cipher.encrypt(plaintext, nonce);
|
|
1150
1156
|
}
|
|
1151
1157
|
/**
|
|
1152
|
-
*
|
|
1153
|
-
* @param ciphertext -
|
|
1154
|
-
* @param nonce -
|
|
1155
|
-
* @returns
|
|
1158
|
+
* Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
|
|
1159
|
+
* @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
|
|
1160
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
1161
|
+
* @returns Decrypted plaintext as an array of bigints.
|
|
1156
1162
|
*/
|
|
1157
1163
|
decrypt(ciphertext, nonce) {
|
|
1158
1164
|
return this.cipher.decrypt(ciphertext, nonce);
|
|
@@ -1206,10 +1212,10 @@ function ed25519_pow_2_252_3(x) {
|
|
|
1206
1212
|
// Fp.sqrt(Fp.neg(1))
|
|
1207
1213
|
const ED25519_SQRT_M1 = /* @__PURE__ */ BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');
|
|
1208
1214
|
/**
|
|
1209
|
-
*
|
|
1215
|
+
* Clamp a 32-byte scalar as required by the Ed25519 signature scheme.
|
|
1210
1216
|
* See: https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.5
|
|
1211
|
-
* @param bytes -
|
|
1212
|
-
* @returns
|
|
1217
|
+
* @param bytes - 32-byte scalar to clamp.
|
|
1218
|
+
* @returns Clamped scalar as a Uint8Array.
|
|
1213
1219
|
*/
|
|
1214
1220
|
function adjustScalarBytes(bytes) {
|
|
1215
1221
|
const clamped = bytes;
|
|
@@ -1220,7 +1226,7 @@ function adjustScalarBytes(bytes) {
|
|
|
1220
1226
|
}
|
|
1221
1227
|
/**
|
|
1222
1228
|
* Helper function for decompression, calculating √(u/v).
|
|
1223
|
-
* @returns
|
|
1229
|
+
* @returns Object with isValid and value.
|
|
1224
1230
|
*/
|
|
1225
1231
|
function uvRatio(u, v) {
|
|
1226
1232
|
const P = ed25519.CURVE.Fp.ORDER;
|
|
@@ -1256,10 +1262,10 @@ class AesCtrCipher {
|
|
|
1256
1262
|
key;
|
|
1257
1263
|
keyBits;
|
|
1258
1264
|
/**
|
|
1259
|
-
*
|
|
1265
|
+
* Construct an AES cipher instance using a shared secret.
|
|
1260
1266
|
* The key is derived using SHA3-256.
|
|
1261
|
-
* @param sharedSecret -
|
|
1262
|
-
* @param keyBits -
|
|
1267
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
1268
|
+
* @param keyBits - AES key size in bits (128, 192, or 256).
|
|
1263
1269
|
*/
|
|
1264
1270
|
constructor(sharedSecret, keyBits) {
|
|
1265
1271
|
this.keyBits = keyBits;
|
|
@@ -1284,10 +1290,10 @@ class AesCtrCipher {
|
|
|
1284
1290
|
this.key = new Uint8Array(hasher.digest()).slice(0, KEY_BYTES[keyBits]);
|
|
1285
1291
|
}
|
|
1286
1292
|
/**
|
|
1287
|
-
*
|
|
1288
|
-
* @param plaintext -
|
|
1289
|
-
* @param nonce -
|
|
1290
|
-
* @returns
|
|
1293
|
+
* Encrypt the plaintext array in Counter (CTR) mode.
|
|
1294
|
+
* @param plaintext - Data to encrypt.
|
|
1295
|
+
* @param nonce - 8-byte nonce for CTR mode.
|
|
1296
|
+
* @returns Encrypted ciphertext as a Uint8Array.
|
|
1291
1297
|
* @throws Error if the nonce is not 8 bytes long.
|
|
1292
1298
|
*/
|
|
1293
1299
|
encrypt(plaintext, nonce) {
|
|
@@ -1300,10 +1306,10 @@ class AesCtrCipher {
|
|
|
1300
1306
|
return new Uint8Array(ciphertext);
|
|
1301
1307
|
}
|
|
1302
1308
|
/**
|
|
1303
|
-
*
|
|
1304
|
-
* @param ciphertext -
|
|
1305
|
-
* @param nonce -
|
|
1306
|
-
* @returns
|
|
1309
|
+
* Decrypt the ciphertext array in Counter (CTR) mode.
|
|
1310
|
+
* @param ciphertext - Data to decrypt.
|
|
1311
|
+
* @param nonce - 8-byte nonce for CTR mode.
|
|
1312
|
+
* @returns Decrypted plaintext as a Uint8Array.
|
|
1307
1313
|
* @throws Error if the nonce is not 8 bytes long.
|
|
1308
1314
|
*/
|
|
1309
1315
|
decrypt(ciphertext, nonce) {
|
|
@@ -1323,9 +1329,9 @@ class AesCtrCipher {
|
|
|
1323
1329
|
*/
|
|
1324
1330
|
class Aes128Cipher extends AesCtrCipher {
|
|
1325
1331
|
/**
|
|
1326
|
-
*
|
|
1332
|
+
* Construct an AES-128 cipher instance using a shared secret.
|
|
1327
1333
|
* The key is derived using SHA3-256.
|
|
1328
|
-
* @param sharedSecret -
|
|
1334
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
1329
1335
|
*/
|
|
1330
1336
|
constructor(sharedSecret) {
|
|
1331
1337
|
super(sharedSecret, 128);
|
|
@@ -1338,9 +1344,9 @@ class Aes128Cipher extends AesCtrCipher {
|
|
|
1338
1344
|
*/
|
|
1339
1345
|
class Aes192Cipher extends AesCtrCipher {
|
|
1340
1346
|
/**
|
|
1341
|
-
*
|
|
1347
|
+
* Construct an AES-192 cipher instance using a shared secret.
|
|
1342
1348
|
* The key is derived using SHA3-256.
|
|
1343
|
-
* @param sharedSecret -
|
|
1349
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
1344
1350
|
*/
|
|
1345
1351
|
constructor(sharedSecret) {
|
|
1346
1352
|
super(sharedSecret, 192);
|
|
@@ -1353,18 +1359,26 @@ class Aes192Cipher extends AesCtrCipher {
|
|
|
1353
1359
|
*/
|
|
1354
1360
|
class Aes256Cipher extends AesCtrCipher {
|
|
1355
1361
|
/**
|
|
1356
|
-
*
|
|
1362
|
+
* Construct an AES-256 cipher instance using a shared secret.
|
|
1357
1363
|
* The key is derived using SHA3-256.
|
|
1358
|
-
* @param sharedSecret -
|
|
1364
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
1359
1365
|
*/
|
|
1360
1366
|
constructor(sharedSecret) {
|
|
1361
1367
|
super(sharedSecret, 256);
|
|
1362
1368
|
}
|
|
1363
1369
|
}
|
|
1364
1370
|
|
|
1371
|
+
/**
|
|
1372
|
+
* Size descriptor for a single field in circuit packing.
|
|
1373
|
+
* A "full" field occupies an entire slot; partial fields are bin-packed together.
|
|
1374
|
+
* @internal
|
|
1375
|
+
*/
|
|
1365
1376
|
class DataSize {
|
|
1377
|
+
/** Whether this field occupies a full slot. */
|
|
1366
1378
|
isFull;
|
|
1379
|
+
/** Bit width of the field (0 if full). */
|
|
1367
1380
|
size;
|
|
1381
|
+
/** Original index in the fields array. */
|
|
1368
1382
|
index;
|
|
1369
1383
|
constructor(index, size) {
|
|
1370
1384
|
const isUndefined = size === undefined;
|
|
@@ -1384,8 +1398,14 @@ function sortDataSizes(arr) {
|
|
|
1384
1398
|
return left.index - right.index;
|
|
1385
1399
|
});
|
|
1386
1400
|
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Packed location of a field within the slot array.
|
|
1403
|
+
* @internal
|
|
1404
|
+
*/
|
|
1387
1405
|
class PackLocation {
|
|
1406
|
+
/** Slot index in the packed array. */
|
|
1388
1407
|
index;
|
|
1408
|
+
/** Bit offset within the slot. */
|
|
1389
1409
|
offset;
|
|
1390
1410
|
constructor(index, offset) {
|
|
1391
1411
|
this.index = index;
|
|
@@ -1444,6 +1464,12 @@ function packing(maxSize, arr) {
|
|
|
1444
1464
|
return [nPacks, res];
|
|
1445
1465
|
}
|
|
1446
1466
|
const ARCIS_PACKING_SIZE = 214;
|
|
1467
|
+
/**
|
|
1468
|
+
* Pack field sizes into minimum slots using the Arcium packing size (214 bits).
|
|
1469
|
+
* @param arr - Array of field size descriptors.
|
|
1470
|
+
* @returns Tuple of [total slot count, pack location for each input field].
|
|
1471
|
+
* @internal
|
|
1472
|
+
*/
|
|
1447
1473
|
function arcisPacking(arr) {
|
|
1448
1474
|
return packing(ARCIS_PACKING_SIZE, arr);
|
|
1449
1475
|
}
|
|
@@ -1460,6 +1486,10 @@ var ArcisValueKind;
|
|
|
1460
1486
|
ArcisValueKind[ArcisValueKind["Float"] = 3] = "Float";
|
|
1461
1487
|
ArcisValueKind[ArcisValueKind["Pubkey"] = 4] = "Pubkey";
|
|
1462
1488
|
})(ArcisValueKind || (ArcisValueKind = {}));
|
|
1489
|
+
/**
|
|
1490
|
+
* Integer type metadata. Used internally by packer.
|
|
1491
|
+
* @internal
|
|
1492
|
+
*/
|
|
1463
1493
|
class IntegerInfo {
|
|
1464
1494
|
signed;
|
|
1465
1495
|
width;
|
|
@@ -1482,6 +1512,10 @@ class IntegerInfo {
|
|
|
1482
1512
|
return (this.signed ? "i" : "u") + this.width;
|
|
1483
1513
|
}
|
|
1484
1514
|
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Runtime field representation. Used internally by packer.
|
|
1517
|
+
* @internal
|
|
1518
|
+
*/
|
|
1485
1519
|
class ArcisValueField {
|
|
1486
1520
|
name;
|
|
1487
1521
|
kind;
|
|
@@ -1657,6 +1691,10 @@ class ArcisValueField {
|
|
|
1657
1691
|
}
|
|
1658
1692
|
}
|
|
1659
1693
|
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Type container for pack/unpack operations. Used internally by packer.
|
|
1696
|
+
* @internal
|
|
1697
|
+
*/
|
|
1660
1698
|
class ArcisType {
|
|
1661
1699
|
name;
|
|
1662
1700
|
fields;
|
|
@@ -1701,11 +1739,21 @@ class ArcisType {
|
|
|
1701
1739
|
}
|
|
1702
1740
|
}
|
|
1703
1741
|
|
|
1742
|
+
/**
|
|
1743
|
+
* Container for circuit type definitions.
|
|
1744
|
+
* Loaded from generated JSON files by build tools -- not typically used directly.
|
|
1745
|
+
* @internal
|
|
1746
|
+
*/
|
|
1704
1747
|
class ArcisModule {
|
|
1748
|
+
/** Map of type name to parsed ArcisType. */
|
|
1705
1749
|
types;
|
|
1706
1750
|
constructor(types) {
|
|
1707
1751
|
this.types = types;
|
|
1708
1752
|
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Parse module from JSON object (as produced by the Arcium compiler).
|
|
1755
|
+
* @param json - Raw JSON object with type name keys.
|
|
1756
|
+
*/
|
|
1709
1757
|
static fromJson(json) {
|
|
1710
1758
|
const typedJson = json;
|
|
1711
1759
|
const res = {};
|
|
@@ -1714,6 +1762,10 @@ class ArcisModule {
|
|
|
1714
1762
|
}
|
|
1715
1763
|
return new ArcisModule(res);
|
|
1716
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Load module from a JSON file on disk.
|
|
1767
|
+
* @param path - Absolute or relative path to the JSON file.
|
|
1768
|
+
*/
|
|
1717
1769
|
static loadFromFile(path) {
|
|
1718
1770
|
const file = fs.readFileSync(path);
|
|
1719
1771
|
const json = JSON.parse(file.toString());
|
|
@@ -1760,10 +1812,33 @@ function groupUnpackedValues(values, fieldNames) {
|
|
|
1760
1812
|
return result;
|
|
1761
1813
|
}
|
|
1762
1814
|
/**
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
1765
|
-
*
|
|
1766
|
-
*
|
|
1815
|
+
* Create a type-safe packer from field definitions.
|
|
1816
|
+
*
|
|
1817
|
+
* Use `as const` on the fields array to enable compile-time field name validation.
|
|
1818
|
+
*
|
|
1819
|
+
* @param fields - Array of {@link FieldInfo} objects defining each field's name and type.
|
|
1820
|
+
* @param typeName - Optional name for debugging (default: 'Packer').
|
|
1821
|
+
* @returns Packer instance with pack() and unpack() methods.
|
|
1822
|
+
* @throws TypeError if field types don't match expected values during pack/unpack.
|
|
1823
|
+
* @throws RangeError if array index is out of bounds.
|
|
1824
|
+
*
|
|
1825
|
+
* @example
|
|
1826
|
+
* import { createPacker } from '@arcium-hq/client';
|
|
1827
|
+
*
|
|
1828
|
+
* // Define fields matching your circuit's input type
|
|
1829
|
+
* const fields = [
|
|
1830
|
+
* { name: 'a', type: { Integer: { signed: false, width: 32 } } },
|
|
1831
|
+
* { name: 'b', type: { Integer: { signed: false, width: 32 } } },
|
|
1832
|
+
* ] as const;
|
|
1833
|
+
*
|
|
1834
|
+
* // Create packer with explicit input/output types
|
|
1835
|
+
* const packer = createPacker<{ a: number; b: number }, { a: bigint; b: bigint }>(fields);
|
|
1836
|
+
*
|
|
1837
|
+
* // Pack values for circuit input
|
|
1838
|
+
* const packed = packer.pack({ a: 10, b: 20 });
|
|
1839
|
+
*
|
|
1840
|
+
* // Unpack circuit output (from decrypted computation result)
|
|
1841
|
+
* const result = packer.unpack(decryptedOutput);
|
|
1767
1842
|
*/
|
|
1768
1843
|
function createPacker(fields, typeName = 'Packer') {
|
|
1769
1844
|
const arcisFields = fields.map(f => ArcisValueField.fromFieldInfo(f));
|
|
@@ -1790,7 +1865,7 @@ function createPacker(fields, typeName = 'Packer') {
|
|
|
1790
1865
|
var address = "Arcj82pX7HxYKLR92qvgZUAd7vGS1k4hQvAFcPATFdEQ";
|
|
1791
1866
|
var metadata = {
|
|
1792
1867
|
name: "arcium",
|
|
1793
|
-
version: "0.
|
|
1868
|
+
version: "0.9.0",
|
|
1794
1869
|
spec: "0.1.0",
|
|
1795
1870
|
description: "The Arcium program"
|
|
1796
1871
|
};
|
|
@@ -1920,6 +1995,167 @@ var instructions = [
|
|
|
1920
1995
|
}
|
|
1921
1996
|
]
|
|
1922
1997
|
},
|
|
1998
|
+
{
|
|
1999
|
+
name: "add_permissioned_recovery_peers",
|
|
2000
|
+
docs: [
|
|
2001
|
+
"Add permissioned recovery peers"
|
|
2002
|
+
],
|
|
2003
|
+
discriminator: [
|
|
2004
|
+
190,
|
|
2005
|
+
177,
|
|
2006
|
+
28,
|
|
2007
|
+
28,
|
|
2008
|
+
204,
|
|
2009
|
+
131,
|
|
2010
|
+
176,
|
|
2011
|
+
251
|
|
2012
|
+
],
|
|
2013
|
+
accounts: [
|
|
2014
|
+
{
|
|
2015
|
+
name: "signer",
|
|
2016
|
+
writable: true,
|
|
2017
|
+
signer: true
|
|
2018
|
+
},
|
|
2019
|
+
{
|
|
2020
|
+
name: "permissioned_recovery_peers_acc",
|
|
2021
|
+
writable: true,
|
|
2022
|
+
pda: {
|
|
2023
|
+
seeds: [
|
|
2024
|
+
{
|
|
2025
|
+
kind: "const",
|
|
2026
|
+
value: [
|
|
2027
|
+
80,
|
|
2028
|
+
101,
|
|
2029
|
+
114,
|
|
2030
|
+
109,
|
|
2031
|
+
105,
|
|
2032
|
+
115,
|
|
2033
|
+
115,
|
|
2034
|
+
105,
|
|
2035
|
+
111,
|
|
2036
|
+
110,
|
|
2037
|
+
101,
|
|
2038
|
+
100,
|
|
2039
|
+
82,
|
|
2040
|
+
101,
|
|
2041
|
+
99,
|
|
2042
|
+
111,
|
|
2043
|
+
118,
|
|
2044
|
+
101,
|
|
2045
|
+
114,
|
|
2046
|
+
121,
|
|
2047
|
+
80,
|
|
2048
|
+
101,
|
|
2049
|
+
101,
|
|
2050
|
+
114,
|
|
2051
|
+
115,
|
|
2052
|
+
65,
|
|
2053
|
+
99,
|
|
2054
|
+
99,
|
|
2055
|
+
111,
|
|
2056
|
+
117,
|
|
2057
|
+
110,
|
|
2058
|
+
116
|
|
2059
|
+
]
|
|
2060
|
+
}
|
|
2061
|
+
]
|
|
2062
|
+
}
|
|
2063
|
+
},
|
|
2064
|
+
{
|
|
2065
|
+
name: "program_data",
|
|
2066
|
+
pda: {
|
|
2067
|
+
seeds: [
|
|
2068
|
+
{
|
|
2069
|
+
kind: "const",
|
|
2070
|
+
value: [
|
|
2071
|
+
146,
|
|
2072
|
+
111,
|
|
2073
|
+
9,
|
|
2074
|
+
170,
|
|
2075
|
+
109,
|
|
2076
|
+
72,
|
|
2077
|
+
125,
|
|
2078
|
+
226,
|
|
2079
|
+
216,
|
|
2080
|
+
140,
|
|
2081
|
+
55,
|
|
2082
|
+
106,
|
|
2083
|
+
22,
|
|
2084
|
+
29,
|
|
2085
|
+
7,
|
|
2086
|
+
127,
|
|
2087
|
+
176,
|
|
2088
|
+
129,
|
|
2089
|
+
11,
|
|
2090
|
+
19,
|
|
2091
|
+
35,
|
|
2092
|
+
107,
|
|
2093
|
+
124,
|
|
2094
|
+
118,
|
|
2095
|
+
71,
|
|
2096
|
+
160,
|
|
2097
|
+
112,
|
|
2098
|
+
40,
|
|
2099
|
+
3,
|
|
2100
|
+
250,
|
|
2101
|
+
93,
|
|
2102
|
+
137
|
|
2103
|
+
]
|
|
2104
|
+
}
|
|
2105
|
+
],
|
|
2106
|
+
program: {
|
|
2107
|
+
kind: "const",
|
|
2108
|
+
value: [
|
|
2109
|
+
2,
|
|
2110
|
+
168,
|
|
2111
|
+
246,
|
|
2112
|
+
145,
|
|
2113
|
+
78,
|
|
2114
|
+
136,
|
|
2115
|
+
161,
|
|
2116
|
+
176,
|
|
2117
|
+
226,
|
|
2118
|
+
16,
|
|
2119
|
+
21,
|
|
2120
|
+
62,
|
|
2121
|
+
247,
|
|
2122
|
+
99,
|
|
2123
|
+
174,
|
|
2124
|
+
43,
|
|
2125
|
+
0,
|
|
2126
|
+
194,
|
|
2127
|
+
185,
|
|
2128
|
+
61,
|
|
2129
|
+
22,
|
|
2130
|
+
193,
|
|
2131
|
+
36,
|
|
2132
|
+
210,
|
|
2133
|
+
192,
|
|
2134
|
+
83,
|
|
2135
|
+
122,
|
|
2136
|
+
16,
|
|
2137
|
+
4,
|
|
2138
|
+
128,
|
|
2139
|
+
0,
|
|
2140
|
+
0
|
|
2141
|
+
]
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
},
|
|
2145
|
+
{
|
|
2146
|
+
name: "system_program",
|
|
2147
|
+
address: "11111111111111111111111111111111"
|
|
2148
|
+
}
|
|
2149
|
+
],
|
|
2150
|
+
args: [
|
|
2151
|
+
{
|
|
2152
|
+
name: "peers",
|
|
2153
|
+
type: {
|
|
2154
|
+
vec: "pubkey"
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
]
|
|
2158
|
+
},
|
|
1923
2159
|
{
|
|
1924
2160
|
name: "bump_epoch_cluster",
|
|
1925
2161
|
discriminator: [
|
|
@@ -3172,16 +3408,19 @@ var instructions = [
|
|
|
3172
3408
|
]
|
|
3173
3409
|
},
|
|
3174
3410
|
{
|
|
3175
|
-
name: "
|
|
3411
|
+
name: "close_permissioned_recovery_peers_account",
|
|
3412
|
+
docs: [
|
|
3413
|
+
"Close the permissioned recovery peers account"
|
|
3414
|
+
],
|
|
3176
3415
|
discriminator: [
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3416
|
+
55,
|
|
3417
|
+
55,
|
|
3418
|
+
184,
|
|
3419
|
+
150,
|
|
3420
|
+
82,
|
|
3182
3421
|
190,
|
|
3183
|
-
|
|
3184
|
-
|
|
3422
|
+
205,
|
|
3423
|
+
92
|
|
3185
3424
|
],
|
|
3186
3425
|
accounts: [
|
|
3187
3426
|
{
|
|
@@ -3190,42 +3429,38 @@ var instructions = [
|
|
|
3190
3429
|
signer: true
|
|
3191
3430
|
},
|
|
3192
3431
|
{
|
|
3193
|
-
name: "
|
|
3432
|
+
name: "permissioned_recovery_peers_acc",
|
|
3194
3433
|
writable: true,
|
|
3195
3434
|
pda: {
|
|
3196
3435
|
seeds: [
|
|
3197
3436
|
{
|
|
3198
3437
|
kind: "const",
|
|
3199
3438
|
value: [
|
|
3200
|
-
|
|
3439
|
+
80,
|
|
3440
|
+
101,
|
|
3201
3441
|
114,
|
|
3202
|
-
|
|
3203
|
-
|
|
3442
|
+
109,
|
|
3443
|
+
105,
|
|
3444
|
+
115,
|
|
3445
|
+
115,
|
|
3446
|
+
105,
|
|
3204
3447
|
111,
|
|
3448
|
+
110,
|
|
3449
|
+
101,
|
|
3205
3450
|
100,
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
},
|
|
3209
|
-
{
|
|
3210
|
-
kind: "arg",
|
|
3211
|
-
path: "_node_offset"
|
|
3212
|
-
}
|
|
3213
|
-
]
|
|
3214
|
-
}
|
|
3215
|
-
},
|
|
3216
|
-
{
|
|
3217
|
-
name: "clock",
|
|
3218
|
-
writable: true,
|
|
3219
|
-
pda: {
|
|
3220
|
-
seeds: [
|
|
3221
|
-
{
|
|
3222
|
-
kind: "const",
|
|
3223
|
-
value: [
|
|
3224
|
-
67,
|
|
3225
|
-
108,
|
|
3226
|
-
111,
|
|
3451
|
+
82,
|
|
3452
|
+
101,
|
|
3227
3453
|
99,
|
|
3228
|
-
|
|
3454
|
+
111,
|
|
3455
|
+
118,
|
|
3456
|
+
101,
|
|
3457
|
+
114,
|
|
3458
|
+
121,
|
|
3459
|
+
80,
|
|
3460
|
+
101,
|
|
3461
|
+
101,
|
|
3462
|
+
114,
|
|
3463
|
+
115,
|
|
3229
3464
|
65,
|
|
3230
3465
|
99,
|
|
3231
3466
|
99,
|
|
@@ -3239,50 +3474,206 @@ var instructions = [
|
|
|
3239
3474
|
}
|
|
3240
3475
|
},
|
|
3241
3476
|
{
|
|
3242
|
-
name: "
|
|
3243
|
-
optional: true,
|
|
3477
|
+
name: "program_data",
|
|
3244
3478
|
pda: {
|
|
3245
3479
|
seeds: [
|
|
3246
3480
|
{
|
|
3247
3481
|
kind: "const",
|
|
3248
3482
|
value: [
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3483
|
+
146,
|
|
3484
|
+
111,
|
|
3485
|
+
9,
|
|
3486
|
+
170,
|
|
3487
|
+
109,
|
|
3488
|
+
72,
|
|
3489
|
+
125,
|
|
3490
|
+
226,
|
|
3491
|
+
216,
|
|
3492
|
+
140,
|
|
3493
|
+
55,
|
|
3494
|
+
106,
|
|
3495
|
+
22,
|
|
3496
|
+
29,
|
|
3497
|
+
7,
|
|
3498
|
+
127,
|
|
3499
|
+
176,
|
|
3500
|
+
129,
|
|
3501
|
+
11,
|
|
3502
|
+
19,
|
|
3503
|
+
35,
|
|
3504
|
+
107,
|
|
3505
|
+
124,
|
|
3506
|
+
118,
|
|
3507
|
+
71,
|
|
3508
|
+
160,
|
|
3509
|
+
112,
|
|
3510
|
+
40,
|
|
3511
|
+
3,
|
|
3512
|
+
250,
|
|
3513
|
+
93,
|
|
3514
|
+
137
|
|
3256
3515
|
]
|
|
3257
|
-
},
|
|
3258
|
-
{
|
|
3259
|
-
kind: "account",
|
|
3260
|
-
path: "arx_node_acc"
|
|
3261
3516
|
}
|
|
3262
|
-
]
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3517
|
+
],
|
|
3518
|
+
program: {
|
|
3519
|
+
kind: "const",
|
|
3520
|
+
value: [
|
|
3521
|
+
2,
|
|
3522
|
+
168,
|
|
3523
|
+
246,
|
|
3524
|
+
145,
|
|
3525
|
+
78,
|
|
3526
|
+
136,
|
|
3527
|
+
161,
|
|
3528
|
+
176,
|
|
3529
|
+
226,
|
|
3530
|
+
16,
|
|
3531
|
+
21,
|
|
3532
|
+
62,
|
|
3533
|
+
247,
|
|
3534
|
+
99,
|
|
3535
|
+
174,
|
|
3536
|
+
43,
|
|
3537
|
+
0,
|
|
3538
|
+
194,
|
|
3539
|
+
185,
|
|
3540
|
+
61,
|
|
3541
|
+
22,
|
|
3542
|
+
193,
|
|
3543
|
+
36,
|
|
3544
|
+
210,
|
|
3545
|
+
192,
|
|
3546
|
+
83,
|
|
3547
|
+
122,
|
|
3548
|
+
16,
|
|
3549
|
+
4,
|
|
3550
|
+
128,
|
|
3551
|
+
0,
|
|
3552
|
+
0
|
|
3553
|
+
]
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
},
|
|
3557
|
+
{
|
|
3558
|
+
name: "system_program",
|
|
3559
|
+
address: "11111111111111111111111111111111"
|
|
3560
|
+
}
|
|
3561
|
+
],
|
|
3562
|
+
args: [
|
|
3563
|
+
]
|
|
3564
|
+
},
|
|
3565
|
+
{
|
|
3566
|
+
name: "deactivate_arx",
|
|
3567
|
+
discriminator: [
|
|
3568
|
+
117,
|
|
3569
|
+
244,
|
|
3570
|
+
137,
|
|
3571
|
+
148,
|
|
3572
|
+
25,
|
|
3573
|
+
190,
|
|
3574
|
+
175,
|
|
3575
|
+
164
|
|
3576
|
+
],
|
|
3577
|
+
accounts: [
|
|
3578
|
+
{
|
|
3579
|
+
name: "signer",
|
|
3580
|
+
writable: true,
|
|
3581
|
+
signer: true
|
|
3582
|
+
},
|
|
3583
|
+
{
|
|
3584
|
+
name: "arx_node_acc",
|
|
3585
|
+
writable: true,
|
|
3586
|
+
pda: {
|
|
3587
|
+
seeds: [
|
|
3588
|
+
{
|
|
3589
|
+
kind: "const",
|
|
3590
|
+
value: [
|
|
3591
|
+
65,
|
|
3592
|
+
114,
|
|
3593
|
+
120,
|
|
3594
|
+
78,
|
|
3595
|
+
111,
|
|
3596
|
+
100,
|
|
3597
|
+
101
|
|
3598
|
+
]
|
|
3599
|
+
},
|
|
3600
|
+
{
|
|
3601
|
+
kind: "arg",
|
|
3602
|
+
path: "_node_offset"
|
|
3603
|
+
}
|
|
3604
|
+
]
|
|
3605
|
+
}
|
|
3606
|
+
},
|
|
3607
|
+
{
|
|
3608
|
+
name: "clock",
|
|
3609
|
+
writable: true,
|
|
3610
|
+
pda: {
|
|
3611
|
+
seeds: [
|
|
3612
|
+
{
|
|
3613
|
+
kind: "const",
|
|
3614
|
+
value: [
|
|
3615
|
+
67,
|
|
3616
|
+
108,
|
|
3617
|
+
111,
|
|
3618
|
+
99,
|
|
3619
|
+
107,
|
|
3620
|
+
65,
|
|
3621
|
+
99,
|
|
3622
|
+
99,
|
|
3623
|
+
111,
|
|
3624
|
+
117,
|
|
3625
|
+
110,
|
|
3626
|
+
116
|
|
3627
|
+
]
|
|
3628
|
+
}
|
|
3629
|
+
]
|
|
3630
|
+
}
|
|
3631
|
+
},
|
|
3632
|
+
{
|
|
3633
|
+
name: "cluster_acc",
|
|
3634
|
+
optional: true,
|
|
3635
|
+
pda: {
|
|
3636
|
+
seeds: [
|
|
3637
|
+
{
|
|
3638
|
+
kind: "const",
|
|
3639
|
+
value: [
|
|
3640
|
+
67,
|
|
3641
|
+
108,
|
|
3642
|
+
117,
|
|
3643
|
+
115,
|
|
3644
|
+
116,
|
|
3645
|
+
101,
|
|
3646
|
+
114
|
|
3647
|
+
]
|
|
3648
|
+
},
|
|
3649
|
+
{
|
|
3650
|
+
kind: "account",
|
|
3651
|
+
path: "arx_node_acc"
|
|
3652
|
+
}
|
|
3653
|
+
]
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
],
|
|
3657
|
+
args: [
|
|
3658
|
+
{
|
|
3659
|
+
name: "node_offset",
|
|
3660
|
+
type: "u32"
|
|
3661
|
+
}
|
|
3662
|
+
]
|
|
3663
|
+
},
|
|
3664
|
+
{
|
|
3665
|
+
name: "deactivate_cluster",
|
|
3666
|
+
discriminator: [
|
|
3667
|
+
13,
|
|
3668
|
+
42,
|
|
3669
|
+
182,
|
|
3670
|
+
159,
|
|
3671
|
+
184,
|
|
3672
|
+
10,
|
|
3673
|
+
212,
|
|
3674
|
+
178
|
|
3675
|
+
],
|
|
3676
|
+
accounts: [
|
|
3286
3677
|
{
|
|
3287
3678
|
name: "authority",
|
|
3288
3679
|
writable: true,
|
|
@@ -6319,16 +6710,19 @@ var instructions = [
|
|
|
6319
6710
|
]
|
|
6320
6711
|
},
|
|
6321
6712
|
{
|
|
6322
|
-
name: "
|
|
6713
|
+
name: "init_permissioned_recovery_peers_account",
|
|
6714
|
+
docs: [
|
|
6715
|
+
"Initialize the permissioned recovery peers account"
|
|
6716
|
+
],
|
|
6323
6717
|
discriminator: [
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6718
|
+
23,
|
|
6719
|
+
147,
|
|
6720
|
+
149,
|
|
6721
|
+
121,
|
|
6722
|
+
218,
|
|
6723
|
+
173,
|
|
6724
|
+
81,
|
|
6725
|
+
117
|
|
6332
6726
|
],
|
|
6333
6727
|
accounts: [
|
|
6334
6728
|
{
|
|
@@ -6337,33 +6731,38 @@ var instructions = [
|
|
|
6337
6731
|
signer: true
|
|
6338
6732
|
},
|
|
6339
6733
|
{
|
|
6340
|
-
name: "
|
|
6734
|
+
name: "permissioned_recovery_peers_acc",
|
|
6735
|
+
writable: true,
|
|
6341
6736
|
pda: {
|
|
6342
6737
|
seeds: [
|
|
6343
6738
|
{
|
|
6344
6739
|
kind: "const",
|
|
6345
6740
|
value: [
|
|
6346
|
-
|
|
6347
|
-
|
|
6741
|
+
80,
|
|
6742
|
+
101,
|
|
6743
|
+
114,
|
|
6348
6744
|
109,
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
97,
|
|
6353
|
-
116,
|
|
6745
|
+
105,
|
|
6746
|
+
115,
|
|
6747
|
+
115,
|
|
6354
6748
|
105,
|
|
6355
6749
|
111,
|
|
6356
6750
|
110,
|
|
6357
|
-
68,
|
|
6358
6751
|
101,
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
116,
|
|
6364
|
-
105,
|
|
6752
|
+
100,
|
|
6753
|
+
82,
|
|
6754
|
+
101,
|
|
6755
|
+
99,
|
|
6365
6756
|
111,
|
|
6366
|
-
|
|
6757
|
+
118,
|
|
6758
|
+
101,
|
|
6759
|
+
114,
|
|
6760
|
+
121,
|
|
6761
|
+
80,
|
|
6762
|
+
101,
|
|
6763
|
+
101,
|
|
6764
|
+
114,
|
|
6765
|
+
115,
|
|
6367
6766
|
65,
|
|
6368
6767
|
99,
|
|
6369
6768
|
99,
|
|
@@ -6372,56 +6771,203 @@ var instructions = [
|
|
|
6372
6771
|
110,
|
|
6373
6772
|
116
|
|
6374
6773
|
]
|
|
6375
|
-
},
|
|
6376
|
-
{
|
|
6377
|
-
kind: "arg",
|
|
6378
|
-
path: "_mxe_program"
|
|
6379
|
-
},
|
|
6380
|
-
{
|
|
6381
|
-
kind: "arg",
|
|
6382
|
-
path: "_comp_offset"
|
|
6383
6774
|
}
|
|
6384
6775
|
]
|
|
6385
6776
|
}
|
|
6386
6777
|
},
|
|
6387
6778
|
{
|
|
6388
|
-
name: "
|
|
6389
|
-
writable: true,
|
|
6779
|
+
name: "program_data",
|
|
6390
6780
|
pda: {
|
|
6391
6781
|
seeds: [
|
|
6392
6782
|
{
|
|
6393
6783
|
kind: "const",
|
|
6394
6784
|
value: [
|
|
6395
|
-
|
|
6785
|
+
146,
|
|
6396
6786
|
111,
|
|
6787
|
+
9,
|
|
6788
|
+
170,
|
|
6397
6789
|
109,
|
|
6790
|
+
72,
|
|
6791
|
+
125,
|
|
6792
|
+
226,
|
|
6793
|
+
216,
|
|
6794
|
+
140,
|
|
6795
|
+
55,
|
|
6796
|
+
106,
|
|
6797
|
+
22,
|
|
6798
|
+
29,
|
|
6799
|
+
7,
|
|
6800
|
+
127,
|
|
6801
|
+
176,
|
|
6802
|
+
129,
|
|
6803
|
+
11,
|
|
6804
|
+
19,
|
|
6805
|
+
35,
|
|
6806
|
+
107,
|
|
6807
|
+
124,
|
|
6808
|
+
118,
|
|
6809
|
+
71,
|
|
6810
|
+
160,
|
|
6398
6811
|
112,
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
111,
|
|
6405
|
-
110,
|
|
6406
|
-
68,
|
|
6407
|
-
101,
|
|
6408
|
-
102,
|
|
6409
|
-
105,
|
|
6410
|
-
110,
|
|
6411
|
-
105,
|
|
6412
|
-
116,
|
|
6413
|
-
105,
|
|
6414
|
-
111,
|
|
6415
|
-
110,
|
|
6416
|
-
82,
|
|
6417
|
-
97,
|
|
6418
|
-
119
|
|
6812
|
+
40,
|
|
6813
|
+
3,
|
|
6814
|
+
250,
|
|
6815
|
+
93,
|
|
6816
|
+
137
|
|
6419
6817
|
]
|
|
6420
|
-
}
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6818
|
+
}
|
|
6819
|
+
],
|
|
6820
|
+
program: {
|
|
6821
|
+
kind: "const",
|
|
6822
|
+
value: [
|
|
6823
|
+
2,
|
|
6824
|
+
168,
|
|
6825
|
+
246,
|
|
6826
|
+
145,
|
|
6827
|
+
78,
|
|
6828
|
+
136,
|
|
6829
|
+
161,
|
|
6830
|
+
176,
|
|
6831
|
+
226,
|
|
6832
|
+
16,
|
|
6833
|
+
21,
|
|
6834
|
+
62,
|
|
6835
|
+
247,
|
|
6836
|
+
99,
|
|
6837
|
+
174,
|
|
6838
|
+
43,
|
|
6839
|
+
0,
|
|
6840
|
+
194,
|
|
6841
|
+
185,
|
|
6842
|
+
61,
|
|
6843
|
+
22,
|
|
6844
|
+
193,
|
|
6845
|
+
36,
|
|
6846
|
+
210,
|
|
6847
|
+
192,
|
|
6848
|
+
83,
|
|
6849
|
+
122,
|
|
6850
|
+
16,
|
|
6851
|
+
4,
|
|
6852
|
+
128,
|
|
6853
|
+
0,
|
|
6854
|
+
0
|
|
6855
|
+
]
|
|
6856
|
+
}
|
|
6857
|
+
}
|
|
6858
|
+
},
|
|
6859
|
+
{
|
|
6860
|
+
name: "system_program",
|
|
6861
|
+
address: "11111111111111111111111111111111"
|
|
6862
|
+
}
|
|
6863
|
+
],
|
|
6864
|
+
args: [
|
|
6865
|
+
]
|
|
6866
|
+
},
|
|
6867
|
+
{
|
|
6868
|
+
name: "init_raw_circuit_acc",
|
|
6869
|
+
discriminator: [
|
|
6870
|
+
16,
|
|
6871
|
+
228,
|
|
6872
|
+
193,
|
|
6873
|
+
228,
|
|
6874
|
+
93,
|
|
6875
|
+
231,
|
|
6876
|
+
58,
|
|
6877
|
+
4
|
|
6878
|
+
],
|
|
6879
|
+
accounts: [
|
|
6880
|
+
{
|
|
6881
|
+
name: "signer",
|
|
6882
|
+
writable: true,
|
|
6883
|
+
signer: true
|
|
6884
|
+
},
|
|
6885
|
+
{
|
|
6886
|
+
name: "comp_def_acc",
|
|
6887
|
+
pda: {
|
|
6888
|
+
seeds: [
|
|
6889
|
+
{
|
|
6890
|
+
kind: "const",
|
|
6891
|
+
value: [
|
|
6892
|
+
67,
|
|
6893
|
+
111,
|
|
6894
|
+
109,
|
|
6895
|
+
112,
|
|
6896
|
+
117,
|
|
6897
|
+
116,
|
|
6898
|
+
97,
|
|
6899
|
+
116,
|
|
6900
|
+
105,
|
|
6901
|
+
111,
|
|
6902
|
+
110,
|
|
6903
|
+
68,
|
|
6904
|
+
101,
|
|
6905
|
+
102,
|
|
6906
|
+
105,
|
|
6907
|
+
110,
|
|
6908
|
+
105,
|
|
6909
|
+
116,
|
|
6910
|
+
105,
|
|
6911
|
+
111,
|
|
6912
|
+
110,
|
|
6913
|
+
65,
|
|
6914
|
+
99,
|
|
6915
|
+
99,
|
|
6916
|
+
111,
|
|
6917
|
+
117,
|
|
6918
|
+
110,
|
|
6919
|
+
116
|
|
6920
|
+
]
|
|
6921
|
+
},
|
|
6922
|
+
{
|
|
6923
|
+
kind: "arg",
|
|
6924
|
+
path: "_mxe_program"
|
|
6925
|
+
},
|
|
6926
|
+
{
|
|
6927
|
+
kind: "arg",
|
|
6928
|
+
path: "_comp_offset"
|
|
6929
|
+
}
|
|
6930
|
+
]
|
|
6931
|
+
}
|
|
6932
|
+
},
|
|
6933
|
+
{
|
|
6934
|
+
name: "comp_def_raw",
|
|
6935
|
+
writable: true,
|
|
6936
|
+
pda: {
|
|
6937
|
+
seeds: [
|
|
6938
|
+
{
|
|
6939
|
+
kind: "const",
|
|
6940
|
+
value: [
|
|
6941
|
+
67,
|
|
6942
|
+
111,
|
|
6943
|
+
109,
|
|
6944
|
+
112,
|
|
6945
|
+
117,
|
|
6946
|
+
116,
|
|
6947
|
+
97,
|
|
6948
|
+
116,
|
|
6949
|
+
105,
|
|
6950
|
+
111,
|
|
6951
|
+
110,
|
|
6952
|
+
68,
|
|
6953
|
+
101,
|
|
6954
|
+
102,
|
|
6955
|
+
105,
|
|
6956
|
+
110,
|
|
6957
|
+
105,
|
|
6958
|
+
116,
|
|
6959
|
+
105,
|
|
6960
|
+
111,
|
|
6961
|
+
110,
|
|
6962
|
+
82,
|
|
6963
|
+
97,
|
|
6964
|
+
119
|
|
6965
|
+
]
|
|
6966
|
+
},
|
|
6967
|
+
{
|
|
6968
|
+
kind: "account",
|
|
6969
|
+
path: "comp_def_acc"
|
|
6970
|
+
},
|
|
6425
6971
|
{
|
|
6426
6972
|
kind: "arg",
|
|
6427
6973
|
path: "_raw_circuit_index"
|
|
@@ -6503,6 +7049,50 @@ var instructions = [
|
|
|
6503
7049
|
]
|
|
6504
7050
|
}
|
|
6505
7051
|
},
|
|
7052
|
+
{
|
|
7053
|
+
name: "permissioned_recovery_peers_acc",
|
|
7054
|
+
pda: {
|
|
7055
|
+
seeds: [
|
|
7056
|
+
{
|
|
7057
|
+
kind: "const",
|
|
7058
|
+
value: [
|
|
7059
|
+
80,
|
|
7060
|
+
101,
|
|
7061
|
+
114,
|
|
7062
|
+
109,
|
|
7063
|
+
105,
|
|
7064
|
+
115,
|
|
7065
|
+
115,
|
|
7066
|
+
105,
|
|
7067
|
+
111,
|
|
7068
|
+
110,
|
|
7069
|
+
101,
|
|
7070
|
+
100,
|
|
7071
|
+
82,
|
|
7072
|
+
101,
|
|
7073
|
+
99,
|
|
7074
|
+
111,
|
|
7075
|
+
118,
|
|
7076
|
+
101,
|
|
7077
|
+
114,
|
|
7078
|
+
121,
|
|
7079
|
+
80,
|
|
7080
|
+
101,
|
|
7081
|
+
101,
|
|
7082
|
+
114,
|
|
7083
|
+
115,
|
|
7084
|
+
65,
|
|
7085
|
+
99,
|
|
7086
|
+
99,
|
|
7087
|
+
111,
|
|
7088
|
+
117,
|
|
7089
|
+
110,
|
|
7090
|
+
116
|
|
7091
|
+
]
|
|
7092
|
+
}
|
|
7093
|
+
]
|
|
7094
|
+
}
|
|
7095
|
+
},
|
|
6506
7096
|
{
|
|
6507
7097
|
name: "system_program",
|
|
6508
7098
|
address: "11111111111111111111111111111111"
|
|
@@ -6514,7 +7104,7 @@ var instructions = [
|
|
|
6514
7104
|
type: "u32"
|
|
6515
7105
|
},
|
|
6516
7106
|
{
|
|
6517
|
-
name: "
|
|
7107
|
+
name: "signer",
|
|
6518
7108
|
type: "pubkey"
|
|
6519
7109
|
},
|
|
6520
7110
|
{
|
|
@@ -7489,6 +8079,32 @@ var instructions = [
|
|
|
7489
8079
|
writable: true,
|
|
7490
8080
|
signer: true
|
|
7491
8081
|
},
|
|
8082
|
+
{
|
|
8083
|
+
name: "mxe",
|
|
8084
|
+
pda: {
|
|
8085
|
+
seeds: [
|
|
8086
|
+
{
|
|
8087
|
+
kind: "const",
|
|
8088
|
+
value: [
|
|
8089
|
+
77,
|
|
8090
|
+
88,
|
|
8091
|
+
69,
|
|
8092
|
+
65,
|
|
8093
|
+
99,
|
|
8094
|
+
99,
|
|
8095
|
+
111,
|
|
8096
|
+
117,
|
|
8097
|
+
110,
|
|
8098
|
+
116
|
|
8099
|
+
]
|
|
8100
|
+
},
|
|
8101
|
+
{
|
|
8102
|
+
kind: "arg",
|
|
8103
|
+
path: "_mxe_program"
|
|
8104
|
+
}
|
|
8105
|
+
]
|
|
8106
|
+
}
|
|
8107
|
+
},
|
|
7492
8108
|
{
|
|
7493
8109
|
name: "comp",
|
|
7494
8110
|
writable: true,
|
|
@@ -7518,8 +8134,9 @@ var instructions = [
|
|
|
7518
8134
|
]
|
|
7519
8135
|
},
|
|
7520
8136
|
{
|
|
7521
|
-
kind: "
|
|
7522
|
-
path: "
|
|
8137
|
+
kind: "account",
|
|
8138
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
8139
|
+
account: "MXEAccount"
|
|
7523
8140
|
},
|
|
7524
8141
|
{
|
|
7525
8142
|
kind: "arg",
|
|
@@ -7528,6 +8145,32 @@ var instructions = [
|
|
|
7528
8145
|
]
|
|
7529
8146
|
}
|
|
7530
8147
|
},
|
|
8148
|
+
{
|
|
8149
|
+
name: "executing_pool",
|
|
8150
|
+
writable: true,
|
|
8151
|
+
pda: {
|
|
8152
|
+
seeds: [
|
|
8153
|
+
{
|
|
8154
|
+
kind: "const",
|
|
8155
|
+
value: [
|
|
8156
|
+
69,
|
|
8157
|
+
120,
|
|
8158
|
+
101,
|
|
8159
|
+
99,
|
|
8160
|
+
112,
|
|
8161
|
+
111,
|
|
8162
|
+
111,
|
|
8163
|
+
108
|
|
8164
|
+
]
|
|
8165
|
+
},
|
|
8166
|
+
{
|
|
8167
|
+
kind: "account",
|
|
8168
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
8169
|
+
account: "MXEAccount"
|
|
8170
|
+
}
|
|
8171
|
+
]
|
|
8172
|
+
}
|
|
8173
|
+
},
|
|
7531
8174
|
{
|
|
7532
8175
|
name: "pool_account",
|
|
7533
8176
|
writable: true,
|
|
@@ -7644,26 +8287,225 @@ var instructions = [
|
|
|
7644
8287
|
99,
|
|
7645
8288
|
99,
|
|
7646
8289
|
111,
|
|
7647
|
-
117,
|
|
7648
|
-
110,
|
|
7649
|
-
116
|
|
8290
|
+
117,
|
|
8291
|
+
110,
|
|
8292
|
+
116
|
|
8293
|
+
]
|
|
8294
|
+
},
|
|
8295
|
+
{
|
|
8296
|
+
kind: "arg",
|
|
8297
|
+
path: "_mxe_program"
|
|
8298
|
+
}
|
|
8299
|
+
]
|
|
8300
|
+
}
|
|
8301
|
+
},
|
|
8302
|
+
{
|
|
8303
|
+
name: "recovery_cluster_acc",
|
|
8304
|
+
pda: {
|
|
8305
|
+
seeds: [
|
|
8306
|
+
{
|
|
8307
|
+
kind: "const",
|
|
8308
|
+
value: [
|
|
8309
|
+
82,
|
|
8310
|
+
101,
|
|
8311
|
+
99,
|
|
8312
|
+
111,
|
|
8313
|
+
118,
|
|
8314
|
+
101,
|
|
8315
|
+
114,
|
|
8316
|
+
121,
|
|
8317
|
+
67,
|
|
8318
|
+
108,
|
|
8319
|
+
117,
|
|
8320
|
+
115,
|
|
8321
|
+
116,
|
|
8322
|
+
101,
|
|
8323
|
+
114,
|
|
8324
|
+
65,
|
|
8325
|
+
99,
|
|
8326
|
+
99,
|
|
8327
|
+
111,
|
|
8328
|
+
117,
|
|
8329
|
+
110,
|
|
8330
|
+
116
|
|
8331
|
+
]
|
|
8332
|
+
},
|
|
8333
|
+
{
|
|
8334
|
+
kind: "arg",
|
|
8335
|
+
path: "_mxe_program"
|
|
8336
|
+
}
|
|
8337
|
+
]
|
|
8338
|
+
}
|
|
8339
|
+
},
|
|
8340
|
+
{
|
|
8341
|
+
name: "mxe_program"
|
|
8342
|
+
}
|
|
8343
|
+
],
|
|
8344
|
+
args: [
|
|
8345
|
+
{
|
|
8346
|
+
name: "mxe_program",
|
|
8347
|
+
type: "pubkey"
|
|
8348
|
+
}
|
|
8349
|
+
]
|
|
8350
|
+
},
|
|
8351
|
+
{
|
|
8352
|
+
name: "remove_permissioned_recovery_peers",
|
|
8353
|
+
docs: [
|
|
8354
|
+
"Remove permissioned recovery peers"
|
|
8355
|
+
],
|
|
8356
|
+
discriminator: [
|
|
8357
|
+
246,
|
|
8358
|
+
123,
|
|
8359
|
+
224,
|
|
8360
|
+
196,
|
|
8361
|
+
110,
|
|
8362
|
+
208,
|
|
8363
|
+
85,
|
|
8364
|
+
6
|
|
8365
|
+
],
|
|
8366
|
+
accounts: [
|
|
8367
|
+
{
|
|
8368
|
+
name: "signer",
|
|
8369
|
+
writable: true,
|
|
8370
|
+
signer: true
|
|
8371
|
+
},
|
|
8372
|
+
{
|
|
8373
|
+
name: "permissioned_recovery_peers_acc",
|
|
8374
|
+
writable: true,
|
|
8375
|
+
pda: {
|
|
8376
|
+
seeds: [
|
|
8377
|
+
{
|
|
8378
|
+
kind: "const",
|
|
8379
|
+
value: [
|
|
8380
|
+
80,
|
|
8381
|
+
101,
|
|
8382
|
+
114,
|
|
8383
|
+
109,
|
|
8384
|
+
105,
|
|
8385
|
+
115,
|
|
8386
|
+
115,
|
|
8387
|
+
105,
|
|
8388
|
+
111,
|
|
8389
|
+
110,
|
|
8390
|
+
101,
|
|
8391
|
+
100,
|
|
8392
|
+
82,
|
|
8393
|
+
101,
|
|
8394
|
+
99,
|
|
8395
|
+
111,
|
|
8396
|
+
118,
|
|
8397
|
+
101,
|
|
8398
|
+
114,
|
|
8399
|
+
121,
|
|
8400
|
+
80,
|
|
8401
|
+
101,
|
|
8402
|
+
101,
|
|
8403
|
+
114,
|
|
8404
|
+
115,
|
|
8405
|
+
65,
|
|
8406
|
+
99,
|
|
8407
|
+
99,
|
|
8408
|
+
111,
|
|
8409
|
+
117,
|
|
8410
|
+
110,
|
|
8411
|
+
116
|
|
8412
|
+
]
|
|
8413
|
+
}
|
|
8414
|
+
]
|
|
8415
|
+
}
|
|
8416
|
+
},
|
|
8417
|
+
{
|
|
8418
|
+
name: "program_data",
|
|
8419
|
+
pda: {
|
|
8420
|
+
seeds: [
|
|
8421
|
+
{
|
|
8422
|
+
kind: "const",
|
|
8423
|
+
value: [
|
|
8424
|
+
146,
|
|
8425
|
+
111,
|
|
8426
|
+
9,
|
|
8427
|
+
170,
|
|
8428
|
+
109,
|
|
8429
|
+
72,
|
|
8430
|
+
125,
|
|
8431
|
+
226,
|
|
8432
|
+
216,
|
|
8433
|
+
140,
|
|
8434
|
+
55,
|
|
8435
|
+
106,
|
|
8436
|
+
22,
|
|
8437
|
+
29,
|
|
8438
|
+
7,
|
|
8439
|
+
127,
|
|
8440
|
+
176,
|
|
8441
|
+
129,
|
|
8442
|
+
11,
|
|
8443
|
+
19,
|
|
8444
|
+
35,
|
|
8445
|
+
107,
|
|
8446
|
+
124,
|
|
8447
|
+
118,
|
|
8448
|
+
71,
|
|
8449
|
+
160,
|
|
8450
|
+
112,
|
|
8451
|
+
40,
|
|
8452
|
+
3,
|
|
8453
|
+
250,
|
|
8454
|
+
93,
|
|
8455
|
+
137
|
|
7650
8456
|
]
|
|
7651
|
-
},
|
|
7652
|
-
{
|
|
7653
|
-
kind: "arg",
|
|
7654
|
-
path: "_mxe_program"
|
|
7655
8457
|
}
|
|
7656
|
-
]
|
|
8458
|
+
],
|
|
8459
|
+
program: {
|
|
8460
|
+
kind: "const",
|
|
8461
|
+
value: [
|
|
8462
|
+
2,
|
|
8463
|
+
168,
|
|
8464
|
+
246,
|
|
8465
|
+
145,
|
|
8466
|
+
78,
|
|
8467
|
+
136,
|
|
8468
|
+
161,
|
|
8469
|
+
176,
|
|
8470
|
+
226,
|
|
8471
|
+
16,
|
|
8472
|
+
21,
|
|
8473
|
+
62,
|
|
8474
|
+
247,
|
|
8475
|
+
99,
|
|
8476
|
+
174,
|
|
8477
|
+
43,
|
|
8478
|
+
0,
|
|
8479
|
+
194,
|
|
8480
|
+
185,
|
|
8481
|
+
61,
|
|
8482
|
+
22,
|
|
8483
|
+
193,
|
|
8484
|
+
36,
|
|
8485
|
+
210,
|
|
8486
|
+
192,
|
|
8487
|
+
83,
|
|
8488
|
+
122,
|
|
8489
|
+
16,
|
|
8490
|
+
4,
|
|
8491
|
+
128,
|
|
8492
|
+
0,
|
|
8493
|
+
0
|
|
8494
|
+
]
|
|
8495
|
+
}
|
|
7657
8496
|
}
|
|
7658
8497
|
},
|
|
7659
8498
|
{
|
|
7660
|
-
name: "
|
|
8499
|
+
name: "system_program",
|
|
8500
|
+
address: "11111111111111111111111111111111"
|
|
7661
8501
|
}
|
|
7662
8502
|
],
|
|
7663
8503
|
args: [
|
|
7664
8504
|
{
|
|
7665
|
-
name: "
|
|
7666
|
-
type:
|
|
8505
|
+
name: "peers",
|
|
8506
|
+
type: {
|
|
8507
|
+
vec: "pubkey"
|
|
8508
|
+
}
|
|
7667
8509
|
}
|
|
7668
8510
|
]
|
|
7669
8511
|
},
|
|
@@ -7745,6 +8587,44 @@ var instructions = [
|
|
|
7745
8587
|
]
|
|
7746
8588
|
}
|
|
7747
8589
|
},
|
|
8590
|
+
{
|
|
8591
|
+
name: "recovery_cluster_acc",
|
|
8592
|
+
pda: {
|
|
8593
|
+
seeds: [
|
|
8594
|
+
{
|
|
8595
|
+
kind: "const",
|
|
8596
|
+
value: [
|
|
8597
|
+
82,
|
|
8598
|
+
101,
|
|
8599
|
+
99,
|
|
8600
|
+
111,
|
|
8601
|
+
118,
|
|
8602
|
+
101,
|
|
8603
|
+
114,
|
|
8604
|
+
121,
|
|
8605
|
+
67,
|
|
8606
|
+
108,
|
|
8607
|
+
117,
|
|
8608
|
+
115,
|
|
8609
|
+
116,
|
|
8610
|
+
101,
|
|
8611
|
+
114,
|
|
8612
|
+
65,
|
|
8613
|
+
99,
|
|
8614
|
+
99,
|
|
8615
|
+
111,
|
|
8616
|
+
117,
|
|
8617
|
+
110,
|
|
8618
|
+
116
|
|
8619
|
+
]
|
|
8620
|
+
},
|
|
8621
|
+
{
|
|
8622
|
+
kind: "arg",
|
|
8623
|
+
path: "_original_mxe_program"
|
|
8624
|
+
}
|
|
8625
|
+
]
|
|
8626
|
+
}
|
|
8627
|
+
},
|
|
7748
8628
|
{
|
|
7749
8629
|
name: "mxe_recovery_account",
|
|
7750
8630
|
writable: true,
|
|
@@ -8358,6 +9238,7 @@ var instructions = [
|
|
|
8358
9238
|
docs: [
|
|
8359
9239
|
"Cluster to set for the MXE."
|
|
8360
9240
|
],
|
|
9241
|
+
writable: true,
|
|
8361
9242
|
pda: {
|
|
8362
9243
|
seeds: [
|
|
8363
9244
|
{
|
|
@@ -8471,6 +9352,66 @@ var instructions = [
|
|
|
8471
9352
|
}
|
|
8472
9353
|
]
|
|
8473
9354
|
},
|
|
9355
|
+
{
|
|
9356
|
+
name: "set_cluster_td_info",
|
|
9357
|
+
discriminator: [
|
|
9358
|
+
182,
|
|
9359
|
+
126,
|
|
9360
|
+
92,
|
|
9361
|
+
101,
|
|
9362
|
+
25,
|
|
9363
|
+
252,
|
|
9364
|
+
84,
|
|
9365
|
+
180
|
|
9366
|
+
],
|
|
9367
|
+
accounts: [
|
|
9368
|
+
{
|
|
9369
|
+
name: "authority",
|
|
9370
|
+
writable: true,
|
|
9371
|
+
signer: true
|
|
9372
|
+
},
|
|
9373
|
+
{
|
|
9374
|
+
name: "cluster_acc",
|
|
9375
|
+
writable: true,
|
|
9376
|
+
pda: {
|
|
9377
|
+
seeds: [
|
|
9378
|
+
{
|
|
9379
|
+
kind: "const",
|
|
9380
|
+
value: [
|
|
9381
|
+
67,
|
|
9382
|
+
108,
|
|
9383
|
+
117,
|
|
9384
|
+
115,
|
|
9385
|
+
116,
|
|
9386
|
+
101,
|
|
9387
|
+
114
|
|
9388
|
+
]
|
|
9389
|
+
},
|
|
9390
|
+
{
|
|
9391
|
+
kind: "arg",
|
|
9392
|
+
path: "_id"
|
|
9393
|
+
}
|
|
9394
|
+
]
|
|
9395
|
+
}
|
|
9396
|
+
}
|
|
9397
|
+
],
|
|
9398
|
+
args: [
|
|
9399
|
+
{
|
|
9400
|
+
name: "cluster_id",
|
|
9401
|
+
type: "u32"
|
|
9402
|
+
},
|
|
9403
|
+
{
|
|
9404
|
+
name: "td_info",
|
|
9405
|
+
type: {
|
|
9406
|
+
option: {
|
|
9407
|
+
defined: {
|
|
9408
|
+
name: "NodeMetadata"
|
|
9409
|
+
}
|
|
9410
|
+
}
|
|
9411
|
+
}
|
|
9412
|
+
}
|
|
9413
|
+
]
|
|
9414
|
+
},
|
|
8474
9415
|
{
|
|
8475
9416
|
name: "set_mxe_keys",
|
|
8476
9417
|
discriminator: [
|
|
@@ -9571,6 +10512,19 @@ var accounts = [
|
|
|
9571
10512
|
117
|
|
9572
10513
|
]
|
|
9573
10514
|
},
|
|
10515
|
+
{
|
|
10516
|
+
name: "PermissionedRecoveryPeersAccount",
|
|
10517
|
+
discriminator: [
|
|
10518
|
+
113,
|
|
10519
|
+
236,
|
|
10520
|
+
217,
|
|
10521
|
+
203,
|
|
10522
|
+
251,
|
|
10523
|
+
98,
|
|
10524
|
+
36,
|
|
10525
|
+
240
|
|
10526
|
+
]
|
|
10527
|
+
},
|
|
9574
10528
|
{
|
|
9575
10529
|
name: "RecoveryClusterAccount",
|
|
9576
10530
|
discriminator: [
|
|
@@ -9999,6 +10953,11 @@ var errors = [
|
|
|
9999
10953
|
name: "ClusterNotReady",
|
|
10000
10954
|
msg: "Cluster is not ready"
|
|
10001
10955
|
},
|
|
10956
|
+
{
|
|
10957
|
+
code: 6508,
|
|
10958
|
+
name: "BlsPubkeyNotSet",
|
|
10959
|
+
msg: "Bls pubkey not set"
|
|
10960
|
+
},
|
|
10002
10961
|
{
|
|
10003
10962
|
code: 6600,
|
|
10004
10963
|
name: "SerializationFailed",
|
|
@@ -10114,15 +11073,25 @@ var errors = [
|
|
|
10114
11073
|
name: "NoFeesToClaim",
|
|
10115
11074
|
msg: "No fees available to claim"
|
|
10116
11075
|
},
|
|
11076
|
+
{
|
|
11077
|
+
code: 6623,
|
|
11078
|
+
name: "RecoveryPeerOffsetZero",
|
|
11079
|
+
msg: "Recovery peer offset is zero"
|
|
11080
|
+
},
|
|
11081
|
+
{
|
|
11082
|
+
code: 6624,
|
|
11083
|
+
name: "InvalidDomainSeparator",
|
|
11084
|
+
msg: "Invalid domain separator"
|
|
11085
|
+
},
|
|
10117
11086
|
{
|
|
10118
11087
|
code: 6700,
|
|
10119
|
-
name: "
|
|
10120
|
-
msg: "MXE is not in
|
|
11088
|
+
name: "MxeNotInMigrationState",
|
|
11089
|
+
msg: "MXE is not in migration state"
|
|
10121
11090
|
},
|
|
10122
11091
|
{
|
|
10123
11092
|
code: 6701,
|
|
10124
|
-
name: "
|
|
10125
|
-
msg: "MXE is already in
|
|
11093
|
+
name: "MxeAlreadyInMigration",
|
|
11094
|
+
msg: "MXE is already in migration state"
|
|
10126
11095
|
},
|
|
10127
11096
|
{
|
|
10128
11097
|
code: 6702,
|
|
@@ -10196,8 +11165,33 @@ var errors = [
|
|
|
10196
11165
|
},
|
|
10197
11166
|
{
|
|
10198
11167
|
code: 6716,
|
|
10199
|
-
name: "
|
|
10200
|
-
msg: "MXE is in
|
|
11168
|
+
name: "MxeInMigrationState",
|
|
11169
|
+
msg: "MXE is in migration state, cannot queue new computations"
|
|
11170
|
+
},
|
|
11171
|
+
{
|
|
11172
|
+
code: 6717,
|
|
11173
|
+
name: "PermissionedRecoveryPeersNotDistinct",
|
|
11174
|
+
msg: "Permissioned recovery peers to add must be distinct"
|
|
11175
|
+
},
|
|
11176
|
+
{
|
|
11177
|
+
code: 6718,
|
|
11178
|
+
name: "TooManyPermissionedRecoveryPeers",
|
|
11179
|
+
msg: "Too many permissioned recovery peers to add"
|
|
11180
|
+
},
|
|
11181
|
+
{
|
|
11182
|
+
code: 6719,
|
|
11183
|
+
name: "RemoveNonExistingPermissionedRecoveryPeers",
|
|
11184
|
+
msg: "Can only remove existing permissioned recovery peers"
|
|
11185
|
+
},
|
|
11186
|
+
{
|
|
11187
|
+
code: 6720,
|
|
11188
|
+
name: "UnauthorizedRecoveryPeerCreation",
|
|
11189
|
+
msg: "Unauthorized to create recovery peer on mainnet"
|
|
11190
|
+
},
|
|
11191
|
+
{
|
|
11192
|
+
code: 6721,
|
|
11193
|
+
name: "CompilationWithoutMainnetFeatureFlag",
|
|
11194
|
+
msg: "Program must be compiled with the \\mainnet\\ feature flag."
|
|
10201
11195
|
}
|
|
10202
11196
|
];
|
|
10203
11197
|
var types = [
|
|
@@ -11184,7 +12178,16 @@ var types = [
|
|
|
11184
12178
|
name: "AcccountAccessInfo"
|
|
11185
12179
|
}
|
|
11186
12180
|
},
|
|
11187
|
-
|
|
12181
|
+
13
|
|
12182
|
+
]
|
|
12183
|
+
}
|
|
12184
|
+
},
|
|
12185
|
+
{
|
|
12186
|
+
name: "_padding",
|
|
12187
|
+
type: {
|
|
12188
|
+
array: [
|
|
12189
|
+
"u8",
|
|
12190
|
+
6
|
|
11188
12191
|
]
|
|
11189
12192
|
}
|
|
11190
12193
|
}
|
|
@@ -11358,6 +12361,12 @@ var types = [
|
|
|
11358
12361
|
}
|
|
11359
12362
|
}
|
|
11360
12363
|
]
|
|
12364
|
+
},
|
|
12365
|
+
{
|
|
12366
|
+
name: "TrustedDealer"
|
|
12367
|
+
},
|
|
12368
|
+
{
|
|
12369
|
+
name: "OutputTooLarge"
|
|
11361
12370
|
}
|
|
11362
12371
|
]
|
|
11363
12372
|
}
|
|
@@ -11479,6 +12488,14 @@ var types = [
|
|
|
11479
12488
|
{
|
|
11480
12489
|
name: "mxe_program_id",
|
|
11481
12490
|
type: "pubkey"
|
|
12491
|
+
},
|
|
12492
|
+
{
|
|
12493
|
+
name: "execution_status",
|
|
12494
|
+
type: {
|
|
12495
|
+
defined: {
|
|
12496
|
+
name: "ExecutionStatus"
|
|
12497
|
+
}
|
|
12498
|
+
}
|
|
11482
12499
|
}
|
|
11483
12500
|
]
|
|
11484
12501
|
}
|
|
@@ -11560,9 +12577,6 @@ var types = [
|
|
|
11560
12577
|
},
|
|
11561
12578
|
{
|
|
11562
12579
|
name: "NoPubkeysSet"
|
|
11563
|
-
},
|
|
11564
|
-
{
|
|
11565
|
-
name: "AccountNotFound"
|
|
11566
12580
|
}
|
|
11567
12581
|
]
|
|
11568
12582
|
}
|
|
@@ -11855,7 +12869,7 @@ var types = [
|
|
|
11855
12869
|
{
|
|
11856
12870
|
name: "status",
|
|
11857
12871
|
docs: [
|
|
11858
|
-
"The status of this MXE (Active or
|
|
12872
|
+
"The status of this MXE (Active or Migration)."
|
|
11859
12873
|
],
|
|
11860
12874
|
type: {
|
|
11861
12875
|
defined: {
|
|
@@ -12159,7 +13173,7 @@ var types = [
|
|
|
12159
13173
|
name: "Active"
|
|
12160
13174
|
},
|
|
12161
13175
|
{
|
|
12162
|
-
name: "
|
|
13176
|
+
name: "Migration"
|
|
12163
13177
|
}
|
|
12164
13178
|
]
|
|
12165
13179
|
}
|
|
@@ -12452,6 +13466,38 @@ var types = [
|
|
|
12452
13466
|
]
|
|
12453
13467
|
}
|
|
12454
13468
|
},
|
|
13469
|
+
{
|
|
13470
|
+
name: "PermissionedRecoveryPeersAccount",
|
|
13471
|
+
docs: [
|
|
13472
|
+
"Account for tracking permissioned recovery peers - needed until we have staking."
|
|
13473
|
+
],
|
|
13474
|
+
serialization: "bytemuck",
|
|
13475
|
+
repr: {
|
|
13476
|
+
kind: "c"
|
|
13477
|
+
},
|
|
13478
|
+
type: {
|
|
13479
|
+
kind: "struct",
|
|
13480
|
+
fields: [
|
|
13481
|
+
{
|
|
13482
|
+
name: "permissioned_peers",
|
|
13483
|
+
docs: [
|
|
13484
|
+
"DO NOT PUT ANYTHING ELSE BEFORE THE PERMISSIONED_PEERS FIELD, IT'S EXPECTED TO BE AT",
|
|
13485
|
+
"OFFSET 8."
|
|
13486
|
+
],
|
|
13487
|
+
type: {
|
|
13488
|
+
array: [
|
|
13489
|
+
"pubkey",
|
|
13490
|
+
25
|
|
13491
|
+
]
|
|
13492
|
+
}
|
|
13493
|
+
},
|
|
13494
|
+
{
|
|
13495
|
+
name: "bump",
|
|
13496
|
+
type: "u8"
|
|
13497
|
+
}
|
|
13498
|
+
]
|
|
13499
|
+
}
|
|
13500
|
+
},
|
|
12455
13501
|
{
|
|
12456
13502
|
name: "QueueComputationEvent",
|
|
12457
13503
|
type: {
|
|
@@ -12615,6 +13661,18 @@ var types = [
|
|
|
12615
13661
|
]
|
|
12616
13662
|
}
|
|
12617
13663
|
},
|
|
13664
|
+
{
|
|
13665
|
+
name: "peer_offset",
|
|
13666
|
+
docs: [
|
|
13667
|
+
"DO NOT PUT ANYTHING ELSE BEFORE THE PEER_OFFSET FIELD, IT'S EXPECTED TO BE AT OFFSET 72."
|
|
13668
|
+
],
|
|
13669
|
+
type: {
|
|
13670
|
+
array: [
|
|
13671
|
+
"u8",
|
|
13672
|
+
4
|
|
13673
|
+
]
|
|
13674
|
+
}
|
|
13675
|
+
},
|
|
12618
13676
|
{
|
|
12619
13677
|
name: "bump",
|
|
12620
13678
|
type: "u8"
|
|
@@ -13107,62 +14165,62 @@ const ARCIUM_IDL = (arcium ?? ARCIUM_IDL_MODULE);
|
|
|
13107
14165
|
const ARCIUM_ADDR = ARCIUM_IDL.address;
|
|
13108
14166
|
|
|
13109
14167
|
/**
|
|
13110
|
-
* Seed for ClockAccount PDA
|
|
14168
|
+
* Seed for ClockAccount PDA.
|
|
13111
14169
|
* @constant {string}
|
|
13112
14170
|
*/
|
|
13113
14171
|
const CLOCK_ACC_SEED = 'ClockAccount';
|
|
13114
14172
|
/**
|
|
13115
|
-
* Seed for FeePool PDA
|
|
14173
|
+
* Seed for FeePool PDA.
|
|
13116
14174
|
* @constant {string}
|
|
13117
14175
|
*/
|
|
13118
14176
|
const POOL_ACC_SEED = 'FeePool';
|
|
13119
14177
|
/**
|
|
13120
|
-
* Seed for ComputationAccount PDA
|
|
14178
|
+
* Seed for ComputationAccount PDA.
|
|
13121
14179
|
* @constant {string}
|
|
13122
14180
|
*/
|
|
13123
14181
|
const COMPUTATION_ACC_SEED = 'ComputationAccount';
|
|
13124
14182
|
/**
|
|
13125
|
-
* Seed for Mempool PDA
|
|
14183
|
+
* Seed for Mempool PDA.
|
|
13126
14184
|
* @constant {string}
|
|
13127
14185
|
*/
|
|
13128
14186
|
const MEMPOOL_ACC_SEED = 'Mempool';
|
|
13129
14187
|
/**
|
|
13130
|
-
* Seed for ExecutingPoolAccount PDA
|
|
14188
|
+
* Seed for ExecutingPoolAccount PDA.
|
|
13131
14189
|
* @constant {string}
|
|
13132
14190
|
*/
|
|
13133
14191
|
const EXEC_POOL_ACC_SEED = 'Execpool';
|
|
13134
14192
|
/**
|
|
13135
|
-
* Seed for ClusterAccount PDA
|
|
14193
|
+
* Seed for ClusterAccount PDA.
|
|
13136
14194
|
* @constant {string}
|
|
13137
14195
|
*/
|
|
13138
14196
|
const CLUSTER_ACC_SEED = 'Cluster';
|
|
13139
14197
|
/**
|
|
13140
|
-
* Seed for ArxNodeAccount PDA
|
|
14198
|
+
* Seed for ArxNodeAccount PDA.
|
|
13141
14199
|
* @constant {string}
|
|
13142
14200
|
*/
|
|
13143
14201
|
const ARX_NODE_ACC_SEED = 'ArxNode';
|
|
13144
14202
|
/**
|
|
13145
|
-
* Seed for MXE Account PDA
|
|
14203
|
+
* Seed for MXE Account PDA.
|
|
13146
14204
|
* @constant {string}
|
|
13147
14205
|
*/
|
|
13148
14206
|
const MXE_ACCOUNT_SEED = 'MXEAccount';
|
|
13149
14207
|
/**
|
|
13150
|
-
* Seed for CompDefAccount PDA
|
|
14208
|
+
* Seed for CompDefAccount PDA.
|
|
13151
14209
|
* @constant {string}
|
|
13152
14210
|
*/
|
|
13153
14211
|
const COMP_DEF_ACC_SEED = 'ComputationDefinitionAccount';
|
|
13154
14212
|
/**
|
|
13155
|
-
* Seed for RecoveryClusterAccount PDA
|
|
14213
|
+
* Seed for RecoveryClusterAccount PDA.
|
|
13156
14214
|
* @constant {string}
|
|
13157
14215
|
*/
|
|
13158
14216
|
const RECOVERY_CLUSTER_ACC_SEED = 'RecoveryClusterAccount';
|
|
13159
14217
|
/**
|
|
13160
|
-
* Seed for MxeRecoveryAccount PDA
|
|
14218
|
+
* Seed for MxeRecoveryAccount PDA.
|
|
13161
14219
|
* @constant {string}
|
|
13162
14220
|
*/
|
|
13163
14221
|
const MXE_RECOVERY_ACC_SEED = 'MxeRecoveryAccount';
|
|
13164
14222
|
/**
|
|
13165
|
-
* Seed for ComputationDefinitionRaw PDA
|
|
14223
|
+
* Seed for ComputationDefinitionRaw PDA.
|
|
13166
14224
|
* @constant {string}
|
|
13167
14225
|
*/
|
|
13168
14226
|
const RAW_CIRCUIT_ACC_SEED = 'ComputationDefinitionRaw';
|
|
@@ -13182,7 +14240,7 @@ const MAX_UPLOAD_PER_TX_BYTES = 814;
|
|
|
13182
14240
|
*/
|
|
13183
14241
|
const MAX_ACCOUNT_SIZE = 10485760;
|
|
13184
14242
|
/**
|
|
13185
|
-
* Maximum number of
|
|
14243
|
+
* Maximum number of Arcium embiggen instructions allowed in a single transaction (due to compute unit limits).
|
|
13186
14244
|
* @constant {number}
|
|
13187
14245
|
*/
|
|
13188
14246
|
const MAX_EMBIGGEN_IX_PER_TX = 18;
|
|
@@ -13203,17 +14261,17 @@ const OFFSET_BUFFER_SIZE = 4;
|
|
|
13203
14261
|
const COMP_DEF_OFFSET_SIZE = 4;
|
|
13204
14262
|
|
|
13205
14263
|
/**
|
|
13206
|
-
*
|
|
13207
|
-
* @returns
|
|
14264
|
+
* Return the public key of the deployed Arcium program on Solana.
|
|
14265
|
+
* @returns Arcium program's public key.
|
|
13208
14266
|
*/
|
|
13209
14267
|
function getArciumProgramId() {
|
|
13210
14268
|
return new anchor.web3.PublicKey(ARCIUM_ADDR);
|
|
13211
14269
|
}
|
|
13212
14270
|
/**
|
|
13213
|
-
*
|
|
13214
|
-
* @param clusterOffset -
|
|
13215
|
-
* @param computationOffset -
|
|
13216
|
-
* @returns
|
|
14271
|
+
* Derive the computation account address for a given cluster and computation offset.
|
|
14272
|
+
* @param clusterOffset - Offset of the cluster this computation will be executed by.
|
|
14273
|
+
* @param computationOffset - Computation offset as an anchor.BN.
|
|
14274
|
+
* @returns Derived computation account public key.
|
|
13217
14275
|
*/
|
|
13218
14276
|
function getComputationAccAddress(clusterOffset, computationOffset) {
|
|
13219
14277
|
const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
@@ -13222,9 +14280,9 @@ function getComputationAccAddress(clusterOffset, computationOffset) {
|
|
|
13222
14280
|
return generateArciumPDAFrom(seeds)[0];
|
|
13223
14281
|
}
|
|
13224
14282
|
/**
|
|
13225
|
-
*
|
|
13226
|
-
* @param clusterOffset -
|
|
13227
|
-
* @returns
|
|
14283
|
+
* Derive the mempool account address for a given cluster.
|
|
14284
|
+
* @param clusterOffset - Offset of the cluster.
|
|
14285
|
+
* @returns Derived mempool account public key.
|
|
13228
14286
|
*/
|
|
13229
14287
|
function getMempoolAccAddress(clusterOffset) {
|
|
13230
14288
|
const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
@@ -13233,9 +14291,9 @@ function getMempoolAccAddress(clusterOffset) {
|
|
|
13233
14291
|
return generateArciumPDAFrom(seeds)[0];
|
|
13234
14292
|
}
|
|
13235
14293
|
/**
|
|
13236
|
-
*
|
|
13237
|
-
* @param clusterOffset -
|
|
13238
|
-
* @returns
|
|
14294
|
+
* Derive the executing pool account address for a given cluster.
|
|
14295
|
+
* @param clusterOffset - Offset of the cluster.
|
|
14296
|
+
* @returns Derived executing pool account public key.
|
|
13239
14297
|
*/
|
|
13240
14298
|
function getExecutingPoolAccAddress(clusterOffset) {
|
|
13241
14299
|
const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
@@ -13244,25 +14302,25 @@ function getExecutingPoolAccAddress(clusterOffset) {
|
|
|
13244
14302
|
return generateArciumPDAFrom(seeds)[0];
|
|
13245
14303
|
}
|
|
13246
14304
|
/**
|
|
13247
|
-
*
|
|
13248
|
-
* @returns
|
|
14305
|
+
* Derive the fee pool account address.
|
|
14306
|
+
* @returns Derived fee pool account public key.
|
|
13249
14307
|
*/
|
|
13250
14308
|
function getFeePoolAccAddress() {
|
|
13251
14309
|
const seeds = [Buffer.from(POOL_ACC_SEED)];
|
|
13252
14310
|
return generateArciumPDAFrom(seeds)[0];
|
|
13253
14311
|
}
|
|
13254
14312
|
/**
|
|
13255
|
-
*
|
|
13256
|
-
* @returns
|
|
14313
|
+
* Derive the clock account address.
|
|
14314
|
+
* @returns Derived clock account public key.
|
|
13257
14315
|
*/
|
|
13258
14316
|
function getClockAccAddress() {
|
|
13259
14317
|
const seeds = [Buffer.from(CLOCK_ACC_SEED)];
|
|
13260
14318
|
return generateArciumPDAFrom(seeds)[0];
|
|
13261
14319
|
}
|
|
13262
14320
|
/**
|
|
13263
|
-
*
|
|
13264
|
-
* @param clusterOffset -
|
|
13265
|
-
* @returns
|
|
14321
|
+
* Derive the cluster account address for a given offset.
|
|
14322
|
+
* @param clusterOffset - Cluster offset as a number.
|
|
14323
|
+
* @returns Derived cluster account public key.
|
|
13266
14324
|
*/
|
|
13267
14325
|
function getClusterAccAddress(clusterOffset) {
|
|
13268
14326
|
const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
@@ -13271,9 +14329,9 @@ function getClusterAccAddress(clusterOffset) {
|
|
|
13271
14329
|
return generateArciumPDAFrom(seeds)[0];
|
|
13272
14330
|
}
|
|
13273
14331
|
/**
|
|
13274
|
-
*
|
|
13275
|
-
* @param nodeOffset -
|
|
13276
|
-
* @returns
|
|
14332
|
+
* Derive the ArxNode account address for a given offset.
|
|
14333
|
+
* @param nodeOffset - ArxNode offset as a number.
|
|
14334
|
+
* @returns Derived ArxNode account public key.
|
|
13277
14335
|
*/
|
|
13278
14336
|
function getArxNodeAccAddress(nodeOffset) {
|
|
13279
14337
|
const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
@@ -13282,19 +14340,19 @@ function getArxNodeAccAddress(nodeOffset) {
|
|
|
13282
14340
|
return generateArciumPDAFrom(seeds)[0];
|
|
13283
14341
|
}
|
|
13284
14342
|
/**
|
|
13285
|
-
*
|
|
13286
|
-
* @param mxeProgramId -
|
|
13287
|
-
* @returns
|
|
14343
|
+
* Derive the MXE account address for a given MXE program ID.
|
|
14344
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14345
|
+
* @returns Derived MXE account public key.
|
|
13288
14346
|
*/
|
|
13289
14347
|
function getMXEAccAddress(mxeProgramId) {
|
|
13290
14348
|
const seeds = [Buffer.from(MXE_ACCOUNT_SEED), mxeProgramId.toBuffer()];
|
|
13291
14349
|
return generateArciumPDAFrom(seeds)[0];
|
|
13292
14350
|
}
|
|
13293
14351
|
/**
|
|
13294
|
-
*
|
|
13295
|
-
* @param mxeProgramId -
|
|
13296
|
-
* @param compDefOffset -
|
|
13297
|
-
* @returns
|
|
14352
|
+
* Derive the computation definition account address for a given MXE program ID and offset.
|
|
14353
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14354
|
+
* @param compDefOffset - Computation definition offset as a number.
|
|
14355
|
+
* @returns Derived computation definition account public key.
|
|
13298
14356
|
*/
|
|
13299
14357
|
function getCompDefAccAddress(mxeProgramId, compDefOffset) {
|
|
13300
14358
|
const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
@@ -13303,19 +14361,19 @@ function getCompDefAccAddress(mxeProgramId, compDefOffset) {
|
|
|
13303
14361
|
return generateArciumPDAFrom(seeds)[0];
|
|
13304
14362
|
}
|
|
13305
14363
|
/**
|
|
13306
|
-
*
|
|
13307
|
-
* @param mxeProgramId -
|
|
13308
|
-
* @returns
|
|
14364
|
+
* Derive the recovery cluster account address for a given MXE program ID.
|
|
14365
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14366
|
+
* @returns Derived recovery cluster account public key.
|
|
13309
14367
|
*/
|
|
13310
14368
|
function getRecoveryClusterAccAddress(mxeProgramId) {
|
|
13311
14369
|
const seeds = [Buffer.from(RECOVERY_CLUSTER_ACC_SEED), mxeProgramId.toBuffer()];
|
|
13312
14370
|
return generateArciumPDAFrom(seeds)[0];
|
|
13313
14371
|
}
|
|
13314
14372
|
/**
|
|
13315
|
-
*
|
|
13316
|
-
* @param backupMxeProgramId -
|
|
13317
|
-
* @param originalMxeProgramId -
|
|
13318
|
-
* @returns
|
|
14373
|
+
* Derive the MXE recovery account address for a key recovery session.
|
|
14374
|
+
* @param backupMxeProgramId - Public key of the backup MXE program that will take over.
|
|
14375
|
+
* @param originalMxeProgramId - Public key of the original MXE program being recovered.
|
|
14376
|
+
* @returns Derived MXE recovery account public key.
|
|
13319
14377
|
*/
|
|
13320
14378
|
function getMxeRecoveryAccAddress(backupMxeProgramId, originalMxeProgramId) {
|
|
13321
14379
|
const seeds = [
|
|
@@ -13326,10 +14384,10 @@ function getMxeRecoveryAccAddress(backupMxeProgramId, originalMxeProgramId) {
|
|
|
13326
14384
|
return generateArciumPDAFrom(seeds)[0];
|
|
13327
14385
|
}
|
|
13328
14386
|
/**
|
|
13329
|
-
*
|
|
13330
|
-
* @param compDefPubkey -
|
|
13331
|
-
* @param rawCircuitIndex -
|
|
13332
|
-
* @returns
|
|
14387
|
+
* Derive the raw circuit account address for a given computation definition and index.
|
|
14388
|
+
* @param compDefPubkey - Public key of the computation definition account.
|
|
14389
|
+
* @param rawCircuitIndex - Index of the raw circuit account (0-based).
|
|
14390
|
+
* @returns Derived raw circuit account public key.
|
|
13333
14391
|
*/
|
|
13334
14392
|
function getRawCircuitAccAddress(compDefPubkey, rawCircuitIndex) {
|
|
13335
14393
|
const seeds = [
|
|
@@ -13340,10 +14398,10 @@ function getRawCircuitAccAddress(compDefPubkey, rawCircuitIndex) {
|
|
|
13340
14398
|
return generateArciumPDAFrom(seeds)[0];
|
|
13341
14399
|
}
|
|
13342
14400
|
/**
|
|
13343
|
-
*
|
|
13344
|
-
* @param mxeProgramId -
|
|
13345
|
-
* @param lutOffset -
|
|
13346
|
-
* @returns
|
|
14401
|
+
* Derive the address lookup table address for an MXE program.
|
|
14402
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14403
|
+
* @param lutOffset - Index of the lookup table, to be fetched from the mxe account.
|
|
14404
|
+
* @returns Derived address lookup table public key.
|
|
13347
14405
|
*/
|
|
13348
14406
|
function getLookupTableAddress(mxeProgramId, lutOffset) {
|
|
13349
14407
|
const mxeAccount = getMXEAccAddress(mxeProgramId);
|
|
@@ -13352,9 +14410,9 @@ function getLookupTableAddress(mxeProgramId, lutOffset) {
|
|
|
13352
14410
|
return PublicKey.findProgramAddressSync(seeds, AddressLookupTableProgram.programId)[0];
|
|
13353
14411
|
}
|
|
13354
14412
|
/**
|
|
13355
|
-
*
|
|
13356
|
-
* @param seeds -
|
|
13357
|
-
* @returns
|
|
14413
|
+
* Generate a program-derived address (PDA) from the provided seeds and the Arcium program ID.
|
|
14414
|
+
* @param seeds - Array of Buffer seeds used for PDA derivation.
|
|
14415
|
+
* @returns Tuple containing the derived public key and the bump seed.
|
|
13358
14416
|
*/
|
|
13359
14417
|
function generateArciumPDAFrom(seeds) {
|
|
13360
14418
|
const programId = getArciumProgramId();
|
|
@@ -13462,10 +14520,10 @@ const EXECPOOL_DISCRIMINATOR_MAP = {
|
|
|
13462
14520
|
[LARGE_EXECPOOL_DISCRIMINATOR.toString()]: LARGE_EXECPOOL_ACC_NAME,
|
|
13463
14521
|
};
|
|
13464
14522
|
/**
|
|
13465
|
-
*
|
|
13466
|
-
* @param provider -
|
|
13467
|
-
* @param mempoolAccPubkey -
|
|
13468
|
-
* @returns
|
|
14523
|
+
* Fetch and decode the mempool account info for any mempool account size.
|
|
14524
|
+
* @param provider - Anchor provider to use for fetching accounts.
|
|
14525
|
+
* @param mempoolAccPubkey - Public key of the mempool account.
|
|
14526
|
+
* @returns Decoded mempool account info.
|
|
13469
14527
|
* @throws Error if the account cannot be fetched or the discriminator is unknown.
|
|
13470
14528
|
*/
|
|
13471
14529
|
async function getMempoolAccInfo(provider, mempoolAccPubkey) {
|
|
@@ -13482,10 +14540,10 @@ async function getMempoolAccInfo(provider, mempoolAccPubkey) {
|
|
|
13482
14540
|
return program.coder.accounts.decode(accName, accData.data);
|
|
13483
14541
|
}
|
|
13484
14542
|
/**
|
|
13485
|
-
*
|
|
13486
|
-
* @param provider -
|
|
13487
|
-
* @param executingPoolAccPubkey -
|
|
13488
|
-
* @returns
|
|
14543
|
+
* Fetch and decode the executing pool account info for any pool size.
|
|
14544
|
+
* @param provider - Anchor provider to use for fetching accounts.
|
|
14545
|
+
* @param executingPoolAccPubkey - Public key of the executing pool account.
|
|
14546
|
+
* @returns Decoded executing pool account info.
|
|
13489
14547
|
* @throws Error if the account cannot be fetched or the discriminator is unknown.
|
|
13490
14548
|
*/
|
|
13491
14549
|
async function getExecutingPoolAccInfo(provider, executingPoolAccPubkey) {
|
|
@@ -13502,10 +14560,10 @@ async function getExecutingPoolAccInfo(provider, executingPoolAccPubkey) {
|
|
|
13502
14560
|
return program.coder.accounts.decode(accName, accData.data);
|
|
13503
14561
|
}
|
|
13504
14562
|
/**
|
|
13505
|
-
*
|
|
14563
|
+
* Return all computation references in the mempool for a given account.
|
|
13506
14564
|
* Only non-stake computations are included.
|
|
13507
|
-
* @param arciumProgram -
|
|
13508
|
-
* @param address -
|
|
14565
|
+
* @param arciumProgram - Anchor program instance.
|
|
14566
|
+
* @param address - Public key of the mempool account.
|
|
13509
14567
|
* @returns Array of ComputationReference objects.
|
|
13510
14568
|
*/
|
|
13511
14569
|
async function getComputationsInMempool(arciumProgram, address) {
|
|
@@ -13536,9 +14594,9 @@ async function getComputationsInMempool(arciumProgram, address) {
|
|
|
13536
14594
|
.filter((ref) => !isNullRef(ref));
|
|
13537
14595
|
}
|
|
13538
14596
|
/**
|
|
13539
|
-
*
|
|
13540
|
-
* @param arciumProgram -
|
|
13541
|
-
* @param mempoolAddress -
|
|
14597
|
+
* Calculate priority fee statistics for computations in a mempool.
|
|
14598
|
+
* @param arciumProgram - Anchor program instance.
|
|
14599
|
+
* @param mempoolAddress - Public key of the mempool account.
|
|
13542
14600
|
* @returns Priority fee statistics (mean, median, min, max, count).
|
|
13543
14601
|
*/
|
|
13544
14602
|
async function getMempoolPriorityFeeStats(arciumProgram, mempoolAddress) {
|
|
@@ -13563,11 +14621,11 @@ async function getMempoolPriorityFeeStats(arciumProgram, mempoolAddress) {
|
|
|
13563
14621
|
};
|
|
13564
14622
|
}
|
|
13565
14623
|
/**
|
|
13566
|
-
*
|
|
13567
|
-
* @param provider -
|
|
13568
|
-
* @param mxeProgramId -
|
|
13569
|
-
* @param field -
|
|
13570
|
-
* @returns
|
|
14624
|
+
* Fetch a specific utility key from the MXE account.
|
|
14625
|
+
* @param provider - Anchor provider to use for fetching accounts.
|
|
14626
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14627
|
+
* @param field - Field name to extract ('x25519Pubkey' or 'ed25519VerifyingKey').
|
|
14628
|
+
* @returns Utility key as a Uint8Array, or null if not set.
|
|
13571
14629
|
*/
|
|
13572
14630
|
async function getMXEUtilityKey(provider, mxeProgramId, field) {
|
|
13573
14631
|
const program = getArciumProgram(provider);
|
|
@@ -13586,28 +14644,28 @@ async function getMXEUtilityKey(provider, mxeProgramId, field) {
|
|
|
13586
14644
|
return null;
|
|
13587
14645
|
}
|
|
13588
14646
|
/**
|
|
13589
|
-
*
|
|
13590
|
-
* @param provider -
|
|
13591
|
-
* @param mxeProgramId -
|
|
13592
|
-
* @returns
|
|
14647
|
+
* Fetch and extract the MXE X25519 public key from the MXE account.
|
|
14648
|
+
* @param provider - Anchor provider to use for fetching accounts.
|
|
14649
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14650
|
+
* @returns MXE's X25519 public key as a Uint8Array, or null if not set.
|
|
13593
14651
|
*/
|
|
13594
14652
|
async function getMXEPublicKey(provider, mxeProgramId) {
|
|
13595
14653
|
return getMXEUtilityKey(provider, mxeProgramId, 'x25519Pubkey');
|
|
13596
14654
|
}
|
|
13597
14655
|
/**
|
|
13598
|
-
*
|
|
13599
|
-
* @param provider -
|
|
13600
|
-
* @param mxeProgramId -
|
|
13601
|
-
* @returns
|
|
14656
|
+
* Fetch and extract the MXE arcis Ed25519 verifying key from the MXE account.
|
|
14657
|
+
* @param provider - Anchor provider to use for fetching accounts.
|
|
14658
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14659
|
+
* @returns MXE's arcis Ed25519 verifying key as a Uint8Array, or null if not set.
|
|
13602
14660
|
*/
|
|
13603
14661
|
async function getMXEArcisEd25519VerifyingKey(provider, mxeProgramId) {
|
|
13604
14662
|
return getMXEUtilityKey(provider, mxeProgramId, 'ed25519VerifyingKey');
|
|
13605
14663
|
}
|
|
13606
14664
|
/**
|
|
13607
|
-
*
|
|
14665
|
+
* Determine the current state of a circuit based on its on-chain configuration.
|
|
13608
14666
|
* @internal Called internally by `uploadCircuit` - most users don't need this directly.
|
|
13609
|
-
* @param circuitSource -
|
|
13610
|
-
* @returns
|
|
14667
|
+
* @param circuitSource - circuitSource field from ComputationDefinitionAccount.
|
|
14668
|
+
* @returns Current state of the circuit.
|
|
13611
14669
|
*/
|
|
13612
14670
|
function getCircuitState(circuitSource) {
|
|
13613
14671
|
if (!('onChain' in circuitSource) || !circuitSource.onChain) {
|
|
@@ -13619,14 +14677,15 @@ function getCircuitState(circuitSource) {
|
|
|
13619
14677
|
return 'OnchainPending';
|
|
13620
14678
|
}
|
|
13621
14679
|
/**
|
|
13622
|
-
*
|
|
13623
|
-
* @param provider -
|
|
13624
|
-
* @param circuitName -
|
|
13625
|
-
* @param mxeProgramId -
|
|
13626
|
-
* @param rawCircuit -
|
|
14680
|
+
* Upload a circuit to the blockchain, splitting it into multiple accounts if necessary.
|
|
14681
|
+
* @param provider - Anchor provider to use for transactions.
|
|
14682
|
+
* @param circuitName - Name of the circuit.
|
|
14683
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14684
|
+
* @param rawCircuit - Raw circuit data as a Uint8Array.
|
|
13627
14685
|
* @param logging - Whether to log progress (default: true).
|
|
13628
|
-
* @param chunkSize -
|
|
13629
|
-
* @
|
|
14686
|
+
* @param chunkSize - Number of upload transactions to send in parallel (default: 500).
|
|
14687
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
14688
|
+
* @returns Array of transaction signatures for all upload and finalize transactions.
|
|
13630
14689
|
*/
|
|
13631
14690
|
async function uploadCircuit(provider, circuitName, mxeProgramId, rawCircuit, logging = true, chunkSize = 500, confirmOptions) {
|
|
13632
14691
|
const compDefAccInfo = getCompDefAccInfo(circuitName, mxeProgramId);
|
|
@@ -13650,6 +14709,14 @@ async function uploadCircuit(provider, circuitName, mxeProgramId, rawCircuit, lo
|
|
|
13650
14709
|
sigs.push(await signAndSendWithBlockhash(provider, finalizeCompDefTx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions));
|
|
13651
14710
|
return sigs;
|
|
13652
14711
|
}
|
|
14712
|
+
/**
|
|
14713
|
+
* Queue a key recovery initialization for an MXE on a given cluster.
|
|
14714
|
+
* @param provider - Anchor provider for signing and sending.
|
|
14715
|
+
* @param clusterOffset - Cluster offset to recover keys from.
|
|
14716
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14717
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
14718
|
+
* @returns Array of transaction signatures.
|
|
14719
|
+
*/
|
|
13653
14720
|
async function queueKeyRecoveryInit(provider, clusterOffset, mxeProgramId, confirmOptions) {
|
|
13654
14721
|
const program = getArciumProgram(provider);
|
|
13655
14722
|
const sigs = [];
|
|
@@ -13664,11 +14731,11 @@ async function queueKeyRecoveryInit(provider, clusterOffset, mxeProgramId, confi
|
|
|
13664
14731
|
return sigs;
|
|
13665
14732
|
}
|
|
13666
14733
|
/**
|
|
13667
|
-
*
|
|
13668
|
-
* @param provider -
|
|
13669
|
-
* @param compDefOffset -
|
|
13670
|
-
* @param mxeProgramId -
|
|
13671
|
-
* @returns
|
|
14734
|
+
* Build a transaction to finalize a computation definition.
|
|
14735
|
+
* @param provider - Anchor provider to use for transactions.
|
|
14736
|
+
* @param compDefOffset - Offset of the computation definition.
|
|
14737
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14738
|
+
* @returns Transaction to finalize the computation definition.
|
|
13672
14739
|
*/
|
|
13673
14740
|
async function buildFinalizeCompDefTx(provider, compDefOffset, mxeProgramId) {
|
|
13674
14741
|
const program = getArciumProgram(provider);
|
|
@@ -13786,35 +14853,35 @@ async function signAndSendWithBlockhash(provider, tx, block, confirmOptions) {
|
|
|
13786
14853
|
return provider.sendAndConfirm(tx, [], confirmOptions || { commitment: 'confirmed' });
|
|
13787
14854
|
}
|
|
13788
14855
|
/**
|
|
13789
|
-
*
|
|
13790
|
-
* @param accName -
|
|
13791
|
-
* @returns
|
|
14856
|
+
* Return the base seed for an Arcium account, given its name.
|
|
14857
|
+
* @param accName - Name of the account.
|
|
14858
|
+
* @returns Base seed as a Uint8Array.
|
|
13792
14859
|
*/
|
|
13793
14860
|
function getArciumAccountBaseSeed(accName) {
|
|
13794
14861
|
return Buffer.from(accName, 'utf-8');
|
|
13795
14862
|
}
|
|
13796
14863
|
/**
|
|
13797
|
-
*
|
|
13798
|
-
* @param circuitName -
|
|
13799
|
-
* @returns
|
|
14864
|
+
* Compute the offset for a computation definition account, based on the circuit name.
|
|
14865
|
+
* @param circuitName - Name of the circuit.
|
|
14866
|
+
* @returns Offset as a 4-byte Uint8Array.
|
|
13800
14867
|
*/
|
|
13801
14868
|
function getCompDefAccOffset(circuitName) {
|
|
13802
14869
|
const hash = new Uint8Array(sha256([Buffer.from(circuitName, 'utf-8')]));
|
|
13803
14870
|
return hash.slice(0, COMP_DEF_OFFSET_SIZE);
|
|
13804
14871
|
}
|
|
13805
14872
|
/**
|
|
13806
|
-
*
|
|
13807
|
-
* @param provider -
|
|
13808
|
-
* @returns
|
|
14873
|
+
* Return an Anchor program instance for the Arcium program.
|
|
14874
|
+
* @param provider - Anchor provider to use.
|
|
14875
|
+
* @returns Anchor program instance for Arcium.
|
|
13809
14876
|
*/
|
|
13810
14877
|
function getArciumProgram(provider) {
|
|
13811
14878
|
return new Program(ARCIUM_IDL, provider);
|
|
13812
14879
|
}
|
|
13813
14880
|
/**
|
|
13814
|
-
*
|
|
13815
|
-
* @param circuitName -
|
|
13816
|
-
* @param mxeProgramId -
|
|
13817
|
-
* @returns
|
|
14881
|
+
* Return the public key and offset for a computation definition account, given the circuit name and MXE program ID.
|
|
14882
|
+
* @param circuitName - Name of the circuit.
|
|
14883
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14884
|
+
* @returns Object containing the public key and offset for the computation definition account.
|
|
13818
14885
|
*/
|
|
13819
14886
|
function getCompDefAccInfo(circuitName, mxeProgramId) {
|
|
13820
14887
|
const offset = getCompDefAccOffset(circuitName);
|
|
@@ -13822,20 +14889,21 @@ function getCompDefAccInfo(circuitName, mxeProgramId) {
|
|
|
13822
14889
|
return { pubkey: pda, offset: Buffer.from(offset).readUInt32LE(0) };
|
|
13823
14890
|
}
|
|
13824
14891
|
/**
|
|
13825
|
-
*
|
|
13826
|
-
* @param arciumProgramId -
|
|
13827
|
-
* @param mxeProgramId -
|
|
13828
|
-
* @param offset -
|
|
13829
|
-
* @returns
|
|
14892
|
+
* Return the PDA for a computation definition account, given the program ID, MXE program ID, and offset.
|
|
14893
|
+
* @param arciumProgramId - Public key of the Arcium program.
|
|
14894
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
14895
|
+
* @param offset - Offset as a Uint8Array.
|
|
14896
|
+
* @returns PDA for the computation definition account.
|
|
13830
14897
|
*/
|
|
13831
14898
|
function getCompDefAccPDA(arciumProgramId, mxeProgramId, offset) {
|
|
13832
14899
|
return anchor.web3.PublicKey.findProgramAddressSync([Buffer.from(COMP_DEF_ACC_SEED, 'utf-8'), mxeProgramId.toBuffer(), offset], arciumProgramId)[0];
|
|
13833
14900
|
}
|
|
13834
14901
|
/**
|
|
13835
|
-
*
|
|
13836
|
-
* @param provider -
|
|
13837
|
-
* @param mxeProgramId -
|
|
13838
|
-
* @
|
|
14902
|
+
* Set an MXE to Recovery status, initiating the key recovery process.
|
|
14903
|
+
* @param provider - Anchor provider to use for transactions.
|
|
14904
|
+
* @param mxeProgramId - Public key of the MXE program to recover.
|
|
14905
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
14906
|
+
* @returns Transaction signature.
|
|
13839
14907
|
*/
|
|
13840
14908
|
async function recoverMxe(provider, mxeProgramId, confirmOptions) {
|
|
13841
14909
|
const program = getArciumProgram(provider);
|
|
@@ -13849,13 +14917,14 @@ async function recoverMxe(provider, mxeProgramId, confirmOptions) {
|
|
|
13849
14917
|
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
13850
14918
|
}
|
|
13851
14919
|
/**
|
|
13852
|
-
*
|
|
14920
|
+
* Initialize key recovery execution by creating the MxeRecoveryAccount and
|
|
13853
14921
|
* registering the key_recovery_final computation definition on the backup MXE.
|
|
13854
14922
|
* This is split into two parts due to Solana's 10KB per-instruction allocation limit.
|
|
13855
|
-
* @param provider -
|
|
13856
|
-
* @param originalMxeProgramId -
|
|
13857
|
-
* @param backupMxeProgramId -
|
|
13858
|
-
* @
|
|
14923
|
+
* @param provider - Anchor provider to use for transactions.
|
|
14924
|
+
* @param originalMxeProgramId - Public key of the original MXE program being recovered.
|
|
14925
|
+
* @param backupMxeProgramId - Public key of the backup MXE program that will take over.
|
|
14926
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
14927
|
+
* @returns Transaction signature from part2.
|
|
13859
14928
|
*/
|
|
13860
14929
|
async function initKeyRecoveryExecution(provider, originalMxeProgramId, backupMxeProgramId, confirmOptions) {
|
|
13861
14930
|
// Part 1: Create MxeRecoveryAccount with partial size
|
|
@@ -13882,16 +14951,17 @@ async function initKeyRecoveryExecution(provider, originalMxeProgramId, backupMx
|
|
|
13882
14951
|
return signAndSendWithBlockhash(provider, tx2, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
13883
14952
|
}
|
|
13884
14953
|
/**
|
|
13885
|
-
*
|
|
14954
|
+
* Submit a re-encrypted key recovery share from a recovery peer.
|
|
13886
14955
|
* Recovery peers must decrypt shares using their x25519 private key and re-encrypt
|
|
13887
14956
|
* them for the backup MXE before submission.
|
|
13888
|
-
* @param provider -
|
|
13889
|
-
* @param originalMxeProgramId -
|
|
13890
|
-
* @param backupMxeProgramId -
|
|
13891
|
-
* @param peerOffset -
|
|
13892
|
-
* @param peerIndex -
|
|
13893
|
-
* @param share -
|
|
13894
|
-
* @
|
|
14957
|
+
* @param provider - Anchor provider to use for transactions.
|
|
14958
|
+
* @param originalMxeProgramId - Public key of the original MXE program being recovered.
|
|
14959
|
+
* @param backupMxeProgramId - Public key of the backup MXE program.
|
|
14960
|
+
* @param peerOffset - Offset of the recovery peer.
|
|
14961
|
+
* @param peerIndex - Index of this peer in the recovery peers list.
|
|
14962
|
+
* @param share - Re-encrypted share: 5 field elements of 32 bytes each (160 bytes total).
|
|
14963
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
14964
|
+
* @returns Transaction signature.
|
|
13895
14965
|
*/
|
|
13896
14966
|
async function submitKeyRecoveryShare(provider, originalMxeProgramId, backupMxeProgramId, peerOffset, peerIndex, share, confirmOptions) {
|
|
13897
14967
|
const program = getArciumProgram(provider);
|
|
@@ -13916,14 +14986,15 @@ async function submitKeyRecoveryShare(provider, originalMxeProgramId, backupMxeP
|
|
|
13916
14986
|
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
13917
14987
|
}
|
|
13918
14988
|
/**
|
|
13919
|
-
*
|
|
14989
|
+
* Finalize key recovery execution after the submission threshold is met.
|
|
13920
14990
|
* This queues the key_recovery_finalize MPC computation on the backup cluster.
|
|
13921
|
-
* @param provider -
|
|
13922
|
-
* @param originalMxeProgramId -
|
|
13923
|
-
* @param backupMxeProgramId -
|
|
13924
|
-
* @param clusterOffset -
|
|
13925
|
-
* @param keyRecoveryFinalizeOffset -
|
|
13926
|
-
* @
|
|
14991
|
+
* @param provider - Anchor provider to use for transactions.
|
|
14992
|
+
* @param originalMxeProgramId - Public key of the original MXE program being recovered.
|
|
14993
|
+
* @param backupMxeProgramId - Public key of the backup MXE program.
|
|
14994
|
+
* @param clusterOffset - Cluster offset where the backup MXE is deployed.
|
|
14995
|
+
* @param keyRecoveryFinalizeOffset - Computation offset for the key_recovery_finalize computation.
|
|
14996
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
14997
|
+
* @returns Transaction signature.
|
|
13927
14998
|
*/
|
|
13928
14999
|
async function finalizeKeyRecoveryExecution(provider, originalMxeProgramId, backupMxeProgramId, clusterOffset, keyRecoveryFinalizeOffset, confirmOptions) {
|
|
13929
15000
|
const program = getArciumProgram(provider);
|
|
@@ -13942,12 +15013,13 @@ async function finalizeKeyRecoveryExecution(provider, originalMxeProgramId, back
|
|
|
13942
15013
|
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
13943
15014
|
}
|
|
13944
15015
|
/**
|
|
13945
|
-
*
|
|
15016
|
+
* Initialize an MXE (part 1). Due to Solana's 10KB per-instruction allocation limit,
|
|
13946
15017
|
* this only partially allocates recovery_cluster_acc.
|
|
13947
15018
|
* Call initMxePart2 afterwards to finish allocation and add keygen to mempool.
|
|
13948
|
-
* @param provider -
|
|
13949
|
-
* @param mxeProgramId -
|
|
13950
|
-
* @
|
|
15019
|
+
* @param provider - Anchor provider to use for transactions.
|
|
15020
|
+
* @param mxeProgramId - Public key to use as the MXE program ID.
|
|
15021
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
15022
|
+
* @returns Transaction signature.
|
|
13951
15023
|
*/
|
|
13952
15024
|
async function initMxePart1(provider, mxeProgramId, confirmOptions) {
|
|
13953
15025
|
const program = getArciumProgram(provider);
|
|
@@ -13961,17 +15033,19 @@ async function initMxePart1(provider, mxeProgramId, confirmOptions) {
|
|
|
13961
15033
|
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
13962
15034
|
}
|
|
13963
15035
|
/**
|
|
13964
|
-
*
|
|
13965
|
-
*
|
|
13966
|
-
* and
|
|
13967
|
-
* @param provider -
|
|
13968
|
-
* @param clusterOffset -
|
|
13969
|
-
* @param mxeProgramId -
|
|
15036
|
+
* Finish MXE initialization (part 2).
|
|
15037
|
+
* Reallocate recovery_cluster_acc to full size, initialize recovery_peers,
|
|
15038
|
+
* and add the keygen computation to the mempool.
|
|
15039
|
+
* @param provider - Anchor provider to use for transactions.
|
|
15040
|
+
* @param clusterOffset - Cluster offset to associate with the MXE.
|
|
15041
|
+
* @param mxeProgramId - Public key to use as the MXE program ID.
|
|
13970
15042
|
* @param recoveryPeers - Array of 100 node offsets for recovery peers (0 for unused slots).
|
|
13971
|
-
* @param keygenOffset -
|
|
13972
|
-
* @param keyRecoveryInitOffset -
|
|
15043
|
+
* @param keygenOffset - Computation offset for the keygen computation.
|
|
15044
|
+
* @param keyRecoveryInitOffset - Computation offset for the key_recovery_init computation.
|
|
15045
|
+
* @param lutOffset - Lookup table offset for the MXE's address lookup table.
|
|
13973
15046
|
* @param mxeAuthority - Optional authority for the MXE (defaults to provider.publicKey).
|
|
13974
|
-
* @
|
|
15047
|
+
* @param confirmOptions - Transaction confirmation options.
|
|
15048
|
+
* @returns Transaction signature.
|
|
13975
15049
|
*/
|
|
13976
15050
|
async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers, keygenOffset, keyRecoveryInitOffset, lutOffset, mxeAuthority, confirmOptions) {
|
|
13977
15051
|
const program = getArciumProgram(provider);
|
|
@@ -13997,9 +15071,9 @@ async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers
|
|
|
13997
15071
|
}
|
|
13998
15072
|
|
|
13999
15073
|
/**
|
|
14000
|
-
*
|
|
15074
|
+
* Read local Arcium environment information from environment variables.
|
|
14001
15075
|
* Only available in Node.js and when testing locally.
|
|
14002
|
-
* @returns
|
|
15076
|
+
* @returns Local Arcium environment configuration.
|
|
14003
15077
|
* @throws Error if called in a browser or if required environment variables are missing or invalid.
|
|
14004
15078
|
*/
|
|
14005
15079
|
function getArciumEnv() {
|
|
@@ -14011,8 +15085,14 @@ function getArciumEnv() {
|
|
|
14011
15085
|
if (isNaN(arciumClusterOffset)) {
|
|
14012
15086
|
throw new Error('ARCIUM_CLUSTER_OFFSET environment variable is not set or is invalid (NaN).');
|
|
14013
15087
|
}
|
|
15088
|
+
const arciumBackupClusterOffset = process.env.ARCIUM_BACKUP_CLUSTER_OFFSET;
|
|
15089
|
+
const arciumBackupClusterOffsetNumber = Number(arciumBackupClusterOffset);
|
|
15090
|
+
if (typeof arciumBackupClusterOffset !== 'undefined' && isNaN(arciumBackupClusterOffsetNumber)) {
|
|
15091
|
+
throw new Error('ARCIUM_BACKUP_CLUSTER_OFFSET environment variable is invalid (NaN).');
|
|
15092
|
+
}
|
|
14014
15093
|
return {
|
|
14015
15094
|
arciumClusterOffset,
|
|
15095
|
+
arciumBackupClusterOffset: arciumBackupClusterOffsetNumber,
|
|
14016
15096
|
};
|
|
14017
15097
|
}
|
|
14018
15098
|
catch (e) {
|
|
@@ -14020,38 +15100,78 @@ function getArciumEnv() {
|
|
|
14020
15100
|
}
|
|
14021
15101
|
}
|
|
14022
15102
|
|
|
15103
|
+
const POLL_INTERVAL_MS = 500;
|
|
14023
15104
|
/**
|
|
14024
|
-
*
|
|
14025
|
-
*
|
|
14026
|
-
*
|
|
14027
|
-
*
|
|
14028
|
-
*
|
|
14029
|
-
*
|
|
14030
|
-
*
|
|
15105
|
+
* Wait for a computation to finalize by polling the computation account
|
|
15106
|
+
* status via HTTP RPC. Does not use WebSocket subscriptions.
|
|
15107
|
+
*
|
|
15108
|
+
* Polls every 500ms (same as Agave's send_and_confirm_transaction_with_config).
|
|
15109
|
+
* Return the most recent transaction signature on the computation account
|
|
15110
|
+
* once finalization is detected.
|
|
15111
|
+
*
|
|
15112
|
+
* @param provider - Anchor provider.
|
|
15113
|
+
* @param computationOffset - Computation offset to wait for.
|
|
15114
|
+
* @param mxeProgramId - MXE program public key.
|
|
15115
|
+
* @param commitment - Commitment level for RPC calls (default: 'confirmed').
|
|
15116
|
+
* @param timeoutMs - Maximum wait time in milliseconds (default: 120000).
|
|
15117
|
+
* @returns Transaction signature from the finalization.
|
|
15118
|
+
* @throws Error if the MXE account has no cluster assigned.
|
|
15119
|
+
* @throws Error if the computation does not finalize within timeoutMs.
|
|
14031
15120
|
*/
|
|
14032
|
-
async function awaitComputationFinalization(provider, computationOffset, mxeProgramId, commitment = 'confirmed') {
|
|
15121
|
+
async function awaitComputationFinalization(provider, computationOffset, mxeProgramId, commitment = 'confirmed', timeoutMs = 120_000) {
|
|
15122
|
+
const conn = provider.connection;
|
|
14033
15123
|
const arciumProgram = getArciumProgram(provider);
|
|
14034
|
-
|
|
14035
|
-
const
|
|
14036
|
-
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
|
|
15124
|
+
// Derive computation account PDA (requires clusterOffset from MXE account)
|
|
15125
|
+
const mxeAccAddress = getMXEAccAddress(mxeProgramId);
|
|
15126
|
+
const mxeAcc = await arciumProgram.account.mxeAccount.fetch(mxeAccAddress, commitment);
|
|
15127
|
+
if (mxeAcc.cluster === null) {
|
|
15128
|
+
throw new Error('MXE account has no cluster assigned');
|
|
15129
|
+
}
|
|
15130
|
+
const compAccAddress = getComputationAccAddress(mxeAcc.cluster, computationOffset);
|
|
15131
|
+
const startTime = Date.now();
|
|
15132
|
+
let lastStatus = 'unknown';
|
|
15133
|
+
let rpcErrorCount = 0;
|
|
15134
|
+
let lastError;
|
|
15135
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
15136
|
+
let compAcc;
|
|
15137
|
+
try {
|
|
15138
|
+
// eslint-disable-next-line no-await-in-loop
|
|
15139
|
+
compAcc = await arciumProgram.account.computationAccount.fetchNullable(compAccAddress, commitment);
|
|
15140
|
+
}
|
|
15141
|
+
catch (e) {
|
|
15142
|
+
rpcErrorCount++;
|
|
15143
|
+
lastError = e instanceof Error ? e.message : String(e);
|
|
15144
|
+
// eslint-disable-next-line no-await-in-loop
|
|
15145
|
+
await new Promise((r) => {
|
|
15146
|
+
setTimeout(r, POLL_INTERVAL_MS);
|
|
15147
|
+
});
|
|
15148
|
+
continue;
|
|
15149
|
+
}
|
|
15150
|
+
if (compAcc !== null && 'finalized' in compAcc.status) {
|
|
15151
|
+
lastStatus = 'finalized';
|
|
15152
|
+
for (let sigRetry = 0; sigRetry < 10; sigRetry++) {
|
|
15153
|
+
// eslint-disable-next-line no-await-in-loop
|
|
15154
|
+
const sigs = await conn.getSignaturesForAddress(compAccAddress, { limit: 1 }, commitment);
|
|
15155
|
+
if (sigs.length > 0)
|
|
15156
|
+
return sigs[0].signature;
|
|
15157
|
+
// eslint-disable-next-line no-await-in-loop
|
|
15158
|
+
await new Promise((r) => {
|
|
15159
|
+
setTimeout(r, POLL_INTERVAL_MS);
|
|
15160
|
+
});
|
|
15161
|
+
}
|
|
15162
|
+
throw new Error('Computation finalized but transaction signature not indexed after retries.');
|
|
15163
|
+
}
|
|
15164
|
+
if (compAcc !== null)
|
|
15165
|
+
lastStatus = 'queued';
|
|
15166
|
+
// eslint-disable-next-line no-await-in-loop
|
|
15167
|
+
await new Promise((r) => {
|
|
15168
|
+
setTimeout(r, POLL_INTERVAL_MS);
|
|
15169
|
+
});
|
|
15170
|
+
}
|
|
15171
|
+
const timeoutMsg = `Computation did not finalize within ${timeoutMs}ms (status: ${lastStatus})`;
|
|
15172
|
+
throw rpcErrorCount > 0
|
|
15173
|
+
? new Error(timeoutMsg, { cause: new Error(`${rpcErrorCount} RPC errors, last: ${lastError}`) })
|
|
15174
|
+
: new Error(timeoutMsg);
|
|
14055
15175
|
}
|
|
14056
15176
|
|
|
14057
15177
|
export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, ArcisModule, ArcisType, ArcisValueField, CSplRescueCipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, IntegerInfo, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, createPacker, deserializeLE, finalizeKeyRecoveryExecution, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getCircuitState, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getLookupTableAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, getMxeRecoveryAccAddress, getRawCircuitAccAddress, getRecoveryClusterAccAddress, initKeyRecoveryExecution, initMxePart1, initMxePart2, isNullRef, positiveModulo, queueKeyRecoveryInit, randMatrix, recoverMxe, serializeLE, sha256, submitKeyRecoveryShare, toVec, uploadCircuit };
|