-
Notifications
You must be signed in to change notification settings - Fork 2
KMS #22
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
Merged
Merged
KMS #22
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ceaa854
Add engine-eip7702-core package and update dependencies
d4mr 509e657
clippy
d4mr 6bcbafc
Update dependencies and implement AWS KMS signing support
d4mr 799a1a8
Enhance AWS KMS integration and error handling
d4mr 638fce6
Update dependencies and enhance signing capabilities
d4mr b8c90b8
remove bad dbg
d4mr e016194
Merge remote-tracking branch 'origin/main' into pb/aws-kms
d4mr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ members = [ | |
"aa-types", | ||
"aa-core", | ||
"core", | ||
"eip7702-core", | ||
"executors", | ||
"server", | ||
"thirdweb-core", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,59 @@ | ||
use alloy::primitives::ChainId; | ||
use alloy_signer_aws::AwsSigner; | ||
use aws_config::{BehaviorVersion, Region}; | ||
use aws_credential_types::provider::future::ProvideCredentials as ProvideCredentialsFuture; | ||
use aws_sdk_kms::config::{Credentials, ProvideCredentials}; | ||
use serde::{Deserialize, Serialize}; | ||
use thirdweb_core::auth::ThirdwebAuth; | ||
use thirdweb_core::iaw::AuthToken; | ||
use vault_types::enclave::auth::Auth; | ||
use vault_types::enclave::auth::Auth as VaultAuth; | ||
|
||
use crate::error::EngineError; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub enum SigningCredential { | ||
Vault(Auth), | ||
Iaw { | ||
auth_token: AuthToken, | ||
thirdweb_auth: ThirdwebAuth | ||
Vault(VaultAuth), | ||
Iaw { | ||
auth_token: AuthToken, | ||
thirdweb_auth: ThirdwebAuth, | ||
}, | ||
AwsKms(AwsKmsCredential), | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct AwsKmsCredential { | ||
pub access_key_id: String, | ||
pub secret_access_key: String, | ||
pub key_id: String, | ||
pub region: String, | ||
} | ||
|
||
impl ProvideCredentials for AwsKmsCredential { | ||
fn provide_credentials<'a>(&'a self) -> ProvideCredentialsFuture<'a> | ||
where | ||
Self: 'a, | ||
{ | ||
let credentials = Credentials::new( | ||
self.access_key_id.clone(), | ||
self.secret_access_key.clone(), | ||
None, | ||
None, | ||
"engine-core", | ||
); | ||
ProvideCredentialsFuture::ready(Ok(credentials)) | ||
} | ||
} | ||
|
||
impl AwsKmsCredential { | ||
pub async fn get_signer(&self, chain_id: Option<ChainId>) -> Result<AwsSigner, EngineError> { | ||
let config = aws_config::defaults(BehaviorVersion::latest()) | ||
.credentials_provider(self.clone()) | ||
.region(Region::new(self.region.clone())) | ||
.load() | ||
.await; | ||
let client = aws_sdk_kms::Client::new(&config); | ||
|
||
let signer = AwsSigner::new(client, self.key_id.clone(), chain_id).await?; | ||
Ok(signer) | ||
} | ||
Comment on lines
+60
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add timeout configuration for AWS operations. AWS SDK operations should have timeout configurations to prevent hanging requests. pub async fn get_signer(&self, chain_id: Option<ChainId>) -> Result<AwsSigner, EngineError> {
let config = aws_config::defaults(BehaviorVersion::latest())
.credentials_provider(self.clone())
.region(Region::new(self.region.clone()))
+ .timeout_config(
+ aws_config::timeout::TimeoutConfig::builder()
+ .operation_timeout(std::time::Duration::from_secs(30))
+ .build()
+ )
.load()
.await;
let client = aws_sdk_kms::Client::new(&config);
let signer = AwsSigner::new(client, self.key_id.clone(), chain_id).await?;
Ok(signer)
} 🤖 Prompt for AI Agents
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
use alloy::primitives::Address; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::defs::AddressDef; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, utoipa::ToSchema)] | ||
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] | ||
#[schema(title = "EIP-7702 Execution Options")] | ||
#[serde(rename_all = "camelCase", untagged)] | ||
pub enum Eip7702ExecutionOptions { | ||
/// Execute the transaction as the owner of the account | ||
Owner(Eip7702OwnerExecution), | ||
/// Execute a transaction on a different delegated account (`account_address`), which has granted a session key to the `session_key_address` | ||
/// `session_key_address` is the signer for this transaction | ||
SessionKey(Eip7702SessionKeyExecution), | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] | ||
#[schema(title = "EIP-7702 Owner Execution")] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Eip7702ExecutionOptions { | ||
/// The EOA address that will sign the EIP-7702 transaction | ||
#[schemars(with = "AddressDef")] | ||
pub struct Eip7702OwnerExecution { | ||
#[schema(value_type = AddressDef)] | ||
/// The delegated EOA address | ||
pub from: Address, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] | ||
#[schema(title = "EIP-7702 Session Key Execution")] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Eip7702SessionKeyExecution { | ||
#[schema(value_type = AddressDef)] | ||
/// The session key address is your server wallet, which has been granted a session key to the `account_address` | ||
pub session_key_address: Address, | ||
#[schema(value_type = AddressDef)] | ||
/// The account address is the address of a delegated account you want to execute the transaction on. This account has granted a session key to the `session_key_address` | ||
pub account_address: Address, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security concern: Storing AWS credentials in memory.
Storing AWS access keys directly in the struct poses security risks. Consider using AWS STS temporary credentials or IAM roles instead of long-lived access keys.
Consider implementing support for:
🤖 Prompt for AI Agents