Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions setup_identities.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Number of nodes to create (default is 3)
NUM_NODES=3

echo "🚀 Setting up Node Identities..."

# Create node directories and copy config files
echo "📁 Creating node directories..."
for i in $(seq 0 $((NUM_NODES-1))); do
mkdir -p "node$i/identity"
if [ ! -f "node$i/config.yaml" ]; then
cp config.yaml "node$i/"
fi
if [ ! -f "node$i/peers.json" ]; then
cp peers.json "node$i/"
fi
done

# Generate identity for each node
echo "🔑 Generating identities for each node..."
for i in $(seq 0 $((NUM_NODES-1))); do
echo "📝 Generating identity for node$i..."
cd "node$i"
mpcium-cli generate-identity --node "node$i"
cd ..
done

# Distribute identity files to all nodes
echo "🔄 Distributing identity files across nodes..."
for i in $(seq 0 $((NUM_NODES-1))); do
for j in $(seq 0 $((NUM_NODES-1))); do
if [ $i != $j ]; then
echo "📋 Copying node${i}_identity.json to node$j..."
cp "node$i/identity/node${i}_identity.json" "node$j/identity/"
fi
done
done

echo "✨ Node identities setup complete!"
echo
echo "📂 Created folder structure:"
echo "├── node0"
echo "│ ├── config.yaml"
echo "│ ├── identity/"
echo "│ └── peers.json"
echo "├── node1"
echo "│ ├── config.yaml"
echo "│ ├── identity/"
echo "│ └── peers.json"
echo "└── node2"
echo " ├── config.yaml"
echo " ├── identity/"
echo " └── peers.json"
echo
echo "✅ You can now start your nodes with:"
echo "cd node0 && mpcium start -n node0"
echo "cd node1 && mpcium start -n node1"
echo "cd node2 && mpcium start -n node2"
41 changes: 41 additions & 0 deletions setup_initiator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

echo "🚀 Setting up Event Initiator..."

# Generate the event initiator
echo "📝 Generating event initiator..."
mpcium-cli generate-initiator

# Extract the public key from the generated file
if [ -f "event_initiator.identity.json" ]; then
PUBLIC_KEY=$(grep -o '"public_key": *"[^"]*"' event_initiator.identity.json | cut -d'"' -f4)

if [ -n "$PUBLIC_KEY" ]; then
echo "🔑 Found public key: $PUBLIC_KEY"

# Update config.yaml
if [ -f "config.yaml" ]; then
echo "📝 Updating config.yaml..."
# Check if event_initiator_pubkey already exists
if grep -q "event_initiator_pubkey:" config.yaml; then
# Replace existing line
sed -i "s/event_initiator_pubkey: .*/event_initiator_pubkey: \"$PUBLIC_KEY\"/" config.yaml
else
# Add new line
echo "event_initiator_pubkey: \"$PUBLIC_KEY\"" >> config.yaml
fi
echo "✅ Successfully updated config.yaml"
else
echo "❌ Error: config.yaml not found. Please create it first."
exit 1
fi
else
echo "❌ Error: Could not extract public key from event_initiator.identity.json"
exit 1
fi
else
echo "❌ Error: event_initiator.identity.json not found"
exit 1
fi

echo "✨ Event Initiator setup complete!"
Loading