# Obol Key Splitting

{% hint style="info" %}
These instructions are used by Ether.fi to split the keys into keyshares for the Obol DVT validators.&#x20;

As a solo staker, you do not need to follow or even understand the steps, but they are provided here for your interest.
{% endhint %}

* [Step 1: Clone the charon repo](#step-1-clone-the-charon-repo)
* [Step 2: Create a directory containing keys to split](#step-2-create-a-directory-containing-keys-to-split)
* [Step 3: Split the keys into keyshares](#step-3-split-the-keys-into-keyshares)

### Step 1: Clone the charon repo

Clone the [charon](https://github.com/ObolNetwork/charon) repo into a new directory called `charon-key-splitter`.

```bash
cd ~
mkdir charon-key-splitter
cd charon-key-splitter
git clone https://github.com/ObolNetwork/charon.git .
mkdir split_keys
```

### Step 2: Create a directory containing keys to split

Copy the existing validator `keystore.json` files into this new folder. Alongside them, with a matching filename but ending with `.txt` should be the password to the keystore. E.g., `keystore-0.json` `keystore-0.txt`. These matching `.txt` files can be generated with a bash script.

At the start of this process, you should have a file tree that looks something like this.

```
├── charon-key-splitter
      ├── split_keys
          ├── keystore-0.json
          ├── keystore-1.json
          ...
          ├── keystore-*.json
```

Create the bash script file.

```bash
cd split_keys
vim generate_txt_files.sh
```

```bash
#!/bin/bash

# Get the input string (password) from the user
echo "Enter the string (password) to be used in all the .txt files:"
read input_string

# Iterate through all .json files in the directory
for file in *.json; do
    # Check if the file is a regular file (not a directory)
    if [[ -f "$file" ]]; then
        # Get the file name without the extension
        filename="${file%.*}"
        # Create a .txt file with the same name and add the input string to it
        echo "$input_string" > "${filename}.txt"
    fi
done
```

Save this script and make it executable.

```bash
chmod +x generate_txt_files.sh
```

Run the script.

```bash
./generate_txt_files.sh
```

At the end of this process, you should have a tree like this.

```
├── split_keys
    ├── keystore-0.json
    ├── keystore-0.txt
    ├── keystore-1.json
    ├── keystore-1.txt
    ...
    ├── keystore-*.json
    ├── keystore-*.txt
```

### Step 3: Split the keys into keyshares

Split the validator keys into keyshares.

```bash
CHARON_VERSION=                # E.g. v0.16.0
NETWORK=                       # E.g. goerli
CLUSTER_NAME=                  # E.g. EtherfiSoloStaker
WITHDRAWAL_ADDRESS=            # Set withdrawal address
FEE_RECIPIENT_ADDRESS=         # Set fee recipient address
THRESHOLD=                     # E.g. 3
NODES=                         # E.g. 4                

docker run --rm -v $(pwd):/opt/charon obolnetwork/charon:${CHARON_VERSION} create cluster --name="${CLUSTER_NAME}" --network="${NETWORK}" --withdrawal-addresses="${WITHDRAWAL_ADDRESS}" --fee-recipient-addresses="${FEE_RECIPIENT_ADDRESS}" --split-existing-keys --split-keys-dir=/opt/charon/split_keys --threshold ${THRESHOLD} --nodes ${NODES}
```

In the `.charon` directory there will now be a `cluster` directory containing sub-directories, each named `node0`, `node1`, etc.

{% hint style="info" %}
**I can't see the `.charon` directory?! 👀**

On most filesystems, files and directories that start with a . are hidden by default.

On a Unix system (Mac or Linux) on the command line you can see hidden files and directories using the `-a` flag for the `ls` command:

<pre><code><strong>ls -la
</strong></code></pre>

{% endhint %}

```
.charon/cluster/
├─ node[0-*]/                   Directory for each node
   ├─ charon-enr-private-key    Charon networking private key for node authentication
   ├─ cluster-lock.json         Cluster lock defines the cluster lock file which is signed by all nodes
   ├─ deposit-data.json         Deposit data file is used to activate a Distributed Validator on DV Launchpad
   ├─ validator_keys            Validator keystores and password
      ├─ keystore-*.json        Validator private share key for duty signing
      ├─ keystore-*.txt         Keystore password files for keystore-*.json
```

Each solo staker participate will receive one of these directories in a compressed format. The exact format depends on the machine being used. The file formats needed for Avado and Dappnode machines are slightly different and are explained below.

{% tabs %}
{% tab title="Avado File Format" %}
Avado requires the files to be uploaded in a `.zip` format.

Make sure you are in the `.charon/cluster/` directory with all the `node*` directories.

For each node directory, compress the folder using the following command:

```bash
zip -r node0.zip node0
```

{% endtab %}

{% tab title="Dappnode File Format" %}
Dappnode requires the files to be uploaded in a `.tar.xz` format.

Make sure you are in the `.charon/cluster/` directory with all the `node*` directories.

For each node directory, compress the folder using the following command:

```bash
tar -cJf node0.tar.xz node0
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://etherfi.gitbook.io/etherfi/solo-stakers/operation-solo-staker/obol-dvt-explained/obol-key-splitting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
