@bitshard.io/bitshard-sdk
v0.0.3
Published
BitShard MPC SDK for distributed key generation and threshold signatures
Maintainers
Readme
BitShard SDK
BitShard SDK is a TypeScript library for distributed key generation (DKG) and threshold signatures using the DKLs23 protocol. It enables secure multi-party computation (MPC) wallets with flexible n-of-m threshold configurations.
Features
- Distributed Key Generation: Secure generation of threshold key shares across multiple parties
- Threshold Signatures: Sign transactions with any t-of-n parties
- Multi-Chain Support: Native support for Ethereum, Bitcoin, and EVM-compatible chains
- WebSocket Coordination: Real-time protocol coordination between parties
- Flexible Configuration: Support for any n-of-m threshold scheme
- Pre-signature Management: Secure generation and consumption of pre-signatures
- Address Derivation: Consistent address generation across all supported chains
Installation
npm i @bitshard.io/bitshard-sdkFor browser environments, you'll also need the web WASM module:
npm install @silencelaboratories/dkls-wasm-ll-webQuick Start
Local Testing (All Parties in One Process)
import { BitShardSDK } from '@bitshard.io/bitshard-sdk'
const sdk = new BitShardSDK();
// Create a 2-of-3 threshold wallet locally
const wallet = await sdk.createLocalWallet({
totalParties: 3,
threshold: 2,
partyIds: [0, 1, 2]
});
// Derive addresses
const addresses = sdk.deriveAddresses(wallet.publicKey);
console.log('Ethereum address:', addresses.ethereum);
console.log('Bitcoin address:', addresses.bitcoin);
// Sign a message
const message = 'Hello BitShard!';
const signature = await sdk.personalSign(message, wallet.keyshares, {
threshold: 2,
publicKey: wallet.publicKey
});Distributed Setup (WebSocket Coordination)
// Party 0 (Coordinator)
const party0 = sdk.createParty({
partyId: 0,
totalParties: 3,
threshold: 2,
role: 'coordinator'
});
// Connect to WebSocket server
await party0.connect('ws://localhost:8080/ws');
// Initiate DKG
const session = await party0.initiateDKG();
// Other parties join using session.id
// ... coordinate protocol rounds via WebSocket ...
const keyshare = await party0.finalize();Architecture
The SDK is organized into several modules:
- Core: DKLS protocol implementation and party management
- Crypto: Address derivation and encoding utilities
- Protocols: DKG, signing, and key refresh protocols
- Chains: Multi-chain configuration and transaction handling
- RPC: EIP-1193 compatible RPC methods
- WebSocket: Real-time protocol coordination
Security
⚠️ CRITICAL: Pre-signatures MUST NOT be reused
Reusing pre-signatures will expose your private key. The SDK includes built-in protection against pre-signature reuse, but developers must ensure proper handling in their applications.
Documentation
Examples
See the examples directory for:
- Basic wallet creation
- WebSocket coordination
- Multi-party signing
- Chain-specific transactions
- Docker deployment
License
MIT
Contributing
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
Releasing new version guide
This document describes the standard release process for publishing the @bitshard.io/bitshard-sdk package.
Rule: Always push commits and tags to GitHub before publishing to npm.
Release Steps
1. Commit your changes
git add .
git commit -m "feat: describe your change"2. Bump version and create a Git tag
Patch release example (0.0.1 → 0.0.2):
npm version patchThis will:
- Update
package.json - Create an annotated Git tag (e.g.
v0.0.2)
3. Push commits and tags to GitHub
git push origin main --follow-tagsThis ensures Git is the source of truth before publishing.
4. Build the package
npm run buildVerify:
- Build output exists (e.g.
dist/) package.jsonpoints to built files (main,module,types)
5. Publish to npm
npm publish --access publicScoped packages default to private unless published with
--access publicorpublishConfig.access = "public".
6. Verify release
npm view @bitshard.io/bitshard-sdk version
git tag --listRelease Checklist
- [ ] Changes committed
- [ ] Version bumped via
npm version - [ ] Commits and tags pushed to GitHub
- [ ] Build successful
- [ ] npm publish successful
Notes
- Do not publish to npm without a Git tag
- Ensure you are authenticated with npm using a publish-capable token (2FA-compliant)
- Prefer annotated tags for all releases
Support
For support, please open an issue on GitHub or contact [email protected]
