@kshan0515/cggmp-node-binding
v0.1.6
Published
Node.js native binding for CGGMP24 MPC ECDSA protocol - Distributed key generation and threshold signing
Maintainers
Readme
cggmp-node-binding
Node.js native binding for CGGMP24 MPC ECDSA protocol - Distributed key generation and threshold signing without exposing private keys.
Based on cggmp21 Rust implementation.
Features
- Distributed Key Generation (DKG): Generate ECDSA key shares across multiple parties
- Threshold Signing: Sign messages with a subset of parties (t-of-n)
- Auxiliary Info Generation: Generate pre-computation data for efficient signing
- State Machine API: Round-based protocol execution with
CggmpExecutor - Cross-platform: Pre-built binaries for macOS, Linux, and Windows
Installation
npm install @kshan0515/cggmp-node-binding
# or
pnpm add @kshan0515/cggmp-node-binding
# or
yarn add @kshan0515/cggmp-node-bindingSupported Platforms
| Platform | Architecture | |----------|-------------| | macOS | x64, arm64 (Apple Silicon) | | Linux | x64 (glibc, musl), arm64 (glibc) | | Windows | x64 |
Usage
import { CggmpExecutor, generatePrimes } from '@kshan0515/cggmp-node-binding';
// Create executor for party 0 in a 2-of-3 threshold setup
const executor = new CggmpExecutor(
'session-id',
'execution-id',
0, // party index
2, // threshold
3 // total parties
);
// Start auxiliary info generation
executor.startAuxGen();
// Process protocol rounds
const outgoing = executor.step([]);
// ... exchange messages with other parties ...
// Check status
const snapshot = JSON.parse(executor.snapshot());
console.log(snapshot.status);
// After aux gen, start keygen
executor.startKeygen();
// ... continue processing rounds ...
// After keygen, export key share
const keyShare = executor.exportKeyshare();
// For signing, import key share and start signing
executor.importKeyshare(keyShare);
executor.setSigners('[0, 1]'); // Select signers
executor.startSigning('0x...'); // Message hash (32 bytes hex)API
CggmpExecutor
Main class for MPC protocol execution.
Constructor
new CggmpExecutor(
sessionId: string,
executionId: string,
partyIndex: number,
threshold: number,
partiesCount: number
)Methods
| Method | Description |
|--------|-------------|
| startAuxGen() | Start auxiliary info generation |
| startAuxGenWithPrimes(primes: Buffer) | Start aux gen with pre-generated primes |
| startKeygen() | Start distributed key generation |
| startSigning(txHex: string) | Start signing (32-byte hash as hex) |
| step(inputs: Buffer[]): Buffer[] | Process incoming messages and return outgoing |
| snapshot(): string | Get current state as JSON |
| setSigners(json: string) | Set signer indices for signing |
| importKeyshare(data: Buffer) | Import key share |
| exportKeyshare(): Buffer | Export key share |
| importAuxInfo(data: Buffer) | Import auxiliary info |
| exportAuxInfo(): Buffer | Export auxiliary info |
generatePrimes(): Buffer
Pre-generate safe primes for faster auxiliary info generation.
Protocol Flow
- Auxiliary Info Generation: Generate Paillier keys and ring-Pedersen parameters
- Key Generation: Generate ECDSA key shares using VSS
- Signing: Create threshold signatures with selected signers
Building from Source
Requirements:
- Node.js >= 18
- Rust (stable)
- pnpm
# Install dependencies
pnpm install
# Build native binary
pnpm build
# Run tests
pnpm testSecurity
This library implements the CGGMP24 protocol which provides:
- UC-secure key generation
- Identifiable abort in case of malicious behavior
- Threshold security (t-of-n)
Warning: This is a cryptographic library. Use with caution in production environments.
License
MIT
