@arcium-hq/client 0.1.46 → 0.1.47
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 -8
- package/build/index.cjs +695 -83
- package/build/index.d.ts +432 -23
- package/build/index.mjs +685 -77
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { IField } from '@noble/curves/abstract/modular';
|
|
2
|
+
import { CurveFn } from '@noble/curves/abstract/edwards';
|
|
2
3
|
import * as anchor from '@coral-xyz/anchor';
|
|
3
4
|
import { AnchorProvider, Program, BN } from '@coral-xyz/anchor';
|
|
4
5
|
import { PublicKey, Finality } from '@solana/web3.js';
|
|
5
6
|
export { x25519 } from '@noble/curves/ed25519';
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Scalar field prime modulus for Curve25519: 2^252 + 27742317777372353535851937790883648493
|
|
10
|
+
*/
|
|
7
11
|
declare const CURVE25519_SCALAR_FIELD_MODULUS: bigint;
|
|
12
|
+
/**
|
|
13
|
+
* Encrypts a value into the format expected by the DA layer, using secret sharing and encryption for each node's public key.
|
|
14
|
+
* @param val - The value to secret-share and encrypt.
|
|
15
|
+
* @param nodeX25519Keys - The array of node X25519 public keys.
|
|
16
|
+
* @returns An array of SecretShare objects, one for each node.
|
|
17
|
+
*/
|
|
8
18
|
declare function secretShareValue(val: bigint, nodeX25519Keys: Uint8Array[]): SecretShare[];
|
|
19
|
+
/**
|
|
20
|
+
* Structure representing a secret share, including ciphertext, nonce, and ephemeral public key.
|
|
21
|
+
*/
|
|
9
22
|
type SecretShare = {
|
|
10
23
|
ciphertext: Uint8Array;
|
|
11
24
|
nonce: Uint8Array;
|
|
@@ -13,29 +26,59 @@ type SecretShare = {
|
|
|
13
26
|
};
|
|
14
27
|
/**
|
|
15
28
|
* Generates secret shares for a given value in the Curve25519 field.
|
|
16
|
-
* @param secret The secret value to be shared (as a BigInt)
|
|
17
|
-
* @param n The number of shares to generate
|
|
18
|
-
* @param mod The modulo of the field over which to generate shares
|
|
19
|
-
* @returns An array of n secret shares
|
|
29
|
+
* @param secret - The secret value to be shared (as a BigInt).
|
|
30
|
+
* @param n - The number of shares to generate.
|
|
31
|
+
* @param mod - The modulo of the field over which to generate shares (default: CURVE25519_SCALAR_FIELD_MODULUS).
|
|
32
|
+
* @returns An array of n secret shares as bigints.
|
|
20
33
|
*/
|
|
21
34
|
declare function genRawShares(secret: bigint, n: number, mod?: bigint): bigint[];
|
|
22
35
|
/**
|
|
23
|
-
* Encrypts a field element for the DA layer.
|
|
24
|
-
* @param publicKey The recipient's x25519 public key
|
|
25
|
-
* @param valueToEncrypt The bigint value to encrypt
|
|
26
|
-
* @param modulo Bound on the value
|
|
27
|
-
* @returns An object containing the ciphertext and ephemeral public key.
|
|
36
|
+
* Encrypts a field element for the DA layer using the recipient's x25519 public key.
|
|
37
|
+
* @param publicKey - The recipient's x25519 public key.
|
|
38
|
+
* @param valueToEncrypt - The bigint value to encrypt.
|
|
39
|
+
* @param modulo - Bound on the value (default: CURVE25519_SCALAR_FIELD_MODULUS).
|
|
40
|
+
* @returns An object containing the ciphertext, nonce, and ephemeral public key.
|
|
28
41
|
*/
|
|
29
42
|
declare function encryptForDA(publicKey: Uint8Array, valueToEncrypt: bigint, modulo?: bigint): SecretShare;
|
|
43
|
+
/**
|
|
44
|
+
* Computes a shared encryption key using ECDH (x25519) and hashes it with blake2s.
|
|
45
|
+
* @param privKey - The private key as a Uint8Array.
|
|
46
|
+
* @param pubKey - The public key as a Uint8Array.
|
|
47
|
+
* @returns The derived encryption key as a Uint8Array.
|
|
48
|
+
*/
|
|
30
49
|
declare function getEncryptionKey(privKey: Uint8Array, pubKey: Uint8Array): Uint8Array;
|
|
31
50
|
/**
|
|
32
|
-
* Generates a random
|
|
51
|
+
* Generates a random value within the field bound by q.
|
|
52
|
+
* @param q - The upper bound (exclusive) for the random value.
|
|
33
53
|
* @returns A random bigint value between 0 and q-1.
|
|
34
|
-
*/
|
|
54
|
+
*/
|
|
35
55
|
declare function generateRandomFieldElem(q: bigint): bigint;
|
|
56
|
+
/**
|
|
57
|
+
* Computes the positive modulo of a over m.
|
|
58
|
+
* @param a - The dividend.
|
|
59
|
+
* @param m - The modulus.
|
|
60
|
+
* @returns The positive remainder of a mod m.
|
|
61
|
+
*/
|
|
36
62
|
declare function positiveModulo(a: bigint, m: bigint): bigint;
|
|
63
|
+
/**
|
|
64
|
+
* Serializes a bigint to a little-endian Uint8Array of the specified length.
|
|
65
|
+
* @param val - The bigint value to serialize.
|
|
66
|
+
* @param lengthInBytes - The desired length of the output array.
|
|
67
|
+
* @returns The serialized value as a Uint8Array.
|
|
68
|
+
* @throws Error if the value is too large for the specified length.
|
|
69
|
+
*/
|
|
37
70
|
declare function serializeLE(val: bigint, lengthInBytes: number): Uint8Array;
|
|
71
|
+
/**
|
|
72
|
+
* Deserializes a little-endian Uint8Array to a bigint.
|
|
73
|
+
* @param bytes - The Uint8Array to deserialize.
|
|
74
|
+
* @returns The deserialized bigint value.
|
|
75
|
+
*/
|
|
38
76
|
declare function deserializeLE(bytes: Uint8Array): bigint;
|
|
77
|
+
/**
|
|
78
|
+
* Computes the SHA-256 hash of an array of Uint8Arrays.
|
|
79
|
+
* @param byteArrays - The arrays to hash.
|
|
80
|
+
* @returns The SHA-256 hash as a Buffer.
|
|
81
|
+
*/
|
|
39
82
|
declare function sha256(byteArrays: Uint8Array[]): Buffer;
|
|
40
83
|
|
|
41
84
|
/**
|
|
@@ -80,8 +123,18 @@ type HashFunction = {
|
|
|
80
123
|
m: number;
|
|
81
124
|
capacity: number;
|
|
82
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Field type for Curve25519 base field.
|
|
128
|
+
*/
|
|
83
129
|
type FpField = IField<bigint>;
|
|
130
|
+
/**
|
|
131
|
+
* Curve25519 base field as an IField instance.
|
|
132
|
+
*/
|
|
84
133
|
declare const CURVE25519_BASE_FIELD: FpField;
|
|
134
|
+
/**
|
|
135
|
+
* Description and parameters for the Rescue cipher or hash function, including round constants, MDS matrix, and key schedule.
|
|
136
|
+
* See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
|
|
137
|
+
*/
|
|
85
138
|
declare class RescueDesc {
|
|
86
139
|
mode: RescueMode;
|
|
87
140
|
field: FpField;
|
|
@@ -92,29 +145,195 @@ declare class RescueDesc {
|
|
|
92
145
|
mdsMat: Matrix;
|
|
93
146
|
mdsMatInverse: Matrix;
|
|
94
147
|
roundKeys: Matrix[];
|
|
148
|
+
/**
|
|
149
|
+
* Constructs a RescueDesc for a given field and mode (cipher or hash).
|
|
150
|
+
* Initializes round constants, MDS matrix, and key schedule.
|
|
151
|
+
* @param field - The field to use (e.g., CURVE25519_BASE_FIELD).
|
|
152
|
+
* @param mode - The mode: block cipher or hash function.
|
|
153
|
+
*/
|
|
95
154
|
constructor(field: FpField, mode: RescueMode);
|
|
155
|
+
/**
|
|
156
|
+
* Samples round constants for the Rescue permutation, using SHAKE256.
|
|
157
|
+
* @param nRounds - The number of rounds.
|
|
158
|
+
* @returns An array of round constant matrices.
|
|
159
|
+
*/
|
|
96
160
|
sampleConstants(nRounds: number): Matrix[];
|
|
161
|
+
/**
|
|
162
|
+
* Applies the Rescue permutation to a state matrix.
|
|
163
|
+
* @param state - The input state matrix.
|
|
164
|
+
* @returns The permuted state matrix.
|
|
165
|
+
*/
|
|
97
166
|
permute(state: Matrix): Matrix;
|
|
167
|
+
/**
|
|
168
|
+
* Applies the inverse Rescue permutation to a state matrix.
|
|
169
|
+
* @param state - The input state matrix.
|
|
170
|
+
* @returns The inverse-permuted state matrix.
|
|
171
|
+
*/
|
|
98
172
|
permuteInverse(state: Matrix): Matrix;
|
|
99
173
|
}
|
|
100
174
|
declare function toVec(data: bigint[]): bigint[][];
|
|
101
175
|
|
|
176
|
+
/**
|
|
177
|
+
* The Rescue cipher in Counter (CTR) mode, with a fixed block size m = 5.
|
|
178
|
+
* See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
|
|
179
|
+
*/
|
|
102
180
|
declare class RescueCipher {
|
|
103
181
|
desc: RescueDesc;
|
|
182
|
+
/**
|
|
183
|
+
* Constructs a RescueCipher instance using a shared secret.
|
|
184
|
+
* The key is derived using HKDF-RescuePrime and used to initialize the RescueDesc.
|
|
185
|
+
* @param sharedSecret - The shared secret to derive the cipher key from.
|
|
186
|
+
*/
|
|
104
187
|
constructor(sharedSecret: Uint8Array);
|
|
188
|
+
/**
|
|
189
|
+
* Encrypts the plaintext vector in Counter (CTR) mode (raw, returns bigints).
|
|
190
|
+
* @param plaintext - The array of plaintext bigints to encrypt.
|
|
191
|
+
* @param nonce - A 16-byte nonce for CTR mode.
|
|
192
|
+
* @returns The ciphertext as an array of bigints.
|
|
193
|
+
* @throws Error if the nonce is not 16 bytes long.
|
|
194
|
+
*/
|
|
105
195
|
encrypt_raw(plaintext: bigint[], nonce: Uint8Array): bigint[];
|
|
196
|
+
/**
|
|
197
|
+
* Encrypts the plaintext vector in Counter (CTR) mode and serializes each block.
|
|
198
|
+
* @param plaintext - The array of plaintext bigints to encrypt.
|
|
199
|
+
* @param nonce - A 16-byte nonce for CTR mode.
|
|
200
|
+
* @returns The ciphertext as an array of arrays of numbers (each 32 bytes).
|
|
201
|
+
*/
|
|
106
202
|
encrypt(plaintext: bigint[], nonce: Uint8Array): number[][];
|
|
203
|
+
/**
|
|
204
|
+
* Decrypts the ciphertext vector in Counter (CTR) mode (raw, expects bigints).
|
|
205
|
+
* @param ciphertext - The array of ciphertext bigints to decrypt.
|
|
206
|
+
* @param nonce - A 16-byte nonce for CTR mode.
|
|
207
|
+
* @returns The decrypted plaintext as an array of bigints.
|
|
208
|
+
* @throws Error if the nonce is not 16 bytes long.
|
|
209
|
+
*/
|
|
107
210
|
decrypt_raw(ciphertext: bigint[], nonce: Uint8Array): bigint[];
|
|
211
|
+
/**
|
|
212
|
+
* Deserializes and decrypts the ciphertext vector in Counter (CTR) mode.
|
|
213
|
+
* @param ciphertext - The array of arrays of numbers (each 32 bytes) to decrypt.
|
|
214
|
+
* @param nonce - A 16-byte nonce for CTR mode.
|
|
215
|
+
* @returns The decrypted plaintext as an array of bigints.
|
|
216
|
+
*/
|
|
108
217
|
decrypt(ciphertext: number[][], nonce: Uint8Array): bigint[];
|
|
109
218
|
}
|
|
110
219
|
|
|
220
|
+
/**
|
|
221
|
+
* The Rescue-Prime hash function, as described in https://eprint.iacr.org/2020/1143.pdf.
|
|
222
|
+
* Used with fixed m = 6 and capacity = 1 (rate = 5). According to Section 2.2, this offers log2(CURVE25519_BASE_FIELD.ORDER) / 2 bits of security against collision, preimage, and second-preimage attacks.
|
|
223
|
+
* See the referenced paper for further details.
|
|
224
|
+
*/
|
|
111
225
|
declare class RescuePrimeHash {
|
|
112
226
|
desc: RescueDesc;
|
|
113
227
|
rate: number;
|
|
228
|
+
/**
|
|
229
|
+
* Constructs a RescuePrimeHash instance with m = 6 and capacity = 1.
|
|
230
|
+
*/
|
|
114
231
|
constructor();
|
|
232
|
+
/**
|
|
233
|
+
* Computes the Rescue-Prime hash of a message, with padding as described in Algorithm 2 of the paper.
|
|
234
|
+
* @param message - The input message as an array of bigints.
|
|
235
|
+
* @returns The hash output as an array of bigints (length = rate).
|
|
236
|
+
*/
|
|
115
237
|
digest(message: bigint[]): bigint[];
|
|
116
238
|
}
|
|
117
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Ed25519 curve instance using SHA3-512 for hashing, suitable for MPC (ArcisEd25519 signature scheme).
|
|
242
|
+
* This is essentially Ed25519 but with SHA3-512 instead of SHA-512 for lower multiplicative depth.
|
|
243
|
+
* See: https://datatracker.ietf.org/doc/html/rfc8032#section-5.1
|
|
244
|
+
*/
|
|
245
|
+
declare const arcisEd25519: CurveFn;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* AES-128 cipher in Counter (CTR) mode, using HKDF-SHA3-256 to derive the key from a shared secret.
|
|
249
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
250
|
+
*/
|
|
251
|
+
declare class Aes128Cipher {
|
|
252
|
+
key: Uint8Array;
|
|
253
|
+
/**
|
|
254
|
+
* Constructs an AES-128 cipher instance using a shared secret.
|
|
255
|
+
* The key is derived using HKDF-SHA3-256.
|
|
256
|
+
* @param sharedSecret - The shared secret to derive the AES key from.
|
|
257
|
+
*/
|
|
258
|
+
constructor(sharedSecret: Uint8Array);
|
|
259
|
+
/**
|
|
260
|
+
* Encrypts the plaintext array in Counter (CTR) mode.
|
|
261
|
+
* @param plaintext - The data to encrypt.
|
|
262
|
+
* @param nonce - An 8-byte nonce for CTR mode.
|
|
263
|
+
* @returns The encrypted ciphertext as a Uint8Array.
|
|
264
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
265
|
+
*/
|
|
266
|
+
encrypt(plaintext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
267
|
+
/**
|
|
268
|
+
* Decrypts the ciphertext array in Counter (CTR) mode.
|
|
269
|
+
* @param ciphertext - The data to decrypt.
|
|
270
|
+
* @param nonce - An 8-byte nonce for CTR mode.
|
|
271
|
+
* @returns The decrypted plaintext as a Uint8Array.
|
|
272
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
273
|
+
*/
|
|
274
|
+
decrypt(ciphertext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* AES-192 cipher in Counter (CTR) mode, using HKDF-SHA3-256 to derive the key from a shared secret.
|
|
279
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
280
|
+
*/
|
|
281
|
+
declare class Aes192Cipher {
|
|
282
|
+
key: Uint8Array;
|
|
283
|
+
/**
|
|
284
|
+
* Constructs an AES-192 cipher instance using a shared secret.
|
|
285
|
+
* The key is derived using HKDF-SHA3-256.
|
|
286
|
+
* @param sharedSecret - The shared secret to derive the AES key from.
|
|
287
|
+
*/
|
|
288
|
+
constructor(sharedSecret: Uint8Array);
|
|
289
|
+
/**
|
|
290
|
+
* Encrypts the plaintext array in Counter (CTR) mode.
|
|
291
|
+
* @param plaintext - The data to encrypt.
|
|
292
|
+
* @param nonce - An 8-byte nonce for CTR mode.
|
|
293
|
+
* @returns The encrypted ciphertext as a Uint8Array.
|
|
294
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
295
|
+
*/
|
|
296
|
+
encrypt(plaintext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
297
|
+
/**
|
|
298
|
+
* Decrypts the ciphertext array in Counter (CTR) mode.
|
|
299
|
+
* @param ciphertext - The data to decrypt.
|
|
300
|
+
* @param nonce - An 8-byte nonce for CTR mode.
|
|
301
|
+
* @returns The decrypted plaintext as a Uint8Array.
|
|
302
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
303
|
+
*/
|
|
304
|
+
decrypt(ciphertext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* AES-256 cipher in Counter (CTR) mode, using HKDF-SHA3-256 to derive the key from a shared secret.
|
|
309
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
310
|
+
*/
|
|
311
|
+
declare class Aes256Cipher {
|
|
312
|
+
key: Uint8Array;
|
|
313
|
+
/**
|
|
314
|
+
* Constructs an AES-256 cipher instance using a shared secret.
|
|
315
|
+
* The key is derived using HKDF-SHA3-256.
|
|
316
|
+
* @param sharedSecret - The shared secret to derive the AES key from.
|
|
317
|
+
*/
|
|
318
|
+
constructor(sharedSecret: Uint8Array);
|
|
319
|
+
/**
|
|
320
|
+
* Encrypts the plaintext array in Counter (CTR) mode.
|
|
321
|
+
* @param plaintext - The data to encrypt.
|
|
322
|
+
* @param nonce - An 8-byte nonce for CTR mode.
|
|
323
|
+
* @returns The encrypted ciphertext as a Uint8Array.
|
|
324
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
325
|
+
*/
|
|
326
|
+
encrypt(plaintext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
327
|
+
/**
|
|
328
|
+
* Decrypts the ciphertext array in Counter (CTR) mode.
|
|
329
|
+
* @param ciphertext - The data to decrypt.
|
|
330
|
+
* @param nonce - An 8-byte nonce for CTR mode.
|
|
331
|
+
* @returns The decrypted plaintext as a Uint8Array.
|
|
332
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
333
|
+
*/
|
|
334
|
+
decrypt(ciphertext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
335
|
+
}
|
|
336
|
+
|
|
118
337
|
/**
|
|
119
338
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
120
339
|
*
|
|
@@ -125,7 +344,7 @@ type Arcium = {
|
|
|
125
344
|
'address': 'BKck65TgoKRokMjQM3datB9oRwJ8rAj2jxPXvHXUvcL6';
|
|
126
345
|
'metadata': {
|
|
127
346
|
'name': 'arcium';
|
|
128
|
-
'version': '0.1.
|
|
347
|
+
'version': '0.1.47';
|
|
129
348
|
'spec': '0.1.0';
|
|
130
349
|
'description': 'The Arcium program';
|
|
131
350
|
};
|
|
@@ -10646,7 +10865,7 @@ type Arcium = {
|
|
|
10646
10865
|
var address = "BKck65TgoKRokMjQM3datB9oRwJ8rAj2jxPXvHXUvcL6";
|
|
10647
10866
|
var metadata = {
|
|
10648
10867
|
name: "arcium",
|
|
10649
|
-
version: "0.1.
|
|
10868
|
+
version: "0.1.47",
|
|
10650
10869
|
spec: "0.1.0",
|
|
10651
10870
|
description: "The Arcium program"
|
|
10652
10871
|
};
|
|
@@ -21187,6 +21406,9 @@ declare namespace arcium$1 {
|
|
|
21187
21406
|
export { arcium$1_accounts as accounts, arcium$1_address as address, arcium as default, arcium$1_errors as errors, arcium$1_events as events, arcium$1_instructions as instructions, arcium$1_metadata as metadata, arcium$1_types as types };
|
|
21188
21407
|
}
|
|
21189
21408
|
|
|
21409
|
+
/**
|
|
21410
|
+
* The deployed address of the Arcium program, as specified in the IDL.
|
|
21411
|
+
*/
|
|
21190
21412
|
declare const ARCIUM_ADDR: "BKck65TgoKRokMjQM3datB9oRwJ8rAj2jxPXvHXUvcL6";
|
|
21191
21413
|
|
|
21192
21414
|
type NodeDAInfo = {
|
|
@@ -21195,22 +21417,96 @@ type NodeDAInfo = {
|
|
|
21195
21417
|
};
|
|
21196
21418
|
type MempoolAcc = anchor.IdlTypes<Arcium>['tinyMempool'] | anchor.IdlTypes<Arcium>['smallMempool'] | anchor.IdlTypes<Arcium>['mediumMempool'] | anchor.IdlTypes<Arcium>['largeMempool'];
|
|
21197
21419
|
type ExecpoolAcc = anchor.IdlTypes<Arcium>['tinyExecPool'] | anchor.IdlTypes<Arcium>['smallExecPool'] | anchor.IdlTypes<Arcium>['mediumExecPool'] | anchor.IdlTypes<Arcium>['largeExecPool'];
|
|
21420
|
+
/**
|
|
21421
|
+
* Returns the public key of the deployed Arcium program on Solana.
|
|
21422
|
+
* @returns The Arcium program's public key.
|
|
21423
|
+
*/
|
|
21198
21424
|
declare function getArciumProgAddress(): anchor.web3.PublicKey;
|
|
21425
|
+
/**
|
|
21426
|
+
* Fetches the DA (Data Availability) info for all nodes in a cluster.
|
|
21427
|
+
* @param provider - The Anchor provider to use for fetching accounts.
|
|
21428
|
+
* @param clusterAddr - The public key of the cluster account.
|
|
21429
|
+
* @returns An array of NodeDAInfo objects for each node in the cluster.
|
|
21430
|
+
*/
|
|
21199
21431
|
declare function getClusterDAInfo(provider: AnchorProvider, clusterAddr: anchor.web3.PublicKey): Promise<NodeDAInfo[]>;
|
|
21432
|
+
/**
|
|
21433
|
+
* Fetches and decodes the mempool account data for any mempool account size.
|
|
21434
|
+
* @param provider - The Anchor provider to use for fetching accounts.
|
|
21435
|
+
* @param mempoolAccPubkey - The public key of the mempool account.
|
|
21436
|
+
* @returns The decoded mempool account data.
|
|
21437
|
+
* @throws Error if the account cannot be fetched or the discriminator is unknown.
|
|
21438
|
+
*/
|
|
21200
21439
|
declare function getMempoolAccData(provider: AnchorProvider, mempoolAccPubkey: anchor.web3.PublicKey): Promise<MempoolAcc>;
|
|
21440
|
+
/**
|
|
21441
|
+
* Fetches and decodes the executing pool account data for any pool size.
|
|
21442
|
+
* @param provider - The Anchor provider to use for fetching accounts.
|
|
21443
|
+
* @param executingPoolAccPubkey - The public key of the executing pool account.
|
|
21444
|
+
* @returns The decoded executing pool account data.
|
|
21445
|
+
* @throws Error if the account cannot be fetched or the discriminator is unknown.
|
|
21446
|
+
*/
|
|
21201
21447
|
declare function getExecutingPoolAccData(provider: AnchorProvider, executingPoolAccPubkey: anchor.web3.PublicKey): Promise<ExecpoolAcc>;
|
|
21448
|
+
/**
|
|
21449
|
+
* Uploads a circuit to the blockchain, splitting it into multiple accounts if necessary.
|
|
21450
|
+
* @param provider - The Anchor provider to use for transactions.
|
|
21451
|
+
* @param circuitName - The name of the circuit.
|
|
21452
|
+
* @param mxeProgramID - The public key of the MXE program.
|
|
21453
|
+
* @param rawCircuit - The raw circuit data as a Uint8Array.
|
|
21454
|
+
* @param logging - Whether to log progress (default: true).
|
|
21455
|
+
* @param chunkSize - The number of upload transactions to send in parallel (default: 500).
|
|
21456
|
+
* @returns An array of transaction signatures for all upload and finalize transactions.
|
|
21457
|
+
*/
|
|
21202
21458
|
declare function uploadCircuit(provider: AnchorProvider, circuitName: string, mxeProgramID: anchor.web3.PublicKey, rawCircuit: Uint8Array, logging?: boolean, chunkSize?: number): Promise<string[]>;
|
|
21459
|
+
/**
|
|
21460
|
+
* Builds a transaction to finalize a computation definition.
|
|
21461
|
+
* @param provider - The Anchor provider to use for transactions.
|
|
21462
|
+
* @param compDefOffset - The offset of the computation definition.
|
|
21463
|
+
* @param mxeProgramID - The public key of the MXE program.
|
|
21464
|
+
* @returns The transaction to finalize the computation definition.
|
|
21465
|
+
*/
|
|
21203
21466
|
declare function buildFinalizeCompDefTx(provider: AnchorProvider, compDefOffset: number, mxeProgramID: anchor.web3.PublicKey): Promise<anchor.web3.Transaction>;
|
|
21467
|
+
/**
|
|
21468
|
+
* Returns the base seed for an Arcium account, given its name.
|
|
21469
|
+
* @param accName - The name of the account.
|
|
21470
|
+
* @returns The base seed as a Uint8Array.
|
|
21471
|
+
*/
|
|
21204
21472
|
declare function getArciumAccountBaseSeed(accName: string): Uint8Array;
|
|
21473
|
+
/**
|
|
21474
|
+
* Computes the offset for a computation definition account, based on the circuit name.
|
|
21475
|
+
* @param circuitName - The name of the circuit.
|
|
21476
|
+
* @returns The offset as a 4-byte Uint8Array.
|
|
21477
|
+
*/
|
|
21205
21478
|
declare function getCompDefAccOffset(circuitName: string): Uint8Array;
|
|
21479
|
+
/**
|
|
21480
|
+
* Returns an Anchor program instance for the Arcium program.
|
|
21481
|
+
* @param provider - The Anchor provider to use.
|
|
21482
|
+
* @returns The Anchor program instance for Arcium.
|
|
21483
|
+
*/
|
|
21206
21484
|
declare function getArciumProgram(provider: AnchorProvider): Program<Arcium>;
|
|
21485
|
+
/**
|
|
21486
|
+
* Returns a read-only Anchor program instance for the Arcium program.
|
|
21487
|
+
* @param provider - The Anchor provider to use.
|
|
21488
|
+
* @returns The Anchor program instance for Arcium.
|
|
21489
|
+
*/
|
|
21207
21490
|
declare function getArciumProgramReadonly(provider: AnchorProvider): Program<Arcium>;
|
|
21208
21491
|
|
|
21209
21492
|
type MScalar = bigint | '_mscalar';
|
|
21210
21493
|
type MFloat = number | '_mfloat';
|
|
21211
21494
|
type MBoolean = boolean | '_mboolean';
|
|
21495
|
+
/**
|
|
21496
|
+
* Number of mantissa bits for double-precision floating point values.
|
|
21497
|
+
*/
|
|
21212
21498
|
declare const DOUBLE_PRECISION_MANTISSA = 52;
|
|
21499
|
+
/**
|
|
21500
|
+
* Encodes a value as a bigint suitable for Rescue encryption, handling booleans, bigints, and numbers.
|
|
21501
|
+
* The encoding is performed in constant-time to avoid leaking information through timing side-channels.
|
|
21502
|
+
* Throws if the value is out of the supported range for the field.
|
|
21503
|
+
* @param v - The value to encode (MScalar, MFloat, or MBoolean).
|
|
21504
|
+
* @returns The encoded value as a bigint.
|
|
21505
|
+
*/
|
|
21213
21506
|
declare function encodeAsRescueEncryptable(v: MScalar | MFloat | MBoolean): bigint;
|
|
21507
|
+
/**
|
|
21508
|
+
* Describes a value type for circuit interface arguments and outputs.
|
|
21509
|
+
*/
|
|
21214
21510
|
type Value = {
|
|
21215
21511
|
type: 'mscalar';
|
|
21216
21512
|
size_in_bits: number;
|
|
@@ -21249,6 +21545,9 @@ type Value = {
|
|
|
21249
21545
|
type: 'struct';
|
|
21250
21546
|
content: readonly Value[];
|
|
21251
21547
|
};
|
|
21548
|
+
/**
|
|
21549
|
+
* Describes an argument to a circuit interface, including its value type and whether it is a raw input or object reference.
|
|
21550
|
+
*/
|
|
21252
21551
|
type Argument = {
|
|
21253
21552
|
value: Value;
|
|
21254
21553
|
type: {
|
|
@@ -21256,17 +21555,29 @@ type Argument = {
|
|
|
21256
21555
|
is_mutable?: boolean;
|
|
21257
21556
|
};
|
|
21258
21557
|
};
|
|
21558
|
+
/**
|
|
21559
|
+
* Describes the interface for a confidential computation circuit, including its name, inputs, and output count.
|
|
21560
|
+
*/
|
|
21259
21561
|
type CircuitInterface = {
|
|
21260
21562
|
name: string;
|
|
21261
21563
|
inputs: readonly Argument[];
|
|
21262
21564
|
output_count: number;
|
|
21263
21565
|
};
|
|
21566
|
+
/**
|
|
21567
|
+
* Converts a struct value definition to a TypeScript type.
|
|
21568
|
+
*/
|
|
21264
21569
|
type JsonToStruct<C> = {
|
|
21265
21570
|
[K in keyof C]: C[K] extends Value ? JsonToValue<C[K]> : never;
|
|
21266
21571
|
};
|
|
21572
|
+
/**
|
|
21573
|
+
* Converts an array value definition to a TypeScript type.
|
|
21574
|
+
*/
|
|
21267
21575
|
type JsonToArray<C> = {
|
|
21268
21576
|
[K in keyof C]: C[K] extends Value ? JsonToValue<C[K]> : never;
|
|
21269
21577
|
};
|
|
21578
|
+
/**
|
|
21579
|
+
* Converts a Value type to its corresponding TypeScript type.
|
|
21580
|
+
*/
|
|
21270
21581
|
type JsonToValue<T extends Value> = T extends {
|
|
21271
21582
|
type: 'struct';
|
|
21272
21583
|
content: infer C;
|
|
@@ -21296,6 +21607,9 @@ type JsonToValue<T extends Value> = T extends {
|
|
|
21296
21607
|
} ? MBoolean : T extends {
|
|
21297
21608
|
type: 'bool';
|
|
21298
21609
|
} ? boolean : never;
|
|
21610
|
+
/**
|
|
21611
|
+
* Converts an Argument type to its corresponding TypeScript type, handling raw inputs and object references.
|
|
21612
|
+
*/
|
|
21299
21613
|
type JsonToArgument<T extends Argument> = T['type'] extends {
|
|
21300
21614
|
type: 'raw_input';
|
|
21301
21615
|
} ? {
|
|
@@ -21306,48 +21620,143 @@ type JsonToArgument<T extends Argument> = T['type'] extends {
|
|
|
21306
21620
|
value: JsonToValue<T['value']>;
|
|
21307
21621
|
isMutable: T['type']['is_mutable'];
|
|
21308
21622
|
} : never;
|
|
21623
|
+
/**
|
|
21624
|
+
* Converts an Argument type to its corresponding TypeScript type, filtering only raw input data objects.
|
|
21625
|
+
*/
|
|
21309
21626
|
type JsonToArgumentFilteredDataObjs<T extends Argument> = T['type'] extends {
|
|
21310
21627
|
type: 'raw_input';
|
|
21311
21628
|
} ? {
|
|
21312
21629
|
value: JsonToValue<T['value']>;
|
|
21313
21630
|
} : never;
|
|
21631
|
+
/**
|
|
21632
|
+
* Converts an array of Argument types to their corresponding TypeScript types.
|
|
21633
|
+
*/
|
|
21314
21634
|
type JsonToInputArr<T extends readonly Argument[]> = {
|
|
21315
21635
|
[K in keyof T]: JsonToArgument<T[K]>;
|
|
21316
21636
|
};
|
|
21637
|
+
/**
|
|
21638
|
+
* Converts an array of Argument types to their corresponding TypeScript types, filtering only raw input data objects.
|
|
21639
|
+
*/
|
|
21317
21640
|
type JsonToInputArrFilteredDataObjs<T extends readonly Argument[]> = T extends [] ? [] : T extends [infer H extends Argument, ...infer R extends readonly Argument[]] ? H['type'] extends {
|
|
21318
21641
|
'type': 'object_reference';
|
|
21319
21642
|
} ? JsonToInputArrFilteredDataObjs<R> : [JsonToArgumentFilteredDataObjs<H>, ...JsonToInputArrFilteredDataObjs<R>] : T;
|
|
21643
|
+
/**
|
|
21644
|
+
* Converts a CircuitInterface type to a TypeScript type representing its name, inputs, and output count.
|
|
21645
|
+
*/
|
|
21320
21646
|
type JsonToCircuitInterface<T extends CircuitInterface> = {
|
|
21321
21647
|
name: T['name'];
|
|
21322
21648
|
inputs: JsonToInputArr<T['inputs']>;
|
|
21323
21649
|
outputCount: T['output_count'];
|
|
21324
21650
|
};
|
|
21651
|
+
/**
|
|
21652
|
+
* Type alias for a confidential instruction, based on a circuit interface.
|
|
21653
|
+
*/
|
|
21325
21654
|
type ConfidentialInstruction<T extends CircuitInterface> = JsonToCircuitInterface<T>;
|
|
21655
|
+
/**
|
|
21656
|
+
* Type alias for the raw confidential instruction inputs, filtering only raw input data objects.
|
|
21657
|
+
*/
|
|
21326
21658
|
type RawConfidentialInstructionInputs<T extends CircuitInterface> = JsonToInputArrFilteredDataObjs<T['inputs']>;
|
|
21659
|
+
/**
|
|
21660
|
+
* Secret-shares the inputs for a confidential instruction, encoding each value as needed and splitting it for each node's public key.
|
|
21661
|
+
* @param ixInput - The array of input values to secret-share.
|
|
21662
|
+
* @param nodeX25519Keys - The array of node X25519 public keys to share with.
|
|
21663
|
+
* @returns A 2D array of SecretShare objects, one array per input value.
|
|
21664
|
+
* @throws Error if an input type cannot be parsed.
|
|
21665
|
+
*/
|
|
21327
21666
|
declare function secretShareInputs(ixInput: readonly ({
|
|
21328
21667
|
value: readonly (MScalar | MFloat | MBoolean)[];
|
|
21329
21668
|
} | {
|
|
21330
21669
|
value: MScalar | MFloat | MBoolean;
|
|
21331
21670
|
} | never)[], nodeX25519Keys: Uint8Array[]): SecretShare[][];
|
|
21332
21671
|
|
|
21672
|
+
/**
|
|
21673
|
+
* Structure representing the local Arcium environment variables required for local development or testing.
|
|
21674
|
+
*/
|
|
21333
21675
|
type ArciumLocalEnv = {
|
|
21334
21676
|
arciumClusterPubkey: PublicKey;
|
|
21335
21677
|
callbackServerPubkey: PublicKey;
|
|
21336
21678
|
};
|
|
21679
|
+
/**
|
|
21680
|
+
* Reads local Arcium environment information from environment variables.
|
|
21681
|
+
* Only available in Node.js and when testing locally.
|
|
21682
|
+
* @returns The local Arcium environment configuration.
|
|
21683
|
+
* @throws Error if called in a browser or if required environment variables are missing or invalid.
|
|
21684
|
+
*/
|
|
21337
21685
|
declare function getArciumEnv(): ArciumLocalEnv;
|
|
21338
21686
|
|
|
21687
|
+
/**
|
|
21688
|
+
* Represents possible error messages that can occur during computation processing or transaction handling.
|
|
21689
|
+
*/
|
|
21339
21690
|
type ComputationErrorType = `Transaction ${string} not found` | 'Transaction inner instructions not found' | `Transaction failed with error: ${string}` | 'No log messages found' | 'No queue computation instruction found' | `Invalid computation offset: ${string}` | 'Computation not found in executing pool, might have already executed' | `Error fetching transactions: ${string}` | `Instruction at index ${number} not found` | 'Account keys or program ID index not found' | `No Program ID found for instruction at index ${number}` | 'Max retries reached while searching for transaction';
|
|
21691
|
+
/**
|
|
21692
|
+
* Waits for the finalization of a computation by listening for the finalizeComputationEvent.
|
|
21693
|
+
* Resolves with the transaction signature once the computation is finalized.
|
|
21694
|
+
* @param provider - The Anchor provider to use for event listening.
|
|
21695
|
+
* @param computationOffset - The offset of the computation to wait for.
|
|
21696
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
21697
|
+
* @param commitment - (Optional) The desired finality/commitment level (default: 'confirmed').
|
|
21698
|
+
* @returns The transaction signature of the finalization event.
|
|
21699
|
+
*/
|
|
21340
21700
|
declare function awaitComputationFinalization(provider: AnchorProvider, computationOffset: BN, mxeProgramId: PublicKey, commitment?: Finality): Promise<string>;
|
|
21341
21701
|
|
|
21702
|
+
/**
|
|
21703
|
+
* Returns the public key of the deployed Arcium program on Solana.
|
|
21704
|
+
* @returns The Arcium program's public key.
|
|
21705
|
+
*/
|
|
21342
21706
|
declare function getArciumProgramId(): PublicKey;
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21347
|
-
|
|
21348
|
-
|
|
21349
|
-
declare function
|
|
21350
|
-
|
|
21351
|
-
|
|
21707
|
+
/**
|
|
21708
|
+
* Derives the computation account address for a given MXE program ID and offset.
|
|
21709
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
21710
|
+
* @param offset - The computation offset as an anchor.BN.
|
|
21711
|
+
* @returns The derived computation account public key.
|
|
21712
|
+
*/
|
|
21713
|
+
declare function getComputationAccAddress(mxeProgramId: PublicKey, offset: anchor.BN): PublicKey;
|
|
21714
|
+
/**
|
|
21715
|
+
* Derives the mempool account address for a given MXE program ID.
|
|
21716
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
21717
|
+
* @returns The derived mempool account public key.
|
|
21718
|
+
*/
|
|
21719
|
+
declare function getMempoolAccAddress(mxeProgramId: PublicKey): PublicKey;
|
|
21720
|
+
/**
|
|
21721
|
+
* Derives the executing pool account address for a given MXE program ID.
|
|
21722
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
21723
|
+
* @returns The derived executing pool account public key.
|
|
21724
|
+
*/
|
|
21725
|
+
declare function getExecutingPoolAccAddress(mxeProgramId: PublicKey): PublicKey;
|
|
21726
|
+
/**
|
|
21727
|
+
* Derives the staking pool account address.
|
|
21728
|
+
* @returns The derived staking pool account public key.
|
|
21729
|
+
*/
|
|
21730
|
+
declare function getStakingPoolAccAddress(): PublicKey;
|
|
21731
|
+
/**
|
|
21732
|
+
* Derives the clock account address.
|
|
21733
|
+
* @returns The derived clock account public key.
|
|
21734
|
+
*/
|
|
21735
|
+
declare function getClockAccAddress(): PublicKey;
|
|
21736
|
+
/**
|
|
21737
|
+
* Derives the cluster account address for a given offset.
|
|
21738
|
+
* @param offset - The cluster offset as a number.
|
|
21739
|
+
* @returns The derived cluster account public key.
|
|
21740
|
+
*/
|
|
21741
|
+
declare function getClusterAccAddress(offset: number): PublicKey;
|
|
21742
|
+
/**
|
|
21743
|
+
* Derives the ArxNode account address for a given offset.
|
|
21744
|
+
* @param offset - The ArxNode offset as a number.
|
|
21745
|
+
* @returns The derived ArxNode account public key.
|
|
21746
|
+
*/
|
|
21747
|
+
declare function getArxNodeAccAddress(offset: number): PublicKey;
|
|
21748
|
+
/**
|
|
21749
|
+
* Derives the MXE account address for a given MXE program ID.
|
|
21750
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
21751
|
+
* @returns The derived MXE account public key.
|
|
21752
|
+
*/
|
|
21753
|
+
declare function getMXEAccAddress(mxeProgramId: PublicKey): PublicKey;
|
|
21754
|
+
/**
|
|
21755
|
+
* Derives the computation definition account address for a given MXE program ID and offset.
|
|
21756
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
21757
|
+
* @param offset - The computation definition offset as a number.
|
|
21758
|
+
* @returns The derived computation definition account public key.
|
|
21759
|
+
*/
|
|
21760
|
+
declare function getCompDefAccAddress(mxeProgramId: PublicKey, offset: number): PublicKey;
|
|
21352
21761
|
|
|
21353
|
-
export { ARCIUM_ADDR, arcium$1 as ARCIUM_IDL, type Arcium as ArciumIdlType, type ArciumLocalEnv, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, type CircuitInterface, type ComputationErrorType, type ConfidentialInstruction, DOUBLE_PRECISION_MANTISSA, type FpField, type JsonToArgument, type JsonToArgumentFilteredDataObjs, type JsonToCircuitInterface, type JsonToInputArr, type JsonToInputArrFilteredDataObjs, type JsonToValue, type MBoolean, type MFloat, type MScalar, Matrix, type NodeDAInfo, type RawConfidentialInstructionInputs, RescueCipher, RescueDesc, RescuePrimeHash, type SecretShare, awaitComputationFinalization, buildFinalizeCompDefTx, deserializeLE, encodeAsRescueEncryptable, encryptForDA, genRawShares, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgAddress, getArciumProgram, getArciumProgramId, getArciumProgramReadonly,
|
|
21762
|
+
export { ARCIUM_ADDR, arcium$1 as ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, type Arcium as ArciumIdlType, type ArciumLocalEnv, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, type CircuitInterface, type ComputationErrorType, type ConfidentialInstruction, DOUBLE_PRECISION_MANTISSA, type FpField, type JsonToArgument, type JsonToArgumentFilteredDataObjs, type JsonToCircuitInterface, type JsonToInputArr, type JsonToInputArrFilteredDataObjs, type JsonToValue, type MBoolean, type MFloat, type MScalar, Matrix, type NodeDAInfo, type RawConfidentialInstructionInputs, RescueCipher, RescueDesc, RescuePrimeHash, type SecretShare, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, deserializeLE, encodeAsRescueEncryptable, encryptForDA, genRawShares, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgAddress, getArciumProgram, getArciumProgramId, getArciumProgramReadonly, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getClusterDAInfo, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getEncryptionKey, getExecutingPoolAccAddress, getExecutingPoolAccData, getMXEAccAddress, getMempoolAccAddress, getMempoolAccData, getStakingPoolAccAddress, positiveModulo, randMatrix, secretShareInputs, secretShareValue, serializeLE, sha256, toVec, uploadCircuit };
|