Skip to main content

Flexible Ethereum key management and signing library supporting local and external backends.

Project description

eth-hub - Ethereum Key Management Toolkit

CI/CD pre-commit

PyPI Version PyPI - Status

Python Versions License

A secure abstraction layer for managing Ethereum keys across different storage backends.

Key Features

🔐 Secure Key Management

  • Unified interface for multiple key storage providers
  • Never exposes private keys outside secure environments
  • Will support both software and hardware security modules

📜 Complete Signing Capabilities

  • Transaction signing
  • Message signing (EIP-191 compatible)
  • Hash signing
  • Consistent signature output format

Core Architecture

from eth_hub import (
    BaseKeyStore,  # Abstract base class
    AwsKeyStore,  # AWS KMS implementation
    LocalKeyStore  # In-memory implementation
)

BaseKeyStore (ABC)

The abstract base class defining all key operations:

class BaseKeyStore(ABC):
    @abstractmethod
    def import_key(self, private_key: bytes) -> BaseKey: ...

    @abstractmethod
    def create_key(self) -> BaseKey: ...

    @abstractmethod
    def get_key(self, key_id: UUID) -> BaseKey: ...

    @abstractmethod
    def list_keys(self) -> Sequence[BaseKey]: ...

    @abstractmethod
    def remove_key(self, key_id: UUID) -> None: ...

    @abstractmethod
    def sign_hash(self, key_id: UUID, hash_: bytes) -> SignatureInfo: ...

    @abstractmethod
    def sign_message(self, key_id: UUID, message: SignableMessage) -> SignatureInfo: ...

    @abstractmethod
    def sign_transaction(self, key_id: UUID, transaction_data: dict[str, Any]) -> SignatureInfo: ...

Current Implementations

1. AWS KMS KeyStore

  • Keys never leave AWS KMS
  • All signing operations performed within KMS
  • Supports both imported and KMS-generated keys

2. LocalKeyStore (Memory)

  • In-memory key storage for development/testing
  • Simulates same interface as other stores
  • Useful for CI/CD pipelines and local testing

3. HashiCorp Vaul - WiP

Installation

pip install eth-hub

Aws usage case

If you want to use your own key material, you can import it into AWS KMS. Otherwise, create a new KMS key for Ethereum signing.

web3_rpc = "..."
web3 = Web3(Web3.HTTPProvider(web3_rpc))

key_storage = AwsKeyStore(boto3.client("kms"))

# import your private key to KMS
key = key_storage.import_key(private_key="...")

# or create new one by KMS:
key = key_storage.create_key()

Sign and send transaction:

web3_rpc = "..."
web3 = Web3(Web3.HTTPProvider(web3_rpc))

key_id = "..."
key_storage = AwsKeyStore(boto3.client("kms"))
key = key_storage.get_key(key_id)
user_address = Web3.to_checksum_address(key.address.hex())

abi = [...]
contract_address = Web3.to_checksum_address(contract_address)
contract = web3.eth.contract(address=contract_address, abi=abi)
nonce = web3.eth.get_transaction_count(user_address)
transaction_dict = contract.functions.foo.build_transaction({"nonce": nonce})

unsigned_transaction = TypedTransaction.from_dict(transaction_dict)
signature = key_storage.sign_hash(key_id, unsigned_transaction.hash())

signed_transaction = TypedTransaction.from_dict(
    {**transaction_dict, "v": signature.v, "r": signature.r, "s": signature.s}
)

tx_hash = web3.eth.send_raw_transaction(encoded_tx.encode())

The private key never leaves AWS KMS. Signing is performed inside KMS, and only the signature is returned to your application.

Planned Features:

  • Integration with HashiCorp Vault's

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eth_hub-1.0.1.tar.gz (59.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eth_hub-1.0.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file eth_hub-1.0.1.tar.gz.

File metadata

  • Download URL: eth_hub-1.0.1.tar.gz
  • Upload date:
  • Size: 59.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.3

File hashes

Hashes for eth_hub-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3b03a9e9b6b631c963ddf7b89c37c187a18efbc39bdbbf0b4538a4067df425ee
MD5 b940b5da91da250d962ef8bd0e814a70
BLAKE2b-256 162f7df2e35f2f07ce05a8f910dc8ad7c64935a78c746901e7e961c3ad1afa21

See more details on using hashes here.

File details

Details for the file eth_hub-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: eth_hub-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.3

File hashes

Hashes for eth_hub-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d9a114b15bcc4f12ba5702e602c9d3b3f633e8c26c9329e8207044003744e78
MD5 6ac274686c72b106959fef6e9c57c0ec
BLAKE2b-256 481b51c9c015c9f5f562bb3057530736475a4a58257d4aa5cceeeddc33d79f31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page