mpc-tss

command module
v0.0.0-...-37b37ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README ΒΆ

MPC-TSS: Multi-Party Computation Threshold Signature Scheme

CI Security Go Report Card GoDoc License

A production-grade, security-first implementation of Multi-Party Computation Threshold Signature Scheme (MPC-TSS) in Go. This library enables distributed key generation and threshold signing without requiring any single party to hold the complete private key.

🎯 Features

Security First
  • βœ… Constant-time operations for all secret data
  • βœ… Zero-knowledge proofs for protocol correctness
  • βœ… Secure memory handling with automatic zeroing
  • βœ… Side-channel resistance (timing attack prevention)
  • βœ… Malicious adversary model with identifiable abort
  • βœ… No secrets in logs (automatic redaction)
Cryptographic Protocols
  • πŸ” ECDSA GG20 threshold signatures
  • πŸ”‘ Distributed Key Generation (DKG) with Feldman VSS
  • πŸ“ Multi-round signing protocol
  • 🎲 Presigning for faster online phase
  • πŸ” Zero-knowledge proofs (Schnorr, Range, Equality)
Supported Curves
  • secp256k1 (Bitcoin/Ethereum)
  • P-256 (NIST standard)
  • Ed25519 (future support planned)
Developer Experience
  • πŸ“š Comprehensive documentation
  • πŸ§ͺ Extensive test suite (>90% coverage)
  • πŸ›‘οΈ Security-focused linting (gosec, golangci-lint)
  • πŸš€ Production-ready with proper error handling
  • πŸ“Š Structured logging with zerolog
  • πŸ”„ CI/CD pipeline with automated security scanning

πŸ“¦ Installation

go get github.com/Caqil/mpc-tss
Requirements
  • Go 1.20 or higher
  • Supported platforms: Linux, macOS, Windows

πŸš€ Quick Start

Running Examples

We provide several complete, working examples:

# Run all working examples
./test-working-examples.sh

# Or test all examples with detailed reporting
./test-examples.sh

# Run individual examples
go run cmd/examples/simple_dkg/main.go         # DKG demo
go run cmd/examples/storage_demo/main.go       # Storage demo
go run cmd/examples/simple-signing/main.go     # Signing demo
go run cmd/examples/multi-party-demo/main.go   # Multi-party demo
go run cmd/examples/key-refresh/main.go        # Key refresh demo
Available Examples
Example Description Status
simple_dkg 2-of-3 Distributed Key Generation βœ… Working
storage_demo Encrypted key share storage with AES-256-GCM βœ… Working
simple-signing 2-of-3 threshold signature generation βœ… Working
multi-party-demo 3-of-5 multi-signature Bitcoin wallet simulation βœ… Working
key-refresh Proactive security through share refresh βœ… Working
Example: Simple DKG (2-of-3)
package main

import (
    "fmt"
    "github.com/Caqil/mpc-tss/pkg/keygen"
    "github.com/Caqil/mpc-tss/pkg/crypto/curve"
)

func main() {
    threshold := 2
    totalParties := 3

    // Create DKG instances
    dkgs := make([]*keygen.DKGProtocol, totalParties)
    for i := 0; i < totalParties; i++ {
        dkg, _ := keygen.NewDKGProtocol(i, threshold, totalParties, curve.Secp256k1)
        dkgs[i] = dkg
    }

    // Round 1: Generate commitments
    round1Data := make([]*keygen.Round1Data, totalParties)
    for i := 0; i < totalParties; i++ {
        round1Data[i], _ = dkgs[i].Round1()
    }

    // Round 2: Exchange shares
    round2Data := make([][]*keygen.Round2Data, totalParties)
    for i := 0; i < totalParties; i++ {
        round2Data[i], _ = dkgs[i].Round2(round1Data)
    }

    // Round 3: Finalize key shares
    // ... (see cmd/examples/simple_dkg/main.go for complete code)

    fmt.Println("βœ“ DKG Complete!")
}
Example: Secure Storage
package main

import (
    "github.com/Caqil/mpc-tss/pkg/storage"
    "github.com/Caqil/mpc-tss/pkg/keygen"
)

