Skip to content

Conversation

@0xHansLee
Copy link
Contributor

@0xHansLee 0xHansLee commented Feb 28, 2025

Support validator priv key encryption.

Updated

init command

Operators can encrypt the newly generated private key with --encrypt-priv-key flag. Without this flag, no encryption is done for private key as before. The encrypted file is stored under story/config/enc_priv_key.json.

For all validator CLI, the private key is retrieved from the encrypted private key file by decrypting it if the enc_priv_key.json file exists. Otherwise, it is retrieved from .env file.

Added

encrypt command

To support the existing operators (using not encrypted key), one command is also added to encrypt the existing private key in .env file: ./story key encrypt. It will generate the encrypted private key file under story/config/enc_priv_key.json.

show command

Also, introduced a new command to decrypt and show the encrypted key: ./story key show-encrypted. With --show-private flag, user can show the private key.

issue: #151

@0xHansLee 0xHansLee changed the title Hans/enc priv key feat(cli): add to encrypt priv key Feb 28, 2025
@0xHansLee 0xHansLee marked this pull request as ready for review February 28, 2025 07:26
"github.com/piplabs/story/lib/tracer"

// Used for ABI embedding of the staking contract.
_ "embed"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is generated by detect-secrets to detect leakage of secrets.
This file lists the secrets detected in our codebase. There are no actual secrets in this PR, but detect-secrets detects some codes as secret, so added to those in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updates are needed for false-positive secret keys to pass PR checks.

@0xHansLee 0xHansLee self-assigned this Mar 4, 2025
// ValidatePasswordInput validates a strong password input for new accounts,
// including a min length.
func ValidatePasswordInput(input string) error {
if len(input) < minPasswordLength {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do more weak criteria, e.g. at least one number.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. This validation is the same one from Prysm. We could add more.

@0xHansLee 0xHansLee requested a review from ramtinms March 11, 2025 06:43
Copy link

@ramtinms ramtinms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks great

@0xHansLee 0xHansLee merged commit e045276 into main Mar 12, 2025
12 checks passed
@0xHansLee 0xHansLee deleted the hans/enc-priv-key branch March 12, 2025 10:52
@github-actions
Copy link

Binary uploaded successfully 🎉

📦 Version Name: 1.1.2-unstable-e045276
📦 Download Source: AWS S3

kim201212 pushed a commit to dsrvlabs/story that referenced this pull request Jul 22, 2025
Support validator priv key encryption. 

## Updated

### `init` command

Operators can encrypt the newly generated private key with
`--encrypt-priv-key` flag. Without this flag, no encryption is done for
private key as before. The encrypted file is stored under
`story/config/enc_priv_key.json`.

For all validator CLI, the private key is retrieved from the encrypted
private key file by decrypting it if the `enc_priv_key.json` file
exists. Otherwise, it is retrieved from `.env` file.

## Added

### `encrypt` command 

To support the existing operators (using not encrypted key), one command
is also added to encrypt the existing private key in `.env` file:
`./story key encrypt`. It will generate the encrypted private key file
under `story/config/enc_priv_key.json`.

### `show` command

Also, introduced a new command to decrypt and show the encrypted key:
`./story key show-encrypted`. With `--show-private` flag, user can show
the private key.

issue: piplabs#151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants