npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@arcium-hq/client

v0.5.2

Published

Client SDK for interacting with encrypted Solana programs

Readme

Arcium Client SDK

The Arcium Client SDK is a TypeScript library for interacting with the Arcium Solana program, enabling secure multi-party computation on encrypted data.

Installation

npm install @arcium-hq/client
# or
yarn add @arcium-hq/client
# or
pnpm add @arcium-hq/client

Quick Start

1. Setup and Environment

import { getArciumEnv } from "@arcium-hq/client";
import * as anchor from "@coral-xyz/anchor";

// Get Arcium environment configuration
const arciumEnv = getArciumEnv();

// Setup Anchor provider
anchor.setProvider(anchor.AnchorProvider.env());
const provider = anchor.getProvider();

2. Encryption Setup

To send private data for computation within Arcium, you need to encrypt it using a shared secret derived from your keypair and the Arcium MXE's public key.

Generate a client keypair:

import { x25519 } from "@arcium-hq/client";

const privateKey = x25519.utils.randomSecretKey();
const publicKey = x25519.getPublicKey(privateKey);

Obtain the MXE's public key:

import { getMXEPublicKey } from "@arcium-hq/client";

// Fetch the MXE public key (handles the complex extraction logic internally)
const mxePublicKey = await getMXEPublicKey(provider, program.programId);

if (!mxePublicKey) {
  throw new Error("MXE public key not set");
}

Compute the shared secret and initialize cipher:

import { RescueCipher } from "@arcium-hq/client";

const sharedSecret = x25519.getSharedSecret(privateKey, mxePublicKey);
const cipher = new RescueCipher(sharedSecret);

3. Encrypt and Submit Data

import { randomBytes } from "crypto";
import { deserializeLE } from "@arcium-hq/client";

// Prepare your data as BigInts
const val1 = BigInt(123);
const val2 = BigInt(456);
const plaintext = [val1, val2];

// Generate a random nonce (16 bytes)
const nonce = randomBytes(16);

// Encrypt the data
const ciphertext = cipher.encrypt(plaintext, nonce);

// Submit to your program
const computationOffset = new anchor.BN(randomBytes(8), "hex");

const sig = await program.methods
  .yourComputationMethod(
    computationOffset,
    Array.from(ciphertext[0]),
    Array.from(ciphertext[1]),
    Array.from(publicKey),
    new anchor.BN(deserializeLE(nonce).toString())
  )
  .accountsPartial({
    // Account setup - see Account Helpers section
  })
  .rpc({ skipPreflight: true, commitment: "confirmed" });

4. Track and Finalize Computation

import { awaitComputationFinalization } from "@arcium-hq/client";

// Wait for computation to complete
const finalizeSig = await awaitComputationFinalization(
  provider as anchor.AnchorProvider,
  computationOffset,
  program.programId,
  "confirmed"
);

console.log("Computation finalized:", finalizeSig);

5. Decrypt Results

// Listen for program events
const event = await awaitEvent("yourResultEvent");

// Decrypt the result using the same cipher
const decrypted = cipher.decrypt([event.encryptedResult], event.nonce)[0];
console.log("Decrypted result:", decrypted);

Account Helpers

The SDK provides helper functions to derive all necessary Arcium PDAs:

import {
  getArciumEnv,
  getMXEAccAddress,
  getMempoolAccAddress,
  getCompDefAccAddress,
  getExecutingPoolAccAddress,
  getComputationAccAddress,
  getCompDefAccOffset,
  getArciumAccountBaseSeed,
  getArciumProgramId,
} from "@arcium-hq/client";

// Get cluster offset from environment
const arciumEnv = getArciumEnv();

// Get MXE account address (uses MXE program ID)
const mxeAccount = getMXEAccAddress(program.programId);

// Get pool addresses (use cluster offset, not program ID)
const mempoolAccount = getMempoolAccAddress(arciumEnv.arciumClusterOffset);
const executingPool = getExecutingPoolAccAddress(arciumEnv.arciumClusterOffset);

// Get computation definition address
const compDefOffset = getCompDefAccOffset("your_computation_name");
const compDefAccount = getCompDefAccAddress(
  program.programId,
  Buffer.from(compDefOffset).readUInt32LE()
);

// Get computation account for a specific offset (uses cluster offset)
const computationAccount = getComputationAccAddress(
  arciumEnv.arciumClusterOffset,
  computationOffset
);

Circuit Management

Upload a Circuit

import { uploadCircuit } from "@arcium-hq/client";
import * as fs from "fs";

const rawCircuit = fs.readFileSync("build/your_circuit.arcis");

await uploadCircuit(
  provider as anchor.AnchorProvider,
  "your_circuit_name",
  program.programId,
  rawCircuit,
  true // use raw circuit
);

Finalize Computation Definition

import { buildFinalizeCompDefTx } from "@arcium-hq/client";

const finalizeTx = await buildFinalizeCompDefTx(
  provider as anchor.AnchorProvider,
  Buffer.from(compDefOffset).readUInt32LE(),
  program.programId
);

// Set blockhash and sign
const latestBlockhash = await provider.connection.getLatestBlockhash();
finalizeTx.recentBlockhash = latestBlockhash.blockhash;
finalizeTx.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
finalizeTx.sign(owner);

// Send transaction
await provider.sendAndConfirm(finalizeTx);

API Reference