Skip to content

Commit e10561f

Browse files
committed
Update EIP-2537: Clarify the formula used to calculate MSM gas cost.
1 parent d64f4c3 commit e10561f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

EIPS/eip-2537.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Assuming `EcRecover` precompile as a baseline.
248248

249249
MSMs are expected to be performed by Pippenger's algorithm (we can also say that it **must** be performed by Pippenger's algorithm to have a speedup that results in a discount over naive implementation by multiplying each pair separately and adding the results). For this case there was a table prepared for discount in case of `k <= 128` points in the MSM with a discount cap `max_discount` for `k > 128`.
250250

251-
To avoid non-integer arithmetic, the call cost is calculated as `(k * multiplication_cost * discount) / multiplier` where `multiplier = 1000`, `k` is a number of (scalar, point) pairs for the call, `multiplication_cost` is a corresponding G1/G2 multiplication cost presented above.
251+
The call cost is calculated as `(k * multiplication_cost * discount) // multiplier` where `multiplier = 1000`, `k` is a number of (scalar, point) pairs for the call, `multiplication_cost` is a corresponding G1/G2 multiplication cost presented above and `//` is an integer division.
252252

253253
G1 and G2 are priced separately, each having their own discount table and `max_discount`.
254254

@@ -299,7 +299,7 @@ k = floor(len(input) / LEN_PER_PAIR);
299299
if k == 0 {
300300
return 0;
301301
}
302-
gas_cost = k * multiplication_cost * discount(k) / multiplier;
302+
gas_cost = k * multiplication_cost * discount(k) // multiplier;
303303
return gas_cost;
304304
```
305305

0 commit comments

Comments
 (0)