Skip to content

Commit 082997d

Browse files
committed
revise backup files
1 parent e466d90 commit 082997d

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ If you have a registered operator, you should already have a private key with yo
1717
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.
1818

1919
### Backup your key
20-
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.
20+
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`.

‎dkg/entrypoint.sh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ DKG_OUTPUT_DIR=${DKG_DATA_DIR}/output
66
DKG_CERT_DIR=${DKG_DATA_DIR}/ssl
77

88
PRIVATE_KEY_FILE=${OPERATOR_CONFIG_DIR}/encrypted_private_key.json
9-
PRIVATE_KEY_PASSWORD_FILE=${OPERATOR_CONFIG_DIR}/password.txt
10-
OPERATOR_ID_FILE=/data/dkg/operator_id.txt
9+
PRIVATE_KEY_PASSWORD_FILE=${OPERATOR_CONFIG_DIR}/private_key_password
10+
OPERATOR_ID_FILE=${OPERATOR_CONFIG_DIR}/operator_id.txt
1111
DKG_CONFIG_FILE=${DKG_CONFIG_DIR}/dkg-config.yml
1212
DKG_LOG_FILE=${DKG_LOGS_DIR}/dkg.log
1313

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

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

6667
# If the PUBLIC_KEY is empty, try extracting using the '.publicKey' field (for previous SSV versions)
6768
if [ -z "$PUBLIC_KEY" ] || [ "$PUBLIC_KEY" = "null" ]; then

‎operator/entrypoint.sh‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ EXECUTION_RPC=$(get_execution_rpc_api_url_from_global_env "$NETWORK")
99
EXECUTION_WS=$(get_execution_ws_url_from_global_env "$NETWORK")
1010
BEACON_NODES=$(get_beacon_api_url_from_global_env "$NETWORK")
1111

12-
PASSWORD_FILE_PATH="/root/keys/password.txt"
12+
PASSWORD_FILE_PATH="/root/keys/private_key_password"
1313
KEY_FILE_PATH="/root/keys/encrypted_private_key.json"
14-
PUBLIC_KEY_FILE_PATH="/root/keys/public_key.txt"
1514
sleep 1
1615

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

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

@@ -37,7 +37,7 @@ post_pubkey_to_dappmanager() {
3737
echo "PUBLIC_KEY=${PUBLIC_KEY}"
3838
}
3939

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

@@ -53,13 +53,6 @@ if [ "${SETUP_MODE}" = "Import Operator" ]; then
5353
echo "[DEBUG] encrypted_private_key.json doesn't exist, restarting"
5454
exit 1
5555
fi
56-
57-
# Extract the public key from the imported encrypted_private_key.json
58-
PUBLIC_KEY=$(jq -r '.pubkey // .pubKey // empty' "$KEY_FILE_PATH")
59-
# Only writing the file when non-empty
60-
if [ -n "$PUBLIC_KEY" ]; then
61-
echo "$PUBLIC_KEY" > "$PUBLIC_KEY_FILE_PATH"
62-
fi
6356
fi
6457

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

0 commit comments

Comments
 (0)