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

solana-mpc-tss-lib

v1.0.2

Published

A comprehensive TypeScript library for Solana Multi-Party Computation (MPC) and Threshold Signature Schemes (TSS) - Compatible with ZenGo-X/solana-tss

Readme

🔐 Solana MPC/TSS Library

npm version License: MIT TypeScript Tests

A comprehensive TypeScript library for Solana Multi-Party Computation (MPC) and Threshold Signature Schemes (TSS), providing seamless integration with the Solana blockchain ecosystem.

✨ Features

🔑 MPC (Multi-Party Computation) Module

  • Secure Signing: Advanced cryptographic operations without private key exposure
  • Solana Integration: Full compatibility with Solana's Signer interface
  • WASM Optimization: High-performance ed25519_tss_wasm with automatic tweetnacl fallback
  • Transaction Utilities: Ready-to-use functions for common Solana operations

🤝 TSS (Threshold Signature Scheme) Module

  • ZenGo-X Compatible: 100% API compatibility with ZenGo-X/solana-tss Rust CLI
  • Flexible Thresholds: Support for n-of-n and m-of-n signature schemes (2-of-3, 3-of-5, etc.)
  • Multi-Network: Seamless operation across mainnet-beta, devnet, and testnet
  • Production Ready: Battle-tested cryptographic protocols for enterprise use

🚀 Quick Start

Installation

npm install solana-mpc-tss-lib
# or
yarn add solana-mpc-tss-lib

Basic Usage

import { TSSCli, createMPCSigner, MPCKeypair } from 'solana-mpc-tss-lib';

// Quick MPC signing
const signer = await createMPCSigner();
const keypair = new MPCKeypair(signer);

// TSS operations
const cli = new TSSCli('devnet');
const keypairInfo = await cli.generate();
console.log('Generated:', keypairInfo.publicKey);

Simple Transaction Example

import { createMPCSigner, MPCKeypair, createTransferTx } from 'solana-mpc-tss-lib';
import { Connection, clusterApiUrl, PublicKey } from '@solana/web3.js';

const connection = new Connection(clusterApiUrl('devnet'));
const signer = await createMPCSigner();
const keypair = new MPCKeypair(signer);

// Create and sign transaction
const tx = await createTransferTx(
  connection,
  keypair.publicKey,
  new PublicKey('destination-address'),
  1000000 // 0.001 SOL in lamports
);

const signedTx = await keypair.signTransaction(tx);
const signature = await connection.sendTransaction(signedTx, [keypair]);

Multi-Party Threshold Signing

import { TSSCli } from 'solana-mpc-tss-lib';

const cli = new TSSCli('devnet');

// Generate participant keypairs
const participant1 = await cli.generate();
const participant2 = await cli.generate();
const participant3 = await cli.generate();

// Create 2-of-3 multisig
const aggregated = cli.aggregateKeys([
  participant1.publicKey,
  participant2.publicKey,
  participant3.publicKey
], 2);

// Initiate multi-party signing (Step 1 for each participant)
const recentBlockhash = await cli.recentBlockHash();
const step1P1 = await cli.aggregateSignStepOne(
  participant1.secretKey,
  'destination-address',
  1000000,
  'Multi-sig payment', // Optional memo
  recentBlockhash
);

const step1P2 = await cli.aggregateSignStepOne(
  participant2.secretKey,
  'destination-address',
  1000000,
  'Multi-sig payment',
  recentBlockhash
);

// Step 2: Create partial signatures
const allPublicNonces = [step1P1.publicNonce, step1P2.publicNonce];
const step2P1 = await cli.aggregateSignStepTwo(
  JSON.stringify(step1P1),
  participant1.secretKey,
  'destination-address',
  1000000,
  allPublicNonces,
  'Multi-sig payment',
  recentBlockhash
);

const step2P2 = await cli.aggregateSignStepTwo(
  JSON.stringify(step1P2),
  participant2.secretKey,
  'destination-address',
  1000000,
  allPublicNonces,
  'Multi-sig payment',
  recentBlockhash
);

// Step 3: Aggregate signatures and broadcast
const partialSignatures = [step2P1, step2P2];
const transactionDetails = {
  amount: 1000000,
  to: 'destination-address',
  from: aggregated.aggregatedPublicKey, // Use the aggregated public key
  network: 'devnet',
  memo: 'Multi-sig payment',
  recentBlockhash
};

const signature = await cli.aggregateSignaturesAndBroadcast(
  JSON.stringify(partialSignatures),
  JSON.stringify(transactionDetails),
  JSON.stringify(aggregated) // Pass the aggregated wallet info here
);

📖 API Reference

Core Classes

TSSCli

Main interface for TSS operations, compatible with ZenGo-X/solana-tss.

const cli = new TSSCli('devnet'); // 'mainnet-beta' | 'devnet' | 'testnet'

