Before starting, ensure you have:
- Go 1.23+ installed: Install Go here
- NATS server running
- Consul server running
git clone https://github.com/fystack/mpcium.git
cd mpciumWith Make:
makeOr with Go:
go install ./cmd/mpcium
go install ./cmd/mpcium-climpcium: Start an MPCium nodempcium-cli: CLI utility for peer, identity, and initiator configuration
⚠️ This setup is insecure and should only be used for development. For production, use a secure cluster environment with TLS certificates.
Create a docker-compose.yaml file:
version: "3"
services:
nats-server:
image: nats:latest
container_name: nats-server
command: -js --http_port 8222
ports:
- "4222:4222"
- "8222:8222"
- "6222:6222"
tty: true
restart: always
consul:
image: consul:1.15.4
container_name: consul
ports:
- "8500:8500"
- "8601:8600/udp"
command: "agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0"
restart: alwaysdocker compose up -dmpcium-cli generate-peers -n 3Example output:
{
"node0": "12345678-1234-1234-1234-123456789abc",
"node1": "23456789-2345-2345-2345-23456789abcd",
"node2": "34567890-3456-3456-3456-3456789abcde"
}cp config.yaml.template config.yamlEdit config.yaml:
nats:
url: nats://127.0.0.1:4222
consul:
address: localhost:8500
mpc_threshold: 2
environment: development
badger_password: "your_badger_password"
event_initiator_pubkey: "your_event_initiator_pubkey"< /dev/urandom tr -dc 'A-Za-z0-9!@#$^&*()-_=+[]{}|;:,.<>?/~' | head -c 16; echoExample:
badger_password: "F))ysJp?E]ol&I;^"mpcium-cli register-peersmpcium-cli generate-initiator💡 Use
--encryptin production.
From event_initiator.identity.json:
{
"public_key": "09be5d070816aadaa1b6638cad33e819a8aed7101626f6bf1e0b427412c3408a"
}Update config.yaml:
event_initiator_pubkey: "09be5d070816aadaa1b6638cad33e819a8aed7101626f6bf1e0b427412c3408a"mkdir node{0..2}
for dir in node{0..2}; do cp config.yaml peers.json "$dir/"; doneExample for node0:
cd node0
mpcium-cli generate-identity --node node0💡 For production, use encryption:
mpcium-cli generate-identity --node node0 --encrypt
< /dev/urandom tr -dc 'A-Za-z0-9!@#$^&*()-_=+[]{}|;:,.<>?/~' | head -c 16; echocp identity/node0_identity.json ../node1/identity/node0_identity.json
cp identity/node0_identity.json ../node2/identity/node0_identity.jsonRepeat this for node1 and node2.
├── node0
│ ├── config.yaml
│ ├── identity
│ │ ├── node0_identity.json
│ │ ├── node0_private.key
│ │ ├── node1_identity.json
│ │ └── node2_identity.json
│ └── peers.json
├── node1
│ ├── config.yaml
│ ├── identity
│ │ ├── node0_identity.json
│ │ ├── node1_identity.json
│ │ ├── node1_private.key
│ │ └── node2_identity.json
│ └── peers.json
├── node2
│ ├── config.yaml
│ ├── identity
│ │ ├── node0_identity.json
│ │ ├── node1_identity.json
│ │ ├── node2_identity.json
│ │ └── node2_private.key
│ └── peers.json
Start each node:
cd node0
mpcium start -n node0cd node1
mpcium start -n node1cd node2
mpcium start -n node2💡 In production, avoid hardcoded passwords:
mpcium start -n node0 --prompt-credentials
- Use production-grade NATS and Consul clusters.
- Enable TLS certificates on all endpoints.
- Encrypt all keys:
mpcium-cli generate-initiator --encrypt mpcium-cli generate-identity --node node0 --encrypt
- Use
--prompt-credentialsto securely input Badger passwords (avoid hardcoding inconfig.yaml).
age --decrypt -o event_initiator.key event_initiator.key.age
