# Encrypting pool files using cntools question

**URL:** <https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697>\
**Category:** Stake Pool Security\
**Created:** [28 October 2022 22:52 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697 "2022-10-28T22:52:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mo-moc](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/mo-moc/32/49129_2.png) [@mo-moc](https://forum.cardano.org/u/mo-moc)\
**Post date:** [28 October 2022 22:52 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/1 "2022-10-28T22:52:00Z")

</div>

Hi There,  
Would a block producer generate blocks successfully if pool files are encrypted and protected using cntools command line interface?

When the pool shows as encrypted on cntools, all files are read-only (400) and cold.skey file is encrypted. Would this be Ok to produce blocks?

Thanks,  
Mil

---

<div class="post-metadata">

**Author:** ![georgem1976](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/georgem1976/32/38471_2.png) [@georgem1976](https://forum.cardano.org/u/georgem1976)\
**Post date:** [29 October 2022 08:02 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/2 "2022-10-29T08:02:46Z")

</div>

I am not using cntools, but you don’t need the cold key on the block producer, so I assume it is fine. But I still don’t understand why cold.skey is there, it should only be on the cold machine, it should never be on a server. I assume it is there for commodity when rotating the kes keys and the operational certificate.  
The read-only files are ok (400) if they belong to the user running the `cnode` service. It is even better to be read-only and only readable by that user.

---

<div class="post-metadata">

**Author:** ![mo-moc](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/mo-moc/32/49129_2.png) [@mo-moc](https://forum.cardano.org/u/mo-moc)\
**Post date:** [29 October 2022 13:49 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/3 "2022-10-29T13:49:51Z")

</div>

As far I understand you do need the cold key to rotate the kes keys, so it makes sense your explanation.

What about the counter file? Read-only wont allow cntools to change the counter. I assume that it should not be read-only.

Thanks for the response

---

<div class="post-metadata">

**Author:** ![Alexd1985](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/alexd1985/32/23759_2.png) [@Alexd1985](https://forum.cardano.org/u/Alexd1985)\
**Post date:** [29 October 2022 20:47 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/4 "2022-10-29T20:47:40Z")

</div>

Before to renew u will need to decrypt the files

Make a copy before to encrypt the files because if u will forget the password …

---

<div class="post-metadata">

**Author:** ![mo-moc](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/mo-moc/32/49129_2.png) [@mo-moc](https://forum.cardano.org/u/mo-moc)\
**Post date:** [29 October 2022 23:48 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/5 "2022-10-29T23:48:33Z")

</div>

Thanks. Makes sense.

---

<div class="post-metadata">

**Author:** ![Terminada](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/terminada/32/80229_2.png) [@Terminada](https://forum.cardano.org/u/Terminada)\
**Post date:** [30 October 2022 00:37 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/6 "2022-10-30T00:37:37Z")

</div>

@Alexd1985 Does cntools software encrypt the cold keys and store them on the block producer? In a LUKS encrypted container?

---

<div class="post-metadata">

**Author:** ![mo-moc](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/mo-moc/32/49129_2.png) [@mo-moc](https://forum.cardano.org/u/mo-moc)\
**Post date:** [30 October 2022 00:48 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/7 "2022-10-30T00:48:18Z")

</div>

It deletes the cold.skey pool file and generates cold.skey.gpg encrypted file in the block producer.

---

<div class="post-metadata">

**Author:** ![Terminada](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/terminada/32/80229_2.png) [@Terminada](https://forum.cardano.org/u/Terminada)\
**Post date:** [30 October 2022 01:01 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/8 "2022-10-30T01:01:35Z")

</div>

OK, I see the encryptFile function in the cntools.library that provides this “feature”:

```auto
# Command : encryptFile [file] [password]
# Description : Encrypt file with GPG
# Parameters : file > Path for file to encrypt, will get a new .gpg file extention added to filename
# : password > Password to encrypt file with
encryptFile() {
  exec >&6 2>&7 # normal stdout/stderr
  sleep 0.1
  echo "${2}" | gpg --symmetric --yes --batch --cipher-algo AES256 --passphrase-fd 0 --output "${1}.gpg" "${1}" &>/dev/null && \
  safeDel "${1}" >/dev/null || {
    exec >&8 2>&9 # custom stdout/stderr
    println ERROR "${FG_RED}ERROR${NC}: failed to encrypt ${1}"
    return 1
  }
  exec >&8 2>&9 # custom stdout/stderr
  println DEBUG "${1} successfully encrypted"
}

```

So cntools encourages cold keys to be actually hot and on the same machine!

---

<div class="post-metadata">

**Author:** ![georgem1976](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/georgem1976/32/38471_2.png) [@georgem1976](https://forum.cardano.org/u/georgem1976)\
**Post date:** [30 October 2022 07:40 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/9 "2022-10-30T07:40:37Z")

</div>

Yes, the counter file needs to be read-write before the kes rotation, I assume cntools are making it read-write before generating the operational certificate, then read-only again.  
However, since the Vasil Hard Fork, the counter needs to be exactly 1 more than the counter used when minting the last block (or 0 if the pool never minted a block), and I understand from people using cntools that the counter for the next operational certificate can be given by them when generating it. The counter file can be generated with carano-cli, there is a subcommand for that.

---

<div class="post-metadata">

**Author:** ![mo-moc](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/mo-moc/32/49129_2.png) [@mo-moc](https://forum.cardano.org/u/mo-moc)\
**Post date:** [30 October 2022 11:14 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/10 "2022-10-30T11:14:53Z")

</div>

Can you provide the cardano-cli command to generate a new counter for reference and those not using cntools? Thanks!

---

<div class="post-metadata">

**Author:** ![georgem1976](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/georgem1976/32/38471_2.png) [@georgem1976](https://forum.cardano.org/u/georgem1976)\
**Post date:** [30 October 2022 11:32 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/11 "2022-10-30T11:32:32Z")

</div>

`cardano-cli node new-counter --cold-verification-key-file cold.vkey --counter-value 0 --operational-certificate-issue-counter-file cold.counter`

---

<div class="post-metadata">

**Author:** ![mo-moc](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/mo-moc/32/49129_2.png) [@mo-moc](https://forum.cardano.org/u/mo-moc)\
**Post date:** [30 October 2022 12:16 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/12 "2022-10-30T12:16:26Z")

</div>

–counter-value 0 means current counter?

---

<div class="post-metadata">

**Author:** ![georgem1976](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/georgem1976/32/38471_2.png) [@georgem1976](https://forum.cardano.org/u/georgem1976)\
**Post date:** [30 October 2022 17:28 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/13 "2022-10-30T17:28:30Z")

</div>

No, it means next.

---

<div class="post-metadata">

**Author:** ![Trevor\_Benson](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@Trevor\_Benson](https://forum.cardano.org/u/Trevor_Benson)\
**Post date:** [26 October 2023 23:01 UTC](https://forum.cardano.org/t/encrypting-pool-files-using-cntools-question/109697/14 "2023-10-26T23:01:50Z")

</div>

Just because cntools has a function to encrypt/decrypt does not mean the tools are encouraging cold keys to be on the block producer. For example, the cold keys could be encrypted on an air-gapped machine; unencrypted when KES rotation is required; KES, etc. sneakernet’d back to the block producer.

This is actually described along with a diagram in the guild operators documentation, review the offline workflow for clarification: [Overview - Guild Operators](https://cardano-community.github.io/guild-operators/Scripts/cntools/#offline-workflow)