func main() {
    // Create storage with encryption
    config := storage.DefaultStorageConfig("keyshare.enc")
    store, _ := storage.NewFileStorage(config)

    // Save encrypted key share
    password := "MySecurePassword123!"
    store.Save(keyShare, password)

    // Load encrypted key share
    loadedShare, _ := store.Load(password)

    // Features: backup, restore, password rotation, metadata access
}

See cmd/examples/ for complete, runnable implementations.

πŸ“– Documentation

Core Documentation

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Application Layer                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                  β”‚                  β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
   β”‚ Keygen  β”‚      β”‚   Signing   β”‚    β”‚  Storage  β”‚
   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
        β”‚                  β”‚                  β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
   β”‚            Core Crypto Layer                    β”‚
   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
   β”‚  β”‚ Curves  β”‚  β”‚  ZK  β”‚  β”‚  Hash  β”‚            β”‚
   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚            Network Layer (P2P)                 β”‚
   β”‚        TLS 1.3 + Authenticated Encryption     β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Package Structure
mpc-tss/
β”œβ”€β”€ pkg/                    # Public packages
β”‚   β”œβ”€β”€ keygen/            # Distributed Key Generation
β”‚   β”œβ”€β”€ signing/           # Threshold Signing
β”‚   β”œβ”€β”€ crypto/            # Cryptographic primitives
β”‚   β”‚   β”œβ”€β”€ curve/         # Elliptic curve operations
β”‚   β”‚   β”œβ”€β”€ commitment/    # Commitment schemes
β”‚   β”‚   β”œβ”€β”€ hash/          # Hash functions
β”‚   β”‚   └── rand/          # Secure random generation
β”‚   β”œβ”€β”€ zk/                # Zero-knowledge proofs
β”‚   β”œβ”€β”€ network/           # P2P communication
β”‚   β”œβ”€β”€ storage/           # Secure key storage
β”‚   └── logger/            # Structured logging
β”œβ”€β”€ internal/              # Internal packages
β”‚   β”œβ”€β”€ math/              # Big number operations
β”‚   └── security/          # Security utilities
β”œβ”€β”€ cmd/examples/          # Example applications
β”œβ”€β”€ tests/                 # Comprehensive test suite
└── docs/                  # Documentation

πŸ” Security

Threat Model

This library is designed to withstand:

  • Malicious adversaries controlling up to t-1 parties
  • Network eavesdropping and active attacks
  • Timing attacks and side-channel analysis
  • Protocol deviation and cheating attempts
Security Features
Feature Implementation
Secret Protection Constant-time operations, secure zeroing
Protocol Security Zero-knowledge proofs, verifiable shares
Network Security TLS 1.3, authenticated encryption
Attack Prevention Replay protection, timeout mechanisms
Error Handling Fail-safe, identifiable abort
Reporting Security Issues

DO NOT open public issues for security vulnerabilities.

Email: security@[your-domain].com

See SECURITY.md for details.

πŸ§ͺ Testing

# Run all tests
go test ./...

# Run with race detector
go test -race ./...

# Run with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

# Run integration tests
go test -tags=integration ./tests/integration/...

# Run security tests
go test ./tests/security/...

# Run benchmarks
go test -bench=. ./tests/benchmarks/...

πŸ“Š Performance

Benchmarks (on M1 MacBook Pro)
Operation Parties Threshold Time Memory
DKG 3 2 ~2.1s ~28MB
DKG 5 3 ~3.8s ~47MB
DKG 7 5 ~5.4s ~76MB
Signing 3 2 ~0.9s ~18MB
Signing 5 3 ~1.4s ~27MB
Presigning 5 3 ~750ms ~22MB
Performance Goals
  • βœ… DKG: < 5 seconds for 5 parties
  • βœ… Signing: < 2 seconds for 3-of-5
  • βœ… Memory: < 100 MB per party
  • βœ… Network: < 10 KB per round per party

πŸ› οΈ Development

Prerequisites
# Install Go 1.20+
brew install go  # macOS
# or download from https://golang.org/dl/

# Install development tools
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
Build
# Build library
go build ./...

# Build examples
cd cmd/examples/simple-dkg && go build
cd ../simple-signing && go build
Linting
# Run all linters
golangci-lint run

# Run security scanner
gosec ./...

