Skip to content

Commit

Permalink
Update Secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
hmzakhalid committed Dec 23, 2024
1 parent 826218f commit cb5bcd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions deploy/copy-secrets.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

set_network_private_key() {
echo "Setting network private key for $1"
jq --arg key "$2" '.network_private_key = $key' "$1.secrets.json" > "$1.secrets.json.tmp" && mv "$1.secrets.json.tmp" "$1.secrets.json"
}

# Set working directory to script location
cd "$(dirname "$0")" || exit 1

Expand All @@ -13,6 +18,7 @@ NC='\033[0m' # No Color

# List of target files
TARGETS=("cn1" "cn2" "cn3" "agg")
NET_KEYS=("0x11a1e500a548b70d88184a1e042900c0ed6c57f8710bcc35dc8c85fa33d3f580" "0x21a1e500a548b70d88184a1e042900c0ed6c57f8710bcc35dc8c85fa33d3f580" "0x31a1e500a548b70d88184a1e042900c0ed6c57f8710bcc35dc8c85fa33d3f580" "0x41a1e500a548b70d88184a1e042900c0ed6c57f8710bcc35dc8c85fa33d3f580")

# Check if source file exists
if [ ! -f "$SOURCE" ]; then
Expand All @@ -26,6 +32,8 @@ for target in "${TARGETS[@]}"; do
echo "Skipping ${target}.secrets.json - file already exists"
else
cp "$SOURCE" "${target}.secrets.json"
set_network_private_key "${target}" "${NET_KEYS[${i:-0}]}"
((i++))
echo "Created ${target}.secrets.json"
fi
done
Expand Down
9 changes: 7 additions & 2 deletions packages/ciphernode/ciphernode-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ fi
# Read secrets from the JSON file
PRIVATE_KEY=$(jq -r '.private_key' "$SECRETS_FILE")
PASSWORD=$(jq -r '.password' "$SECRETS_FILE")
NETWORK_PRIVATE_KEY=$(jq -r '.network_private_key' "$SECRETS_FILE")

if [ -z "$PRIVATE_KEY" ] || [ -z "$PASSWORD" ]; then
echo "Error: Missing 'private_key' or 'password' in secrets file!"
if [ -z "$PRIVATE_KEY" ] || [ -z "$PASSWORD" ] || [ -z "$NETWORK_PRIVATE_KEY" ]; then
echo "Error: Missing 'private_key', 'password' or 'network_private_key' in secrets file!"
exit 1
fi

# Set password and private key
echo "Setting password"
enclave password create --config "$CONFIG_FILE" --password "$PASSWORD"

# Set network private key
echo "Setting network private key"
enclave net set-key --config "$CONFIG_FILE" --net-keypair "$NETWORK_PRIVATE_KEY"

if [ "$AGGREGATOR" = "true" ]; then
echo "Setting private key"
enclave wallet set --config "$CONFIG_FILE" --private-key "$PRIVATE_KEY"
Expand Down

0 comments on commit cb5bcd7

Please sign in to comment.