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
3 changes: 2 additions & 1 deletion INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ go install ./cmd/mpcium-cli
### Set everything up in one go

```bash
. setup.sh
chmod +x ./setup.sh
./setup.sh
```

Detailed steps can be found in [SETUP.md](SETUP.md).
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all build clean mpcium mpc install test test-verbose test-coverage e2e-test e2e-clean cleanup-test-env
.PHONY: all build clean mpcium mpc install reset test test-verbose test-coverage e2e-test e2e-clean cleanup-test-env

BIN_DIR := bin

Expand Down Expand Up @@ -69,3 +69,15 @@ clean:

# Full clean (including E2E artifacts)
clean-all: clean e2e-clean

# Reset the entire local environment
reset:
@echo "Removing project artifacts..."
rm -rf $(BIN_DIR)
rm -rf node0 node1 node2
rm -rf event_initiator.identity.json event_initiator.key event_initiator.key.age
rm -rf config.yaml peers.json
rm -f coverage.out coverage.html
@echo "Cleaning E2E artifacts..."
- $(MAKE) e2e-clean || true
@echo "Reset completed."
4 changes: 2 additions & 2 deletions setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ cp config.yaml.template config.yaml
echo "🚀 Registering peers to Consul..."
mpcium-cli register-peers

. setup_initiator.sh
. setup_identities.sh
./setup_initiator.sh
./setup_identities.sh
15 changes: 11 additions & 4 deletions setup_identities.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/bin/bash
set -euo pipefail

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

echo "🚀 Setting up Node Identities..."

# Preconditions
command -v mpcium-cli >/dev/null 2>&1 || { echo "❌ mpcium-cli not found in PATH"; exit 1; }
[ -f config.yaml ] || { echo "❌ config.yaml not found in repo root"; exit 1; }
[ -f peers.json ] || { echo "❌ peers.json not found in repo root"; exit 1; }

# Create node directories and copy config files
echo "📁 Creating node directories..."
for i in $(seq 0 $((NUM_NODES-1))); do
Expand All @@ -21,18 +27,19 @@ done
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 ..
( cd "node$i" && mpcium-cli generate-identity --node "node$i" )
done

# Distribute identity files to all nodes
echo "🔄 Distributing identity files across nodes..."
for i in $(seq 0 $((NUM_NODES-1))); do
src="node$i/identity/node${i}_identity.json"
[ -f "$src" ] || { echo "❌ Missing identity file for node$i at $src"; exit 1; }
for j in $(seq 0 $((NUM_NODES-1))); do
if [ $i != $j ]; then
mkdir -p "node$j/identity"
echo "📋 Copying node${i}_identity.json to node$j..."
cp "node$i/identity/node${i}_identity.json" "node$j/identity/"
cp -f "$src" "node$j/identity/"
fi
done
done
Expand Down
25 changes: 12 additions & 13 deletions setup_initiator.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail

echo "🚀 Setting up Event Initiator..."

Expand All @@ -8,25 +9,23 @@ 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"
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
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/event_initiator_pubkey: ./event_initiator_pubkey: "$PUBLIC_KEY"/" config.yaml
# If key exists, replace the whole line; otherwise append a new line
if grep -q "^\s*event_initiator_pubkey:" config.yaml; then
if [[ "${OSTYPE:-}" == darwin* ]]; then
sed -i '' -E "s|^([[:space:]]*event_initiator_pubkey:).*|\1 \"${PUBLIC_KEY}\"|" config.yaml
else
sed -i "s/event_initiator_pubkey: ./event_initiator_pubkey: "$PUBLIC_KEY"/" config.yaml
sed -i -E "s|^([[:space:]]*event_initiator_pubkey:).*|\1 \"${PUBLIC_KEY}\"|" config.yaml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Azzurriii is this compatiblefor both linux and macOS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anhthii It can. Tested on Darwin 24.x ARM. Please see
image

fi
else
# Add new line
echo "event_initiator_pubkey: \"$PUBLIC_KEY\"" >> config.yaml
printf '\n%s\n' "event_initiator_pubkey: \"${PUBLIC_KEY}\"" >> config.yaml
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question @Azzurriii is this compatiblefor both linux and macOS?

echo "✅ Successfully updated config.yaml"
else
Expand Down
Loading