Skip to content

Commit

Permalink
Update EIP-1191: Fix Implementation Table (#6965)
Browse files Browse the repository at this point in the history
* Update EIP-1191: Fix Implementation Table

* Update EIP-1191: Fix blanks-around-headers lint

* Update EIP-1191: Fix markdown-link-first lints

* Update EIP-1191: Fix blanks-around-fences lint

* Update EIP-1191: Fix blanks-around-lists lint
  • Loading branch information
digiwand authored Sep 20, 2023
1 parent 5c9a797 commit 61397f6
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions EIPS/eip-1191.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@ discussions-to: https://github.com/ethereum/EIPs/issues/1121
---

## Simple Summary
This EIP extends EIP-55 by optionally adding a chain id defined by EIP-155 to the checksum calculation.

This EIP extends [EIP-55](./eip-55.md) by optionally adding a chain id defined by [EIP-155](./eip-155.md) to the checksum calculation.

## Abstract
The EIP-55 was created to prevent users from losing funds by sending them to invalid addresses. This EIP extends EIP-55 to protect users from losing funds by sending them to addresses that are valid but that where obtained from a client of another network.For example, if this EIP is implemented, a wallet can alert the user that is trying to send funds to an Ethereum Testnet address from an Ethereum Mainnet wallet.

The [EIP-55](./eip-55.md) was created to prevent users from losing funds by sending them to invalid addresses. This EIP extends [EIP-55](./eip-55.md) to protect users from losing funds by sending them to addresses that are valid but that where obtained from a client of another network.For example, if this EIP is implemented, a wallet can alert the user that is trying to send funds to an Ethereum Testnet address from an Ethereum Mainnet wallet.

## Motivation
The motivation of this proposal is to provide a mechanism to allow software to distinguish addresses from different Ethereum based networks. This proposal is necessary because Ethereum addresses are hashes of public keys and do not include any metadata. By extending the EIP-55 checksum algorithm it is possible to achieve this objective.

The motivation of this proposal is to provide a mechanism to allow software to distinguish addresses from different Ethereum based networks. This proposal is necessary because Ethereum addresses are hashes of public keys and do not include any metadata. By extending the [EIP-55](./eip-55.md) checksum algorithm it is possible to achieve this objective.

## Specification
Convert the address using the same algorithm defined by EIP-55 but if a registered chain id is provided, add it to the input of the hash function. If the chain id passed to the function belongs to a network that opted for using this checksum variant, prefix the address with the chain id and the `0x` separator before calculating the hash. Then convert the address to hexadecimal, but if the ith digit is a letter (ie. it's one of `abcdef`) print it in uppercase if the 4*ith bit of the calculated hash is 1 otherwise print it in lowercase.

## Rationale
Convert the address using the same algorithm defined by [EIP-55](./eip-55.md) but if a registered chain id is provided, add it to the input of the hash function. If the chain id passed to the function belongs to a network that opted for using this checksum variant, prefix the address with the chain id and the `0x` separator before calculating the hash. Then convert the address to hexadecimal, but if the ith digit is a letter (ie. it's one of `abcdef`) print it in uppercase if the 4*ith bit of the calculated hash is 1 otherwise print it in lowercase.

## Rationale

Benefits:

- By means of a minimal code change on existing libraries, users are protected from losing funds by mixing addresses of different Ethereum based networks.

## Implementation

```python
#!/usr/bin/python3
from sha3 import keccak_256
Expand All @@ -45,6 +52,7 @@ def eth_checksum_encode(addr, chainid=1):
```

## Test Cases

```python
eth_mainnet = [
"0x27b1fdb04752bbc536007a920d24acb045561c26",
Expand Down Expand Up @@ -97,6 +105,7 @@ for chainid, cases in test_cases.items():
for addr in cases:
assert ( addr == eth_checksum_encode(addr,chainid) )
```

## Usage

### Usage Table
Expand All @@ -107,6 +116,7 @@ for chainid, cases in test_cases.items():
| RSK Testnet | 31 | Yes |

### Implementation Table

| Project | EIP Usage | Implementation |
|-|-|-|
| MyCrypto | Yes | [JavaScript](https://github.com/MyCryptoHQ/MyCrypto/blob/develop/common/utils/formatters.ts#L126) |
Expand Down

0 comments on commit 61397f6

Please sign in to comment.