@arcium-hq/client 0.4.0 → 0.5.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 +15 -9
- package/build/index.cjs +1523 -1064
- package/build/index.d.ts +1060 -1933
- package/build/index.mjs +1520 -1061
- package/package.json +3 -6
package/build/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomBytes, createHash,
|
|
1
|
+
import { randomBytes, createHash, createCipheriv, createDecipheriv } from 'crypto';
|
|
2
2
|
import { ed25519 } from '@noble/curves/ed25519';
|
|
3
3
|
export { x25519 } from '@noble/curves/ed25519';
|
|
4
4
|
import { shake256, sha3_512 } from '@noble/hashes/sha3';
|
|
@@ -81,6 +81,92 @@ function sha256(byteArrays) {
|
|
|
81
81
|
return hash.digest();
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Seed for ClockAccount PDA
|
|
86
|
+
* @constant {string}
|
|
87
|
+
*/
|
|
88
|
+
const CLOCK_ACC_SEED = 'ClockAccount';
|
|
89
|
+
/**
|
|
90
|
+
* Seed for FeePool PDA
|
|
91
|
+
* @constant {string}
|
|
92
|
+
*/
|
|
93
|
+
const POOL_ACC_SEED = 'FeePool';
|
|
94
|
+
/**
|
|
95
|
+
* Seed for ComputationAccount PDA
|
|
96
|
+
* @constant {string}
|
|
97
|
+
*/
|
|
98
|
+
const COMPUTATION_ACC_SEED = 'ComputationAccount';
|
|
99
|
+
/**
|
|
100
|
+
* Seed for Mempool PDA
|
|
101
|
+
* @constant {string}
|
|
102
|
+
*/
|
|
103
|
+
const MEMPOOL_ACC_SEED = 'Mempool';
|
|
104
|
+
/**
|
|
105
|
+
* Seed for ExecutingPoolAccount PDA
|
|
106
|
+
* @constant {string}
|
|
107
|
+
*/
|
|
108
|
+
const EXEC_POOL_ACC_SEED = 'Execpool';
|
|
109
|
+
/**
|
|
110
|
+
* Seed for ClusterAccount PDA
|
|
111
|
+
* @constant {string}
|
|
112
|
+
*/
|
|
113
|
+
const CLUSTER_ACC_SEED = 'Cluster';
|
|
114
|
+
/**
|
|
115
|
+
* Seed for ArxNodeAccount PDA
|
|
116
|
+
* @constant {string}
|
|
117
|
+
*/
|
|
118
|
+
const ARX_NODE_ACC_SEED = 'ArxNode';
|
|
119
|
+
/**
|
|
120
|
+
* Seed for MXE Account PDA
|
|
121
|
+
* @constant {string}
|
|
122
|
+
*/
|
|
123
|
+
const MXE_ACCOUNT_SEED = 'MXEAccount';
|
|
124
|
+
/**
|
|
125
|
+
* Seed for CompDefAccount PDA
|
|
126
|
+
* @constant {string}
|
|
127
|
+
*/
|
|
128
|
+
const COMP_DEF_ACC_SEED = 'ComputationDefinitionAccount';
|
|
129
|
+
/**
|
|
130
|
+
* Maximum number of bytes that can be reallocated per instruction.
|
|
131
|
+
* @constant {number}
|
|
132
|
+
*/
|
|
133
|
+
const MAX_REALLOC_PER_IX = 10240;
|
|
134
|
+
/**
|
|
135
|
+
* Maximum number of bytes that can be uploaded in a single transaction with the upload instruction.
|
|
136
|
+
* @constant {number}
|
|
137
|
+
*/
|
|
138
|
+
const MAX_UPLOAD_PER_TX_BYTES = 814;
|
|
139
|
+
/**
|
|
140
|
+
* Maximum size of an account in bytes (10MB = 10 * 1024 * 1024).
|
|
141
|
+
* @constant {number}
|
|
142
|
+
*/
|
|
143
|
+
const MAX_ACCOUNT_SIZE = 10485760;
|
|
144
|
+
/**
|
|
145
|
+
* Maximum number of arcium embiggen instructions allowed in a single transaction (due to compute unit limits).
|
|
146
|
+
* @constant {number}
|
|
147
|
+
*/
|
|
148
|
+
const MAX_EMBIGGEN_IX_PER_TX = 18;
|
|
149
|
+
/**
|
|
150
|
+
* Size of account discriminator in bytes.
|
|
151
|
+
* @constant {number}
|
|
152
|
+
*/
|
|
153
|
+
const DISCRIMINATOR_SIZE = 8;
|
|
154
|
+
/**
|
|
155
|
+
* Size of offset buffer in bytes (u32).
|
|
156
|
+
* @constant {number}
|
|
157
|
+
*/
|
|
158
|
+
const OFFSET_BUFFER_SIZE = 4;
|
|
159
|
+
/**
|
|
160
|
+
* Size of computation definition offset slice in bytes.
|
|
161
|
+
* @constant {number}
|
|
162
|
+
*/
|
|
163
|
+
const COMP_DEF_OFFSET_SIZE = 4;
|
|
164
|
+
/**
|
|
165
|
+
* Size of a uint128 in bytes.
|
|
166
|
+
* @constant {number}
|
|
167
|
+
*/
|
|
168
|
+
const UINT128_BYTE_SIZE = 16;
|
|
169
|
+
|
|
84
170
|
/**
|
|
85
171
|
* Converts a bigint to an array of bits (least significant to most significant, in 2's complement representation).
|
|
86
172
|
* @param x - The bigint to convert.
|
|
@@ -198,17 +284,32 @@ function verifyBinSize(x, binSize) {
|
|
|
198
284
|
return bin === '0' || bin === '-1';
|
|
199
285
|
}
|
|
200
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Checks if code is running in a browser environment.
|
|
289
|
+
* @returns true if window object exists, false otherwise
|
|
290
|
+
*/
|
|
201
291
|
function isBrowser() {
|
|
202
292
|
return (
|
|
203
293
|
// eslint-disable-next-line no-prototype-builtins
|
|
204
294
|
typeof window !== 'undefined' && !window.process?.hasOwnProperty('type'));
|
|
205
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Conditionally logs a message if logging is enabled.
|
|
298
|
+
* @param log - Whether to output the log
|
|
299
|
+
* @param args - Arguments to pass to console.log
|
|
300
|
+
*/
|
|
206
301
|
function optionalLog(log, ...args) {
|
|
207
302
|
if (log) {
|
|
208
303
|
// eslint-disable-next-line no-console
|
|
209
304
|
console.log(...args);
|
|
210
305
|
}
|
|
211
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Calculates the minimum number of bits needed to represent a value.
|
|
309
|
+
* Formula: floor(log2(max)) + 1 for unsigned, +1 for signed, +1 for diff of two negatives.
|
|
310
|
+
* @param max - The bigint value to measure
|
|
311
|
+
* @returns Number of bits required
|
|
312
|
+
*/
|
|
212
313
|
function getBinSize(max) {
|
|
213
314
|
// floor(log2(max)) + 1 to represent unsigned elements, a +1 for signed elements
|
|
214
315
|
// and another +1 to account for the diff of two negative elements
|
|
@@ -224,12 +325,12 @@ function getBinSize(max) {
|
|
|
224
325
|
* @throws Error if the input length is not a multiple of 16.
|
|
225
326
|
*/
|
|
226
327
|
function compressUint128(bytes) {
|
|
227
|
-
if (bytes.length %
|
|
228
|
-
throw Error(`bytes.length must be a multiple of
|
|
328
|
+
if (bytes.length % UINT128_BYTE_SIZE !== 0) {
|
|
329
|
+
throw Error(`bytes.length must be a multiple of ${UINT128_BYTE_SIZE} (found ${bytes.length})`);
|
|
229
330
|
}
|
|
230
331
|
const res = [];
|
|
231
|
-
for (let n = 0; n < bytes.length /
|
|
232
|
-
res.push(deserializeLE(bytes.slice(n *
|
|
332
|
+
for (let n = 0; n < bytes.length / UINT128_BYTE_SIZE; ++n) {
|
|
333
|
+
res.push(deserializeLE(bytes.slice(n * UINT128_BYTE_SIZE, (n + 1) * UINT128_BYTE_SIZE)));
|
|
233
334
|
}
|
|
234
335
|
return res;
|
|
235
336
|
}
|
|
@@ -250,10 +351,20 @@ function decompressUint128(compressed) {
|
|
|
250
351
|
});
|
|
251
352
|
const res = [];
|
|
252
353
|
for (let n = 0; n < compressed.length; ++n) {
|
|
253
|
-
res.push(...serializeLE(compressed[n],
|
|
354
|
+
res.push(...serializeLE(compressed[n], UINT128_BYTE_SIZE));
|
|
254
355
|
}
|
|
255
356
|
return new Uint8Array(res);
|
|
256
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Checks if a computation reference is null (all zeros).
|
|
360
|
+
* @param ref - The computation reference to check
|
|
361
|
+
* @returns true if the reference is null, false otherwise
|
|
362
|
+
*/
|
|
363
|
+
function isNullRef(ref) {
|
|
364
|
+
const bigZero = new anchor.BN(0);
|
|
365
|
+
return (ref.computationOffset === bigZero
|
|
366
|
+
&& ref.priorityFee === bigZero);
|
|
367
|
+
}
|
|
257
368
|
|
|
258
369
|
/**
|
|
259
370
|
* Matrix class over FpField. Data is row-major.
|
|
@@ -441,8 +552,10 @@ function randMatrix(field, nrows, ncols) {
|
|
|
441
552
|
* Curve25519 base field as an IField instance.
|
|
442
553
|
*/
|
|
443
554
|
const CURVE25519_BASE_FIELD = ed25519.CURVE.Fp;
|
|
444
|
-
//
|
|
445
|
-
const
|
|
555
|
+
// Security level for the block cipher.
|
|
556
|
+
const SECURITY_LEVEL_BLOCK_CIPHER = 128;
|
|
557
|
+
// Security level for the hash function.
|
|
558
|
+
const SECURITY_LEVEL_HASH_FUNCTION = 256;
|
|
446
559
|
// We refer to https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287 for more details.
|
|
447
560
|
/**
|
|
448
561
|
* Description and parameters for the Rescue cipher or hash function, including round constants, MDS matrix, and key schedule.
|
|
@@ -565,7 +678,7 @@ class RescueDesc {
|
|
|
565
678
|
return roundConstants;
|
|
566
679
|
}
|
|
567
680
|
case 'hash': {
|
|
568
|
-
hasher.update(`Rescue-XLIX(${this.field.ORDER},${m},${this.mode.capacity},${
|
|
681
|
+
hasher.update(`Rescue-XLIX(${this.field.ORDER},${m},${this.mode.capacity},${SECURITY_LEVEL_HASH_FUNCTION})`);
|
|
569
682
|
// this.permute requires an odd number of round keys
|
|
570
683
|
// prepending a 0 matrix makes it equivalent to Algorithm 3 from https://eprint.iacr.org/2020/1143.pdf
|
|
571
684
|
const zeros = [];
|
|
@@ -609,6 +722,13 @@ class RescueDesc {
|
|
|
609
722
|
return rescuePermutationInverse(this.mode, this.alpha, this.alphaInverse, this.mdsMatInverse, this.roundKeys, state)[2 * this.nRounds];
|
|
610
723
|
}
|
|
611
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* Finds the smallest prime alpha that does not divide p-1, and computes its inverse modulo p-1.
|
|
727
|
+
* The alpha parameter is used in the Rescue permutation for exponentiation operations.
|
|
728
|
+
* @param p - The field modulus (prime number)
|
|
729
|
+
* @returns A tuple [alpha, alphaInverse] where alpha is the prime and alphaInverse is its modular inverse
|
|
730
|
+
* @throws Error if no suitable prime alpha is found
|
|
731
|
+
*/
|
|
612
732
|
function getAlphaAndInverse(p) {
|
|
613
733
|
const pMinusOne = p - 1n;
|
|
614
734
|
let alpha = 0n;
|
|
@@ -624,6 +744,16 @@ function getAlphaAndInverse(p) {
|
|
|
624
744
|
const alphaInverse = invert(alpha, pMinusOne);
|
|
625
745
|
return [alpha, alphaInverse];
|
|
626
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* Calculates the number of rounds required for the Rescue permutation based on security analysis.
|
|
749
|
+
* The number of rounds is determined by analyzing resistance to differential and algebraic attacks.
|
|
750
|
+
* See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287 for the security analysis.
|
|
751
|
+
* @param p - The field modulus
|
|
752
|
+
* @param mode - The Rescue mode (cipher or hash)
|
|
753
|
+
* @param alpha - The prime alpha parameter
|
|
754
|
+
* @param m - The state size (block size for cipher, total size for hash)
|
|
755
|
+
* @returns The number of rounds (will be doubled for the full permutation)
|
|
756
|
+
*/
|
|
627
757
|
function getNRounds(p, mode, alpha, m) {
|
|
628
758
|
function dcon(n) {
|
|
629
759
|
return Math.floor(0.5 * (Number(alpha) - 1) * m * (n - 1) + 2.0);
|
|
@@ -642,20 +772,20 @@ function getNRounds(p, mode, alpha, m) {
|
|
|
642
772
|
}
|
|
643
773
|
switch (mode.kind) {
|
|
644
774
|
case 'cipher': {
|
|
645
|
-
const l0 = Math.ceil((2 *
|
|
775
|
+
const l0 = Math.ceil((2 * SECURITY_LEVEL_BLOCK_CIPHER) / ((m + 1) * (Math.log2(Number(p)) - Math.log2(Number(alpha) - 1))));
|
|
646
776
|
let l1 = 0;
|
|
647
777
|
if (alpha === 3n) {
|
|
648
|
-
l1 = Math.ceil((
|
|
778
|
+
l1 = Math.ceil((SECURITY_LEVEL_BLOCK_CIPHER + 2) / (4 * m));
|
|
649
779
|
}
|
|
650
780
|
else {
|
|
651
|
-
l1 = Math.ceil((
|
|
781
|
+
l1 = Math.ceil((SECURITY_LEVEL_BLOCK_CIPHER + 3) / (5.5 * m));
|
|
652
782
|
}
|
|
653
783
|
return 2 * Math.max(l0, l1, 5);
|
|
654
784
|
}
|
|
655
785
|
case 'hash': {
|
|
656
786
|
// get number of rounds for Groebner basis attack
|
|
657
787
|
const rate = m - mode.capacity;
|
|
658
|
-
const target = 1n << BigInt(
|
|
788
|
+
const target = 1n << BigInt(SECURITY_LEVEL_HASH_FUNCTION);
|
|
659
789
|
let l1 = 1;
|
|
660
790
|
let tmp = binomial(v(l1, rate) + dcon(l1), v(l1, rate));
|
|
661
791
|
while (tmp * tmp <= target && l1 <= 23) {
|
|
@@ -668,6 +798,14 @@ function getNRounds(p, mode, alpha, m) {
|
|
|
668
798
|
default: return 0;
|
|
669
799
|
}
|
|
670
800
|
}
|
|
801
|
+
/**
|
|
802
|
+
* Builds a Cauchy matrix for use as an MDS (Maximum Distance Separable) matrix.
|
|
803
|
+
* A Cauchy matrix is guaranteed to be invertible and provides optimal diffusion properties.
|
|
804
|
+
* The matrix is constructed using the formula: M[i][j] = 1/(i + j) for i, j in [1, size].
|
|
805
|
+
* @param field - The finite field over which to construct the matrix
|
|
806
|
+
* @param size - The size of the square matrix
|
|
807
|
+
* @returns A Cauchy matrix of the specified size
|
|
808
|
+
*/
|
|
671
809
|
function buildCauchy(field, size) {
|
|
672
810
|
const data = [];
|
|
673
811
|
for (let i = 1n; i <= size; ++i) {
|
|
@@ -679,6 +817,13 @@ function buildCauchy(field, size) {
|
|
|
679
817
|
}
|
|
680
818
|
return new Matrix(field, data);
|
|
681
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Builds the inverse of a Cauchy matrix for use as the inverse MDS matrix.
|
|
822
|
+
* The inverse is computed using a closed-form formula for Cauchy matrix inversion.
|
|
823
|
+
* @param field - The finite field over which to construct the matrix
|
|
824
|
+
* @param size - The size of the square matrix
|
|
825
|
+
* @returns The inverse of the Cauchy matrix
|
|
826
|
+
*/
|
|
682
827
|
function buildInverseCauchy(field, size) {
|
|
683
828
|
function product(arr) {
|
|
684
829
|
return arr.reduce((acc, curr) => field.mul(acc, field.create(curr)), field.ONE);
|
|
@@ -732,6 +877,19 @@ function exponentForOdd(mode, alpha, alphaInverse) {
|
|
|
732
877
|
default: return 0n;
|
|
733
878
|
}
|
|
734
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* Core Rescue permutation function implementing the cryptographic primitive.
|
|
882
|
+
* Applies alternating rounds of exponentiation and MDS matrix multiplication with round keys.
|
|
883
|
+
* The permutation alternates between using alpha and alphaInverse as exponents based on round parity.
|
|
884
|
+
* This is the fundamental building block for both Rescue cipher and Rescue-Prime hash.
|
|
885
|
+
* @param mode - The Rescue mode (cipher or hash) determining exponent selection
|
|
886
|
+
* @param alpha - The prime exponent for even rounds
|
|
887
|
+
* @param alphaInverse - The inverse exponent for odd rounds
|
|
888
|
+
* @param mdsMat - The Maximum Distance Separable matrix for diffusion
|
|
889
|
+
* @param subkeys - Array of round key matrices
|
|
890
|
+
* @param state - The initial state matrix to permute
|
|
891
|
+
* @returns Array of all intermediate states during the permutation
|
|
892
|
+
*/
|
|
735
893
|
function rescuePermutation(mode, alpha, alphaInverse, mdsMat, subkeys, state) {
|
|
736
894
|
const exponentEven = exponentForEven(mode, alpha, alphaInverse);
|
|
737
895
|
const exponentOdd = exponentForOdd(mode, alpha, alphaInverse);
|
|
@@ -777,41 +935,49 @@ function toVec(data) {
|
|
|
777
935
|
}
|
|
778
936
|
|
|
779
937
|
/**
|
|
780
|
-
* The Rescue-Prime hash function, as described in https://eprint.iacr.org/2020/1143.pdf
|
|
781
|
-
*
|
|
782
|
-
*
|
|
938
|
+
* The Rescue-Prime hash function, as described in https://eprint.iacr.org/2020/1143.pdf, offering 256 bits
|
|
939
|
+
* of security against collision, preimage and second-preimage attacks for any field of size at least 102 bits.
|
|
940
|
+
* We use the sponge construction with fixed rate = 7 and capacity = 5 (i.e., m = 12), and truncate the
|
|
941
|
+
* output to 5 field elements.
|
|
783
942
|
*/
|
|
784
943
|
class RescuePrimeHash {
|
|
785
944
|
desc;
|
|
786
945
|
rate;
|
|
946
|
+
digestLength;
|
|
787
947
|
/**
|
|
788
|
-
* Constructs a RescuePrimeHash instance with
|
|
948
|
+
* Constructs a RescuePrimeHash instance with rate = 7 and capacity = 5.
|
|
789
949
|
*/
|
|
790
950
|
constructor() {
|
|
791
|
-
this.desc = new RescueDesc(CURVE25519_BASE_FIELD, { kind: 'hash', m:
|
|
792
|
-
this.rate =
|
|
951
|
+
this.desc = new RescueDesc(CURVE25519_BASE_FIELD, { kind: 'hash', m: 12, capacity: 5 });
|
|
952
|
+
this.rate = 7;
|
|
953
|
+
this.digestLength = 5;
|
|
793
954
|
}
|
|
794
955
|
// This is Algorithm 1 from https://eprint.iacr.org/2020/1143.pdf, though with the padding (see Algorithm 2).
|
|
795
|
-
// The hash
|
|
956
|
+
// The hash is truncated to digestLength elements.
|
|
957
|
+
// According to Section 2.2, this offers min(log2(CURVE25519_BASE_FIELD.ORDER) / 2 * min(digestLength, capacity), s)
|
|
958
|
+
// bits of security against collision, preimage and second-preimage attacks.
|
|
959
|
+
// The security level is thus of the order of 256 bits for any field of size at least 102 bits.
|
|
960
|
+
// The rate and capacity are chosen to achieve minimal number of rounds 8.
|
|
796
961
|
/**
|
|
797
962
|
* Computes the Rescue-Prime hash of a message, with padding as described in Algorithm 2 of the paper.
|
|
798
963
|
* @param message - The input message as an array of bigints.
|
|
799
|
-
* @returns The hash output as an array of bigints (length =
|
|
964
|
+
* @returns The hash output as an array of bigints (length = digestLength).
|
|
800
965
|
*/
|
|
801
966
|
digest(message) {
|
|
802
|
-
message
|
|
803
|
-
|
|
804
|
-
|
|
967
|
+
// Create a copy and pad message to avoid mutating input parameter
|
|
968
|
+
const paddedMessage = [...message, 1n];
|
|
969
|
+
while (paddedMessage.length % this.rate !== 0) {
|
|
970
|
+
paddedMessage.push(0n);
|
|
805
971
|
}
|
|
806
972
|
const zeros = [];
|
|
807
973
|
for (let i = 0; i < this.desc.m; ++i) {
|
|
808
974
|
zeros.push([0n]);
|
|
809
975
|
}
|
|
810
976
|
let state = new Matrix(this.desc.field, zeros);
|
|
811
|
-
for (let r = 0; r <
|
|
977
|
+
for (let r = 0; r < paddedMessage.length / this.rate; ++r) {
|
|
812
978
|
const data = [];
|
|
813
979
|
for (let i = 0; i < this.rate; ++i) {
|
|
814
|
-
data[i] = [
|
|
980
|
+
data[i] = [paddedMessage[r * this.rate + i]];
|
|
815
981
|
}
|
|
816
982
|
for (let i = this.rate; i < this.desc.m; ++i) {
|
|
817
983
|
data[i] = [0n];
|
|
@@ -820,7 +986,7 @@ class RescuePrimeHash {
|
|
|
820
986
|
state = this.desc.permute(state.add(s, true));
|
|
821
987
|
}
|
|
822
988
|
const res = [];
|
|
823
|
-
for (let i = 0; i < this.
|
|
989
|
+
for (let i = 0; i < this.digestLength; ++i) {
|
|
824
990
|
res.push(state.data[i][0]);
|
|
825
991
|
}
|
|
826
992
|
return res;
|
|
@@ -828,101 +994,10 @@ class RescuePrimeHash {
|
|
|
828
994
|
}
|
|
829
995
|
|
|
830
996
|
/**
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*/
|
|
834
|
-
class HMACRescuePrime {
|
|
835
|
-
hasher;
|
|
836
|
-
/**
|
|
837
|
-
* Constructs a new HMACRescuePrime instance.
|
|
838
|
-
*/
|
|
839
|
-
constructor() {
|
|
840
|
-
this.hasher = new RescuePrimeHash();
|
|
841
|
-
}
|
|
842
|
-
/**
|
|
843
|
-
* Computes the HMAC digest of a message with a given key using Rescue-Prime.
|
|
844
|
-
* @param key - The key as an array of bigints.
|
|
845
|
-
* @param message - The message as an array of bigints.
|
|
846
|
-
* @returns The HMAC digest as an array of bigints.
|
|
847
|
-
* @throws Error if the key is longer than the hash function's rate.
|
|
848
|
-
*/
|
|
849
|
-
digest(key, message) {
|
|
850
|
-
// We follow https://datatracker.ietf.org/doc/html/rfc2104, though since Rescue-Prime is not based
|
|
851
|
-
// on the Merkle-Damgard construction we cannot have an exact anology between the
|
|
852
|
-
// parameters. For our purpose, we set B = L = hasher.rate.
|
|
853
|
-
if (key.length > this.hasher.rate) {
|
|
854
|
-
throw Error(`length of key is supposed to be at most the hash function's rate (found ${key.length} and ${this.hasher.rate})`);
|
|
855
|
-
}
|
|
856
|
-
const ipad = deserializeLE(new Uint8Array(32).fill(0x36));
|
|
857
|
-
const opad = deserializeLE(new Uint8Array(32).fill(0x5c));
|
|
858
|
-
// the key is first extended to length B
|
|
859
|
-
for (let i = 0; i < this.hasher.rate - key.length; ++i) {
|
|
860
|
-
key.push(0n);
|
|
861
|
-
}
|
|
862
|
-
// inner padding
|
|
863
|
-
const keyPlusIpad = key.map((k) => k + ipad);
|
|
864
|
-
keyPlusIpad.push(...message);
|
|
865
|
-
const innerDigest = this.hasher.digest(keyPlusIpad);
|
|
866
|
-
// outer padding
|
|
867
|
-
const keyPlusOpad = key.map((k) => k + opad);
|
|
868
|
-
keyPlusOpad.push(...innerDigest);
|
|
869
|
-
return this.hasher.digest(keyPlusOpad);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
/**
|
|
874
|
-
* HKDF (HMAC-based Extract-and-Expand Key Derivation Function) using the Rescue-Prime hash function.
|
|
875
|
-
* Follows RFC 5869. Only supports L = HashLen.
|
|
997
|
+
* Block size m for Rescue cipher operations.
|
|
998
|
+
* Rescue operates on 5-element blocks of field elements.
|
|
876
999
|
*/
|
|
877
|
-
|
|
878
|
-
hmac;
|
|
879
|
-
/**
|
|
880
|
-
* Constructs a new HKDFRescuePrime instance.
|
|
881
|
-
*/
|
|
882
|
-
constructor() {
|
|
883
|
-
this.hmac = new HMACRescuePrime();
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* HKDF-Extract step: derives a pseudorandom key (PRK) from the input keying material (IKM) and salt.
|
|
887
|
-
* @param salt - The salt value as an array of bigints.
|
|
888
|
-
* @param ikm - The input keying material as an array of bigints.
|
|
889
|
-
* @returns The pseudorandom key (PRK) as an array of bigints.
|
|
890
|
-
*/
|
|
891
|
-
extract(salt, ikm) {
|
|
892
|
-
if (salt.length === 0) {
|
|
893
|
-
// HashLen = hasher.rate for Rescue-Prime
|
|
894
|
-
for (let i = 0; i < this.hmac.hasher.rate; ++i) {
|
|
895
|
-
salt.push(0n);
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
return this.hmac.digest(salt, ikm);
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* HKDF-Expand step: expands the pseudorandom key (PRK) with info to produce output keying material (OKM).
|
|
902
|
-
* Only supports L = HashLen = 5, i.e. N = 1.
|
|
903
|
-
* @param prk - The pseudorandom key as an array of bigints.
|
|
904
|
-
* @param info - The context and application specific information as an array of bigints.
|
|
905
|
-
* @returns The output keying material (OKM) as an array of bigints.
|
|
906
|
-
*/
|
|
907
|
-
expand(prk, info) {
|
|
908
|
-
// we only support L = HashLen = 5, i.e. N = 1
|
|
909
|
-
// message = empty string | info | 0x01
|
|
910
|
-
info.push(1n);
|
|
911
|
-
return this.hmac.digest(prk, info);
|
|
912
|
-
}
|
|
913
|
-
/**
|
|
914
|
-
* Performs the full HKDF (extract and expand) to derive output keying material (OKM).
|
|
915
|
-
* @param salt - The salt value as an array of bigints.
|
|
916
|
-
* @param ikm - The input keying material as an array of bigints.
|
|
917
|
-
* @param info - The context and application specific information as an array of bigints.
|
|
918
|
-
* @returns The output keying material (OKM) as an array of bigints.
|
|
919
|
-
*/
|
|
920
|
-
okm(salt, ikm, info) {
|
|
921
|
-
const prk = this.extract(salt, ikm);
|
|
922
|
-
return this.expand(prk, info);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
|
|
1000
|
+
const RESCUE_CIPHER_BLOCK_SIZE = 5;
|
|
926
1001
|
/**
|
|
927
1002
|
* The Rescue cipher in Counter (CTR) mode, with a fixed block size m = 5.
|
|
928
1003
|
* See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
|
|
@@ -931,12 +1006,21 @@ class RescueCipher {
|
|
|
931
1006
|
desc;
|
|
932
1007
|
/**
|
|
933
1008
|
* Constructs a RescueCipher instance using a shared secret.
|
|
934
|
-
* The key is derived using
|
|
1009
|
+
* The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
|
|
935
1010
|
* @param sharedSecret - The shared secret to derive the cipher key from.
|
|
936
1011
|
*/
|
|
937
1012
|
constructor(sharedSecret) {
|
|
938
|
-
const
|
|
939
|
-
|
|
1013
|
+
const hasher = new RescuePrimeHash();
|
|
1014
|
+
// We follow [Section 4, Option 1.](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Cr2.pdf).
|
|
1015
|
+
// For our choice of hash function, we have:
|
|
1016
|
+
// - H_outputBits = hasher.digestLength = RESCUE_CIPHER_BLOCK_SIZE
|
|
1017
|
+
// - max_H_inputBits = arbitrarily long, as the Rescue-Prime hash function is built upon the
|
|
1018
|
+
// sponge construction
|
|
1019
|
+
// - L = RESCUE_CIPHER_BLOCK_SIZE.
|
|
1020
|
+
// Build the vector `counter || Z || FixedInfo` (we only have i = 1, since reps = 1).
|
|
1021
|
+
// For the FixedInfo we simply take L.
|
|
1022
|
+
const counter = [1n, deserializeLE(sharedSecret), BigInt(RESCUE_CIPHER_BLOCK_SIZE)];
|
|
1023
|
+
const rescueKey = hasher.digest(counter);
|
|
940
1024
|
this.desc = new RescueDesc(CURVE25519_BASE_FIELD, { kind: 'cipher', key: rescueKey });
|
|
941
1025
|
}
|
|
942
1026
|
/**
|
|
@@ -952,8 +1036,8 @@ class RescueCipher {
|
|
|
952
1036
|
}
|
|
953
1037
|
const binSize = getBinSize(this.desc.field.ORDER - 1n);
|
|
954
1038
|
function encryptBatch(desc, ptxt, cntr) {
|
|
955
|
-
if (cntr.length !==
|
|
956
|
-
throw Error(`counter must be of length
|
|
1039
|
+
if (cntr.length !== RESCUE_CIPHER_BLOCK_SIZE) {
|
|
1040
|
+
throw Error(`counter must be of length ${RESCUE_CIPHER_BLOCK_SIZE} (found ${cntr.length})`);
|
|
957
1041
|
}
|
|
958
1042
|
const encryptedCounter = desc.permute(new Matrix(desc.field, toVec(cntr)));
|
|
959
1043
|
const ciphertext = [];
|
|
@@ -966,12 +1050,12 @@ class RescueCipher {
|
|
|
966
1050
|
}
|
|
967
1051
|
return ciphertext;
|
|
968
1052
|
}
|
|
969
|
-
const nBlocks = Math.ceil(plaintext.length /
|
|
1053
|
+
const nBlocks = Math.ceil(plaintext.length / RESCUE_CIPHER_BLOCK_SIZE);
|
|
970
1054
|
const counter = getCounter(deserializeLE(nonce), nBlocks);
|
|
971
1055
|
const ciphertext = [];
|
|
972
1056
|
for (let i = 0; i < nBlocks; ++i) {
|
|
973
|
-
const cnt =
|
|
974
|
-
const newCiphertext = encryptBatch(this.desc, plaintext.slice(cnt, Math.min(cnt +
|
|
1057
|
+
const cnt = RESCUE_CIPHER_BLOCK_SIZE * i;
|
|
1058
|
+
const newCiphertext = encryptBatch(this.desc, plaintext.slice(cnt, Math.min(cnt + RESCUE_CIPHER_BLOCK_SIZE, plaintext.length)), counter.slice(cnt, cnt + RESCUE_CIPHER_BLOCK_SIZE));
|
|
975
1059
|
for (let j = 0; j < newCiphertext.length; ++j) {
|
|
976
1060
|
ciphertext.push(newCiphertext[j]);
|
|
977
1061
|
}
|
|
@@ -1000,8 +1084,8 @@ class RescueCipher {
|
|
|
1000
1084
|
}
|
|
1001
1085
|
const binSize = getBinSize(this.desc.field.ORDER - 1n);
|
|
1002
1086
|
function decryptBatch(desc, ctxt, cntr) {
|
|
1003
|
-
if (cntr.length !==
|
|
1004
|
-
throw Error(`counter must be of length
|
|
1087
|
+
if (cntr.length !== RESCUE_CIPHER_BLOCK_SIZE) {
|
|
1088
|
+
throw Error(`counter must be of length ${RESCUE_CIPHER_BLOCK_SIZE} (found ${cntr.length})`);
|
|
1005
1089
|
}
|
|
1006
1090
|
const encryptedCounter = desc.permute(new Matrix(desc.field, toVec(cntr)));
|
|
1007
1091
|
const decrypted = [];
|
|
@@ -1011,12 +1095,12 @@ class RescueCipher {
|
|
|
1011
1095
|
}
|
|
1012
1096
|
return decrypted;
|
|
1013
1097
|
}
|
|
1014
|
-
const nBlocks = Math.ceil(ciphertext.length /
|
|
1098
|
+
const nBlocks = Math.ceil(ciphertext.length / RESCUE_CIPHER_BLOCK_SIZE);
|
|
1015
1099
|
const counter = getCounter(deserializeLE(nonce), nBlocks);
|
|
1016
1100
|
const decrypted = [];
|
|
1017
1101
|
for (let i = 0; i < nBlocks; ++i) {
|
|
1018
|
-
const cnt =
|
|
1019
|
-
const newDecrypted = decryptBatch(this.desc, ciphertext.slice(cnt, Math.min(cnt +
|
|
1102
|
+
const cnt = RESCUE_CIPHER_BLOCK_SIZE * i;
|
|
1103
|
+
const newDecrypted = decryptBatch(this.desc, ciphertext.slice(cnt, Math.min(cnt + RESCUE_CIPHER_BLOCK_SIZE, ciphertext.length)), counter.slice(cnt, cnt + RESCUE_CIPHER_BLOCK_SIZE));
|
|
1020
1104
|
for (let j = 0; j < newDecrypted.length; ++j) {
|
|
1021
1105
|
decrypted.push(newDecrypted[j]);
|
|
1022
1106
|
}
|
|
@@ -1049,9 +1133,10 @@ function getCounter(nonce, nBlocks) {
|
|
|
1049
1133
|
for (let i = 0n; i < nBlocks; ++i) {
|
|
1050
1134
|
counter.push(nonce);
|
|
1051
1135
|
counter.push(i);
|
|
1052
|
-
counter
|
|
1053
|
-
|
|
1054
|
-
|
|
1136
|
+
// Pad to RESCUE_CIPHER_BLOCK_SIZE elements per counter block
|
|
1137
|
+
for (let j = 2; j < RESCUE_CIPHER_BLOCK_SIZE; ++j) {
|
|
1138
|
+
counter.push(0n);
|
|
1139
|
+
}
|
|
1055
1140
|
}
|
|
1056
1141
|
return counter;
|
|
1057
1142
|
}
|
|
@@ -1142,19 +1227,43 @@ function uvRatio(u, v) {
|
|
|
1142
1227
|
}
|
|
1143
1228
|
|
|
1144
1229
|
/**
|
|
1145
|
-
*
|
|
1230
|
+
* Mapping from key bits to key byte length.
|
|
1231
|
+
*/
|
|
1232
|
+
const KEY_BYTES = { 128: 16, 192: 24, 256: 32 };
|
|
1233
|
+
/**
|
|
1234
|
+
* Generic AES cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
1146
1235
|
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
1147
1236
|
*/
|
|
1148
|
-
class
|
|
1237
|
+
class AesCtrCipher {
|
|
1149
1238
|
key;
|
|
1239
|
+
keyBits;
|
|
1150
1240
|
/**
|
|
1151
|
-
* Constructs an AES
|
|
1152
|
-
* The key is derived using
|
|
1241
|
+
* Constructs an AES cipher instance using a shared secret.
|
|
1242
|
+
* The key is derived using SHA3-256.
|
|
1153
1243
|
* @param sharedSecret - The shared secret to derive the AES key from.
|
|
1244
|
+
* @param keyBits - The AES key size in bits (128, 192, or 256).
|
|
1154
1245
|
*/
|
|
1155
|
-
constructor(sharedSecret) {
|
|
1156
|
-
|
|
1157
|
-
|
|
1246
|
+
constructor(sharedSecret, keyBits) {
|
|
1247
|
+
this.keyBits = keyBits;
|
|
1248
|
+
const hasher = createHash('sha3-256');
|
|
1249
|
+
// We follow [Section 4, Option 1.](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Cr2.pdf).
|
|
1250
|
+
// For our choice of hash function, we have:
|
|
1251
|
+
// - H_outputBits = 256
|
|
1252
|
+
// - max_H_inputBits = arbitrarily long, as SHA3 is built upon the sponge
|
|
1253
|
+
// construction
|
|
1254
|
+
// - L = keyBits (128, 192, or 256).
|
|
1255
|
+
// Build the vector `counter || Z || FixedInfo` (we only have i = 1, since reps = 1).
|
|
1256
|
+
// the counter is a big-endian 4-byte unsigned integer
|
|
1257
|
+
const counter = [0, 0, 0, 1];
|
|
1258
|
+
for (let i = 0; i < sharedSecret.length; ++i) {
|
|
1259
|
+
counter.push(sharedSecret[i]);
|
|
1260
|
+
}
|
|
1261
|
+
// For the FixedInfo we simply take L. We represent L as a big-endian 2-byte
|
|
1262
|
+
// unsigned integer.
|
|
1263
|
+
counter.push(Math.floor(keyBits / 256));
|
|
1264
|
+
counter.push(keyBits % 256);
|
|
1265
|
+
hasher.update(new Uint8Array(counter));
|
|
1266
|
+
this.key = new Uint8Array(hasher.digest()).slice(0, KEY_BYTES[keyBits]);
|
|
1158
1267
|
}
|
|
1159
1268
|
/**
|
|
1160
1269
|
* Encrypts the plaintext array in Counter (CTR) mode.
|
|
@@ -1168,7 +1277,7 @@ class Aes128Cipher {
|
|
|
1168
1277
|
throw Error(`nonce must be of length 8 (found ${nonce.length})`);
|
|
1169
1278
|
}
|
|
1170
1279
|
const paddedNonce = Buffer.concat([nonce, Buffer.alloc(16 - nonce.length, 0)]);
|
|
1171
|
-
const cipher = createCipheriv(
|
|
1280
|
+
const cipher = createCipheriv(`aes-${this.keyBits}-ctr`, this.key, paddedNonce);
|
|
1172
1281
|
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
1173
1282
|
return new Uint8Array(ciphertext);
|
|
1174
1283
|
}
|
|
@@ -1184,114 +1293,61 @@ class Aes128Cipher {
|
|
|
1184
1293
|
throw Error(`nonce must be of length 8 (found ${nonce.length})`);
|
|
1185
1294
|
}
|
|
1186
1295
|
const paddedNonce = Buffer.concat([nonce, Buffer.alloc(16 - nonce.length, 0)]);
|
|
1187
|
-
const cipher = createDecipheriv(
|
|
1296
|
+
const cipher = createDecipheriv(`aes-${this.keyBits}-ctr`, this.key, paddedNonce);
|
|
1188
1297
|
const decrypted = Buffer.concat([cipher.update(ciphertext), cipher.final()]);
|
|
1189
1298
|
return new Uint8Array(decrypted);
|
|
1190
1299
|
}
|
|
1191
1300
|
}
|
|
1192
1301
|
|
|
1193
1302
|
/**
|
|
1194
|
-
* AES-
|
|
1303
|
+
* AES-128 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
1195
1304
|
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
1196
1305
|
*/
|
|
1197
|
-
class
|
|
1198
|
-
key;
|
|
1306
|
+
class Aes128Cipher extends AesCtrCipher {
|
|
1199
1307
|
/**
|
|
1200
|
-
* Constructs an AES-
|
|
1201
|
-
* The key is derived using
|
|
1308
|
+
* Constructs an AES-128 cipher instance using a shared secret.
|
|
1309
|
+
* The key is derived using SHA3-256.
|
|
1202
1310
|
* @param sharedSecret - The shared secret to derive the AES key from.
|
|
1203
1311
|
*/
|
|
1204
1312
|
constructor(sharedSecret) {
|
|
1205
|
-
|
|
1206
|
-
this.key = new Uint8Array(aesKey);
|
|
1207
|
-
}
|
|
1208
|
-
/**
|
|
1209
|
-
* Encrypts the plaintext array in Counter (CTR) mode.
|
|
1210
|
-
* @param plaintext - The data to encrypt.
|
|
1211
|
-
* @param nonce - An 8-byte nonce for CTR mode.
|
|
1212
|
-
* @returns The encrypted ciphertext as a Uint8Array.
|
|
1213
|
-
* @throws Error if the nonce is not 8 bytes long.
|
|
1214
|
-
*/
|
|
1215
|
-
encrypt(plaintext, nonce) {
|
|
1216
|
-
if (nonce.length !== 8) {
|
|
1217
|
-
throw Error(`nonce must be of length 8 (found ${nonce.length})`);
|
|
1218
|
-
}
|
|
1219
|
-
const paddedNonce = Buffer.concat([nonce, Buffer.alloc(16 - nonce.length, 0)]);
|
|
1220
|
-
const cipher = createCipheriv('aes-192-ctr', this.key, paddedNonce);
|
|
1221
|
-
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
1222
|
-
return new Uint8Array(ciphertext);
|
|
1313
|
+
super(sharedSecret, 128);
|
|
1223
1314
|
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* AES-192 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
1319
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
1320
|
+
*/
|
|
1321
|
+
class Aes192Cipher extends AesCtrCipher {
|
|
1224
1322
|
/**
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
* @param
|
|
1228
|
-
* @returns The decrypted plaintext as a Uint8Array.
|
|
1229
|
-
* @throws Error if the nonce is not 8 bytes long.
|
|
1323
|
+
* Constructs an AES-192 cipher instance using a shared secret.
|
|
1324
|
+
* The key is derived using SHA3-256.
|
|
1325
|
+
* @param sharedSecret - The shared secret to derive the AES key from.
|
|
1230
1326
|
*/
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
throw Error(`nonce must be of length 8 (found ${nonce.length})`);
|
|
1234
|
-
}
|
|
1235
|
-
const paddedNonce = Buffer.concat([nonce, Buffer.alloc(16 - nonce.length, 0)]);
|
|
1236
|
-
const cipher = createDecipheriv('aes-192-ctr', this.key, paddedNonce);
|
|
1237
|
-
const decrypted = Buffer.concat([cipher.update(ciphertext), cipher.final()]);
|
|
1238
|
-
return new Uint8Array(decrypted);
|
|
1327
|
+
constructor(sharedSecret) {
|
|
1328
|
+
super(sharedSecret, 192);
|
|
1239
1329
|
}
|
|
1240
1330
|
}
|
|
1241
1331
|
|
|
1242
1332
|
/**
|
|
1243
|
-
* AES-256 cipher in Counter (CTR) mode, using
|
|
1333
|
+
* AES-256 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
1244
1334
|
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
1245
1335
|
*/
|
|
1246
|
-
class Aes256Cipher {
|
|
1247
|
-
key;
|
|
1336
|
+
class Aes256Cipher extends AesCtrCipher {
|
|
1248
1337
|
/**
|
|
1249
1338
|
* Constructs an AES-256 cipher instance using a shared secret.
|
|
1250
|
-
* The key is derived using
|
|
1339
|
+
* The key is derived using SHA3-256.
|
|
1251
1340
|
* @param sharedSecret - The shared secret to derive the AES key from.
|
|
1252
1341
|
*/
|
|
1253
1342
|
constructor(sharedSecret) {
|
|
1254
|
-
|
|
1255
|
-
this.key = new Uint8Array(aesKey);
|
|
1256
|
-
}
|
|
1257
|
-
/**
|
|
1258
|
-
* Encrypts the plaintext array in Counter (CTR) mode.
|
|
1259
|
-
* @param plaintext - The data to encrypt.
|
|
1260
|
-
* @param nonce - An 8-byte nonce for CTR mode.
|
|
1261
|
-
* @returns The encrypted ciphertext as a Uint8Array.
|
|
1262
|
-
* @throws Error if the nonce is not 8 bytes long.
|
|
1263
|
-
*/
|
|
1264
|
-
encrypt(plaintext, nonce) {
|
|
1265
|
-
if (nonce.length !== 8) {
|
|
1266
|
-
throw Error(`nonce must be of length 8 (found ${nonce.length})`);
|
|
1267
|
-
}
|
|
1268
|
-
const paddedNonce = Buffer.concat([nonce, Buffer.alloc(16 - nonce.length, 0)]);
|
|
1269
|
-
const cipher = createCipheriv('aes-256-ctr', this.key, paddedNonce);
|
|
1270
|
-
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
1271
|
-
return new Uint8Array(ciphertext);
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* Decrypts the ciphertext array in Counter (CTR) mode.
|
|
1275
|
-
* @param ciphertext - The data to decrypt.
|
|
1276
|
-
* @param nonce - An 8-byte nonce for CTR mode.
|
|
1277
|
-
* @returns The decrypted plaintext as a Uint8Array.
|
|
1278
|
-
* @throws Error if the nonce is not 8 bytes long.
|
|
1279
|
-
*/
|
|
1280
|
-
decrypt(ciphertext, nonce) {
|
|
1281
|
-
if (nonce.length !== 8) {
|
|
1282
|
-
throw Error(`nonce must be of length 8 (found ${nonce.length})`);
|
|
1283
|
-
}
|
|
1284
|
-
const paddedNonce = Buffer.concat([nonce, Buffer.alloc(16 - nonce.length, 0)]);
|
|
1285
|
-
const cipher = createDecipheriv('aes-256-ctr', this.key, paddedNonce);
|
|
1286
|
-
const decrypted = Buffer.concat([cipher.update(ciphertext), cipher.final()]);
|
|
1287
|
-
return new Uint8Array(decrypted);
|
|
1343
|
+
super(sharedSecret, 256);
|
|
1288
1344
|
}
|
|
1289
1345
|
}
|
|
1290
1346
|
|
|
1291
1347
|
var address = "Bv3Fb9VjzjWGfX18QTUcVycAfeLoQ5zZN6vv2g3cTZxp";
|
|
1292
1348
|
var metadata = {
|
|
1293
1349
|
name: "arcium",
|
|
1294
|
-
version: "0.
|
|
1350
|
+
version: "0.5.0",
|
|
1295
1351
|
spec: "0.1.0",
|
|
1296
1352
|
description: "The Arcium program"
|
|
1297
1353
|
};
|
|
@@ -1644,8 +1700,9 @@ var instructions = [
|
|
|
1644
1700
|
]
|
|
1645
1701
|
},
|
|
1646
1702
|
{
|
|
1647
|
-
kind: "
|
|
1648
|
-
path: "
|
|
1703
|
+
kind: "account",
|
|
1704
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
1705
|
+
account: "MXEAccount"
|
|
1649
1706
|
},
|
|
1650
1707
|
{
|
|
1651
1708
|
kind: "arg",
|
|
@@ -1672,8 +1729,9 @@ var instructions = [
|
|
|
1672
1729
|
]
|
|
1673
1730
|
},
|
|
1674
1731
|
{
|
|
1675
|
-
kind: "
|
|
1676
|
-
path: "
|
|
1732
|
+
kind: "account",
|
|
1733
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
1734
|
+
account: "MXEAccount"
|
|
1677
1735
|
}
|
|
1678
1736
|
]
|
|
1679
1737
|
}
|
|
@@ -1697,8 +1755,9 @@ var instructions = [
|
|
|
1697
1755
|
]
|
|
1698
1756
|
},
|
|
1699
1757
|
{
|
|
1700
|
-
kind: "
|
|
1701
|
-
path: "
|
|
1758
|
+
kind: "account",
|
|
1759
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
1760
|
+
account: "MXEAccount"
|
|
1702
1761
|
}
|
|
1703
1762
|
]
|
|
1704
1763
|
}
|
|
@@ -1792,16 +1851,16 @@ var instructions = [
|
|
|
1792
1851
|
]
|
|
1793
1852
|
},
|
|
1794
1853
|
{
|
|
1795
|
-
name: "
|
|
1854
|
+
name: "claim_computation_rent",
|
|
1796
1855
|
discriminator: [
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1856
|
+
215,
|
|
1857
|
+
218,
|
|
1858
|
+
1,
|
|
1859
|
+
166,
|
|
1860
|
+
81,
|
|
1861
|
+
218,
|
|
1862
|
+
16,
|
|
1863
|
+
151
|
|
1805
1864
|
],
|
|
1806
1865
|
accounts: [
|
|
1807
1866
|
{
|
|
@@ -1810,38 +1869,111 @@ var instructions = [
|
|
|
1810
1869
|
signer: true
|
|
1811
1870
|
},
|
|
1812
1871
|
{
|
|
1813
|
-
name: "
|
|
1872
|
+
name: "comp",
|
|
1814
1873
|
writable: true,
|
|
1815
1874
|
pda: {
|
|
1816
1875
|
seeds: [
|
|
1817
1876
|
{
|
|
1818
1877
|
kind: "const",
|
|
1819
1878
|
value: [
|
|
1820
|
-
70,
|
|
1821
|
-
97,
|
|
1822
|
-
105,
|
|
1823
|
-
108,
|
|
1824
|
-
117,
|
|
1825
|
-
114,
|
|
1826
|
-
101,
|
|
1827
1879
|
67,
|
|
1828
|
-
|
|
1880
|
+
111,
|
|
1881
|
+
109,
|
|
1882
|
+
112,
|
|
1883
|
+
117,
|
|
1884
|
+
116,
|
|
1829
1885
|
97,
|
|
1886
|
+
116,
|
|
1830
1887
|
105,
|
|
1831
|
-
|
|
1888
|
+
111,
|
|
1889
|
+
110,
|
|
1832
1890
|
65,
|
|
1833
1891
|
99,
|
|
1834
1892
|
99,
|
|
1835
1893
|
111,
|
|
1836
1894
|
117,
|
|
1837
1895
|
110,
|
|
1838
|
-
116
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1896
|
+
116
|
|
1897
|
+
]
|
|
1898
|
+
},
|
|
1899
|
+
{
|
|
1900
|
+
kind: "arg",
|
|
1901
|
+
path: "_cluster_offset"
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
kind: "arg",
|
|
1905
|
+
path: "_comp_offset"
|
|
1906
|
+
}
|
|
1907
|
+
]
|
|
1908
|
+
}
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
name: "system_program",
|
|
1912
|
+
address: "11111111111111111111111111111111"
|
|
1913
|
+
}
|
|
1914
|
+
],
|
|
1915
|
+
args: [
|
|
1916
|
+
{
|
|
1917
|
+
name: "comp_offset",
|
|
1918
|
+
type: "u64"
|
|
1919
|
+
},
|
|
1920
|
+
{
|
|
1921
|
+
name: "cluster_offset",
|
|
1922
|
+
type: "u32"
|
|
1923
|
+
}
|
|
1924
|
+
]
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
name: "claim_failure_append",
|
|
1928
|
+
discriminator: [
|
|
1929
|
+
92,
|
|
1930
|
+
52,
|
|
1931
|
+
184,
|
|
1932
|
+
203,
|
|
1933
|
+
76,
|
|
1934
|
+
221,
|
|
1935
|
+
128,
|
|
1936
|
+
69
|
|
1937
|
+
],
|
|
1938
|
+
accounts: [
|
|
1939
|
+
{
|
|
1940
|
+
name: "signer",
|
|
1941
|
+
writable: true,
|
|
1942
|
+
signer: true
|
|
1943
|
+
},
|
|
1944
|
+
{
|
|
1945
|
+
name: "failure_acc",
|
|
1946
|
+
writable: true,
|
|
1947
|
+
pda: {
|
|
1948
|
+
seeds: [
|
|
1949
|
+
{
|
|
1950
|
+
kind: "const",
|
|
1951
|
+
value: [
|
|
1952
|
+
70,
|
|
1953
|
+
97,
|
|
1954
|
+
105,
|
|
1955
|
+
108,
|
|
1956
|
+
117,
|
|
1957
|
+
114,
|
|
1958
|
+
101,
|
|
1959
|
+
67,
|
|
1960
|
+
108,
|
|
1961
|
+
97,
|
|
1962
|
+
105,
|
|
1963
|
+
109,
|
|
1964
|
+
65,
|
|
1965
|
+
99,
|
|
1966
|
+
99,
|
|
1967
|
+
111,
|
|
1968
|
+
117,
|
|
1969
|
+
110,
|
|
1970
|
+
116,
|
|
1971
|
+
72,
|
|
1972
|
+
101,
|
|
1973
|
+
97,
|
|
1974
|
+
100,
|
|
1975
|
+
101,
|
|
1976
|
+
114
|
|
1845
1977
|
]
|
|
1846
1978
|
},
|
|
1847
1979
|
{
|
|
@@ -1965,8 +2097,9 @@ var instructions = [
|
|
|
1965
2097
|
]
|
|
1966
2098
|
},
|
|
1967
2099
|
{
|
|
1968
|
-
kind: "
|
|
1969
|
-
path: "
|
|
2100
|
+
kind: "account",
|
|
2101
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
2102
|
+
account: "MXEAccount"
|
|
1970
2103
|
}
|
|
1971
2104
|
]
|
|
1972
2105
|
}
|
|
@@ -1989,8 +2122,9 @@ var instructions = [
|
|
|
1989
2122
|
]
|
|
1990
2123
|
},
|
|
1991
2124
|
{
|
|
1992
|
-
kind: "
|
|
1993
|
-
path: "
|
|
2125
|
+
kind: "account",
|
|
2126
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
2127
|
+
account: "MXEAccount"
|
|
1994
2128
|
}
|
|
1995
2129
|
]
|
|
1996
2130
|
}
|
|
@@ -2024,8 +2158,9 @@ var instructions = [
|
|
|
2024
2158
|
]
|
|
2025
2159
|
},
|
|
2026
2160
|
{
|
|
2027
|
-
kind: "
|
|
2028
|
-
path: "
|
|
2161
|
+
kind: "account",
|
|
2162
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
2163
|
+
account: "MXEAccount"
|
|
2029
2164
|
},
|
|
2030
2165
|
{
|
|
2031
2166
|
kind: "arg",
|
|
@@ -2221,8 +2356,9 @@ var instructions = [
|
|
|
2221
2356
|
]
|
|
2222
2357
|
},
|
|
2223
2358
|
{
|
|
2224
|
-
kind: "
|
|
2225
|
-
path: "
|
|
2359
|
+
kind: "account",
|
|
2360
|
+
path: "mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? ",
|
|
2361
|
+
account: "MXEAccount"
|
|
2226
2362
|
},
|
|
2227
2363
|
{
|
|
2228
2364
|
kind: "arg",
|
|
@@ -2413,7 +2549,7 @@ var instructions = [
|
|
|
2413
2549
|
}
|
|
2414
2550
|
},
|
|
2415
2551
|
{
|
|
2416
|
-
name: "
|
|
2552
|
+
name: "cluster_acc",
|
|
2417
2553
|
optional: true,
|
|
2418
2554
|
pda: {
|
|
2419
2555
|
seeds: [
|
|
@@ -2431,15 +2567,40 @@ var instructions = [
|
|
|
2431
2567
|
},
|
|
2432
2568
|
{
|
|
2433
2569
|
kind: "account",
|
|
2434
|
-
path: "arx_node_acc
|
|
2435
|
-
account: "ArxNode"
|
|
2570
|
+
path: "arx_node_acc"
|
|
2436
2571
|
}
|
|
2437
2572
|
]
|
|
2438
2573
|
}
|
|
2574
|
+
}
|
|
2575
|
+
],
|
|
2576
|
+
args: [
|
|
2577
|
+
{
|
|
2578
|
+
name: "node_offset",
|
|
2579
|
+
type: "u32"
|
|
2580
|
+
}
|
|
2581
|
+
]
|
|
2582
|
+
},
|
|
2583
|
+
{
|
|
2584
|
+
name: "deactivate_cluster",
|
|
2585
|
+
discriminator: [
|
|
2586
|
+
13,
|
|
2587
|
+
42,
|
|
2588
|
+
182,
|
|
2589
|
+
159,
|
|
2590
|
+
184,
|
|
2591
|
+
10,
|
|
2592
|
+
212,
|
|
2593
|
+
178
|
|
2594
|
+
],
|
|
2595
|
+
accounts: [
|
|
2596
|
+
{
|
|
2597
|
+
name: "authority",
|
|
2598
|
+
writable: true,
|
|
2599
|
+
signer: true
|
|
2439
2600
|
},
|
|
2440
2601
|
{
|
|
2441
|
-
name: "
|
|
2442
|
-
|
|
2602
|
+
name: "cluster_acc",
|
|
2603
|
+
writable: true,
|
|
2443
2604
|
pda: {
|
|
2444
2605
|
seeds: [
|
|
2445
2606
|
{
|
|
@@ -2455,16 +2616,14 @@ var instructions = [
|
|
|
2455
2616
|
]
|
|
2456
2617
|
},
|
|
2457
2618
|
{
|
|
2458
|
-
kind: "
|
|
2459
|
-
path: "
|
|
2460
|
-
account: "ArxNode"
|
|
2619
|
+
kind: "arg",
|
|
2620
|
+
path: "_id"
|
|
2461
2621
|
}
|
|
2462
2622
|
]
|
|
2463
2623
|
}
|
|
2464
2624
|
},
|
|
2465
2625
|
{
|
|
2466
|
-
name: "
|
|
2467
|
-
optional: true,
|
|
2626
|
+
name: "clock",
|
|
2468
2627
|
pda: {
|
|
2469
2628
|
seeds: [
|
|
2470
2629
|
{
|
|
@@ -2472,355 +2631,106 @@ var instructions = [
|
|
|
2472
2631
|
value: [
|
|
2473
2632
|
67,
|
|
2474
2633
|
108,
|
|
2634
|
+
111,
|
|
2635
|
+
99,
|
|
2636
|
+
107,
|
|
2637
|
+
65,
|
|
2638
|
+
99,
|
|
2639
|
+
99,
|
|
2640
|
+
111,
|
|
2475
2641
|
117,
|
|
2476
|
-
|
|
2477
|
-
116
|
|
2478
|
-
101,
|
|
2479
|
-
114
|
|
2642
|
+
110,
|
|
2643
|
+
116
|
|
2480
2644
|
]
|
|
2481
|
-
},
|
|
2482
|
-
{
|
|
2483
|
-
kind: "account",
|
|
2484
|
-
path: "arx_node_acc.cluster_memberships.get(2).ok_or(ArciumError ::\nInvalidClusterMembership) ? ",
|
|
2485
|
-
account: "ArxNode"
|
|
2486
2645
|
}
|
|
2487
2646
|
]
|
|
2488
2647
|
}
|
|
2489
2648
|
},
|
|
2490
2649
|
{
|
|
2491
|
-
name: "
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
},
|
|
2507
|
-
{
|
|
2508
|
-
kind: "account",
|
|
2509
|
-
path: "arx_node_acc.cluster_memberships.get(3).ok_or(ArciumError ::\nInvalidClusterMembership) ? ",
|
|
2510
|
-
account: "ArxNode"
|
|
2511
|
-
}
|
|
2512
|
-
]
|
|
2650
|
+
name: "system_program",
|
|
2651
|
+
address: "11111111111111111111111111111111"
|
|
2652
|
+
}
|
|
2653
|
+
],
|
|
2654
|
+
args: [
|
|
2655
|
+
{
|
|
2656
|
+
name: "cluster_id",
|
|
2657
|
+
type: "u32"
|
|
2658
|
+
},
|
|
2659
|
+
{
|
|
2660
|
+
name: "deactivation_epoch",
|
|
2661
|
+
type: {
|
|
2662
|
+
defined: {
|
|
2663
|
+
name: "Epoch"
|
|
2664
|
+
}
|
|
2513
2665
|
}
|
|
2666
|
+
}
|
|
2667
|
+
]
|
|
2668
|
+
},
|
|
2669
|
+
{
|
|
2670
|
+
name: "dummy_instruction",
|
|
2671
|
+
docs: [
|
|
2672
|
+
"Only present so the mempool and execpool accounts are actually included in the idl, since we",
|
|
2673
|
+
"don't explicitly declare them in the accounts section of the other instructions."
|
|
2674
|
+
],
|
|
2675
|
+
discriminator: [
|
|
2676
|
+
57,
|
|
2677
|
+
4,
|
|
2678
|
+
200,
|
|
2679
|
+
151,
|
|
2680
|
+
58,
|
|
2681
|
+
19,
|
|
2682
|
+
120,
|
|
2683
|
+
9
|
|
2684
|
+
],
|
|
2685
|
+
accounts: [
|
|
2686
|
+
{
|
|
2687
|
+
name: "tiny_mempool"
|
|
2514
2688
|
},
|
|
2515
2689
|
{
|
|
2516
|
-
name: "
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
account: "ArxNode"
|
|
2561
|
-
}
|
|
2562
|
-
]
|
|
2563
|
-
}
|
|
2564
|
-
},
|
|
2565
|
-
{
|
|
2566
|
-
name: "cluster_acc_6",
|
|
2567
|
-
optional: true,
|
|
2568
|
-
pda: {
|
|
2569
|
-
seeds: [
|
|
2570
|
-
{
|
|
2571
|
-
kind: "const",
|
|
2572
|
-
value: [
|
|
2573
|
-
67,
|
|
2574
|
-
108,
|
|
2575
|
-
117,
|
|
2576
|
-
115,
|
|
2577
|
-
116,
|
|
2578
|
-
101,
|
|
2579
|
-
114
|
|
2580
|
-
]
|
|
2581
|
-
},
|
|
2582
|
-
{
|
|
2583
|
-
kind: "account",
|
|
2584
|
-
path: "arx_node_acc.cluster_memberships.get(6).ok_or(ArciumError ::\nInvalidClusterMembership) ? ",
|
|
2585
|
-
account: "ArxNode"
|
|
2586
|
-
}
|
|
2587
|
-
]
|
|
2588
|
-
}
|
|
2589
|
-
},
|
|
2590
|
-
{
|
|
2591
|
-
name: "cluster_acc_7",
|
|
2592
|
-
optional: true,
|
|
2593
|
-
pda: {
|
|
2594
|
-
seeds: [
|
|
2595
|
-
{
|
|
2596
|
-
kind: "const",
|
|
2597
|
-
value: [
|
|
2598
|
-
67,
|
|
2599
|
-
108,
|
|
2600
|
-
117,
|
|
2601
|
-
115,
|
|
2602
|
-
116,
|
|
2603
|
-
101,
|
|
2604
|
-
114
|
|
2605
|
-
]
|
|
2606
|
-
},
|
|
2607
|
-
{
|
|
2608
|
-
kind: "account",
|
|
2609
|
-
path: "arx_node_acc.cluster_memberships.get(7).ok_or(ArciumError ::\nInvalidClusterMembership) ? ",
|
|
2610
|
-
account: "ArxNode"
|
|
2611
|
-
}
|
|
2612
|
-
]
|
|
2613
|
-
}
|
|
2614
|
-
},
|
|
2615
|
-
{
|
|
2616
|
-
name: "cluster_acc_8",
|
|
2617
|
-
optional: true,
|
|
2618
|
-
pda: {
|
|
2619
|
-
seeds: [
|
|
2620
|
-
{
|
|
2621
|
-
kind: "const",
|
|
2622
|
-
value: [
|
|
2623
|
-
67,
|
|
2624
|
-
108,
|
|
2625
|
-
117,
|
|
2626
|
-
115,
|
|
2627
|
-
116,
|
|
2628
|
-
101,
|
|
2629
|
-
114
|
|
2630
|
-
]
|
|
2631
|
-
},
|
|
2632
|
-
{
|
|
2633
|
-
kind: "account",
|
|
2634
|
-
path: "arx_node_acc.cluster_memberships.get(8).ok_or(ArciumError ::\nInvalidClusterMembership) ? ",
|
|
2635
|
-
account: "ArxNode"
|
|
2636
|
-
}
|
|
2637
|
-
]
|
|
2638
|
-
}
|
|
2639
|
-
},
|
|
2640
|
-
{
|
|
2641
|
-
name: "cluster_acc_9",
|
|
2642
|
-
optional: true,
|
|
2643
|
-
pda: {
|
|
2644
|
-
seeds: [
|
|
2645
|
-
{
|
|
2646
|
-
kind: "const",
|
|
2647
|
-
value: [
|
|
2648
|
-
67,
|
|
2649
|
-
108,
|
|
2650
|
-
117,
|
|
2651
|
-
115,
|
|
2652
|
-
116,
|
|
2653
|
-
101,
|
|
2654
|
-
114
|
|
2655
|
-
]
|
|
2656
|
-
},
|
|
2657
|
-
{
|
|
2658
|
-
kind: "account",
|
|
2659
|
-
path: "arx_node_acc.cluster_memberships.get(9).ok_or(ArciumError ::\nInvalidClusterMembership) ? ",
|
|
2660
|
-
account: "ArxNode"
|
|
2661
|
-
}
|
|
2662
|
-
]
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
],
|
|
2666
|
-
args: [
|
|
2667
|
-
{
|
|
2668
|
-
name: "node_offset",
|
|
2669
|
-
type: "u32"
|
|
2670
|
-
}
|
|
2671
|
-
]
|
|
2672
|
-
},
|
|
2673
|
-
{
|
|
2674
|
-
name: "deactivate_cluster",
|
|
2675
|
-
discriminator: [
|
|
2676
|
-
13,
|
|
2677
|
-
42,
|
|
2678
|
-
182,
|
|
2679
|
-
159,
|
|
2680
|
-
184,
|
|
2681
|
-
10,
|
|
2682
|
-
212,
|
|
2683
|
-
178
|
|
2684
|
-
],
|
|
2685
|
-
accounts: [
|
|
2686
|
-
{
|
|
2687
|
-
name: "authority",
|
|
2688
|
-
writable: true,
|
|
2689
|
-
signer: true
|
|
2690
|
-
},
|
|
2691
|
-
{
|
|
2692
|
-
name: "cluster_acc",
|
|
2693
|
-
writable: true,
|
|
2694
|
-
pda: {
|
|
2695
|
-
seeds: [
|
|
2696
|
-
{
|
|
2697
|
-
kind: "const",
|
|
2698
|
-
value: [
|
|
2699
|
-
67,
|
|
2700
|
-
108,
|
|
2701
|
-
117,
|
|
2702
|
-
115,
|
|
2703
|
-
116,
|
|
2704
|
-
101,
|
|
2705
|
-
114
|
|
2706
|
-
]
|
|
2707
|
-
},
|
|
2708
|
-
{
|
|
2709
|
-
kind: "arg",
|
|
2710
|
-
path: "_id"
|
|
2711
|
-
}
|
|
2712
|
-
]
|
|
2713
|
-
}
|
|
2714
|
-
},
|
|
2715
|
-
{
|
|
2716
|
-
name: "clock",
|
|
2717
|
-
pda: {
|
|
2718
|
-
seeds: [
|
|
2719
|
-
{
|
|
2720
|
-
kind: "const",
|
|
2721
|
-
value: [
|
|
2722
|
-
67,
|
|
2723
|
-
108,
|
|
2724
|
-
111,
|
|
2725
|
-
99,
|
|
2726
|
-
107,
|
|
2727
|
-
65,
|
|
2728
|
-
99,
|
|
2729
|
-
99,
|
|
2730
|
-
111,
|
|
2731
|
-
117,
|
|
2732
|
-
110,
|
|
2733
|
-
116
|
|
2734
|
-
]
|
|
2735
|
-
}
|
|
2736
|
-
]
|
|
2737
|
-
}
|
|
2738
|
-
},
|
|
2739
|
-
{
|
|
2740
|
-
name: "system_program",
|
|
2741
|
-
address: "11111111111111111111111111111111"
|
|
2742
|
-
}
|
|
2743
|
-
],
|
|
2744
|
-
args: [
|
|
2745
|
-
{
|
|
2746
|
-
name: "cluster_id",
|
|
2747
|
-
type: "u32"
|
|
2748
|
-
},
|
|
2749
|
-
{
|
|
2750
|
-
name: "deactivation_epoch",
|
|
2751
|
-
type: {
|
|
2752
|
-
defined: {
|
|
2753
|
-
name: "Epoch"
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
]
|
|
2758
|
-
},
|
|
2759
|
-
{
|
|
2760
|
-
name: "dummy_instruction",
|
|
2761
|
-
docs: [
|
|
2762
|
-
"Only present so the mempool and execpool accounts are actually included in the idl, since we",
|
|
2763
|
-
"don't explicitly declare them in the accounts section of the other instructions."
|
|
2764
|
-
],
|
|
2765
|
-
discriminator: [
|
|
2766
|
-
57,
|
|
2767
|
-
4,
|
|
2768
|
-
200,
|
|
2769
|
-
151,
|
|
2770
|
-
58,
|
|
2771
|
-
19,
|
|
2772
|
-
120,
|
|
2773
|
-
9
|
|
2774
|
-
],
|
|
2775
|
-
accounts: [
|
|
2776
|
-
{
|
|
2777
|
-
name: "tiny_mempool"
|
|
2778
|
-
},
|
|
2779
|
-
{
|
|
2780
|
-
name: "tiny_execpool"
|
|
2781
|
-
},
|
|
2782
|
-
{
|
|
2783
|
-
name: "small_mempool"
|
|
2784
|
-
},
|
|
2785
|
-
{
|
|
2786
|
-
name: "small_execpool"
|
|
2787
|
-
},
|
|
2788
|
-
{
|
|
2789
|
-
name: "medium_mempool"
|
|
2790
|
-
},
|
|
2791
|
-
{
|
|
2792
|
-
name: "medium_execpool"
|
|
2793
|
-
},
|
|
2794
|
-
{
|
|
2795
|
-
name: "large_mempool"
|
|
2796
|
-
},
|
|
2797
|
-
{
|
|
2798
|
-
name: "large_execpool"
|
|
2799
|
-
}
|
|
2800
|
-
],
|
|
2801
|
-
args: [
|
|
2802
|
-
]
|
|
2803
|
-
},
|
|
2804
|
-
{
|
|
2805
|
-
name: "embiggen_raw_circuit_acc",
|
|
2806
|
-
discriminator: [
|
|
2807
|
-
92,
|
|
2808
|
-
195,
|
|
2809
|
-
192,
|
|
2810
|
-
21,
|
|
2811
|
-
193,
|
|
2812
|
-
242,
|
|
2813
|
-
135,
|
|
2814
|
-
194
|
|
2815
|
-
],
|
|
2816
|
-
accounts: [
|
|
2817
|
-
{
|
|
2818
|
-
name: "signer",
|
|
2819
|
-
writable: true,
|
|
2820
|
-
signer: true
|
|
2821
|
-
},
|
|
2822
|
-
{
|
|
2823
|
-
name: "comp_def_acc",
|
|
2690
|
+
name: "tiny_execpool"
|
|
2691
|
+
},
|
|
2692
|
+
{
|
|
2693
|
+
name: "small_mempool"
|
|
2694
|
+
},
|
|
2695
|
+
{
|
|
2696
|
+
name: "small_execpool"
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
name: "medium_mempool"
|
|
2700
|
+
},
|
|
2701
|
+
{
|
|
2702
|
+
name: "medium_execpool"
|
|
2703
|
+
},
|
|
2704
|
+
{
|
|
2705
|
+
name: "large_mempool"
|
|
2706
|
+
},
|
|
2707
|
+
{
|
|
2708
|
+
name: "large_execpool"
|
|
2709
|
+
}
|
|
2710
|
+
],
|
|
2711
|
+
args: [
|
|
2712
|
+
]
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
name: "embiggen_raw_circuit_acc",
|
|
2716
|
+
discriminator: [
|
|
2717
|
+
92,
|
|
2718
|
+
195,
|
|
2719
|
+
192,
|
|
2720
|
+
21,
|
|
2721
|
+
193,
|
|
2722
|
+
242,
|
|
2723
|
+
135,
|
|
2724
|
+
194
|
|
2725
|
+
],
|
|
2726
|
+
accounts: [
|
|
2727
|
+
{
|
|
2728
|
+
name: "signer",
|
|
2729
|
+
writable: true,
|
|
2730
|
+
signer: true
|
|
2731
|
+
},
|
|
2732
|
+
{
|
|
2733
|
+
name: "comp_def_acc",
|
|
2824
2734
|
pda: {
|
|
2825
2735
|
seeds: [
|
|
2826
2736
|
{
|
|
@@ -3129,21 +3039,22 @@ var instructions = [
|
|
|
3129
3039
|
]
|
|
3130
3040
|
},
|
|
3131
3041
|
{
|
|
3132
|
-
kind: "
|
|
3133
|
-
path: "
|
|
3042
|
+
kind: "arg",
|
|
3043
|
+
path: "_cluster_offset"
|
|
3134
3044
|
}
|
|
3135
3045
|
]
|
|
3136
3046
|
}
|
|
3137
3047
|
},
|
|
3138
|
-
{
|
|
3139
|
-
name: "mxe_program"
|
|
3140
|
-
},
|
|
3141
3048
|
{
|
|
3142
3049
|
name: "system_program",
|
|
3143
3050
|
address: "11111111111111111111111111111111"
|
|
3144
3051
|
}
|
|
3145
3052
|
],
|
|
3146
3053
|
args: [
|
|
3054
|
+
{
|
|
3055
|
+
name: "cluster_offset",
|
|
3056
|
+
type: "u32"
|
|
3057
|
+
}
|
|
3147
3058
|
]
|
|
3148
3059
|
},
|
|
3149
3060
|
{
|
|
@@ -3338,6 +3249,14 @@ var instructions = [
|
|
|
3338
3249
|
name: "cu_capacity_claim",
|
|
3339
3250
|
type: "u64"
|
|
3340
3251
|
},
|
|
3252
|
+
{
|
|
3253
|
+
name: "bls_pubkey",
|
|
3254
|
+
type: {
|
|
3255
|
+
defined: {
|
|
3256
|
+
name: "BN254G2BLSPublicKey"
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
},
|
|
3341
3260
|
{
|
|
3342
3261
|
name: "metadata",
|
|
3343
3262
|
type: {
|
|
@@ -3367,20 +3286,75 @@ var instructions = [
|
|
|
3367
3286
|
signer: true
|
|
3368
3287
|
},
|
|
3369
3288
|
{
|
|
3370
|
-
name: "cluster_acc",
|
|
3289
|
+
name: "cluster_acc",
|
|
3290
|
+
writable: true,
|
|
3291
|
+
pda: {
|
|
3292
|
+
seeds: [
|
|
3293
|
+
{
|
|
3294
|
+
kind: "const",
|
|
3295
|
+
value: [
|
|
3296
|
+
67,
|
|
3297
|
+
108,
|
|
3298
|
+
117,
|
|
3299
|
+
115,
|
|
3300
|
+
116,
|
|
3301
|
+
101,
|
|
3302
|
+
114
|
|
3303
|
+
]
|
|
3304
|
+
},
|
|
3305
|
+
{
|
|
3306
|
+
kind: "arg",
|
|
3307
|
+
path: "_id"
|
|
3308
|
+
}
|
|
3309
|
+
]
|
|
3310
|
+
}
|
|
3311
|
+
},
|
|
3312
|
+
{
|
|
3313
|
+
name: "authority"
|
|
3314
|
+
},
|
|
3315
|
+
{
|
|
3316
|
+
name: "mempool",
|
|
3317
|
+
docs: [
|
|
3318
|
+
"function"
|
|
3319
|
+
],
|
|
3320
|
+
writable: true,
|
|
3321
|
+
pda: {
|
|
3322
|
+
seeds: [
|
|
3323
|
+
{
|
|
3324
|
+
kind: "const",
|
|
3325
|
+
value: [
|
|
3326
|
+
77,
|
|
3327
|
+
101,
|
|
3328
|
+
109,
|
|
3329
|
+
112,
|
|
3330
|
+
111,
|
|
3331
|
+
111,
|
|
3332
|
+
108
|
|
3333
|
+
]
|
|
3334
|
+
},
|
|
3335
|
+
{
|
|
3336
|
+
kind: "arg",
|
|
3337
|
+
path: "_id"
|
|
3338
|
+
}
|
|
3339
|
+
]
|
|
3340
|
+
}
|
|
3341
|
+
},
|
|
3342
|
+
{
|
|
3343
|
+
name: "execpool",
|
|
3371
3344
|
writable: true,
|
|
3372
3345
|
pda: {
|
|
3373
3346
|
seeds: [
|
|
3374
3347
|
{
|
|
3375
3348
|
kind: "const",
|
|
3376
3349
|
value: [
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
117,
|
|
3380
|
-
115,
|
|
3381
|
-
116,
|
|
3350
|
+
69,
|
|
3351
|
+
120,
|
|
3382
3352
|
101,
|
|
3383
|
-
|
|
3353
|
+
99,
|
|
3354
|
+
112,
|
|
3355
|
+
111,
|
|
3356
|
+
111,
|
|
3357
|
+
108
|
|
3384
3358
|
]
|
|
3385
3359
|
},
|
|
3386
3360
|
{
|
|
@@ -3390,9 +3364,6 @@ var instructions = [
|
|
|
3390
3364
|
]
|
|
3391
3365
|
}
|
|
3392
3366
|
},
|
|
3393
|
-
{
|
|
3394
|
-
name: "authority"
|
|
3395
|
-
},
|
|
3396
3367
|
{
|
|
3397
3368
|
name: "pool_account",
|
|
3398
3369
|
pda: {
|
|
@@ -3446,6 +3417,14 @@ var instructions = [
|
|
|
3446
3417
|
name: "cluster_id",
|
|
3447
3418
|
type: "u32"
|
|
3448
3419
|
},
|
|
3420
|
+
{
|
|
3421
|
+
name: "mempool_size",
|
|
3422
|
+
type: {
|
|
3423
|
+
defined: {
|
|
3424
|
+
name: "MempoolSize"
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
},
|
|
3449
3428
|
{
|
|
3450
3429
|
name: "max_size",
|
|
3451
3430
|
type: "u32"
|
|
@@ -3658,19 +3637,17 @@ var instructions = [
|
|
|
3658
3637
|
}
|
|
3659
3638
|
},
|
|
3660
3639
|
{
|
|
3661
|
-
name: "
|
|
3662
|
-
docs: [
|
|
3663
|
-
"function"
|
|
3664
|
-
],
|
|
3640
|
+
name: "executing_pool",
|
|
3665
3641
|
writable: true,
|
|
3666
3642
|
pda: {
|
|
3667
3643
|
seeds: [
|
|
3668
3644
|
{
|
|
3669
3645
|
kind: "const",
|
|
3670
3646
|
value: [
|
|
3671
|
-
|
|
3647
|
+
69,
|
|
3648
|
+
120,
|
|
3672
3649
|
101,
|
|
3673
|
-
|
|
3650
|
+
99,
|
|
3674
3651
|
112,
|
|
3675
3652
|
111,
|
|
3676
3653
|
111,
|
|
@@ -3678,24 +3655,23 @@ var instructions = [
|
|
|
3678
3655
|
]
|
|
3679
3656
|
},
|
|
3680
3657
|
{
|
|
3681
|
-
kind: "
|
|
3682
|
-
path: "
|
|
3658
|
+
kind: "arg",
|
|
3659
|
+
path: "cluster_offset"
|
|
3683
3660
|
}
|
|
3684
3661
|
]
|
|
3685
3662
|
}
|
|
3686
3663
|
},
|
|
3687
3664
|
{
|
|
3688
|
-
name: "
|
|
3665
|
+
name: "mempool",
|
|
3689
3666
|
writable: true,
|
|
3690
3667
|
pda: {
|
|
3691
3668
|
seeds: [
|
|
3692
3669
|
{
|
|
3693
3670
|
kind: "const",
|
|
3694
3671
|
value: [
|
|
3695
|
-
|
|
3696
|
-
120,
|
|
3672
|
+
77,
|
|
3697
3673
|
101,
|
|
3698
|
-
|
|
3674
|
+
109,
|
|
3699
3675
|
112,
|
|
3700
3676
|
111,
|
|
3701
3677
|
111,
|
|
@@ -3703,8 +3679,8 @@ var instructions = [
|
|
|
3703
3679
|
]
|
|
3704
3680
|
},
|
|
3705
3681
|
{
|
|
3706
|
-
kind: "
|
|
3707
|
-
path: "
|
|
3682
|
+
kind: "arg",
|
|
3683
|
+
path: "cluster_offset"
|
|
3708
3684
|
}
|
|
3709
3685
|
]
|
|
3710
3686
|
}
|
|
@@ -3714,7 +3690,6 @@ var instructions = [
|
|
|
3714
3690
|
docs: [
|
|
3715
3691
|
"Cluster to add to the MXE."
|
|
3716
3692
|
],
|
|
3717
|
-
writable: true,
|
|
3718
3693
|
pda: {
|
|
3719
3694
|
seeds: [
|
|
3720
3695
|
{
|
|
@@ -3819,8 +3794,8 @@ var instructions = [
|
|
|
3819
3794
|
]
|
|
3820
3795
|
},
|
|
3821
3796
|
{
|
|
3822
|
-
kind: "
|
|
3823
|
-
path: "
|
|
3797
|
+
kind: "arg",
|
|
3798
|
+
path: "cluster_offset"
|
|
3824
3799
|
},
|
|
3825
3800
|
{
|
|
3826
3801
|
kind: "const",
|
|
@@ -3848,6 +3823,26 @@ var instructions = [
|
|
|
3848
3823
|
"constraint in tests because setting it would require us to deploy a program each time."
|
|
3849
3824
|
]
|
|
3850
3825
|
},
|
|
3826
|
+
{
|
|
3827
|
+
name: "pool_account",
|
|
3828
|
+
writable: true,
|
|
3829
|
+
pda: {
|
|
3830
|
+
seeds: [
|
|
3831
|
+
{
|
|
3832
|
+
kind: "const",
|
|
3833
|
+
value: [
|
|
3834
|
+
70,
|
|
3835
|
+
101,
|
|
3836
|
+
101,
|
|
3837
|
+
80,
|
|
3838
|
+
111,
|
|
3839
|
+
111,
|
|
3840
|
+
108
|
|
3841
|
+
]
|
|
3842
|
+
}
|
|
3843
|
+
]
|
|
3844
|
+
}
|
|
3845
|
+
},
|
|
3851
3846
|
{
|
|
3852
3847
|
name: "system_program",
|
|
3853
3848
|
docs: [
|
|
@@ -3860,14 +3855,6 @@ var instructions = [
|
|
|
3860
3855
|
{
|
|
3861
3856
|
name: "cluster_offset",
|
|
3862
3857
|
type: "u32"
|
|
3863
|
-
},
|
|
3864
|
-
{
|
|
3865
|
-
name: "mempool_size",
|
|
3866
|
-
type: {
|
|
3867
|
-
defined: {
|
|
3868
|
-
name: "MempoolSize"
|
|
3869
|
-
}
|
|
3870
|
-
}
|
|
3871
3858
|
}
|
|
3872
3859
|
]
|
|
3873
3860
|
},
|
|
@@ -4507,7 +4494,7 @@ var instructions = [
|
|
|
4507
4494
|
},
|
|
4508
4495
|
{
|
|
4509
4496
|
kind: "arg",
|
|
4510
|
-
path: "
|
|
4497
|
+
path: "cluster_index.map_or(mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? , | i |\nmxe.fallback_clusters [i as usize])"
|
|
4511
4498
|
},
|
|
4512
4499
|
{
|
|
4513
4500
|
kind: "arg",
|
|
@@ -4562,7 +4549,7 @@ var instructions = [
|
|
|
4562
4549
|
},
|
|
4563
4550
|
{
|
|
4564
4551
|
kind: "arg",
|
|
4565
|
-
path: "
|
|
4552
|
+
path: "cluster_index.map_or(mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? , | i |\nmxe.fallback_clusters [i as usize])"
|
|
4566
4553
|
}
|
|
4567
4554
|
]
|
|
4568
4555
|
}
|
|
@@ -4586,7 +4573,7 @@ var instructions = [
|
|
|
4586
4573
|
},
|
|
4587
4574
|
{
|
|
4588
4575
|
kind: "arg",
|
|
4589
|
-
path: "
|
|
4576
|
+
path: "cluster_index.map_or(mxe.cluster.ok_or(ArciumError :: ClusterNotSet) ? , | i |\nmxe.fallback_clusters [i as usize])"
|
|
4590
4577
|
}
|
|
4591
4578
|
]
|
|
4592
4579
|
}
|
|
@@ -4730,10 +4717,8 @@ var instructions = [
|
|
|
4730
4717
|
{
|
|
4731
4718
|
name: "args",
|
|
4732
4719
|
type: {
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
name: "Argument"
|
|
4736
|
-
}
|
|
4720
|
+
defined: {
|
|
4721
|
+
name: "ArgumentList"
|
|
4737
4722
|
}
|
|
4738
4723
|
}
|
|
4739
4724
|
},
|
|
@@ -4766,92 +4751,295 @@ var instructions = [
|
|
|
4766
4751
|
type: "u64"
|
|
4767
4752
|
},
|
|
4768
4753
|
{
|
|
4769
|
-
name: "cu_price_micro",
|
|
4770
|
-
type: "u64"
|
|
4771
|
-
}
|
|
4772
|
-
]
|
|
4773
|
-
},
|
|
4774
|
-
{
|
|
4775
|
-
name: "reclaim_failure_rent",
|
|
4776
|
-
discriminator: [
|
|
4777
|
-
159,
|
|
4778
|
-
99,
|
|
4779
|
-
116,
|
|
4780
|
-
180,
|
|
4781
|
-
42,
|
|
4782
|
-
9,
|
|
4783
|
-
202,
|
|
4784
|
-
219
|
|
4785
|
-
],
|
|
4786
|
-
accounts: [
|
|
4787
|
-
{
|
|
4788
|
-
name: "signer",
|
|
4754
|
+
name: "cu_price_micro",
|
|
4755
|
+
type: "u64"
|
|
4756
|
+
}
|
|
4757
|
+
]
|
|
4758
|
+
},
|
|
4759
|
+
{
|
|
4760
|
+
name: "reclaim_failure_rent",
|
|
4761
|
+
discriminator: [
|
|
4762
|
+
159,
|
|
4763
|
+
99,
|
|
4764
|
+
116,
|
|
4765
|
+
180,
|
|
4766
|
+
42,
|
|
4767
|
+
9,
|
|
4768
|
+
202,
|
|
4769
|
+
219
|
|
4770
|
+
],
|
|
4771
|
+
accounts: [
|
|
4772
|
+
{
|
|
4773
|
+
name: "signer",
|
|
4774
|
+
writable: true,
|
|
4775
|
+
signer: true
|
|
4776
|
+
},
|
|
4777
|
+
{
|
|
4778
|
+
name: "failure_acc",
|
|
4779
|
+
writable: true,
|
|
4780
|
+
pda: {
|
|
4781
|
+
seeds: [
|
|
4782
|
+
{
|
|
4783
|
+
kind: "const",
|
|
4784
|
+
value: [
|
|
4785
|
+
70,
|
|
4786
|
+
97,
|
|
4787
|
+
105,
|
|
4788
|
+
108,
|
|
4789
|
+
117,
|
|
4790
|
+
114,
|
|
4791
|
+
101,
|
|
4792
|
+
67,
|
|
4793
|
+
108,
|
|
4794
|
+
97,
|
|
4795
|
+
105,
|
|
4796
|
+
109,
|
|
4797
|
+
65,
|
|
4798
|
+
99,
|
|
4799
|
+
99,
|
|
4800
|
+
111,
|
|
4801
|
+
117,
|
|
4802
|
+
110,
|
|
4803
|
+
116,
|
|
4804
|
+
72,
|
|
4805
|
+
101,
|
|
4806
|
+
97,
|
|
4807
|
+
100,
|
|
4808
|
+
101,
|
|
4809
|
+
114
|
|
4810
|
+
]
|
|
4811
|
+
},
|
|
4812
|
+
{
|
|
4813
|
+
kind: "arg",
|
|
4814
|
+
path: "mxe_program"
|
|
4815
|
+
},
|
|
4816
|
+
{
|
|
4817
|
+
kind: "arg",
|
|
4818
|
+
path: "comp_offset"
|
|
4819
|
+
}
|
|
4820
|
+
]
|
|
4821
|
+
}
|
|
4822
|
+
},
|
|
4823
|
+
{
|
|
4824
|
+
name: "clock",
|
|
4825
|
+
address: "SysvarC1ock11111111111111111111111111111111"
|
|
4826
|
+
}
|
|
4827
|
+
],
|
|
4828
|
+
args: [
|
|
4829
|
+
{
|
|
4830
|
+
name: "comp_offset",
|
|
4831
|
+
type: "u64"
|
|
4832
|
+
},
|
|
4833
|
+
{
|
|
4834
|
+
name: "node_offset",
|
|
4835
|
+
type: "u32"
|
|
4836
|
+
},
|
|
4837
|
+
{
|
|
4838
|
+
name: "mxe_program",
|
|
4839
|
+
type: "pubkey"
|
|
4840
|
+
}
|
|
4841
|
+
]
|
|
4842
|
+
},
|
|
4843
|
+
{
|
|
4844
|
+
name: "requeue_mxe_keygen",
|
|
4845
|
+
docs: [
|
|
4846
|
+
"Re-queues the MXE keygen computation if it has expired from the mempool.",
|
|
4847
|
+
"This allows retrying the keygen if it wasn't processed in time."
|
|
4848
|
+
],
|
|
4849
|
+
discriminator: [
|
|
4850
|
+
90,
|
|
4851
|
+
98,
|
|
4852
|
+
117,
|
|
4853
|
+
181,
|
|
4854
|
+
88,
|
|
4855
|
+
71,
|
|
4856
|
+
135,
|
|
4857
|
+
30
|
|
4858
|
+
],
|
|
4859
|
+
accounts: [
|
|
4860
|
+
{
|
|
4861
|
+
name: "signer",
|
|
4862
|
+
writable: true,
|
|
4863
|
+
signer: true
|
|
4864
|
+
},
|
|
4865
|
+
{
|
|
4866
|
+
name: "mxe",
|
|
4867
|
+
pda: {
|
|
4868
|
+
seeds: [
|
|
4869
|
+
{
|
|
4870
|
+
kind: "const",
|
|
4871
|
+
value: [
|
|
4872
|
+
77,
|
|
4873
|
+
88,
|
|
4874
|
+
69,
|
|
4875
|
+
65,
|
|
4876
|
+
99,
|
|
4877
|
+
99,
|
|
4878
|
+
111,
|
|
4879
|
+
117,
|
|
4880
|
+
110,
|
|
4881
|
+
116
|
|
4882
|
+
]
|
|
4883
|
+
},
|
|
4884
|
+
{
|
|
4885
|
+
kind: "account",
|
|
4886
|
+
path: "mxe_program"
|
|
4887
|
+
}
|
|
4888
|
+
]
|
|
4889
|
+
}
|
|
4890
|
+
},
|
|
4891
|
+
{
|
|
4892
|
+
name: "executing_pool",
|
|
4893
|
+
writable: true,
|
|
4894
|
+
pda: {
|
|
4895
|
+
seeds: [
|
|
4896
|
+
{
|
|
4897
|
+
kind: "const",
|
|
4898
|
+
value: [
|
|
4899
|
+
69,
|
|
4900
|
+
120,
|
|
4901
|
+
101,
|
|
4902
|
+
99,
|
|
4903
|
+
112,
|
|
4904
|
+
111,
|
|
4905
|
+
111,
|
|
4906
|
+
108
|
|
4907
|
+
]
|
|
4908
|
+
},
|
|
4909
|
+
{
|
|
4910
|
+
kind: "arg",
|
|
4911
|
+
path: "cluster_offset"
|
|
4912
|
+
}
|
|
4913
|
+
]
|
|
4914
|
+
}
|
|
4915
|
+
},
|
|
4916
|
+
{
|
|
4917
|
+
name: "mempool",
|
|
4789
4918
|
writable: true,
|
|
4790
|
-
|
|
4919
|
+
pda: {
|
|
4920
|
+
seeds: [
|
|
4921
|
+
{
|
|
4922
|
+
kind: "const",
|
|
4923
|
+
value: [
|
|
4924
|
+
77,
|
|
4925
|
+
101,
|
|
4926
|
+
109,
|
|
4927
|
+
112,
|
|
4928
|
+
111,
|
|
4929
|
+
111,
|
|
4930
|
+
108
|
|
4931
|
+
]
|
|
4932
|
+
},
|
|
4933
|
+
{
|
|
4934
|
+
kind: "arg",
|
|
4935
|
+
path: "cluster_offset"
|
|
4936
|
+
}
|
|
4937
|
+
]
|
|
4938
|
+
}
|
|
4791
4939
|
},
|
|
4792
4940
|
{
|
|
4793
|
-
name: "
|
|
4794
|
-
writable: true,
|
|
4941
|
+
name: "cluster",
|
|
4795
4942
|
pda: {
|
|
4796
4943
|
seeds: [
|
|
4797
4944
|
{
|
|
4798
4945
|
kind: "const",
|
|
4799
4946
|
value: [
|
|
4800
|
-
|
|
4801
|
-
97,
|
|
4802
|
-
105,
|
|
4947
|
+
67,
|
|
4803
4948
|
108,
|
|
4804
4949
|
117,
|
|
4805
|
-
|
|
4950
|
+
115,
|
|
4951
|
+
116,
|
|
4806
4952
|
101,
|
|
4953
|
+
114
|
|
4954
|
+
]
|
|
4955
|
+
},
|
|
4956
|
+
{
|
|
4957
|
+
kind: "arg",
|
|
4958
|
+
path: "cluster_offset"
|
|
4959
|
+
}
|
|
4960
|
+
]
|
|
4961
|
+
}
|
|
4962
|
+
},
|
|
4963
|
+
{
|
|
4964
|
+
name: "mxe_keygen_computation",
|
|
4965
|
+
writable: true,
|
|
4966
|
+
pda: {
|
|
4967
|
+
seeds: [
|
|
4968
|
+
{
|
|
4969
|
+
kind: "const",
|
|
4970
|
+
value: [
|
|
4807
4971
|
67,
|
|
4808
|
-
|
|
4972
|
+
111,
|
|
4973
|
+
109,
|
|
4974
|
+
112,
|
|
4975
|
+
117,
|
|
4976
|
+
116,
|
|
4809
4977
|
97,
|
|
4978
|
+
116,
|
|
4810
4979
|
105,
|
|
4811
|
-
|
|
4980
|
+
111,
|
|
4981
|
+
110,
|
|
4812
4982
|
65,
|
|
4813
4983
|
99,
|
|
4814
4984
|
99,
|
|
4815
4985
|
111,
|
|
4816
4986
|
117,
|
|
4817
4987
|
110,
|
|
4818
|
-
116
|
|
4819
|
-
72,
|
|
4820
|
-
101,
|
|
4821
|
-
97,
|
|
4822
|
-
100,
|
|
4823
|
-
101,
|
|
4824
|
-
114
|
|
4988
|
+
116
|
|
4825
4989
|
]
|
|
4826
4990
|
},
|
|
4827
4991
|
{
|
|
4828
4992
|
kind: "arg",
|
|
4829
|
-
path: "
|
|
4993
|
+
path: "cluster_offset"
|
|
4830
4994
|
},
|
|
4831
4995
|
{
|
|
4832
|
-
kind: "
|
|
4833
|
-
|
|
4996
|
+
kind: "const",
|
|
4997
|
+
value: [
|
|
4998
|
+
1,
|
|
4999
|
+
0,
|
|
5000
|
+
0,
|
|
5001
|
+
0,
|
|
5002
|
+
0,
|
|
5003
|
+
0,
|
|
5004
|
+
0,
|
|
5005
|
+
0
|
|
5006
|
+
]
|
|
4834
5007
|
}
|
|
4835
5008
|
]
|
|
4836
5009
|
}
|
|
4837
5010
|
},
|
|
4838
5011
|
{
|
|
4839
|
-
name: "
|
|
4840
|
-
|
|
5012
|
+
name: "pool_account",
|
|
5013
|
+
writable: true,
|
|
5014
|
+
pda: {
|
|
5015
|
+
seeds: [
|
|
5016
|
+
{
|
|
5017
|
+
kind: "const",
|
|
5018
|
+
value: [
|
|
5019
|
+
70,
|
|
5020
|
+
101,
|
|
5021
|
+
101,
|
|
5022
|
+
80,
|
|
5023
|
+
111,
|
|
5024
|
+
111,
|
|
5025
|
+
108
|
|
5026
|
+
]
|
|
5027
|
+
}
|
|
5028
|
+
]
|
|
5029
|
+
}
|
|
5030
|
+
},
|
|
5031
|
+
{
|
|
5032
|
+
name: "mxe_program"
|
|
5033
|
+
},
|
|
5034
|
+
{
|
|
5035
|
+
name: "system_program",
|
|
5036
|
+
address: "11111111111111111111111111111111"
|
|
4841
5037
|
}
|
|
4842
5038
|
],
|
|
4843
5039
|
args: [
|
|
4844
5040
|
{
|
|
4845
|
-
name: "
|
|
4846
|
-
type: "u64"
|
|
4847
|
-
},
|
|
4848
|
-
{
|
|
4849
|
-
name: "node_offset",
|
|
5041
|
+
name: "cluster_offset",
|
|
4850
5042
|
type: "u32"
|
|
4851
|
-
},
|
|
4852
|
-
{
|
|
4853
|
-
name: "mxe_program",
|
|
4854
|
-
type: "pubkey"
|
|
4855
5043
|
}
|
|
4856
5044
|
]
|
|
4857
5045
|
},
|
|
@@ -5001,7 +5189,6 @@ var instructions = [
|
|
|
5001
5189
|
docs: [
|
|
5002
5190
|
"MXE account to set the cluster for."
|
|
5003
5191
|
],
|
|
5004
|
-
writable: true,
|
|
5005
5192
|
pda: {
|
|
5006
5193
|
seeds: [
|
|
5007
5194
|
{
|
|
@@ -5031,7 +5218,6 @@ var instructions = [
|
|
|
5031
5218
|
docs: [
|
|
5032
5219
|
"Cluster to set for the MXE."
|
|
5033
5220
|
],
|
|
5034
|
-
writable: true,
|
|
5035
5221
|
pda: {
|
|
5036
5222
|
seeds: [
|
|
5037
5223
|
{
|
|
@@ -5231,47 +5417,136 @@ var instructions = [
|
|
|
5231
5417
|
],
|
|
5232
5418
|
args: [
|
|
5233
5419
|
{
|
|
5234
|
-
name: "node_offset",
|
|
5420
|
+
name: "node_offset",
|
|
5421
|
+
type: "u32"
|
|
5422
|
+
},
|
|
5423
|
+
{
|
|
5424
|
+
name: "_mxe_program",
|
|
5425
|
+
type: "pubkey"
|
|
5426
|
+
},
|
|
5427
|
+
{
|
|
5428
|
+
name: "mxe_x25519_pubkey",
|
|
5429
|
+
type: {
|
|
5430
|
+
array: [
|
|
5431
|
+
"u8",
|
|
5432
|
+
32
|
|
5433
|
+
]
|
|
5434
|
+
}
|
|
5435
|
+
},
|
|
5436
|
+
{
|
|
5437
|
+
name: "mxe_ed25519_verifying_key",
|
|
5438
|
+
type: {
|
|
5439
|
+
array: [
|
|
5440
|
+
"u8",
|
|
5441
|
+
32
|
|
5442
|
+
]
|
|
5443
|
+
}
|
|
5444
|
+
},
|
|
5445
|
+
{
|
|
5446
|
+
name: "mxe_elgamal_pubkey",
|
|
5447
|
+
type: {
|
|
5448
|
+
array: [
|
|
5449
|
+
"u8",
|
|
5450
|
+
32
|
|
5451
|
+
]
|
|
5452
|
+
}
|
|
5453
|
+
},
|
|
5454
|
+
{
|
|
5455
|
+
name: "mxe_pubkey_validity_proof",
|
|
5456
|
+
type: {
|
|
5457
|
+
array: [
|
|
5458
|
+
"u8",
|
|
5459
|
+
64
|
|
5460
|
+
]
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
]
|
|
5464
|
+
},
|
|
5465
|
+
{
|
|
5466
|
+
name: "submit_aggregated_bls_pubkey",
|
|
5467
|
+
discriminator: [
|
|
5468
|
+
192,
|
|
5469
|
+
135,
|
|
5470
|
+
47,
|
|
5471
|
+
120,
|
|
5472
|
+
63,
|
|
5473
|
+
18,
|
|
5474
|
+
232,
|
|
5475
|
+
164
|
|
5476
|
+
],
|
|
5477
|
+
accounts: [
|
|
5478
|
+
{
|
|
5479
|
+
name: "node_authority",
|
|
5480
|
+
writable: true,
|
|
5481
|
+
signer: true
|
|
5482
|
+
},
|
|
5483
|
+
{
|
|
5484
|
+
name: "cluster_acc",
|
|
5485
|
+
writable: true,
|
|
5486
|
+
pda: {
|
|
5487
|
+
seeds: [
|
|
5488
|
+
{
|
|
5489
|
+
kind: "const",
|
|
5490
|
+
value: [
|
|
5491
|
+
67,
|
|
5492
|
+
108,
|
|
5493
|
+
117,
|
|
5494
|
+
115,
|
|
5495
|
+
116,
|
|
5496
|
+
101,
|
|
5497
|
+
114
|
|
5498
|
+
]
|
|
5499
|
+
},
|
|
5500
|
+
{
|
|
5501
|
+
kind: "arg",
|
|
5502
|
+
path: "cluster_offset"
|
|
5503
|
+
}
|
|
5504
|
+
]
|
|
5505
|
+
}
|
|
5506
|
+
},
|
|
5507
|
+
{
|
|
5508
|
+
name: "arx_node_acc",
|
|
5509
|
+
pda: {
|
|
5510
|
+
seeds: [
|
|
5511
|
+
{
|
|
5512
|
+
kind: "const",
|
|
5513
|
+
value: [
|
|
5514
|
+
65,
|
|
5515
|
+
114,
|
|
5516
|
+
120,
|
|
5517
|
+
78,
|
|
5518
|
+
111,
|
|
5519
|
+
100,
|
|
5520
|
+
101
|
|
5521
|
+
]
|
|
5522
|
+
},
|
|
5523
|
+
{
|
|
5524
|
+
kind: "arg",
|
|
5525
|
+
path: "node_offset"
|
|
5526
|
+
}
|
|
5527
|
+
]
|
|
5528
|
+
}
|
|
5529
|
+
},
|
|
5530
|
+
{
|
|
5531
|
+
name: "system_program",
|
|
5532
|
+
address: "11111111111111111111111111111111"
|
|
5533
|
+
}
|
|
5534
|
+
],
|
|
5535
|
+
args: [
|
|
5536
|
+
{
|
|
5537
|
+
name: "cluster_id",
|
|
5235
5538
|
type: "u32"
|
|
5236
5539
|
},
|
|
5237
5540
|
{
|
|
5238
|
-
name: "
|
|
5239
|
-
type: "
|
|
5240
|
-
},
|
|
5241
|
-
{
|
|
5242
|
-
name: "mxe_x25519_pubkey",
|
|
5243
|
-
type: {
|
|
5244
|
-
array: [
|
|
5245
|
-
"u8",
|
|
5246
|
-
32
|
|
5247
|
-
]
|
|
5248
|
-
}
|
|
5249
|
-
},
|
|
5250
|
-
{
|
|
5251
|
-
name: "mxe_ed25519_verifying_key",
|
|
5252
|
-
type: {
|
|
5253
|
-
array: [
|
|
5254
|
-
"u8",
|
|
5255
|
-
32
|
|
5256
|
-
]
|
|
5257
|
-
}
|
|
5258
|
-
},
|
|
5259
|
-
{
|
|
5260
|
-
name: "mxe_elgamal_pubkey",
|
|
5261
|
-
type: {
|
|
5262
|
-
array: [
|
|
5263
|
-
"u8",
|
|
5264
|
-
32
|
|
5265
|
-
]
|
|
5266
|
-
}
|
|
5541
|
+
name: "node_bump",
|
|
5542
|
+
type: "u32"
|
|
5267
5543
|
},
|
|
5268
5544
|
{
|
|
5269
|
-
name: "
|
|
5545
|
+
name: "aggregated_bls_pubkey",
|
|
5270
5546
|
type: {
|
|
5271
|
-
|
|
5272
|
-
"
|
|
5273
|
-
|
|
5274
|
-
]
|
|
5547
|
+
defined: {
|
|
5548
|
+
name: "BN254G2BLSPublicKey"
|
|
5549
|
+
}
|
|
5275
5550
|
}
|
|
5276
5551
|
}
|
|
5277
5552
|
]
|
|
@@ -5976,6 +6251,11 @@ var errors = [
|
|
|
5976
6251
|
name: "InvalidCallbackInstructions",
|
|
5977
6252
|
msg: "Callback instructions are invalid"
|
|
5978
6253
|
},
|
|
6254
|
+
{
|
|
6255
|
+
code: 6210,
|
|
6256
|
+
name: "ComputationNotExpired",
|
|
6257
|
+
msg: "Computation has not expired from mempool yet"
|
|
6258
|
+
},
|
|
5979
6259
|
{
|
|
5980
6260
|
code: 6300,
|
|
5981
6261
|
name: "ComputationDefinitionNotCompleted",
|
|
@@ -5996,6 +6276,11 @@ var errors = [
|
|
|
5996
6276
|
name: "ComputationDefinitionAlreadyCompleted",
|
|
5997
6277
|
msg: "Computation definition already completed"
|
|
5998
6278
|
},
|
|
6279
|
+
{
|
|
6280
|
+
code: 6304,
|
|
6281
|
+
name: "InvalidCUAmount",
|
|
6282
|
+
msg: "CU amount exceeds maximum limit"
|
|
6283
|
+
},
|
|
5999
6284
|
{
|
|
6000
6285
|
code: 6400,
|
|
6001
6286
|
name: "InvalidNode",
|
|
@@ -6041,6 +6326,11 @@ var errors = [
|
|
|
6041
6326
|
name: "InvalidNodeConfig",
|
|
6042
6327
|
msg: "Node config is invalid"
|
|
6043
6328
|
},
|
|
6329
|
+
{
|
|
6330
|
+
code: 6409,
|
|
6331
|
+
name: "UnauthorizedNodeCreation",
|
|
6332
|
+
msg: "Unauthorized to create node on mainnet"
|
|
6333
|
+
},
|
|
6044
6334
|
{
|
|
6045
6335
|
code: 6500,
|
|
6046
6336
|
name: "ClusterFull",
|
|
@@ -6115,6 +6405,41 @@ var errors = [
|
|
|
6115
6405
|
code: 6607,
|
|
6116
6406
|
name: "EpochOverflow",
|
|
6117
6407
|
msg: "Epoch overflowed"
|
|
6408
|
+
},
|
|
6409
|
+
{
|
|
6410
|
+
code: 6608,
|
|
6411
|
+
name: "InvalidLighthouseProgramID",
|
|
6412
|
+
msg: "Lighthouse program ID is invalid"
|
|
6413
|
+
},
|
|
6414
|
+
{
|
|
6415
|
+
code: 6609,
|
|
6416
|
+
name: "ExtraInstructionFound",
|
|
6417
|
+
msg: "Extra instruction found in transaction"
|
|
6418
|
+
},
|
|
6419
|
+
{
|
|
6420
|
+
code: 6610,
|
|
6421
|
+
name: "InvalidLighthouseInstructionCount",
|
|
6422
|
+
msg: "Invalid number of Lighthouse program instructions"
|
|
6423
|
+
},
|
|
6424
|
+
{
|
|
6425
|
+
code: 6611,
|
|
6426
|
+
name: "InvalidSignature",
|
|
6427
|
+
msg: "Invalid BLS signature"
|
|
6428
|
+
},
|
|
6429
|
+
{
|
|
6430
|
+
code: 6612,
|
|
6431
|
+
name: "ValueAlreadySet",
|
|
6432
|
+
msg: "Value already set"
|
|
6433
|
+
},
|
|
6434
|
+
{
|
|
6435
|
+
code: 6613,
|
|
6436
|
+
name: "InvalidValueSetterIndex",
|
|
6437
|
+
msg: "Invalid value setter index"
|
|
6438
|
+
},
|
|
6439
|
+
{
|
|
6440
|
+
code: 6614,
|
|
6441
|
+
name: "NotAllNodesVotedForBlsPublicKey",
|
|
6442
|
+
msg: "Not all nodes have voted for the BLS public key"
|
|
6118
6443
|
}
|
|
6119
6444
|
];
|
|
6120
6445
|
var types = [
|
|
@@ -6190,6 +6515,26 @@ var types = [
|
|
|
6190
6515
|
]
|
|
6191
6516
|
}
|
|
6192
6517
|
},
|
|
6518
|
+
{
|
|
6519
|
+
name: "AccountArgument",
|
|
6520
|
+
type: {
|
|
6521
|
+
kind: "struct",
|
|
6522
|
+
fields: [
|
|
6523
|
+
{
|
|
6524
|
+
name: "pubkey",
|
|
6525
|
+
type: "pubkey"
|
|
6526
|
+
},
|
|
6527
|
+
{
|
|
6528
|
+
name: "offset",
|
|
6529
|
+
type: "u32"
|
|
6530
|
+
},
|
|
6531
|
+
{
|
|
6532
|
+
name: "length",
|
|
6533
|
+
type: "u32"
|
|
6534
|
+
}
|
|
6535
|
+
]
|
|
6536
|
+
}
|
|
6537
|
+
},
|
|
6193
6538
|
{
|
|
6194
6539
|
name: "Activation",
|
|
6195
6540
|
type: {
|
|
@@ -6221,10 +6566,64 @@ var types = [
|
|
|
6221
6566
|
}
|
|
6222
6567
|
},
|
|
6223
6568
|
{
|
|
6224
|
-
name: "
|
|
6569
|
+
name: "ArgumentList",
|
|
6570
|
+
docs: [
|
|
6571
|
+
"Container for arguments that separates small inline values from large indexed data"
|
|
6572
|
+
],
|
|
6573
|
+
type: {
|
|
6574
|
+
kind: "struct",
|
|
6575
|
+
fields: [
|
|
6576
|
+
{
|
|
6577
|
+
name: "args",
|
|
6578
|
+
type: {
|
|
6579
|
+
vec: {
|
|
6580
|
+
defined: {
|
|
6581
|
+
name: "ArgumentRef"
|
|
6582
|
+
}
|
|
6583
|
+
}
|
|
6584
|
+
}
|
|
6585
|
+
},
|
|
6586
|
+
{
|
|
6587
|
+
name: "byte_arrays",
|
|
6588
|
+
type: {
|
|
6589
|
+
vec: {
|
|
6590
|
+
array: [
|
|
6591
|
+
"u8",
|
|
6592
|
+
32
|
|
6593
|
+
]
|
|
6594
|
+
}
|
|
6595
|
+
}
|
|
6596
|
+
},
|
|
6597
|
+
{
|
|
6598
|
+
name: "plaintext_numbers",
|
|
6599
|
+
type: {
|
|
6600
|
+
vec: "u64"
|
|
6601
|
+
}
|
|
6602
|
+
},
|
|
6603
|
+
{
|
|
6604
|
+
name: "values_128_bit",
|
|
6605
|
+
type: {
|
|
6606
|
+
vec: "u128"
|
|
6607
|
+
}
|
|
6608
|
+
},
|
|
6609
|
+
{
|
|
6610
|
+
name: "accounts",
|
|
6611
|
+
type: {
|
|
6612
|
+
vec: {
|
|
6613
|
+
defined: {
|
|
6614
|
+
name: "AccountArgument"
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
}
|
|
6618
|
+
}
|
|
6619
|
+
]
|
|
6620
|
+
}
|
|
6621
|
+
},
|
|
6622
|
+
{
|
|
6623
|
+
name: "ArgumentRef",
|
|
6225
6624
|
docs: [
|
|
6226
|
-
"
|
|
6227
|
-
"
|
|
6625
|
+
"A reference to an argument - stores small values that don't affect alignment inline and large",
|
|
6626
|
+
"values as indices."
|
|
6228
6627
|
],
|
|
6229
6628
|
type: {
|
|
6230
6629
|
kind: "enum",
|
|
@@ -6241,153 +6640,160 @@ var types = [
|
|
|
6241
6640
|
"u8"
|
|
6242
6641
|
]
|
|
6243
6642
|
},
|
|
6643
|
+
{
|
|
6644
|
+
name: "PlaintextI8",
|
|
6645
|
+
fields: [
|
|
6646
|
+
"i8"
|
|
6647
|
+
]
|
|
6648
|
+
},
|
|
6244
6649
|
{
|
|
6245
6650
|
name: "PlaintextU16",
|
|
6246
6651
|
fields: [
|
|
6247
|
-
"
|
|
6652
|
+
"u8"
|
|
6248
6653
|
]
|
|
6249
6654
|
},
|
|
6250
6655
|
{
|
|
6251
6656
|
name: "PlaintextU32",
|
|
6252
6657
|
fields: [
|
|
6253
|
-
"
|
|
6658
|
+
"u8"
|
|
6254
6659
|
]
|
|
6255
6660
|
},
|
|
6256
6661
|
{
|
|
6257
6662
|
name: "PlaintextU64",
|
|
6258
6663
|
fields: [
|
|
6259
|
-
"
|
|
6664
|
+
"u8"
|
|
6260
6665
|
]
|
|
6261
6666
|
},
|
|
6262
6667
|
{
|
|
6263
6668
|
name: "PlaintextU128",
|
|
6264
6669
|
fields: [
|
|
6265
|
-
"
|
|
6670
|
+
"u8"
|
|
6266
6671
|
]
|
|
6267
6672
|
},
|
|
6268
6673
|
{
|
|
6269
6674
|
name: "PlaintextFloat",
|
|
6270
6675
|
fields: [
|
|
6271
|
-
"
|
|
6676
|
+
"u8"
|
|
6272
6677
|
]
|
|
6273
6678
|
},
|
|
6274
6679
|
{
|
|
6275
6680
|
name: "EncryptedBool",
|
|
6276
6681
|
fields: [
|
|
6277
|
-
|
|
6278
|
-
array: [
|
|
6279
|
-
"u8",
|
|
6280
|
-
32
|
|
6281
|
-
]
|
|
6282
|
-
}
|
|
6682
|
+
"u8"
|
|
6283
6683
|
]
|
|
6284
6684
|
},
|
|
6285
6685
|
{
|
|
6286
6686
|
name: "EncryptedU8",
|
|
6287
6687
|
fields: [
|
|
6288
|
-
|
|
6289
|
-
array: [
|
|
6290
|
-
"u8",
|
|
6291
|
-
32
|
|
6292
|
-
]
|
|
6293
|
-
}
|
|
6688
|
+
"u8"
|
|
6294
6689
|
]
|
|
6295
6690
|
},
|
|
6296
6691
|
{
|
|
6297
6692
|
name: "EncryptedU16",
|
|
6298
6693
|
fields: [
|
|
6299
|
-
|
|
6300
|
-
array: [
|
|
6301
|
-
"u8",
|
|
6302
|
-
32
|
|
6303
|
-
]
|
|
6304
|
-
}
|
|
6694
|
+
"u8"
|
|
6305
6695
|
]
|
|
6306
6696
|
},
|
|
6307
6697
|
{
|
|
6308
6698
|
name: "EncryptedU32",
|
|
6309
6699
|
fields: [
|
|
6310
|
-
|
|
6311
|
-
array: [
|
|
6312
|
-
"u8",
|
|
6313
|
-
32
|
|
6314
|
-
]
|
|
6315
|
-
}
|
|
6700
|
+
"u8"
|
|
6316
6701
|
]
|
|
6317
6702
|
},
|
|
6318
6703
|
{
|
|
6319
6704
|
name: "EncryptedU64",
|
|
6320
6705
|
fields: [
|
|
6321
|
-
|
|
6322
|
-
array: [
|
|
6323
|
-
"u8",
|
|
6324
|
-
32
|
|
6325
|
-
]
|
|
6326
|
-
}
|
|
6706
|
+
"u8"
|
|
6327
6707
|
]
|
|
6328
6708
|
},
|
|
6329
6709
|
{
|
|
6330
6710
|
name: "EncryptedU128",
|
|
6331
6711
|
fields: [
|
|
6332
|
-
|
|
6333
|
-
array: [
|
|
6334
|
-
"u8",
|
|
6335
|
-
32
|
|
6336
|
-
]
|
|
6337
|
-
}
|
|
6712
|
+
"u8"
|
|
6338
6713
|
]
|
|
6339
6714
|
},
|
|
6340
6715
|
{
|
|
6341
6716
|
name: "EncryptedFloat",
|
|
6342
6717
|
fields: [
|
|
6343
|
-
|
|
6344
|
-
array: [
|
|
6345
|
-
"u8",
|
|
6346
|
-
32
|
|
6347
|
-
]
|
|
6348
|
-
}
|
|
6718
|
+
"u8"
|
|
6349
6719
|
]
|
|
6350
6720
|
},
|
|
6351
6721
|
{
|
|
6352
|
-
name: "
|
|
6722
|
+
name: "X25519Pubkey",
|
|
6353
6723
|
fields: [
|
|
6354
|
-
|
|
6355
|
-
array: [
|
|
6356
|
-
"u8",
|
|
6357
|
-
32
|
|
6358
|
-
]
|
|
6359
|
-
}
|
|
6724
|
+
"u8"
|
|
6360
6725
|
]
|
|
6361
6726
|
},
|
|
6362
6727
|
{
|
|
6363
|
-
name: "
|
|
6728
|
+
name: "ArcisEd25519Signature",
|
|
6364
6729
|
fields: [
|
|
6365
|
-
|
|
6366
|
-
array: [
|
|
6367
|
-
"u8",
|
|
6368
|
-
64
|
|
6369
|
-
]
|
|
6370
|
-
}
|
|
6730
|
+
"u8"
|
|
6371
6731
|
]
|
|
6372
6732
|
},
|
|
6373
6733
|
{
|
|
6374
6734
|
name: "Account",
|
|
6375
6735
|
fields: [
|
|
6376
|
-
"
|
|
6377
|
-
|
|
6378
|
-
|
|
6736
|
+
"u8"
|
|
6737
|
+
]
|
|
6738
|
+
},
|
|
6739
|
+
{
|
|
6740
|
+
name: "PlaintextI16",
|
|
6741
|
+
fields: [
|
|
6742
|
+
"u8"
|
|
6743
|
+
]
|
|
6744
|
+
},
|
|
6745
|
+
{
|
|
6746
|
+
name: "PlaintextI32",
|
|
6747
|
+
fields: [
|
|
6748
|
+
"u8"
|
|
6749
|
+
]
|
|
6750
|
+
},
|
|
6751
|
+
{
|
|
6752
|
+
name: "PlaintextI64",
|
|
6753
|
+
fields: [
|
|
6754
|
+
"u8"
|
|
6755
|
+
]
|
|
6756
|
+
},
|
|
6757
|
+
{
|
|
6758
|
+
name: "PlaintextI128",
|
|
6759
|
+
fields: [
|
|
6760
|
+
"u8"
|
|
6761
|
+
]
|
|
6762
|
+
},
|
|
6763
|
+
{
|
|
6764
|
+
name: "EncryptedI8",
|
|
6765
|
+
fields: [
|
|
6766
|
+
"u8"
|
|
6767
|
+
]
|
|
6768
|
+
},
|
|
6769
|
+
{
|
|
6770
|
+
name: "EncryptedI16",
|
|
6771
|
+
fields: [
|
|
6772
|
+
"u8"
|
|
6773
|
+
]
|
|
6774
|
+
},
|
|
6775
|
+
{
|
|
6776
|
+
name: "EncryptedI32",
|
|
6777
|
+
fields: [
|
|
6778
|
+
"u8"
|
|
6779
|
+
]
|
|
6780
|
+
},
|
|
6781
|
+
{
|
|
6782
|
+
name: "EncryptedI64",
|
|
6783
|
+
fields: [
|
|
6784
|
+
"u8"
|
|
6379
6785
|
]
|
|
6380
6786
|
},
|
|
6381
6787
|
{
|
|
6382
|
-
name: "
|
|
6788
|
+
name: "EncryptedI128",
|
|
6383
6789
|
fields: [
|
|
6384
|
-
"
|
|
6790
|
+
"u8"
|
|
6385
6791
|
]
|
|
6386
6792
|
},
|
|
6387
6793
|
{
|
|
6388
|
-
name: "
|
|
6794
|
+
name: "PlaintextPoint",
|
|
6389
6795
|
fields: [
|
|
6390
|
-
"
|
|
6796
|
+
"u8"
|
|
6391
6797
|
]
|
|
6392
6798
|
}
|
|
6393
6799
|
]
|
|
@@ -6419,21 +6825,14 @@ var types = [
|
|
|
6419
6825
|
}
|
|
6420
6826
|
},
|
|
6421
6827
|
{
|
|
6422
|
-
name: "
|
|
6828
|
+
name: "cluster_membership",
|
|
6423
6829
|
docs: [
|
|
6424
6830
|
"The offsets of the cluster the node is a member of."
|
|
6425
6831
|
],
|
|
6426
6832
|
type: {
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
{
|
|
6431
|
-
name: "proposed_cluster_memberships",
|
|
6432
|
-
docs: [
|
|
6433
|
-
"The offsets of the clusters the node has been proposed to be a member of."
|
|
6434
|
-
],
|
|
6435
|
-
type: {
|
|
6436
|
-
vec: "u32"
|
|
6833
|
+
defined: {
|
|
6834
|
+
name: "ClusterMembership"
|
|
6835
|
+
}
|
|
6437
6836
|
}
|
|
6438
6837
|
},
|
|
6439
6838
|
{
|
|
@@ -6445,12 +6844,14 @@ var types = [
|
|
|
6445
6844
|
type: "bool"
|
|
6446
6845
|
},
|
|
6447
6846
|
{
|
|
6448
|
-
name: "
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6847
|
+
name: "bls_pubkey",
|
|
6848
|
+
docs: [
|
|
6849
|
+
"BLS public key for this node (64 bytes compressed G2 point for alt-bn128)"
|
|
6850
|
+
],
|
|
6851
|
+
type: {
|
|
6852
|
+
defined: {
|
|
6853
|
+
name: "BN254G2BLSPublicKey"
|
|
6854
|
+
}
|
|
6454
6855
|
}
|
|
6455
6856
|
},
|
|
6456
6857
|
{
|
|
@@ -6465,10 +6866,6 @@ var types = [
|
|
|
6465
6866
|
type: {
|
|
6466
6867
|
kind: "struct",
|
|
6467
6868
|
fields: [
|
|
6468
|
-
{
|
|
6469
|
-
name: "max_cluster_memberships",
|
|
6470
|
-
type: "u32"
|
|
6471
|
-
},
|
|
6472
6869
|
{
|
|
6473
6870
|
name: "authority",
|
|
6474
6871
|
docs: [
|
|
@@ -6486,6 +6883,20 @@ var types = [
|
|
|
6486
6883
|
]
|
|
6487
6884
|
}
|
|
6488
6885
|
},
|
|
6886
|
+
{
|
|
6887
|
+
name: "BN254G2BLSPublicKey",
|
|
6888
|
+
type: {
|
|
6889
|
+
kind: "struct",
|
|
6890
|
+
fields: [
|
|
6891
|
+
{
|
|
6892
|
+
array: [
|
|
6893
|
+
"u8",
|
|
6894
|
+
64
|
|
6895
|
+
]
|
|
6896
|
+
}
|
|
6897
|
+
]
|
|
6898
|
+
}
|
|
6899
|
+
},
|
|
6489
6900
|
{
|
|
6490
6901
|
name: "CallbackAccount",
|
|
6491
6902
|
docs: [
|
|
@@ -6703,15 +7114,6 @@ var types = [
|
|
|
6703
7114
|
}
|
|
6704
7115
|
}
|
|
6705
7116
|
},
|
|
6706
|
-
{
|
|
6707
|
-
name: "mxes",
|
|
6708
|
-
docs: [
|
|
6709
|
-
"The MXE's that this cluster is assigned to. Referred to by the MXE's program id."
|
|
6710
|
-
],
|
|
6711
|
-
type: {
|
|
6712
|
-
vec: "pubkey"
|
|
6713
|
-
}
|
|
6714
|
-
},
|
|
6715
7117
|
{
|
|
6716
7118
|
name: "nodes",
|
|
6717
7119
|
type: {
|
|
@@ -6732,6 +7134,28 @@ var types = [
|
|
|
6732
7134
|
}
|
|
6733
7135
|
}
|
|
6734
7136
|
},
|
|
7137
|
+
{
|
|
7138
|
+
name: "bls_public_key",
|
|
7139
|
+
docs: [
|
|
7140
|
+
"BLS public key for the cluster (64 bytes compressed G2 point for alt-bn128)",
|
|
7141
|
+
"Set only when all nodes have submitted and agreed on the aggregated pubkey"
|
|
7142
|
+
],
|
|
7143
|
+
type: {
|
|
7144
|
+
defined: {
|
|
7145
|
+
name: "SetUnset",
|
|
7146
|
+
generics: [
|
|
7147
|
+
{
|
|
7148
|
+
kind: "type",
|
|
7149
|
+
type: {
|
|
7150
|
+
defined: {
|
|
7151
|
+
name: "BN254G2BLSPublicKey"
|
|
7152
|
+
}
|
|
7153
|
+
}
|
|
7154
|
+
}
|
|
7155
|
+
]
|
|
7156
|
+
}
|
|
7157
|
+
}
|
|
7158
|
+
},
|
|
6735
7159
|
{
|
|
6736
7160
|
name: "bump",
|
|
6737
7161
|
type: "u8"
|
|
@@ -6739,6 +7163,29 @@ var types = [
|
|
|
6739
7163
|
]
|
|
6740
7164
|
}
|
|
6741
7165
|
},
|
|
7166
|
+
{
|
|
7167
|
+
name: "ClusterMembership",
|
|
7168
|
+
type: {
|
|
7169
|
+
kind: "enum",
|
|
7170
|
+
variants: [
|
|
7171
|
+
{
|
|
7172
|
+
name: "Inactive"
|
|
7173
|
+
},
|
|
7174
|
+
{
|
|
7175
|
+
name: "Active",
|
|
7176
|
+
fields: [
|
|
7177
|
+
"u32"
|
|
7178
|
+
]
|
|
7179
|
+
},
|
|
7180
|
+
{
|
|
7181
|
+
name: "Proposed",
|
|
7182
|
+
fields: [
|
|
7183
|
+
"u32"
|
|
7184
|
+
]
|
|
7185
|
+
}
|
|
7186
|
+
]
|
|
7187
|
+
}
|
|
7188
|
+
},
|
|
6742
7189
|
{
|
|
6743
7190
|
name: "ComputationAccount",
|
|
6744
7191
|
docs: [
|
|
@@ -6752,18 +7199,11 @@ var types = [
|
|
|
6752
7199
|
type: "pubkey"
|
|
6753
7200
|
},
|
|
6754
7201
|
{
|
|
6755
|
-
name: "
|
|
7202
|
+
name: "mxe_program_id",
|
|
6756
7203
|
docs: [
|
|
6757
|
-
"The MXE
|
|
6758
|
-
"",
|
|
6759
|
-
"# Notes",
|
|
6760
|
-
"",
|
|
6761
|
-
"- [None] represents the default cluster,",
|
|
6762
|
-
"- [Some] specifies the index of the fallback cluster."
|
|
7204
|
+
"The program ID of the MXE that this computation is associated with."
|
|
6763
7205
|
],
|
|
6764
|
-
type:
|
|
6765
|
-
option: "u16"
|
|
6766
|
-
}
|
|
7206
|
+
type: "pubkey"
|
|
6767
7207
|
},
|
|
6768
7208
|
{
|
|
6769
7209
|
name: "computation_definition_offset",
|
|
@@ -6800,16 +7240,24 @@ var types = [
|
|
|
6800
7240
|
}
|
|
6801
7241
|
},
|
|
6802
7242
|
{
|
|
6803
|
-
name: "
|
|
7243
|
+
name: "cluster_index",
|
|
6804
7244
|
docs: [
|
|
6805
|
-
"The
|
|
6806
|
-
"
|
|
7245
|
+
"The MXE's cluster to be used for execution.",
|
|
7246
|
+
"",
|
|
7247
|
+
"# Notes",
|
|
7248
|
+
"",
|
|
7249
|
+
"- [None] represents the default cluster,",
|
|
7250
|
+
"- [Some] specifies the index of the fallback cluster."
|
|
6807
7251
|
],
|
|
6808
7252
|
type: {
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
7253
|
+
option: "u16"
|
|
7254
|
+
}
|
|
7255
|
+
},
|
|
7256
|
+
{
|
|
7257
|
+
name: "arguments",
|
|
7258
|
+
type: {
|
|
7259
|
+
defined: {
|
|
7260
|
+
name: "ArgumentList"
|
|
6813
7261
|
}
|
|
6814
7262
|
}
|
|
6815
7263
|
},
|
|
@@ -6965,10 +7413,6 @@ var types = [
|
|
|
6965
7413
|
name: "priority_fee",
|
|
6966
7414
|
type: "u64"
|
|
6967
7415
|
},
|
|
6968
|
-
{
|
|
6969
|
-
name: "computation_definition_offset",
|
|
6970
|
-
type: "u32"
|
|
6971
|
-
},
|
|
6972
7416
|
{
|
|
6973
7417
|
name: "accs",
|
|
6974
7418
|
type: {
|
|
@@ -6978,7 +7422,7 @@ var types = [
|
|
|
6978
7422
|
name: "AcccountAccessInfo"
|
|
6979
7423
|
}
|
|
6980
7424
|
},
|
|
6981
|
-
|
|
7425
|
+
12
|
|
6982
7426
|
]
|
|
6983
7427
|
}
|
|
6984
7428
|
}
|
|
@@ -7499,21 +7943,29 @@ var types = [
|
|
|
7499
7943
|
kind: "struct",
|
|
7500
7944
|
fields: [
|
|
7501
7945
|
{
|
|
7502
|
-
name: "
|
|
7946
|
+
name: "cluster",
|
|
7503
7947
|
docs: [
|
|
7504
|
-
"The
|
|
7948
|
+
"The cluster executing the MXE."
|
|
7505
7949
|
],
|
|
7506
7950
|
type: {
|
|
7507
|
-
option: "
|
|
7951
|
+
option: "u32"
|
|
7508
7952
|
}
|
|
7509
7953
|
},
|
|
7510
7954
|
{
|
|
7511
|
-
name: "
|
|
7955
|
+
name: "mxe_program_id",
|
|
7512
7956
|
docs: [
|
|
7513
|
-
"The
|
|
7957
|
+
"The program ID of the program that this MXE is associated with. Needed so that when we",
|
|
7958
|
+
"index this account offchain we can find out what program it is associated with."
|
|
7959
|
+
],
|
|
7960
|
+
type: "pubkey"
|
|
7961
|
+
},
|
|
7962
|
+
{
|
|
7963
|
+
name: "authority",
|
|
7964
|
+
docs: [
|
|
7965
|
+
"The management authority of the MXE."
|
|
7514
7966
|
],
|
|
7515
7967
|
type: {
|
|
7516
|
-
option: "
|
|
7968
|
+
option: "pubkey"
|
|
7517
7969
|
}
|
|
7518
7970
|
},
|
|
7519
7971
|
{
|
|
@@ -7973,13 +8425,28 @@ var types = [
|
|
|
7973
8425
|
name: "Ciphertext"
|
|
7974
8426
|
},
|
|
7975
8427
|
{
|
|
7976
|
-
name: "
|
|
8428
|
+
name: "ArcisX25519Pubkey"
|
|
7977
8429
|
},
|
|
7978
8430
|
{
|
|
7979
8431
|
name: "PlaintextFloat"
|
|
7980
8432
|
},
|
|
7981
8433
|
{
|
|
7982
8434
|
name: "PlaintextPoint"
|
|
8435
|
+
},
|
|
8436
|
+
{
|
|
8437
|
+
name: "PlaintextI8"
|
|
8438
|
+
},
|
|
8439
|
+
{
|
|
8440
|
+
name: "PlaintextI16"
|
|
8441
|
+
},
|
|
8442
|
+
{
|
|
8443
|
+
name: "PlaintextI32"
|
|
8444
|
+
},
|
|
8445
|
+
{
|
|
8446
|
+
name: "PlaintextI64"
|
|
8447
|
+
},
|
|
8448
|
+
{
|
|
8449
|
+
name: "PlaintextI128"
|
|
7983
8450
|
}
|
|
7984
8451
|
]
|
|
7985
8452
|
}
|
|
@@ -8018,7 +8485,7 @@ var types = [
|
|
|
8018
8485
|
name: "Ciphertext"
|
|
8019
8486
|
},
|
|
8020
8487
|
{
|
|
8021
|
-
name: "
|
|
8488
|
+
name: "ArcisX25519Pubkey"
|
|
8022
8489
|
},
|
|
8023
8490
|
{
|
|
8024
8491
|
name: "ArcisSignature"
|
|
@@ -8027,10 +8494,22 @@ var types = [
|
|
|
8027
8494
|
name: "PlaintextFloat"
|
|
8028
8495
|
},
|
|
8029
8496
|
{
|
|
8030
|
-
name: "
|
|
8497
|
+
name: "PlaintextI8"
|
|
8498
|
+
},
|
|
8499
|
+
{
|
|
8500
|
+
name: "PlaintextI16"
|
|
8031
8501
|
},
|
|
8032
8502
|
{
|
|
8033
|
-
name: "
|
|
8503
|
+
name: "PlaintextI32"
|
|
8504
|
+
},
|
|
8505
|
+
{
|
|
8506
|
+
name: "PlaintextI64"
|
|
8507
|
+
},
|
|
8508
|
+
{
|
|
8509
|
+
name: "PlaintextI128"
|
|
8510
|
+
},
|
|
8511
|
+
{
|
|
8512
|
+
name: "PlaintextPoint"
|
|
8034
8513
|
}
|
|
8035
8514
|
]
|
|
8036
8515
|
}
|
|
@@ -8053,6 +8532,11 @@ var types = [
|
|
|
8053
8532
|
},
|
|
8054
8533
|
{
|
|
8055
8534
|
name: "SetUnset",
|
|
8535
|
+
docs: [
|
|
8536
|
+
"Utility struct to store a value that needs to be set by a certain number of participants (keys",
|
|
8537
|
+
"in our case). Once all participants have set the value, the value is considered set and we only",
|
|
8538
|
+
"store it once."
|
|
8539
|
+
],
|
|
8056
8540
|
generics: [
|
|
8057
8541
|
{
|
|
8058
8542
|
kind: "type",
|
|
@@ -8511,7 +8995,7 @@ var arcium = {
|
|
|
8511
8995
|
types: types
|
|
8512
8996
|
};
|
|
8513
8997
|
|
|
8514
|
-
var
|
|
8998
|
+
var ARCIUM_IDL_MODULE = /*#__PURE__*/Object.freeze({
|
|
8515
8999
|
__proto__: null,
|
|
8516
9000
|
accounts: accounts,
|
|
8517
9001
|
address: address,
|
|
@@ -8523,110 +9007,52 @@ var ARCIUM_IDL = /*#__PURE__*/Object.freeze({
|
|
|
8523
9007
|
types: types
|
|
8524
9008
|
});
|
|
8525
9009
|
|
|
9010
|
+
// Handle both ESM (ts-node wraps as {default: ...}) and bundled (direct) imports
|
|
9011
|
+
const ARCIUM_IDL = (arcium ?? ARCIUM_IDL_MODULE);
|
|
8526
9012
|
/**
|
|
8527
9013
|
* The deployed address of the Arcium program, as specified in the IDL.
|
|
8528
9014
|
*/
|
|
8529
|
-
const ARCIUM_ADDR = address;
|
|
8530
|
-
|
|
8531
|
-
/**
|
|
8532
|
-
* Seed for ClockAccount PDA
|
|
8533
|
-
* @constant {string}
|
|
8534
|
-
*/
|
|
8535
|
-
const CLOCK_ACC_SEED = 'ClockAccount';
|
|
8536
|
-
/**
|
|
8537
|
-
* Seed for FeePool PDA
|
|
8538
|
-
* @constant {string}
|
|
8539
|
-
*/
|
|
8540
|
-
const POOL_ACC_SEED = 'FeePool';
|
|
8541
|
-
/**
|
|
8542
|
-
* Seed for ComputationAccount PDA
|
|
8543
|
-
* @constant {string}
|
|
8544
|
-
*/
|
|
8545
|
-
const COMPUTATION_ACC_SEED = 'ComputationAccount';
|
|
8546
|
-
/**
|
|
8547
|
-
* Seed for Mempool PDA
|
|
8548
|
-
* @constant {string}
|
|
8549
|
-
*/
|
|
8550
|
-
const MEMPOOL_ACC_SEED = 'Mempool';
|
|
8551
|
-
/**
|
|
8552
|
-
* Seed for ExecutingPoolAccount PDA
|
|
8553
|
-
* @constant {string}
|
|
8554
|
-
*/
|
|
8555
|
-
const EXEC_POOL_ACC_SEED = 'Execpool';
|
|
8556
|
-
/**
|
|
8557
|
-
* Seed for ClusterAccount PDA
|
|
8558
|
-
* @constant {string}
|
|
8559
|
-
*/
|
|
8560
|
-
const CLUSTER_ACC_SEED = 'Cluster';
|
|
8561
|
-
/**
|
|
8562
|
-
* Seed for ArxNodeAccount PDA
|
|
8563
|
-
* @constant {string}
|
|
8564
|
-
*/
|
|
8565
|
-
const ARX_NODE_ACC_SEED = 'ArxNode';
|
|
8566
|
-
/**
|
|
8567
|
-
* Seed for MXEAccAccount PDA
|
|
8568
|
-
* @constant {string}
|
|
8569
|
-
*/
|
|
8570
|
-
const MXE_ACC_ACC_SEED = 'MXEAccount';
|
|
8571
|
-
/**
|
|
8572
|
-
* Seed for CompDefAccount PDA
|
|
8573
|
-
* @constant {string}
|
|
8574
|
-
*/
|
|
8575
|
-
const COMP_DEF_ACC_SEED = 'ComputationDefinitionAccount';
|
|
8576
|
-
/**
|
|
8577
|
-
* Maximum number of bytes that can be reallocated per instruction.
|
|
8578
|
-
* @constant {number}
|
|
8579
|
-
*/
|
|
8580
|
-
const MAX_REALLOC_PER_IX = 10240;
|
|
8581
|
-
/**
|
|
8582
|
-
* Maximum number of bytes that can be uploaded in a single transaction with the upload instruction.
|
|
8583
|
-
* @constant {number}
|
|
8584
|
-
*/
|
|
8585
|
-
const MAX_UPLOAD_PER_TX_BYTES = 814;
|
|
8586
|
-
/**
|
|
8587
|
-
* Maximum size of an account in bytes (10MB = 10 * 1024 * 1024).
|
|
8588
|
-
* @constant {number}
|
|
8589
|
-
*/
|
|
8590
|
-
const MAX_ACCOUNT_SIZE = 10485760;
|
|
8591
|
-
/**
|
|
8592
|
-
* Maximum number of arcium embiggen instructions allowed in a single transaction (due to compute unit limits).
|
|
8593
|
-
* @constant {number}
|
|
8594
|
-
*/
|
|
8595
|
-
const MAX_EMBIGGEN_IX_PER_TX = 18;
|
|
9015
|
+
const ARCIUM_ADDR = ARCIUM_IDL.address;
|
|
8596
9016
|
|
|
8597
9017
|
/**
|
|
8598
9018
|
* Returns the public key of the deployed Arcium program on Solana.
|
|
8599
9019
|
* @returns The Arcium program's public key.
|
|
8600
9020
|
*/
|
|
8601
9021
|
function getArciumProgramId() {
|
|
8602
|
-
return new PublicKey(
|
|
9022
|
+
return new anchor.web3.PublicKey(ARCIUM_ADDR);
|
|
8603
9023
|
}
|
|
8604
9024
|
/**
|
|
8605
|
-
* Derives the computation account address for a given
|
|
8606
|
-
* @param
|
|
8607
|
-
* @param
|
|
9025
|
+
* Derives the computation account address for a given cluster and computation offset.
|
|
9026
|
+
* @param clusterOffset - The offset of the cluster this computation will be executed by.
|
|
9027
|
+
* @param computationOffset - The computation offset as an anchor.BN.
|
|
8608
9028
|
* @returns The derived computation account public key.
|
|
8609
9029
|
*/
|
|
8610
|
-
function getComputationAccAddress(
|
|
8611
|
-
const
|
|
9030
|
+
function getComputationAccAddress(clusterOffset, computationOffset) {
|
|
9031
|
+
const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
9032
|
+
clOffsetBuffer.writeUInt32LE(clusterOffset, 0);
|
|
9033
|
+
const seeds = [Buffer.from(COMPUTATION_ACC_SEED), clOffsetBuffer, computationOffset.toArrayLike(Buffer, 'le', 8)];
|
|
8612
9034
|
return generateArciumPDAFrom(seeds)[0];
|
|
8613
9035
|
}
|
|
8614
9036
|
/**
|
|
8615
|
-
* Derives the mempool account address for a given
|
|
8616
|
-
* @param
|
|
9037
|
+
* Derives the mempool account address for a given cluster.
|
|
9038
|
+
* @param clusterOffset - The offset of the cluster.
|
|
8617
9039
|
* @returns The derived mempool account public key.
|
|
8618
9040
|
*/
|
|
8619
|
-
function getMempoolAccAddress(
|
|
8620
|
-
const
|
|
9041
|
+
function getMempoolAccAddress(clusterOffset) {
|
|
9042
|
+
const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
9043
|
+
clOffsetBuffer.writeUInt32LE(clusterOffset, 0);
|
|
9044
|
+
const seeds = [Buffer.from(MEMPOOL_ACC_SEED), clOffsetBuffer];
|
|
8621
9045
|
return generateArciumPDAFrom(seeds)[0];
|
|
8622
9046
|
}
|
|
8623
9047
|
/**
|
|
8624
|
-
* Derives the executing pool account address for a given
|
|
8625
|
-
* @param
|
|
9048
|
+
* Derives the executing pool account address for a given cluster.
|
|
9049
|
+
* @param clusterOffset - The offset of the cluster.
|
|
8626
9050
|
* @returns The derived executing pool account public key.
|
|
8627
9051
|
*/
|
|
8628
|
-
function getExecutingPoolAccAddress(
|
|
8629
|
-
const
|
|
9052
|
+
function getExecutingPoolAccAddress(clusterOffset) {
|
|
9053
|
+
const clOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
9054
|
+
clOffsetBuffer.writeUInt32LE(clusterOffset, 0);
|
|
9055
|
+
const seeds = [Buffer.from(EXEC_POOL_ACC_SEED), clOffsetBuffer];
|
|
8630
9056
|
return generateArciumPDAFrom(seeds)[0];
|
|
8631
9057
|
}
|
|
8632
9058
|
/**
|
|
@@ -8647,23 +9073,23 @@ function getClockAccAddress() {
|
|
|
8647
9073
|
}
|
|
8648
9074
|
/**
|
|
8649
9075
|
* Derives the cluster account address for a given offset.
|
|
8650
|
-
* @param
|
|
9076
|
+
* @param clusterOffset - The cluster offset as a number.
|
|
8651
9077
|
* @returns The derived cluster account public key.
|
|
8652
9078
|
*/
|
|
8653
|
-
function getClusterAccAddress(
|
|
8654
|
-
const offsetBuffer = Buffer.alloc(
|
|
8655
|
-
offsetBuffer.writeUInt32LE(
|
|
9079
|
+
function getClusterAccAddress(clusterOffset) {
|
|
9080
|
+
const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
9081
|
+
offsetBuffer.writeUInt32LE(clusterOffset, 0);
|
|
8656
9082
|
const seeds = [Buffer.from(CLUSTER_ACC_SEED), offsetBuffer];
|
|
8657
9083
|
return generateArciumPDAFrom(seeds)[0];
|
|
8658
9084
|
}
|
|
8659
9085
|
/**
|
|
8660
9086
|
* Derives the ArxNode account address for a given offset.
|
|
8661
|
-
* @param
|
|
9087
|
+
* @param nodeOffset - The ArxNode offset as a number.
|
|
8662
9088
|
* @returns The derived ArxNode account public key.
|
|
8663
9089
|
*/
|
|
8664
|
-
function getArxNodeAccAddress(
|
|
8665
|
-
const offsetBuffer = Buffer.alloc(
|
|
8666
|
-
offsetBuffer.writeUInt32LE(
|
|
9090
|
+
function getArxNodeAccAddress(nodeOffset) {
|
|
9091
|
+
const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
9092
|
+
offsetBuffer.writeUInt32LE(nodeOffset, 0);
|
|
8667
9093
|
const seeds = [Buffer.from(ARX_NODE_ACC_SEED), offsetBuffer];
|
|
8668
9094
|
return generateArciumPDAFrom(seeds)[0];
|
|
8669
9095
|
}
|
|
@@ -8673,18 +9099,18 @@ function getArxNodeAccAddress(offset) {
|
|
|
8673
9099
|
* @returns The derived MXE account public key.
|
|
8674
9100
|
*/
|
|
8675
9101
|
function getMXEAccAddress(mxeProgramId) {
|
|
8676
|
-
const seeds = [Buffer.from(
|
|
9102
|
+
const seeds = [Buffer.from(MXE_ACCOUNT_SEED), mxeProgramId.toBuffer()];
|
|
8677
9103
|
return generateArciumPDAFrom(seeds)[0];
|
|
8678
9104
|
}
|
|
8679
9105
|
/**
|
|
8680
9106
|
* Derives the computation definition account address for a given MXE program ID and offset.
|
|
8681
9107
|
* @param mxeProgramId - The public key of the MXE program.
|
|
8682
|
-
* @param
|
|
9108
|
+
* @param compDefOffset - The computation definition offset as a number.
|
|
8683
9109
|
* @returns The derived computation definition account public key.
|
|
8684
9110
|
*/
|
|
8685
|
-
function getCompDefAccAddress(mxeProgramId,
|
|
8686
|
-
const offsetBuffer = Buffer.alloc(
|
|
8687
|
-
offsetBuffer.writeUInt32LE(
|
|
9111
|
+
function getCompDefAccAddress(mxeProgramId, compDefOffset) {
|
|
9112
|
+
const offsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
9113
|
+
offsetBuffer.writeUInt32LE(compDefOffset, 0);
|
|
8688
9114
|
const seeds = [Buffer.from(COMP_DEF_ACC_SEED), mxeProgramId.toBuffer(), offsetBuffer];
|
|
8689
9115
|
return generateArciumPDAFrom(seeds)[0];
|
|
8690
9116
|
}
|
|
@@ -8799,25 +9225,18 @@ const EXECPOOL_DISCRIMINATOR_MAP = {
|
|
|
8799
9225
|
[LARGE_EXECPOOL_DISCRIMINATOR.toString()]: LARGE_EXECPOOL_ACC_NAME,
|
|
8800
9226
|
};
|
|
8801
9227
|
/**
|
|
8802
|
-
*
|
|
8803
|
-
* @returns The Arcium program's public key.
|
|
8804
|
-
*/
|
|
8805
|
-
function getArciumProgAddress() {
|
|
8806
|
-
return new anchor.web3.PublicKey(ARCIUM_ADDR);
|
|
8807
|
-
}
|
|
8808
|
-
/**
|
|
8809
|
-
* Fetches and decodes the mempool account data for any mempool account size.
|
|
9228
|
+
* Fetches and decodes the mempool account info for any mempool account size.
|
|
8810
9229
|
* @param provider - The Anchor provider to use for fetching accounts.
|
|
8811
9230
|
* @param mempoolAccPubkey - The public key of the mempool account.
|
|
8812
|
-
* @returns The decoded mempool account
|
|
9231
|
+
* @returns The decoded mempool account info.
|
|
8813
9232
|
* @throws Error if the account cannot be fetched or the discriminator is unknown.
|
|
8814
9233
|
*/
|
|
8815
|
-
async function
|
|
9234
|
+
async function getMempoolAccInfo(provider, mempoolAccPubkey) {
|
|
8816
9235
|
const accData = await provider.connection.getAccountInfo(mempoolAccPubkey);
|
|
8817
9236
|
if (accData === null) {
|
|
8818
9237
|
throw new Error(`Failed to fetch mempool account ${mempoolAccPubkey.toBase58()}`);
|
|
8819
9238
|
}
|
|
8820
|
-
const discriminator = Array.from(accData.data.subarray(0,
|
|
9239
|
+
const discriminator = Array.from(accData.data.subarray(0, DISCRIMINATOR_SIZE)).toString();
|
|
8821
9240
|
const accName = MEMPOOL_DISCRIMINATOR_MAP[discriminator];
|
|
8822
9241
|
if (accName === undefined) {
|
|
8823
9242
|
throw new Error(`Unknown mempool account discriminator: ${discriminator}`);
|
|
@@ -8826,18 +9245,18 @@ async function getMempoolAccData(provider, mempoolAccPubkey) {
|
|
|
8826
9245
|
return program.coder.accounts.decode(accName, accData.data);
|
|
8827
9246
|
}
|
|
8828
9247
|
/**
|
|
8829
|
-
* Fetches and decodes the executing pool account
|
|
9248
|
+
* Fetches and decodes the executing pool account info for any pool size.
|
|
8830
9249
|
* @param provider - The Anchor provider to use for fetching accounts.
|
|
8831
9250
|
* @param executingPoolAccPubkey - The public key of the executing pool account.
|
|
8832
|
-
* @returns The decoded executing pool account
|
|
9251
|
+
* @returns The decoded executing pool account info.
|
|
8833
9252
|
* @throws Error if the account cannot be fetched or the discriminator is unknown.
|
|
8834
9253
|
*/
|
|
8835
|
-
async function
|
|
9254
|
+
async function getExecutingPoolAccInfo(provider, executingPoolAccPubkey) {
|
|
8836
9255
|
const accData = await provider.connection.getAccountInfo(executingPoolAccPubkey);
|
|
8837
9256
|
if (accData === null) {
|
|
8838
9257
|
throw new Error(`Failed to fetch executing pool account ${executingPoolAccPubkey.toBase58()}`);
|
|
8839
9258
|
}
|
|
8840
|
-
const discriminator = Array.from(accData.data.subarray(0,
|
|
9259
|
+
const discriminator = Array.from(accData.data.subarray(0, DISCRIMINATOR_SIZE)).toString();
|
|
8841
9260
|
const accName = EXECPOOL_DISCRIMINATOR_MAP[discriminator];
|
|
8842
9261
|
if (accName === undefined) {
|
|
8843
9262
|
throw new Error(`Unknown executing pool account discriminator: ${discriminator}`);
|
|
@@ -8846,70 +9265,129 @@ async function getExecutingPoolAccData(provider, executingPoolAccPubkey) {
|
|
|
8846
9265
|
return program.coder.accounts.decode(accName, accData.data);
|
|
8847
9266
|
}
|
|
8848
9267
|
/**
|
|
8849
|
-
*
|
|
8850
|
-
*
|
|
8851
|
-
* @param
|
|
8852
|
-
* @
|
|
9268
|
+
* Returns all computation references in the mempool for a given account.
|
|
9269
|
+
* Only non-stake computations are included.
|
|
9270
|
+
* @param arciumProgram - The Anchor program instance.
|
|
9271
|
+
* @param address - The public key of the mempool account.
|
|
9272
|
+
* @returns Array of ComputationReference objects.
|
|
8853
9273
|
*/
|
|
8854
|
-
async function
|
|
8855
|
-
const
|
|
8856
|
-
const
|
|
8857
|
-
const
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
9274
|
+
async function getComputationsInMempool(arciumProgram, address) {
|
|
9275
|
+
const mempool = await getMempoolAccInfo(arciumProgram.provider, address);
|
|
9276
|
+
const startIndex = mempool.inner.computations.startIndex;
|
|
9277
|
+
const length = mempool.inner.computations.length;
|
|
9278
|
+
const elems = mempool.inner.computations.elems;
|
|
9279
|
+
function isValid(validBits, idx) {
|
|
9280
|
+
const byte = idx >>> 3;
|
|
9281
|
+
const bit = idx & 7;
|
|
9282
|
+
if (byte >= validBits.length) {
|
|
9283
|
+
// This should never happen, so we'll want to know about it
|
|
9284
|
+
throw new Error(`isValid: byte ${byte} >= validBits.length ${validBits.length}`);
|
|
9285
|
+
}
|
|
9286
|
+
return (validBits[byte] & (1 << bit)) !== 0;
|
|
8861
9287
|
}
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
9288
|
+
// Handle circular buffer wraparound
|
|
9289
|
+
const refs = [];
|
|
9290
|
+
for (let i = 0; i < length; i++) {
|
|
9291
|
+
const idx = (startIndex + i) % elems.length;
|
|
9292
|
+
// Only save non-stake computations
|
|
9293
|
+
if (isValid(mempool.inner.computations.validBits, idx)) {
|
|
9294
|
+
refs.push(...elems[idx].entries);
|
|
8866
9295
|
}
|
|
8867
9296
|
}
|
|
8868
|
-
return
|
|
9297
|
+
return refs
|
|
9298
|
+
.flat()
|
|
9299
|
+
.filter((ref) => !isNullRef(ref));
|
|
8869
9300
|
}
|
|
8870
9301
|
/**
|
|
8871
|
-
*
|
|
9302
|
+
* Calculates priority fee statistics for computations in a mempool.
|
|
9303
|
+
* @param arciumProgram - The Anchor program instance.
|
|
9304
|
+
* @param mempoolAddress - The public key of the mempool account.
|
|
9305
|
+
* @returns Priority fee statistics (mean, median, min, max, count).
|
|
9306
|
+
*/
|
|
9307
|
+
async function getMempoolPriorityFeeStats(arciumProgram, mempoolAddress) {
|
|
9308
|
+
const refs = await getComputationsInMempool(arciumProgram, mempoolAddress);
|
|
9309
|
+
if (refs.length === 0) {
|
|
9310
|
+
const zero = new anchor.BN(0);
|
|
9311
|
+
return { mean: zero, median: zero, min: zero, max: zero, count: 0 };
|
|
9312
|
+
}
|
|
9313
|
+
const fees = refs.map(ref => ref.priorityFee).sort((a, b) => a.cmp(b));
|
|
9314
|
+
const sum = fees.reduce((acc, fee) => acc.add(fee), new anchor.BN(0));
|
|
9315
|
+
const mean = sum.div(new anchor.BN(fees.length));
|
|
9316
|
+
const mid = Math.floor(fees.length / 2);
|
|
9317
|
+
const median = fees.length % 2 === 0
|
|
9318
|
+
? fees[mid - 1].add(fees[mid]).div(new anchor.BN(2))
|
|
9319
|
+
: fees[mid];
|
|
9320
|
+
return {
|
|
9321
|
+
mean,
|
|
9322
|
+
median,
|
|
9323
|
+
min: fees[0],
|
|
9324
|
+
max: fees[fees.length - 1],
|
|
9325
|
+
count: fees.length,
|
|
9326
|
+
};
|
|
9327
|
+
}
|
|
9328
|
+
/**
|
|
9329
|
+
* Helper function to fetch a specific utility key from the MXE account.
|
|
8872
9330
|
* @param provider - The Anchor provider to use for fetching accounts.
|
|
8873
|
-
* @param
|
|
8874
|
-
* @
|
|
9331
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
9332
|
+
* @param field - The field name to extract ('x25519Pubkey' or 'ed25519VerifyingKey').
|
|
9333
|
+
* @returns The utility key as a Uint8Array, or null if not set.
|
|
8875
9334
|
*/
|
|
8876
|
-
async function
|
|
9335
|
+
async function getMXEUtilityKey(provider, mxeProgramId, field) {
|
|
8877
9336
|
const program = getArciumProgram(provider);
|
|
8878
|
-
const mxeAccAddress = getMXEAccAddress(
|
|
9337
|
+
const mxeAccAddress = getMXEAccAddress(mxeProgramId);
|
|
8879
9338
|
const mxeAccInfo = await program.account.mxeAccount.fetch(mxeAccAddress);
|
|
8880
9339
|
if ('set' in mxeAccInfo.utilityPubkeys) {
|
|
8881
9340
|
const setData = mxeAccInfo.utilityPubkeys.set;
|
|
8882
|
-
return new Uint8Array(setData[0]
|
|
9341
|
+
return new Uint8Array(setData[0][field]);
|
|
8883
9342
|
}
|
|
8884
9343
|
else if ('unset' in mxeAccInfo.utilityPubkeys) {
|
|
8885
9344
|
const unsetData = mxeAccInfo.utilityPubkeys.unset;
|
|
8886
9345
|
if (unsetData[1].every(Boolean)) {
|
|
8887
|
-
return new Uint8Array(unsetData[0]
|
|
9346
|
+
return new Uint8Array(unsetData[0][field]);
|
|
8888
9347
|
}
|
|
8889
9348
|
}
|
|
8890
9349
|
return null;
|
|
8891
9350
|
}
|
|
9351
|
+
/**
|
|
9352
|
+
* Fetches and extracts the MXE x25519 public key from the MXE account.
|
|
9353
|
+
* @param provider - The Anchor provider to use for fetching accounts.
|
|
9354
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
9355
|
+
* @returns The MXE's x25519 public key as a Uint8Array, or null if not set.
|
|
9356
|
+
*/
|
|
9357
|
+
async function getMXEPublicKey(provider, mxeProgramId) {
|
|
9358
|
+
return getMXEUtilityKey(provider, mxeProgramId, 'x25519Pubkey');
|
|
9359
|
+
}
|
|
9360
|
+
/**
|
|
9361
|
+
* Fetches and extracts the MXE arcis ed25519 verifying key from the MXE account.
|
|
9362
|
+
* @param provider - The Anchor provider to use for fetching accounts.
|
|
9363
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
9364
|
+
* @returns The MXE's arcis ed25519 verifying key as a Uint8Array, or null if not set.
|
|
9365
|
+
*/
|
|
9366
|
+
async function getMXEArcisEd25519VerifyingKey(provider, mxeProgramId) {
|
|
9367
|
+
return getMXEUtilityKey(provider, mxeProgramId, 'ed25519VerifyingKey');
|
|
9368
|
+
}
|
|
8892
9369
|
/**
|
|
8893
9370
|
* Uploads a circuit to the blockchain, splitting it into multiple accounts if necessary.
|
|
8894
9371
|
* @param provider - The Anchor provider to use for transactions.
|
|
8895
9372
|
* @param circuitName - The name of the circuit.
|
|
8896
|
-
* @param
|
|
9373
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
8897
9374
|
* @param rawCircuit - The raw circuit data as a Uint8Array.
|
|
8898
9375
|
* @param logging - Whether to log progress (default: true).
|
|
8899
9376
|
* @param chunkSize - The number of upload transactions to send in parallel (default: 500).
|
|
8900
9377
|
* @returns An array of transaction signatures for all upload and finalize transactions.
|
|
8901
9378
|
*/
|
|
8902
|
-
async function uploadCircuit(provider, circuitName,
|
|
9379
|
+
async function uploadCircuit(provider, circuitName, mxeProgramId, rawCircuit, logging = true, chunkSize = 500) {
|
|
9380
|
+
// 9 = 8-byte discriminator + 1-byte bump for ComputationDefinitionRaw account
|
|
8903
9381
|
const numAccs = Math.ceil(rawCircuit.length / (MAX_ACCOUNT_SIZE - 9));
|
|
8904
|
-
const compDefAccInfo = getCompDefAccInfo(circuitName,
|
|
9382
|
+
const compDefAccInfo = getCompDefAccInfo(circuitName, mxeProgramId);
|
|
8905
9383
|
const program = getArciumProgram(provider);
|
|
8906
9384
|
const sigs = [];
|
|
8907
9385
|
const uploadPromises = [];
|
|
8908
9386
|
for (let i = 0; i < numAccs; i++) {
|
|
8909
|
-
uploadPromises.push(uploadToCircuitAcc(provider, program, rawCircuit.subarray(i * (MAX_ACCOUNT_SIZE - 9), (i + 1) * (MAX_ACCOUNT_SIZE - 9)), i, compDefAccInfo,
|
|
9387
|
+
uploadPromises.push(uploadToCircuitAcc(provider, program, rawCircuit.subarray(i * (MAX_ACCOUNT_SIZE - 9), (i + 1) * (MAX_ACCOUNT_SIZE - 9)), i, compDefAccInfo, mxeProgramId, logging, chunkSize));
|
|
8910
9388
|
}
|
|
8911
9389
|
sigs.push(...(await Promise.all(uploadPromises)).flat());
|
|
8912
|
-
const finalizeCompDefTx = await buildFinalizeCompDefTx(provider, compDefAccInfo.offset,
|
|
9390
|
+
const finalizeCompDefTx = await buildFinalizeCompDefTx(provider, compDefAccInfo.offset, mxeProgramId);
|
|
8913
9391
|
sigs.push(await signAndSendWithBlockhash(provider, finalizeCompDefTx, await provider.connection.getLatestBlockhash()));
|
|
8914
9392
|
return sigs;
|
|
8915
9393
|
}
|
|
@@ -8917,24 +9395,24 @@ async function uploadCircuit(provider, circuitName, mxeProgramID, rawCircuit, lo
|
|
|
8917
9395
|
* Builds a transaction to finalize a computation definition.
|
|
8918
9396
|
* @param provider - The Anchor provider to use for transactions.
|
|
8919
9397
|
* @param compDefOffset - The offset of the computation definition.
|
|
8920
|
-
* @param
|
|
9398
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
8921
9399
|
* @returns The transaction to finalize the computation definition.
|
|
8922
9400
|
*/
|
|
8923
|
-
async function buildFinalizeCompDefTx(provider, compDefOffset,
|
|
9401
|
+
async function buildFinalizeCompDefTx(provider, compDefOffset, mxeProgramId) {
|
|
8924
9402
|
const program = getArciumProgram(provider);
|
|
8925
|
-
const compDefOffsetBuffer = Buffer.alloc(
|
|
9403
|
+
const compDefOffsetBuffer = Buffer.alloc(OFFSET_BUFFER_SIZE);
|
|
8926
9404
|
compDefOffsetBuffer.writeUInt32LE(compDefOffset, 0);
|
|
8927
9405
|
return program.methods
|
|
8928
|
-
.finalizeComputationDefinition(compDefOffset,
|
|
9406
|
+
.finalizeComputationDefinition(compDefOffset, mxeProgramId)
|
|
8929
9407
|
.accounts({
|
|
8930
9408
|
signer: provider.publicKey,
|
|
8931
9409
|
})
|
|
8932
9410
|
.transaction();
|
|
8933
9411
|
}
|
|
8934
|
-
async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitIndex, compDefAccInfo,
|
|
9412
|
+
async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitIndex, compDefAccInfo, mxeProgramId, shouldLog = true, chunkSize = 500) {
|
|
8935
9413
|
const sigs = [];
|
|
8936
9414
|
const initTx = await program.methods
|
|
8937
|
-
.initRawCircuitAcc(compDefAccInfo.offset,
|
|
9415
|
+
.initRawCircuitAcc(compDefAccInfo.offset, mxeProgramId, rawCircuitIndex)
|
|
8938
9416
|
.accounts({
|
|
8939
9417
|
signer: provider.publicKey,
|
|
8940
9418
|
})
|
|
@@ -8947,7 +9425,7 @@ async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitI
|
|
|
8947
9425
|
for (let i = 0; i < nonAsyncTxCount; i++) {
|
|
8948
9426
|
optionalLog(shouldLog, `Sending resize tx ${i} of ${nonAsyncTxCount}`);
|
|
8949
9427
|
// eslint-disable-next-line no-await-in-loop
|
|
8950
|
-
const tx = await buildResizeTx(program, provider.publicKey, compDefAccInfo,
|
|
9428
|
+
const tx = await buildResizeTx(program, provider.publicKey, compDefAccInfo, mxeProgramId, rawCircuitIndex, MAX_REALLOC_PER_IX
|
|
8951
9429
|
+ i * (MAX_REALLOC_PER_IX * MAX_EMBIGGEN_IX_PER_TX), rawCircuitPart.length);
|
|
8952
9430
|
// eslint-disable-next-line no-await-in-loop
|
|
8953
9431
|
const blockInfo = await provider.connection.getLatestBlockhash();
|
|
@@ -8970,7 +9448,7 @@ async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitI
|
|
|
8970
9448
|
for (let j = 0; j < currentChunkSize; j++) {
|
|
8971
9449
|
const offset = MAX_UPLOAD_PER_TX_BYTES * (i + j);
|
|
8972
9450
|
// eslint-disable-next-line no-await-in-loop
|
|
8973
|
-
const tx = await buildUploadCircuitTx(program, provider.publicKey, compDefAccInfo,
|
|
9451
|
+
const tx = await buildUploadCircuitTx(program, provider.publicKey, compDefAccInfo, mxeProgramId, Buffer.copyBytesFrom(rawCircuitPart, offset, MAX_UPLOAD_PER_TX_BYTES), offset, rawCircuitIndex);
|
|
8974
9452
|
chunkPromises.push(signAndSendWithBlockhash(provider, tx, blockInfo));
|
|
8975
9453
|
}
|
|
8976
9454
|
// Wait for the current chunk to complete before proceeding
|
|
@@ -8981,9 +9459,9 @@ async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitI
|
|
|
8981
9459
|
}
|
|
8982
9460
|
return sigs.concat(remainingTxs);
|
|
8983
9461
|
}
|
|
8984
|
-
async function buildResizeTx(program, signerPubkey, compDefAccInfo,
|
|
9462
|
+
async function buildResizeTx(program, signerPubkey, compDefAccInfo, mxeProgramId, rawCircuitIndex, currentSize, requiredSize) {
|
|
8985
9463
|
const ix = await program.methods
|
|
8986
|
-
.embiggenRawCircuitAcc(compDefAccInfo.offset,
|
|
9464
|
+
.embiggenRawCircuitAcc(compDefAccInfo.offset, mxeProgramId, rawCircuitIndex)
|
|
8987
9465
|
.accounts({
|
|
8988
9466
|
signer: signerPubkey,
|
|
8989
9467
|
})
|
|
@@ -8997,9 +9475,9 @@ async function buildResizeTx(program, signerPubkey, compDefAccInfo, mxeProgramID
|
|
|
8997
9475
|
}
|
|
8998
9476
|
return tx;
|
|
8999
9477
|
}
|
|
9000
|
-
async function buildUploadCircuitTx(program, signerPubkey, compDefAccInfo,
|
|
9478
|
+
async function buildUploadCircuitTx(program, signerPubkey, compDefAccInfo, mxeProgramId, bytes, circuitOffset, rawCircuitIndex) {
|
|
9001
9479
|
if (bytes.length > MAX_UPLOAD_PER_TX_BYTES) {
|
|
9002
|
-
throw new Error(
|
|
9480
|
+
throw new Error(`Upload circuit bytes must be ${MAX_UPLOAD_PER_TX_BYTES} bytes or less per tx`);
|
|
9003
9481
|
}
|
|
9004
9482
|
let bytesInner = bytes;
|
|
9005
9483
|
if (bytesInner.length < MAX_UPLOAD_PER_TX_BYTES) {
|
|
@@ -9008,7 +9486,7 @@ async function buildUploadCircuitTx(program, signerPubkey, compDefAccInfo, mxePr
|
|
|
9008
9486
|
bytesInner = paddedBytes;
|
|
9009
9487
|
}
|
|
9010
9488
|
return program.methods
|
|
9011
|
-
.uploadCircuit(compDefAccInfo.offset,
|
|
9489
|
+
.uploadCircuit(compDefAccInfo.offset, mxeProgramId, rawCircuitIndex, Array.from(bytesInner), circuitOffset)
|
|
9012
9490
|
.accounts({
|
|
9013
9491
|
signer: signerPubkey,
|
|
9014
9492
|
})
|
|
@@ -9036,7 +9514,7 @@ function getArciumAccountBaseSeed(accName) {
|
|
|
9036
9514
|
*/
|
|
9037
9515
|
function getCompDefAccOffset(circuitName) {
|
|
9038
9516
|
const hash = new Uint8Array(sha256([Buffer.from(circuitName, 'utf-8')]));
|
|
9039
|
-
return hash.slice(0,
|
|
9517
|
+
return hash.slice(0, COMP_DEF_OFFSET_SIZE);
|
|
9040
9518
|
}
|
|
9041
9519
|
/**
|
|
9042
9520
|
* Returns an Anchor program instance for the Arcium program.
|
|
@@ -9046,45 +9524,26 @@ function getCompDefAccOffset(circuitName) {
|
|
|
9046
9524
|
function getArciumProgram(provider) {
|
|
9047
9525
|
return new Program(ARCIUM_IDL, provider);
|
|
9048
9526
|
}
|
|
9049
|
-
/**
|
|
9050
|
-
* Returns a read-only Anchor program instance for the Arcium program.
|
|
9051
|
-
* @param provider - The Anchor provider to use.
|
|
9052
|
-
* @returns The Anchor program instance for Arcium.
|
|
9053
|
-
*/
|
|
9054
|
-
function getArciumProgramReadonly(provider) {
|
|
9055
|
-
return new Program(ARCIUM_IDL, provider);
|
|
9056
|
-
}
|
|
9057
|
-
/**
|
|
9058
|
-
* Returns the PDA (program-derived address) for an ArxNode account given the program ID and node offset.
|
|
9059
|
-
* @param arciumProgramID - The public key of the Arcium program.
|
|
9060
|
-
* @param nodeOffset - The offset of the node.
|
|
9061
|
-
* @returns The PDA for the ArxNode account.
|
|
9062
|
-
*/
|
|
9063
|
-
function getArxAccPDA(arciumProgramID, nodeOffset) {
|
|
9064
|
-
const nodeOffsetBuffer = Buffer.alloc(4);
|
|
9065
|
-
nodeOffsetBuffer.writeUInt32LE(nodeOffset, 0);
|
|
9066
|
-
return anchor.web3.PublicKey.findProgramAddressSync([Buffer.from('ArxNode', 'utf-8'), nodeOffsetBuffer], arciumProgramID)[0];
|
|
9067
|
-
}
|
|
9068
9527
|
/**
|
|
9069
9528
|
* Returns the public key and offset for a computation definition account, given the circuit name and MXE program ID.
|
|
9070
9529
|
* @param circuitName - The name of the circuit.
|
|
9071
|
-
* @param
|
|
9530
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
9072
9531
|
* @returns An object containing the public key and offset for the computation definition account.
|
|
9073
9532
|
*/
|
|
9074
|
-
function getCompDefAccInfo(circuitName,
|
|
9533
|
+
function getCompDefAccInfo(circuitName, mxeProgramId) {
|
|
9075
9534
|
const offset = getCompDefAccOffset(circuitName);
|
|
9076
|
-
const pda = getCompDefAccPDA(
|
|
9535
|
+
const pda = getCompDefAccPDA(getArciumProgramId(), mxeProgramId, offset);
|
|
9077
9536
|
return { pubkey: pda, offset: Buffer.from(offset).readUInt32LE(0) };
|
|
9078
9537
|
}
|
|
9079
9538
|
/**
|
|
9080
9539
|
* Returns the PDA for a computation definition account, given the program ID, MXE program ID, and offset.
|
|
9081
|
-
* @param
|
|
9082
|
-
* @param
|
|
9540
|
+
* @param arciumProgramId - The public key of the Arcium program.
|
|
9541
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
9083
9542
|
* @param offset - The offset as a Uint8Array.
|
|
9084
9543
|
* @returns The PDA for the computation definition account.
|
|
9085
9544
|
*/
|
|
9086
|
-
function getCompDefAccPDA(
|
|
9087
|
-
return anchor.web3.PublicKey.findProgramAddressSync([Buffer.from(
|
|
9545
|
+
function getCompDefAccPDA(arciumProgramId, mxeProgramId, offset) {
|
|
9546
|
+
return anchor.web3.PublicKey.findProgramAddressSync([Buffer.from(COMP_DEF_ACC_SEED, 'utf-8'), mxeProgramId.toBuffer(), offset], arciumProgramId)[0];
|
|
9088
9547
|
}
|
|
9089
9548
|
|
|
9090
9549
|
/**
|
|
@@ -9097,13 +9556,13 @@ function getArciumEnv() {
|
|
|
9097
9556
|
if (isBrowser()) {
|
|
9098
9557
|
throw new Error('Arcium local env is not available in browser.');
|
|
9099
9558
|
}
|
|
9100
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
9101
|
-
const process = require('process');
|
|
9102
9559
|
try {
|
|
9103
|
-
|
|
9104
|
-
|
|
9560
|
+
const arciumClusterOffset = Number(process.env.ARCIUM_CLUSTER_OFFSET);
|
|
9561
|
+
if (isNaN(arciumClusterOffset)) {
|
|
9562
|
+
throw new Error('ARCIUM_CLUSTER_OFFSET environment variable is not set or is invalid (NaN).');
|
|
9563
|
+
}
|
|
9105
9564
|
return {
|
|
9106
|
-
|
|
9565
|
+
arciumClusterOffset,
|
|
9107
9566
|
};
|
|
9108
9567
|
}
|
|
9109
9568
|
catch (e) {
|
|
@@ -9145,4 +9604,4 @@ async function awaitEvent(eventListener, eventName, eventCheck, commitment = 'co
|
|
|
9145
9604
|
return { event: foundEvent[0], sig: foundEvent[1] };
|
|
9146
9605
|
}
|
|
9147
9606
|
|
|
9148
|
-
export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, compressUint128, decompressUint128, deserializeLE, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv,
|
|
9607
|
+
export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, compressUint128, decompressUint128, deserializeLE, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, isNullRef, positiveModulo, randMatrix, serializeLE, sha256, toVec, uploadCircuit };
|