Skip to content

feat(cmd): conversion of PEM-encoded ED25519 node keys#564

Merged
lklimek merged 6 commits intov0.10-devfrom
feat/convert-pem-keys
Feb 2, 2023
Merged

feat(cmd): conversion of PEM-encoded ED25519 node keys#564
lklimek merged 6 commits intov0.10-devfrom
feat/convert-pem-keys

Conversation

@lklimek
Copy link
Collaborator

@lklimek lklimek commented Jan 27, 2023

Issue being fixed or feature implemented

For various key management processes it is useful to be able to use existing ED25519 keys as Tenderdash node keys.
Various tools, like OpenSSL, generate keys in PEM format.
PEM keys need to be converted in order to use in Tenderdash, which uses its own (JSON) key storage format.

What was done?

tenderdash gen-node-key was extended by adding additional flag, --from-pem:

      --from-pem-file string          read PEM-encoded ED25519 private key file (use '-' for stdin)

How Has This Been Tested?

Using OpenSSL, generated ED25519 private key:

openssl genpkey -algorithm ed25519 -out privkey.pem

Generated node ID for this private key:

openssl pkey -in privkey.pem -noout  -text_pub |tail -n +3 | tr -d '[:space:]' | xxd -r -p| sha256sum | head -c 40
ec95355821c3b172455d8ca75898b0d15e9a2de2

Used provided privkey.pem to generate Tenderdash keys, and compare node ID with the one in id field:

go run ./cmd/tenderdash gen-node-key  --from-pem-file /tmp/privkey.pem 
{"id":"ec95355821c3b172455d8ca75898b0d15e9a2de2","priv_key":{"type":"tendermint/PrivKeyEd25519","value":"sku7KdJcQXvzrwTd6ZaCuHB4H2hzZ4ZS0/P7hntW+i42dXcOr+umuF+huhiWG8XxSGEUU+MCFEtUp1iynm/EIw=="}}

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@lklimek lklimek changed the title feat(cmd): conversion of PEM-encoded ed25519 keys feat(cmd): conversion of PEM-encoded node keys Jan 27, 2023
@lklimek lklimek changed the title feat(cmd): conversion of PEM-encoded node keys feat(cmd): conversion of PEM-encoded ED25519 node keys Jan 27, 2023
@lklimek lklimek marked this pull request as ready for review January 30, 2023 13:32
Copy link
Collaborator

@shotonoff shotonoff left a comment

Choose a reason for hiding this comment

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

please, have a look at the questions/comments/suggestions

@lklimek lklimek requested a review from shotonoff February 2, 2023 12:49
shotonoff
shotonoff previously approved these changes Feb 2, 2023
Copy link
Collaborator

@shotonoff shotonoff left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@shotonoff shotonoff left a comment

Choose a reason for hiding this comment

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

🚀

@lklimek lklimek merged commit 1dd71db into v0.10-dev Feb 2, 2023
@lklimek lklimek deleted the feat/convert-pem-keys branch February 2, 2023 13:40
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.

2 participants