Skip to content

Commit 0ee1edd

Browse files
committed
Add setup_identities, initiator
1 parent 01d4852 commit 0ee1edd

2 files changed

Lines changed: 100 additions & 0 deletions

File tree

setup_identities.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Number of nodes to create (default is 3)
4+
NUM_NODES=3
5+
6+
echo "🚀 Setting up Node Identities..."
7+
8+
# Create node directories and copy config files
9+
echo "📁 Creating node directories..."
10+
for i in $(seq 0 $((NUM_NODES-1))); do
11+
mkdir -p "node$i/identity"
12+
if [ ! -f "node$i/config.yaml" ]; then
13+
cp config.yaml "node$i/"
14+
fi
15+
if [ ! -f "node$i/peers.json" ]; then
16+
cp peers.json "node$i/"
17+
fi
18+
done
19+
20+
# Generate identity for each node
21+
echo "🔑 Generating identities for each node..."
22+
for i in $(seq 0 $((NUM_NODES-1))); do
23+
echo "📝 Generating identity for node$i..."
24+
cd "node$i"
25+
mpcium-cli generate-identity --node "node$i"
26+
cd ..
27+
done
28+
29+
# Distribute identity files to all nodes
30+
echo "🔄 Distributing identity files across nodes..."
31+
for i in $(seq 0 $((NUM_NODES-1))); do
32+
for j in $(seq 0 $((NUM_NODES-1))); do
33+
if [ $i != $j ]; then
34+
echo "📋 Copying node${i}_identity.json to node$j..."
35+
cp "node$i/identity/node${i}_identity.json" "node$j/identity/"
36+
fi
37+
done
38+
done
39+
40+
echo "✨ Node identities setup complete!"
41+
echo
42+
echo "📂 Created folder structure:"
43+
echo "├── node0"
44+
echo "│ ├── config.yaml"
45+
echo "│ ├── identity/"
46+
echo "│ └── peers.json"
47+
echo "├── node1"
48+
echo "│ ├── config.yaml"
49+
echo "│ ├── identity/"
50+
echo "│ └── peers.json"
51+
echo "└── node2"
52+
echo " ├── config.yaml"
53+
echo " ├── identity/"
54+
echo " └── peers.json"
55+
echo
56+
echo "✅ You can now start your nodes with:"
57+
echo "cd node0 && mpcium start -n node0"
58+
echo "cd node1 && mpcium start -n node1"
59+
echo "cd node2 && mpcium start -n node2"

setup_initiator.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
echo "🚀 Setting up Event Initiator..."
4+
5+
# Generate the event initiator
6+
echo "📝 Generating event initiator..."
7+
mpcium-cli generate-initiator
8+
9+
# Extract the public key from the generated file
10+
if [ -f "event_initiator.identity.json" ]; then
11+
PUBLIC_KEY=$(grep -o '"public_key": *"[^"]*"' event_initiator.identity.json | cut -d'"' -f4)
12+
13+
if [ -n "$PUBLIC_KEY" ]; then
14+
echo "🔑 Found public key: $PUBLIC_KEY"
15+
16+
# Update config.yaml
17+
if [ -f "config.yaml" ]; then
18+
echo "📝 Updating config.yaml..."
19+
# Check if event_initiator_pubkey already exists
20+
if grep -q "event_initiator_pubkey:" config.yaml; then
21+
# Replace existing line
22+
sed -i "s/event_initiator_pubkey: .*/event_initiator_pubkey: \"$PUBLIC_KEY\"/" config.yaml
23+
else
24+
# Add new line
25+
echo "event_initiator_pubkey: \"$PUBLIC_KEY\"" >> config.yaml
26+
fi
27+
echo "✅ Successfully updated config.yaml"
28+
else
29+
echo "❌ Error: config.yaml not found. Please create it first."
30+
exit 1
31+
fi
32+
else
33+
echo "❌ Error: Could not extract public key from event_initiator.identity.json"
34+
exit 1
35+
fi
36+
else
37+
echo "❌ Error: event_initiator.identity.json not found"
38+
exit 1
39+
fi
40+
41+
echo "✨ Event Initiator setup complete!"

0 commit comments

Comments
 (0)