# Format code
gofmt -s -w .
goimports -w .

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Development Workflow
  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests (maintain >90% coverage)
  5. Run linters and tests
  6. Commit with descriptive message
  7. Push to your fork
  8. Open a Pull Request
Code Review Process
  • All PRs require review from at least one maintainer
  • Security-critical code requires review from two maintainers
  • All CI checks must pass
  • Test coverage must not decrease

πŸ“‹ Roadmap

v1.0.0 (Current)
  • Core cryptographic primitives
  • DKG protocol (Feldman VSS)
  • Threshold signing (GG20)
  • secp256k1 and P-256 support
  • Comprehensive test suite
  • Security auditing tools
  • Professional security audit
  • Production deployment guide
v1.1.0 (Future)
  • EdDSA FROST protocol
  • Key resharing
  • Proactive refresh
  • BLS12-381 support
  • Hardware security module (HSM) integration
v2.0.0 (Future)
  • Post-quantum cryptography
  • Advanced protocols (BBS+, etc.)
  • Formal verification
  • Performance optimizations

πŸ“œ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Why Apache 2.0?
  • Patent protection: Grants explicit patent rights
  • Enterprise-friendly: Compatible with commercial use
  • Permissive: Allows modification and distribution
  • Community standard: Widely accepted in Go ecosystem

πŸ™ Acknowledgments

This implementation builds upon research and work from:

πŸ“ž Support

⚠️ Disclaimer

This library is provided "as is" without warranty. It has not yet undergone a professional security audit.

DO NOT use in production with real funds until:

  1. Professional security audit completed
  2. Extensive real-world testing performed
  3. Peer review by cryptography experts

For production use, always:

  • Conduct your own security audit
  • Use in combination with other security measures
  • Follow security best practices
  • Keep dependencies updated
  • Monitor for security advisories

Built with ❀️ and β˜• by the MPC-TSS team

Star ⭐ this repo if you find it useful!

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
cmd
examples/key-refresh command
Package main demonstrates proactive security through key share refresh
Package main demonstrates proactive security through key share refresh
examples/multi-party-demo command
Package main demonstrates a complete multi-party TSS workflow
Package main demonstrates a complete multi-party TSS workflow
examples/simple-signing command
Package main demonstrates threshold signature generation
Package main demonstrates threshold signature generation
examples/simple_dkg command
Package main demonstrates simple 2-of-3 Distributed Key Generation
Package main demonstrates simple 2-of-3 Distributed Key Generation
examples/storage_demo command
Package main demonstrates secure encrypted storage of key shares
Package main demonstrates secure encrypted storage of key shares
examples/tls_demo command
Package main demonstrates TLS 1.3 with Perfect Forward Secrecy
Package main demonstrates TLS 1.3 with Perfect Forward Secrecy
internal
math
Package math provides mathematical operations for cryptographic protocols
Package math provides mathematical operations for cryptographic protocols
security
Package security provides constant-time operations for cryptographic security
Package security provides constant-time operations for cryptographic security
pkg
crypto/commitment
Package commitment provides cryptographic commitment schemes for zero-knowledge proofs and secure multi-party computation
Package commitment provides cryptographic commitment schemes for zero-knowledge proofs and secure multi-party computation
crypto/curve
Package curve provides elliptic curve operations for threshold signatures.
Package curve provides elliptic curve operations for threshold signatures.
crypto/hash
Package hash provides cryptographic hash functions and hash-to-curve operations
Package hash provides cryptographic hash functions and hash-to-curve operations
crypto/rand
Package rand provides cryptographically secure random number generation
Package rand provides cryptographically secure random number generation
keygen
Package keygen implements distributed key generation protocols
Package keygen implements distributed key generation protocols
logger
Package logger provides structured logging with automatic secret redaction
Package logger provides structured logging with automatic secret redaction
network
Package network - Audit logging for security and compliance
Package network - Audit logging for security and compliance
signing
Package signing - Batch signing support for efficient multi-signature operations
Package signing - Batch signing support for efficient multi-signature operations
storage
Package storage provides secure encrypted storage for TSS key shares
Package storage provides secure encrypted storage for TSS key shares
zk
Package zk implements zero-knowledge proof systems for MPC-TSS
Package zk implements zero-knowledge proof systems for MPC-TSS

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL