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

Implement Key Management and Storage for Stacks Blockchain Provider #319

Open
CyrusVorwald opened this issue Jul 29, 2024 · 0 comments
Open
Assignees

Comments

@CyrusVorwald
Copy link

We need to develop secure key management and storage capabilities for the Stacks blockchain provider. This includes implementing methods for creating, restoring, and importing keystores, as well as handling encryption and decryption of keystore data using our KMS.

Implement RestoreKeystore()

This method should:

  • Read the encrypted keystore file from the appropriate path
  • Decrypt the keystore data using the KMS
  • Read and decrypt the associated password file
  • Use the decrypted data to create a Stacks wallet object
  • Set the wallet object in the provider

func (p *Provider) RestoreKeystore(ctx context.Context) error

Implement NewKeystore()

This method should:

  • Generate a new Stacks private key
  • Create a keystore file with the generated key
  • Encrypt the keystore file and password using the KMS
  • Save the encrypted keystore and password files
  • Return the address associated with the new keystore

func (p *Provider) NewKeystore(password string) (string, error)

Implement ImportKeystore()

This method should:

  • Read the keystore file from the provided path
  • Decrypt the keystore using the provided passphrase
  • Encrypt the keystore and passphrase using the KMS
  • Save the encrypted keystore and passphrase files
  • Return the address associated with the imported keystore

func (p *Provider) ImportKeystore(ctx context.Context, keyPath, passphrase string) (string, error)

Implement keystorePath()

This method should return the appropriate file path for storing keystore files.

func (p *Provider) keystorePath(addr string) string

Implement Init() in the Stacks provider.go

func (p *Provider) Init(ctx context.Context, homeDir string, kms kms.KMS) error {
    p.kms = kms
    return nil
}

Acceptance Criteria

  • All keystore-related methods (RestoreKeystore, NewKeystore, ImportKeystore) are implemented and working correctly for Stacks
  • Keystore files are properly encrypted when saved and decrypted when read
  • The KMS is correctly utilized for encrypting and decrypting sensitive data
  • Unit tests cover all methods and edge cases with >80% code coverage
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

No branches or pull requests

1 participant