Skip to content

feat(consensus/keys): add consensus keys verify - #1199

Open
leninmehedy wants to merge 1 commit into
01167-consensus-keys-import-exportfrom
01168-consensus-keys-verify
Open

leninmehedy wants to merge 1 commit into
01167-consensus-keys-import-exportfrom
01168-consensus-keys-verify

Conversation

@leninmehedy

@leninmehedy leninmehedy commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Fourth PR in the stacked series for epic #1164 — Consensus Node Key & Secret Management. Stacked on #1198 (base branch 01167-consensus-keys-import-export).

Adds the verify verb: validate that a node's key material is well-formed, from a folder or from the cluster.

What's in it

  • internal/consensus/keys — VerifyDir and VerifyCluster produce a per-key VerifyReport. Checks:
    • private keys and certificates parse as enhanced PEM;
    • each certificate's public key matches its private key (gossip + gRPC);
    • the gossip signing key is RSA-3072;
    • the admin public key is a valid Ed25519 (32-byte) or secp256k1 (33-byte compressed) key. In a folder with no selector, admin.pub is checked only when it exists. The admin private key is never read (it stays in the wallet).
  • --from-cluster finds each secret by its labels (not a fixed name), reports several generations or a name/content mismatch as a failed finding, and takes --fingerprint / --secret-suffix to choose one.
  • --from-cluster reads the admin secret as raw bytes (see feat(consensus/keys): add keys import and keys export #1198) and flags a secret that holds hex text instead.
  • consensus keys verify — --keys-dir <dir> or --from-cluster --node-id N (mutually exclusive); --gossip/--tls/--admin selectors. Prints a per-key report and exits non-zero on any failure.

Files

File Purpose
internal/consensus/keys/verify.go VerifyDir/VerifyCluster, Finding/VerifyReport, cert↔key checks and admin public key validation
internal/consensus/keys/verify_test.go orchestration tests (valid, secp256k1 admin key, tampered cert, corrupt PEM, missing)
cmd/cli/commands/consensus/keys/verify.go verify subcommand
cmd/cli/commands/consensus/keys/verify_test.go command tests
cmd/cli/commands/consensus/keys/keys.go wire verify
docs/commands/consensus.md verify section

Testing

Validated in the UTM VM:

go test -race -cover ./internal/consensus/keys/... ./cmd/cli/commands/consensus/keys/...

All pass.

Update: admin key generation was removed from the stack, so the VM run above predates that change. Unit tests pass on macOS for the touched packages; a VM run is still needed.

Closes #1168.

@leninmehedy
leninmehedy requested a review from a team as a code owner September 26, 2026 13:42
@swirlds-automation

swirlds-automation commented Sep 26, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 1b40107 to 60deba8 Compare September 26, 2026 13:50
@leninmehedy leninmehedy changed the title feat(consensus/keys): add consensus node keys verify feat(consensus/keys): add consensus keys verify Sep 26, 2026
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 60deba8 to 236cbf4 Compare September 26, 2026 14:16
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 236cbf4 to c944b87 Compare September 26, 2026 14:28
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from c944b87 to b9ce53a Compare September 26, 2026 14:41
@leninmehedy
leninmehedy added this pull request to stack #1201 September 26, 2026 14:44
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from b9ce53a to 95c9a60 Compare September 29, 2026 05:12
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 95c9a60 to 18d3875 Compare October 13, 2026 06:27
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 18d3875 to 15a97e0 Compare October 13, 2026 10:33
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 15a97e0 to 13d22b9 Compare October 13, 2026 11:05
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 13d22b9 to 0acdc49 Compare October 13, 2026 11:29
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 0acdc49 to f24a8b1 Compare October 13, 2026 12:37
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from f24a8b1 to a50f972 Compare October 13, 2026 12:52
@leninmehedy
leninmehedy marked this pull request as draft October 20, 2026 06:24
@leninmehedy leninmehedy added the skip-kvm-runner Skip kvm-runner jobs (UAT, integration) in PR checks; for stacked PRs below the top label Oct 21, 2026
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from a50f972 to 9c33db0 Compare October 21, 2026 03:38
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 9c33db0 to 13fb6db Compare October 21, 2026 04:44
@leninmehedy
leninmehedy force-pushed the 01168-consensus-keys-verify branch from 13fb6db to 32a245c Compare October 21, 2026 05:19
Add the verify verb over the #1165 parse helpers and #1167 secret
reader. Validate key material from a folder (--from) or from the cluster
(--from-cluster --node-id):

- private keys and certificates parse as enhanced PEM;
- each certificate's public key matches its private key (gossip + gRPC);
- the gossip signing key is RSA-3072;
- the admin public key (supplied by the operator from an external wallet)
  is a valid Ed25519 or secp256k1 key; in a folder with no selector it is
  checked only when admin.pub exists.

Prints a per-key report and exits non-zero on any failure. Selectors
--gossip/--tls/--admin choose which key types to check.

Refs #1168

Signed-off-by: Lenin Mehedy <lenin.mehedy@hashgraph.com>
@radkomih
radkomih force-pushed the 01168-consensus-keys-verify branch from 32a245c to 39f3b56 Compare November 4, 2026 12:45
@radkomih
radkomih marked this pull request as ready for review November 4, 2026 13:06
@radkomih
radkomih requested review from a team as code owners November 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-kvm-runner Skip kvm-runner jobs (UAT, integration) in PR checks; for stacked PRs below the top

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(consensus/keys): 'consensus node keys verify' command

2 participants