// Wallet operations
await cli.generate()                    // Generate keypair
await cli.balance(address)              // Check balance
await cli.airdrop(address, amount)      // Request SOL (devnet/testnet)

// Transaction operations  
await cli.sendSingle(secret, to, amount, memo)  // Single-party transaction
cli.aggregateKeys(keys, threshold)              // Create multisig

// Multi-party signing workflow
await cli.aggregateSignStepOne(...)     // Initialize signing
await cli.aggregateSignStepTwo(...)     // Create partial signature
await cli.aggregateSignaturesAndBroadcast(...) // Finalize transaction

MPCKeypair

Implements Solana's Signer interface with MPC backend.

const signer = await createMPCSigner();
const keypair = new MPCKeypair(signer);

await keypair.signTransaction(tx)       // Sign single transaction
await keypair.signAllTransactions(txs)  // Sign multiple transactions

TSSWallet

Wallet management and key aggregation utilities.

const wallet = new TSSWallet('devnet');

await wallet.generateKeypair()          // Generate TSS keypair
await wallet.getBalance(publicKey)      // Check balance
wallet.aggregateKeys(keys, threshold)   // Create aggregate wallet

Utility Functions

// MPC operations
createMPCSigner()                       // Create new MPC signer
createMPCSignerFromSecretKey(bytes)     // From existing secret

// Solana utilities
createTransferTx(connection, from, to, amount)  // Create transfer transaction

🔧 TypeScript Types

The library includes comprehensive TypeScript definitions:

// Core interfaces
interface MPCSigner {
  publicKey: PublicKey;
  sign(data: Uint8Array): Promise<Uint8Array>;
}

interface TSSKeypair {
  publicKey: PublicKey;
  secretKey: Uint8Array;
}

// Network types
type SolanaNetwork = 'mainnet-beta' | 'devnet' | 'testnet';

// TSS workflow types
interface StepOneData {
  secretNonce: string;
  publicNonce: string;
  participantKey: string;
}

interface PartialSignature {
  partialSignature: string;
  publicNonce: string;
  participantKey: string;
}

🧪 Testing

The library includes comprehensive test coverage:

npm test                    # Run all tests (30 tests)
npm run test:watch          # Watch mode
npm run test:usage          # Test built library

Test Coverage:

  • ✅ MPC signing operations (12 tests)
  • ✅ TSS workflow end-to-end (18 tests)
  • ✅ Error handling and edge cases
  • ✅ Network integration (mocked)
  • ✅ TypeScript compilation

🏗️ Building & Development

# Clone and setup
git clone https://github.com/kiralightyagami/solana-mpc-tss.git
cd solana-mpc-tss
npm install

# Development commands
npm run build               # Build CJS + ESM + types
npm run dev                 # Watch mode build
npm test                    # Run tests
npm run typecheck           # TypeScript validation
npm run example             # Run example code

🔒 Security Features

  • No Private Key Exposure: MPC protocols ensure keys never exist in plaintext
  • Threshold Security: Configurable m-of-n signature requirements
  • Network Isolation: Separate configurations for different Solana networks
  • Fallback Mechanisms: Automatic fallback from WASM to pure JavaScript
  • Type Safety: Full TypeScript coverage prevents runtime errors

🌐 Network Support

| Network | RPC Endpoint | Features | |---------|-------------|----------| | mainnet-beta | Solana mainnet | Production transactions | | devnet | Solana devnet | Development + airdrops | | testnet | Solana testnet | Testing + airdrops |

📚 Documentation

🤝 ZenGo-X Compatibility

This library provides 100% API compatibility with ZenGo-X/solana-tss:

| ZenGo-X CLI Command | Library Method | Description | |---------------------|----------------|-------------| | solana-tss generate | cli.generate() | Generate keypair | | solana-tss balance | cli.balance() | Check balance | | solana-tss airdrop | cli.airdrop() | Request airdrop | | solana-tss send-single | cli.sendSingle() | Single-key signing | | solana-tss aggregate-keys | cli.aggregateKeys() | Key aggregation | | solana-tss agg-send-step-one | cli.aggregateSignStepOne() | Step 1 signing | | solana-tss recent-block-hash | cli.recentBlockHash() | Get blockhash | | solana-tss agg-send-step-two | cli.aggregateSignStepTwo() | Step 2 signing | | solana-tss aggregate-signatures-and-broadcast | cli.aggregateSignaturesAndBroadcast() | Finalize |

📦 Package Information

  • Bundle Size: ~24KB (CJS) / ~22KB (ESM)
  • Dependencies: @solana/web3.js, tweetnacl
  • Node.js: >=16.0.0
  • License: MIT
  • Repository: GitHub

🐛 Issues & Support

📄 License

MIT License - see LICENSE file for details.