Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use global private key for singing cluster messages. #400

Open
wants to merge 3 commits into
base: feature/relayer-security-cluster
Choose a base branch
from

Conversation

debendraoli
Copy link
Collaborator

@debendraoli debendraoli commented Oct 21, 2024

This pull request introduces several changes to the cmd and relayer packages, focusing on adding cluster mode support, enhancing key management, and updating message signing logic. The most important changes include adding new imports, modifying configurations, and updating key management and message signing functionalities

Breaking Change

Chains are previously stored in a following format: keystore/[nid]/[key]

Now it is `keystore/wallets/[nid]/[key]

This choice is logical because keystore location houses all the keys and we need to differentiate the cluster key and the wallets.

Migration script will be needed for the upgrade.

Summary

Cluster Mode and Configuration Enhancements:

  • cmd/config.go: Introduced ClusterConfig struct to manage cluster mode settings, including methods for enabling, signing messages, and verifying signatures.
  • cmd/appstate.go: Added cluster field to appState struct to store cluster mode configuration.
  • cmd/chains.go: Updated SetClusterMode to use ClusterConfig.Enabled for enabling cluster mode.

Key Management Improvements:

  • cmd/keystore.go: Added generateClusterKey command to generate and encrypt cluster keys, saving them to the keystore.
  • cmd/config.go: Implemented logic in RuntimeConfig to decrypt and set the cluster private key if cluster mode is enabled.

Message Signing Updates:

Directory Structure Adjustments:

  • relayer/chains/evm/keys.go, relayer/chains/icon/keys.go, relayer/chains/steller/keys.go, relayer/chains/sui/keys.go: Updated keystorePath function to include a "wallets" subdirectory for better organization. [1] [2] [3] [4]

These changes collectively enhance the application's support for cluster mode, improve key management and security, and streamline the message signing process.

@debendraoli debendraoli self-assigned this Oct 21, 2024
@debendraoli debendraoli changed the title Add generate cluster private key command feat: generate cluster private key command Oct 21, 2024
@@ -109,5 +109,5 @@ func (p *Provider) ImportKeystore(ctx context.Context, keyPath, passphrase strin

// keystorePath is the path to the keystore file
func (p *Provider) keystorePath(addr string) string {
return path.Join(p.cfg.HomeDir, "keystore", p.NID(), addr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

since we already have NID folder for general wallet key, should we wrap it inside wallet folder as this would mean breaking changes which doesn't seem required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was planning to write a migration script to facilitate the breaking change.

The keystore location seems logical because it houses all the keys inside.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes but is the new "wallet" folder really required ? All the NID folders contains wallet and the new one with cluster identifier contains cluster key.

@debendraoli debendraoli changed the title feat: generate cluster private key command feat: use global private key for singing cluster messages. Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants