@arcium-hq/client
Client SDK for encrypted Solana programs using Arcium MPC.
Key exports:
- createPacker - Pack/unpack circuit inputs and outputs
- awaitComputationFinalization - Wait for computation results
- Cryptography: AES, Rescue ciphers, HMAC, HKDF
- PDAs: Address derivation utilities
Classes
| Class | Description |
|---|---|
| Aes128Cipher | AES-128 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret. See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode. |
| Aes192Cipher | AES-192 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret. See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode. |
| Aes256Cipher | AES-256 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret. See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode. |
| CSplRescueCipher | The Rescue cipher over Curve25519's scalar field in Counter (CTR) mode, with a fixed block size m = 5. See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287 |
| RescueCipher | The Rescue cipher over Curve25519's base field in Counter (CTR) mode, with a fixed block size m = 5. See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287 |
| RescueDesc | Description and parameters for the Rescue cipher or hash function, including round constants, MDS matrix, and key schedule. See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287 |
| RescuePrimeHash | The Rescue-Prime hash function, as described in https://eprint.iacr.org/2020/1143.pdf, offering 256 bits of security against collision, preimage and second-preimage attacks for any field of size at least 102 bits. We use the sponge construction with fixed rate = 7 and capacity = 5 (i.e., m = 12), and truncate the output to 5 field elements. |
Interfaces
| Interface | Description |
|---|---|
| FieldInfo | Field definition for circuit input/output packing. Pass an array of these to createPacker to create a type-safe packer. |
| MempoolPriorityFeeStats | Statistics about priority fees for computations in a mempool. |
| Packer | Type-safe packer for converting between TypeScript objects and circuit-compatible bigint arrays. |
Type Aliases
| Type Alias | Description |
|---|---|
| ArciumIdlType | Program IDL in camelCase format in order to be used in JS/TS. |
| ArciumLocalEnv | Structure representing the local Arcium environment variables required for local development or testing. |
| CircuitSource | IDL-generated type for circuit source location. Discriminated union with variants: local, onChain, offChain. |
| ComputationReference | Reference to a computation in a mempool or executing pool. Contains the computation offset and priority fee information. |
| ExecutingPoolAccount | Represents an executing pool account of any size (tiny, small, medium, or large). Executing pools manage parallel computation execution with account locking. Each size supports different maximum parallel computations: - Tiny: 1 parallel computation - Small: 3 parallel computations - Medium: 10 parallel computations - Large: 100 parallel computations |
| FpField | Field type. |
| MempoolAccount | Represents a mempool account of any size (tiny, small, medium, or large). Mempools store pending computations prioritized by fee, with a time-to-live of 180 slots. Each size supports different maximum heap capacities: - Tiny: 1 computation - Small: 3 computations - Medium: 10 computations - Large: 100 computations |
Variables
| Variable | Description |
|---|---|
| arcisEd25519 | Ed25519 curve instance using SHA3-512 for hashing, suitable for MPC (ArcisEd25519 signature scheme). This is essentially Ed25519 but with SHA3-512 instead of SHA-512 for lower multiplicative depth. See: https://datatracker.ietf.org/doc/html/rfc8032#section-5.1 |
| ARCIUM_ADDR | The deployed address of the Arcium program, as specified in the IDL. |
| ARCIUM_IDL | The Anchor-generated IDL JSON object for the Arcium program. |
| CURVE25519_BASE_FIELD | Curve25519 base field as an IField instance. |
| CURVE25519_SCALAR_FIELD | Curve25519 scalar field as an IField instance. |
| CURVE25519_SCALAR_FIELD_MODULUS | Scalar field prime modulus for Curve25519: 2^252 + 27742317777372353535851937790883648493 |
| x25519 | ECDH using curve25519 aka x25519. |
Functions
| Function | Description |
|---|---|
| awaitComputationFinalization | Wait for a computation to finalize by polling the computation account status via HTTP RPC. Does not use WebSocket subscriptions. |
| buildFinalizeCompDefTx | Build a transaction to finalize a computation definition. |
| claimComputationRent | - |
| createPacker | Create a type-safe packer from field definitions. |
| deserializeLE | Deserialize a little-endian Uint8Array to a bigint. |
| finalizeKeyRecoveryExecution | Finalize key recovery execution after the submission threshold is met. This queues the key_recovery_finalize MPC computation on the backup cluster. |
| generateRandomFieldElem | Generate a random value within the field bound by q. |
| getArciumAccountBaseSeed | Return the base seed for an Arcium account, given its name. |
| getArciumEnv | Read local Arcium environment information from environment variables. Only available in Node.js and when testing locally. |
| getArciumProgram | Return an Anchor program instance for the Arcium program. |
| getArciumProgramId | Return the public key of the deployed Arcium program on Solana. |
| getArxNodeAccAddress | Derive the ArxNode account address for a given offset. |
| getClockAccAddress | Derive the clock account address. |
| getClusterAccAddress | Derive the cluster account address for a given offset. |
| getCompDefAccAddress | Derive the computation definition account address for a given MXE program ID and offset. |
| getCompDefAccOffset | Compute the offset for a computation definition account, based on the circuit name. |
| getComputationAccAddress | Derive the computation account address for a given cluster and computation offset. |
| getComputationsInMempool | Return all computation references in the mempool for a given account. Only non-stake computations are included. |
| getExecutingPoolAccAddress | Derive the executing pool account address for a given cluster. |
| getExecutingPoolAccInfo | Fetch and decode the executing pool account info for any pool size. |
| getFeePoolAccAddress | Derive the fee pool account address. |
| getLookupTableAddress | Derive the address lookup table address for an MXE program. |
| getMempoolAccAddress | Derive the mempool account address for a given cluster. |
| getMempoolAccInfo | Fetch and decode the mempool account info for any mempool account size. |
| getMempoolPriorityFeeStats | Calculate priority fee statistics for computations in a mempool. |
| getMXEAccAddress | Derive the MXE account address for a given MXE program ID. |
| getMXEArcisEd25519VerifyingKey | Fetch and extract the MXE arcis Ed25519 verifying key from the MXE account. |
| getMXEPublicKey | Fetch and extract the MXE X25519 public key from the MXE account. |
| getMxeRecoveryAccAddress | Derive the MXE recovery account address for a key recovery session. |
| getRawCircuitAccAddress | Derive the raw circuit account address for a given computation definition and index. |
| getRecoveryClusterAccAddress | Derive the recovery cluster account address for a given MXE program ID. |
| initKeyRecoveryExecution | Initialize key recovery execution by creating the MxeRecoveryAccount and registering the key_recovery_final computation definition on the backup MXE. This is split into two parts due to Solana's 10KB per-instruction allocation limit. |
| initMxePart1 | Initialize an MXE (part 1). Due to Solana's 10KB per-instruction allocation limit, this only partially allocates recovery_cluster_acc. Call initMxePart2 afterwards to finish allocation and add keygen to mempool. |
| initMxePart2 | Finish MXE initialization (part 2). Reallocate recovery_cluster_acc to full size, initialize recovery_peers, and add the keygen computation to the mempool. |
| isNullRef | Check if a computation reference is null (all zeros). |
| positiveModulo | Compute the positive modulo of a over m. |
| queueKeyRecoveryInit | Queue a key recovery initialization for an MXE on a given cluster. |
| recoverMxe | Set an MXE to Recovery status, initiating the key recovery process. |
| serializeLE | Serialize a bigint to a little-endian Uint8Array of the specified length. |
| sha256 | Compute the SHA-256 hash of an array of Uint8Arrays. |
| submitKeyRecoveryShare | Submit a re-encrypted key recovery share from a recovery peer. Recovery peers must decrypt shares using their x25519 private key and re-encrypt them for the backup MXE before submission. |
| toVec | - |
| uploadCircuit | Upload a circuit to the blockchain, splitting it into multiple accounts if necessary. |