rustywallet-multisig
Bitcoin multi-signature wallet utilities with Shamir Secret Sharing.
Features
- M-of-N Multisig - Create 1-of-2 up to 15-of-15 configurations
- Multiple Address Types - P2SH (legacy), P2WSH (native SegWit), P2SH-P2WSH (nested)
- BIP67 Compliance - Automatic lexicographic key sorting
- Partial Signing - Sign with individual keys
- Signature Combination - Combine signatures for broadcast
- Shamir Secret Sharing - Split keys into recoverable shares
Installation
[]
= "0.1"
Quick Start
use *;
use PrivateKey;
// Generate 3 keys
let key1 = random;
let key2 = random;
let key3 = random;
let pubkeys = vec!;
// Create 2-of-3 multisig wallet
let wallet = from_pubkeys.unwrap;
println!; // 3...
println!; // bc1q...
println!; // 3...
Signing Transactions
use ;
// Each party signs with their key
let sig1 = sign_p2sh_multisig.unwrap;
let sig2 = sign_p2sh_multisig.unwrap;
// Combine signatures (need M signatures)
let combined = combine_signatures.unwrap;
// Build scriptSig for P2SH
let script_sig = combined.build_script_sig;
// Or build witness for P2WSH
let witness = combined.build_witness;
Shamir Secret Sharing
Split a private key into shares for secure backup:
use ;
// Split into 5 shares, requiring 3 to recover
let secret = ; // Your private key bytes
let shares = split_secret.unwrap;
// Distribute shares to different locations...
// Later, recover with any 3 shares
let recovered = combine_shares.unwrap;
assert_eq!;
Address Types
| Type | Prefix | Description |
|---|---|---|
| P2SH | 3... (mainnet) |
Legacy multisig |
| P2WSH | bc1q... |
Native SegWit (lower fees) |
| P2SH-P2WSH | 3... |
Nested SegWit (compatibility) |
License
MIT