Metadata-Version: 2.1
Name: eth-signer
Version: 0.1.8
Summary: A Python library for transection signing using AWS Key Management Service.
Home-page: https://github.com/sejpalkalpesh/eth-signer
Author: Kalpesh Sejpal
Author-email: sejpalkalpesh@gmail.com
License: MIT
Keywords: ethereum AWS KMS,
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.6,<4
Description-Content-Type: text/markdown
Requires-Dist: boto3 (<1.19.0,>=1.18.42)
Requires-Dist: eth-keys (>=0.3.1)
Requires-Dist: eth-typing (<3.0.0,>=2.2.1)
Requires-Dist: eth-utils (<2.0.0,>=1.8.2)
Requires-Dist: eth-account (<2,>=0.5.5eth-rlp>=0.1.2)
Requires-Dist: hexbytes (<1,>=0.1.0)
Requires-Dist: pycryptodome (<4,>=3.6.6)
Provides-Extra: dev
Requires-Dist: Sphinx (<2,>=1.6.5) ; extra == 'dev'
Requires-Dist: bumpversion (==0.5.3) ; extra == 'dev'
Requires-Dist: flake8 (==3.8.3) ; extra == 'dev'
Requires-Dist: isort (<4.3.5,>=4.2.15) ; extra == 'dev'
Requires-Dist: mypy (==0.812) ; extra == 'dev'
Requires-Dist: pytest (==5.4.1) ; extra == 'dev'
Requires-Dist: setuptools (>=38.6.0) ; extra == 'dev'
Requires-Dist: sphinx-rtd-theme (<2,>=0.1.9) ; extra == 'dev'
Requires-Dist: towncrier (<20,>=19.2.0) ; extra == 'dev'
Requires-Dist: tox (>=1.8.0) ; extra == 'dev'
Requires-Dist: twine (<2,>=1.13) ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: Sphinx (<2,>=1.6.5) ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme (<2,>=0.1.9) ; extra == 'docs'
Requires-Dist: towncrier (<20,>=19.2.0) ; extra == 'docs'
Provides-Extra: eth-signer
Requires-Dist: boto3 (<1.19.0,>=1.18.42) ; extra == 'eth-signer'
Requires-Dist: eth-keys (>=0.3.1) ; extra == 'eth-signer'
Requires-Dist: eth-typing (<3.0.0,>=2.2.1) ; extra == 'eth-signer'
Requires-Dist: eth-utils (<2.0.0,>=1.8.2) ; extra == 'eth-signer'
Requires-Dist: eth-account (<2,>=0.5.5eth-rlp>=0.1.2) ; extra == 'eth-signer'
Requires-Dist: hexbytes (<1,>=0.1.0) ; extra == 'eth-signer'
Requires-Dist: pycryptodome (<4,>=3.6.6) ; extra == 'eth-signer'
Provides-Extra: lint
Requires-Dist: flake8 (==3.8.3) ; extra == 'lint'
Requires-Dist: isort (<4.3.5,>=4.2.15) ; extra == 'lint'
Requires-Dist: mypy (==0.812) ; extra == 'lint'
Provides-Extra: test
Requires-Dist: pytest (==5.4.1) ; extra == 'test'

# eth-signer
A Python library for transection signing using AWS Key Management Service.

## Dependencies

- Python 3.6+

## QuickStart

This Package is available on [PyPI](https://pypi.org/project/eth-signer/). Install via pip as:

```sh
  pip install eth-signer
```

## Usage

`eth-signer` needs AWS-KMS Client Object from `boto3` to sign Ethereum transaction or message.

In the following example, the Basic use of `eth-signer` with `boto3` has been given.

Step - 1 :  Install required dependencies 
```bash 
$ pip3 install boto3 eth-signer web3
```
Step - 2 : Create a new key pair using boto3 ( Optional )
```python
import boto3
from eth_signer.signer import AWSKMSKey
from web3 import Web3

# Get a kms_client Object From boto3
kms_client = boto3.client('kms', 'us-east-1')

# Generate new Key Pair using kms_client
new_key = kms.create_key(
    Description='New Eth Key',
    KeyUsage='SIGN_VERIFY',
    KeySpec='ECC_SECG_P256K1',
    Origin='AWS_KMS',
    MultiRegion=False
)

# Use KekId of newly generated key pair for AWSKMSKey Object
key_id = new_key['KeyMetadata']['KeyId']
kms_signer = AWSKMSKey(kms_client, key_id)

web3 = Web3(Web3.HTTPProvider('https://ropsten.infura.io/v3/<PROJECT_ID>'))

# Print Key ID and Eth address
print("KeyId: ", key_id)
print("Eth Address: ", kms_signer.address)
```
Step - 3 : Send a new transaction using web3, boto3 and eth-signer
> Example: Transfer 0.01 ETH from AWS KMS managed Ethereum Account to another Ethereum Account. ( Please, do make you have sufficient balance in Account before executing the example code.)
```python
import boto3
from eth_signer.signer import AWSKMSKey
from web3 import Web3

# Get a kms_client Object From boto3
kms_client = boto3.client('kms', 'us-east-1')

# User a KeyId of the AWS KMS Key
key_id = 'af8929db-010c-4476-00X0-0X00000X00X0'
kms_signer = AWSKMSKey(kms_client, key_id)

web3 = Web3(Web3.HTTPProvider('https://ropsten.infura.io/v3/<PROJECT_ID>'))
nonce = web3.eth.get_transaction_count(kms_signer.address)

print(web3.eth.getBalance(kms_signer.address))
# build a transaction in a dictionary
tx_obj = {
        "nonce": nonce,
        "from": kms_signer.address,
        "to": '0xBe0745cF5b82aB1de6fB1CEd849081BE06d9b3be',
        "value": web3.toWei(0.01, "ether"),
        "gas": 200000,
        "gasPrice": web3.toWei("50", "gwei"),
    }

signed_tx = kms_signer.sign_transaction(tx_obj)
tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction)
```
Output:
`HexBytes('0x826a52e59431a4be8780807cdd09da01d0dbbb00848fd7c9dff8383869c7372c')`

Transaction on [etherscan.io](https://ropsten.etherscan.io/tx/0x826a52e59431a4be8780807cdd09da01d0dbbb00848fd7c9dff8383869c7372c) 
### Features

- Support for Ethereum Transaction and Message Signing using AWS Key Management Service  

### Contributors

* [Kalpesh Sejpal](https://github.com/sejpalkalpesh/)
* [Medium Article from Lucas Henning](https://luhenning.medium.com/the-dark-side-of-the-elliptic-curve-signing-ethereum-transactions-with-aws-kms-in-javascript-83610d9a6f81)

### Runtime dependencies
The distributed eth-signer contains software from the following projects from PyPi:

* eth-utils
* eth-typing
* hexbytes
* eth-rlp
* pycryptodome
* boto3
* flake8
* isort
* mypy
* Sphinx
* sphinx_rtd_theme
* towncrier
* bumpversion
* setuptools
* tox
* twine



