Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions EIPS/eip-7883.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ Upon activation of this EIP, the gas cost of calling the precompile at address `
def calculate_multiplication_complexity(base_length, modulus_length):
max_length = max(base_length, modulus_length)
words = math.ceil(max_length / 8)
multiplication_complexity = 0
if max_length <= 32: multiplication_complexity = words**2
elif max_length > 32: multiplication_complexity = 2 * words**2
multiplication_complexity = 16
if max_length > 32: multiplication_complexity = 2 * words**2
return multiplication_complexity

def calculate_iteration_count(exponent_length, exponent):
Expand All @@ -49,7 +48,7 @@ Changes (with algorithm from [EIP-2565](./eip-2565.md)):

### 1. Increase minimal price from 200 to 500

This part of equation:
This part of the equation:

```
return max(200, math.floor(multiplication_complexity * iteration_count / 3))
Expand All @@ -63,7 +62,7 @@ Is replaced by this:

### 2. Increase cost when exponent is larger than 32 bytes

This part of equation:
This part of the equation:

```
elif exponent_length > 32: iteration_count = (8 * (exponent_length - 32)) + ((exponent & (2**256 - 1)).bit_length() - 1)
Expand All @@ -77,9 +76,9 @@ Is replaced by this:

Multiplier 8 is replaced by 16.

### 3. Increase cost when base or modulus is larger than 32 bytes
### 3. Assume the minimal base / modulus length to be 32 and increase the cost when it is larger than 32 bytes

This part of equation:
This part of the equation:

```
def calculate_multiplication_complexity(base_length, modulus_length):
Expand All @@ -94,9 +93,8 @@ Is replaced by this:
def calculate_multiplication_complexity(base_length, modulus_length):
max_length = max(base_length, modulus_length)
words = math.ceil(max_length / 8)
multiplication_complexity = 0
if max_length <= 32: multiplication_complexity = words**2
elif max_length > 32: multiplication_complexity = 2 * words**2
multiplication_complexity = 16
if max_length > 32: multiplication_complexity = 2 * words**2
return multiplication_complexity
```

Expand Down