Skip to content

Conversation

@dartdart26
Copy link
Owner

No description provided.

This commit introduces support for signing transactions using AWS KMS
in the `transaction-sender` application, while retaining the existing
plaintext private key signing functionality.

Key changes:

1.  **Command-Line Interface:**
    *   Added `--aws-kms-key-id` and `--aws-region` command-line arguments.
    *   `--private-key` is now optional.
    *   The application now requires either the private key or both AWS KMS
        parameters to be specified, enforced by `clap` argument groups.

2.  **Signer Abstraction (`DynamicSigner`):**
    *   Introduced a `DynamicSigner` enum that can encapsulate either a
        `PrivateKeySigner` or an `alloy_signer::aws::AwsSigner`.
    *   This enum implements the `alloy_signer::Signer` trait, allowing
        it to be used polymorphically throughout the application.
    *   The `DynamicSigner` definition has been moved to `lib.rs` for
        broader accessibility.

3.  **Application Logic Updates:**
    *   The main binary (`bin/transaction_sender.rs`) now determines which
        signer to instantiate based on the provided CLI arguments.
    *   It fetches the `chain_id` and configures the chosen signer and
        the `EthereumWallet` accordingly.
    *   `TransactionSender` and `VerifyProofOperation` now accept the
        `DynamicSigner` type, replacing the previous hardcoded
        `PrivateKeySigner`.
    *   The `VerifyProofOperation` was updated to use asynchronous
        `sign_hash` from the `Signer` trait.

4.  **Provider Compatibility:**
    *   No changes were required in `NonceManagedProvider`. The generic
        nature of `alloy-rs`'s `ProviderBuilder` and `Filler` traits
        ensures compatibility with `EthereumWallet<DynamicSigner>`.

5.  **Integration Tests:**
    *   Added new integration tests in `tests/kms_integration_tests.rs`.
    *   These tests use `testcontainers` to spin up a LocalStack instance
        emulating AWS KMS.
    *   KMS keys are created on-the-fly within LocalStack for testing.
    *   `rstest` is used to parameterize the tests, ensuring that message
        signing works correctly with both `PrivateKeySigner` and `AwsSigner`
        (communicating with the LocalStack KMS).

This enhancement provides you with a more secure option for managing
your signing keys by leveraging AWS KMS, reducing the need to handle
plaintext private keys directly.
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.

1 participant