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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ If you have a registered operator, you should already have a private key with yo
Anchor will start to run and after a short time, you should see that Anchor will display the operator id on the log. Note that the upload option will only appear once on a fresh install and it can't be modified afterwards without deleting the whole Anchor package.

### Backup your key
There is a `BACKUP` tab in the Anchor package. It enables you to download the Anchor data which includes the public-private key pair. We strongly recommend you to make a backup copy of the key pair. Once you go to the `BACKUP` tab, click on `Download backup`. This will download a compressed file. After extracting the file, under the folder `keys` lies the private key, named `encrpted_private_key.json` and the password text file. You can then backup the private key file with your preferred backup option.
There is a `BACKUP` tab in the Anchor package. It enables you to download the Anchor data which includes the public-private key pair. We strongly recommend you to make a backup copy of the key pair. Once you go to the `BACKUP` tab, click on `Download backup`. This will download a compressed file. After extracting the file, under the folder `keys` lies the private key, named `encrypted_private_key.json` and the password file, named `private_key_password`. Once the operator is registered and the operator id is known to the DKG service, the backup folder also contains `operator_id.txt`.
7 changes: 4 additions & 3 deletions dkg/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ DKG_OUTPUT_DIR=${DKG_DATA_DIR}/output
DKG_CERT_DIR=${DKG_DATA_DIR}/ssl

PRIVATE_KEY_FILE=${OPERATOR_CONFIG_DIR}/encrypted_private_key.json
PRIVATE_KEY_PASSWORD_FILE=${OPERATOR_CONFIG_DIR}/password.txt
OPERATOR_ID_FILE=/data/dkg/operator_id.txt
PRIVATE_KEY_PASSWORD_FILE=${OPERATOR_CONFIG_DIR}/private_key_password
OPERATOR_ID_FILE=${OPERATOR_CONFIG_DIR}/operator_id.txt
DKG_CONFIG_FILE=${DKG_CONFIG_DIR}/dkg-config.yml
DKG_LOG_FILE=${DKG_LOGS_DIR}/dkg.log

Expand Down Expand Up @@ -61,7 +61,8 @@ get_operator_id() {
fetch_operator_id_from_api() {
echo "[INFO] OPERATOR_ID not provided. Fetching OPERATOR_ID from the API..."

PUBLIC_KEY=$(jq -r '.pubKey' "${PRIVATE_KEY_FILE}")
# Anchor generates keys with '.pubkey', SSV with '.pubKey'
PUBLIC_KEY=$(jq -r '.pubkey // .pubKey' "${PRIVATE_KEY_FILE}")

# If the PUBLIC_KEY is empty, try extracting using the '.publicKey' field (for previous SSV versions)
if [ -z "$PUBLIC_KEY" ] || [ "$PUBLIC_KEY" = "null" ]; then
Expand Down
19 changes: 7 additions & 12 deletions operator/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ EXECUTION_RPC=$(get_execution_rpc_api_url_from_global_env "$NETWORK")
EXECUTION_WS=$(get_execution_ws_url_from_global_env "$NETWORK")
BEACON_NODES=$(get_beacon_api_url_from_global_env "$NETWORK")

PASSWORD_FILE_PATH="/root/keys/password.txt"
PASSWORD_FILE_PATH="/root/keys/private_key_password"
KEY_FILE_PATH="/root/keys/encrypted_private_key.json"
PUBLIC_KEY_FILE_PATH="/root/keys/public_key.txt"
sleep 1

post_pubkey_to_dappmanager() {
PUBLIC_KEY=$(cat "$PUBLIC_KEY_FILE_PATH")
# The public key is embedded in the encrypted private key file
PUBLIC_KEY=$(jq -r '.pubkey // .pubKey // empty' "$KEY_FILE_PATH")

if [ -z "$PUBLIC_KEY" ]; then
echo "[ERROR - entrypoint] Public key not found at ${PUBLIC_KEY_FILE_PATH}, skipping Dappmanager post"
echo "[ERROR - entrypoint] Public key not found in ${KEY_FILE_PATH}, skipping Dappmanager post"
return 1
fi

Expand All @@ -37,7 +37,7 @@ post_pubkey_to_dappmanager() {
echo "PUBLIC_KEY=${PUBLIC_KEY}"
}

# If Import Operator, save the EXISTING_PASSWORD to the password.txt at first import
# In Import Operator, save the EXISTING_PASSWORD to the password file at first import
# Later when Anchor is starting it will use --password-file flag to decrypt the private key
if [ "${SETUP_MODE}" = "Import Operator" ]; then

Expand All @@ -53,13 +53,6 @@ if [ "${SETUP_MODE}" = "Import Operator" ]; then
echo "[DEBUG] encrypted_private_key.json doesn't exist, restarting"
exit 1
fi

# Extract the public key from the imported encrypted_private_key.json
PUBLIC_KEY=$(jq -r '.pubkey // .pubKey // empty' "$KEY_FILE_PATH")
# Only writing the file when non-empty
if [ -n "$PUBLIC_KEY" ]; then
echo "$PUBLIC_KEY" > "$PUBLIC_KEY_FILE_PATH"
fi
fi

# If New Operator, generate a new public-private key pair during the first time setup
Expand All @@ -73,6 +66,8 @@ if [ "${SETUP_MODE}" = "New Operator" ]; then
echo "$NEW_PASSWORD" > "$PASSWORD_FILE_PATH"
echo "[INFO - entrypoint] Generating new public-private key pair"
anchor keygen --encrypt --password-file="$PASSWORD_FILE_PATH" --data-dir /root/keys
# keygen also writes public_key.txt, remove it to keep it out of the backup files
rm -f /root/keys/public_key.txt
fi
fi

Expand Down
Loading