A comprehensive TypeScript library for Solana Multi-Party Computation (MPC) and Threshold Signature Schemes (TSS), providing seamless integration with the Solana blockchain ecosystem.
- Secure Signing: Advanced cryptographic operations without private key exposure
- Solana Integration: Full compatibility with Solana's
Signerinterface - WASM Optimization: High-performance ed25519_tss_wasm with automatic tweetnacl fallback
- Transaction Utilities: Ready-to-use functions for common Solana operations
- 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
npm install solana-mpc-tss-lib
# or
yarn add solana-mpc-tss-libimport { 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);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]);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
);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 transactionImplements 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 transactionsWallet 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// MPC operations
createMPCSigner() // Create new MPC signer
createMPCSignerFromSecretKey(bytes) // From existing secret
// Solana utilities
createTransferTx(connection, from, to, amount) // Create transfer transactionThe 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;
}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 libraryTest Coverage:
- β MPC signing operations (12 tests)
- β TSS workflow end-to-end (18 tests)
- β Error handling and edge cases
- β Network integration (mocked)
- β TypeScript compilation
# 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- 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 | RPC Endpoint | Features |
|---|---|---|
| mainnet-beta | Solana mainnet | Production transactions |
| devnet | Solana devnet | Development + airdrops |
| testnet | Solana testnet | Testing + airdrops |
- User Guide - Comprehensive usage examples
- API Documentation - Full API reference
- Examples - Working code examples
- Changelog - Version history
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 |
- Bundle Size: ~24KB (CJS) / ~22KB (ESM)
- Dependencies: @solana/web3.js, tweetnacl
- Node.js: >=16.0.0
- License: MIT
- Repository: GitHub
- Bug Reports: GitHub Issues
- Feature Requests: GitHub Discussions
- Documentation: User Guide
MIT License - see LICENSE file for details.