Skip to content

Commit b6b2b84

Browse files
authored
Update EIP-2537: Rename multiexponentiation to MSM
Merged by EIP-Bot.
1 parent fd8cb79 commit b6b2b84

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

EIPS/eip-2537.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ The motivation of this precompile is to add a cryptographic primitive that allow
2929
|`FORK_TIMESTAMP` | *TBD* | Mainnet |
3030
|BLS12_G1ADD | 0x0b | precompile address |
3131
|BLS12_G1MUL | 0x0c | precompile address |
32-
|BLS12_G1MULTIEXP | 0x0d | precompile address |
32+
|BLS12_G1MSM | 0x0d | precompile address |
3333
|BLS12_G2ADD | 0x0e | precompile address |
3434
|BLS12_G2MUL | 0x0f | precompile address |
35-
|BLS12_G2MULTIEXP | 0x10 | precompile address |
35+
|BLS12_G2MSM | 0x10 | precompile address |
3636
|BLS12_PAIRING | 0x11 | precompile address |
3737
|BLS12_MAP_FP_TO_G1 | 0x12 | precompile address |
3838
|BLS12_MAP_FP2_TO_G2 | 0x13 | precompile address |
@@ -41,10 +41,10 @@ If `block.timestamp >= FORK_TIMESTAMP` we introduce *nine* separate precompiles
4141

4242
- BLS12_G1ADD - to perform point addition in G1 (curve over base prime field) with a gas cost of `500` gas
4343
- BLS12_G1MUL - to perform point multiplication in G1 (curve over base prime field) with a gas cost of `12000` gas
44-
- BLS12_G1MULTIEXP - to perform multiexponentiation in G1 (curve over base prime field) with a gas cost formula defined in the corresponding section
44+
- BLS12_G1MSM - to perform multi-scalar-multiplication (MSM) in G1 (curve over base prime field) with a gas cost formula defined in the corresponding section
4545
- BLS12_G2ADD - to perform point addition in G2 (curve over quadratic extension of the base prime field) with a gas cost of `800` gas
4646
- BLS12_G2MUL - to perform point multiplication in G2 (curve over quadratic extension of the base prime field) with a gas cost of `45000` gas
47-
- BLS12_G2MULTIEXP - to perform multiexponentiation in G2 (curve over quadratic extension of the base prime field) with a gas cost formula defined in the corresponding section
47+
- BLS12_G2MSM - to perform multi-scalar-multiplication (MSM) in G2 (curve over quadratic extension of the base prime field) with a gas cost formula defined in the corresponding section
4848
- BLS12_PAIRING - to perform a pairing operations between a set of *pairs* of (G1, G2) points a gas cost formula defined in the corresponding section
4949
- BLS12_MAP_FP_TO_G1 - maps base field element into the G1 point with a gas cost of `5500` gas
5050
- BLS12_MAP_FP2_TO_G2 - maps extension field element into the G2 point with a gas cost of `75000` gas
@@ -127,7 +127,7 @@ A scalar for the multiplication operation is encoded as `32` bytes by performing
127127

128128
#### Behavior on empty inputs:
129129

130-
Certain operations have variable length input, such as multiexponentiations (takes a list of pairs `(point, scalar)`), or pairing (takes a list of `(G1, G2)` points). While their behavior is well-defined (from an arithmetic perspective) on empty inputs, this EIP discourages such use cases and variable input length operations must return an error if the input is empty.
130+
Certain operations have variable length input, such as MSMs (takes a list of pairs `(point, scalar)`), or pairing (takes a list of `(G1, G2)` points). While their behavior is well-defined (from an arithmetic perspective) on empty inputs, this EIP discourages such use cases and variable input length operations must return an error if the input is empty.
131131

132132
### ABI for operations
133133

@@ -151,9 +151,9 @@ Error cases:
151151
- The point not in G1 (i.e. neither on a curve nor the infinity point)
152152
- Input has invalid length
153153

154-
#### ABI for G1 multiexponentiation
154+
#### ABI for G1 MSM
155155

156-
G1 multiexponentiation call expects `160*k` (`k` being a **positive** integer) bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of a G1 point (`128` bytes) and encoding of a scalar value (`32` bytes). Output is an encoding of multiexponentiation operation result - a single G1 point (`128` bytes).
156+
G1 MSM call expects `160*k` (`k` being a **positive** integer) bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of a G1 point (`128` bytes) and encoding of a scalar value (`32` bytes). Output is an encoding of MSM operation result - a single G1 point (`128` bytes).
157157

158158
Error cases:
159159

@@ -182,9 +182,9 @@ Error cases:
182182
- Input has invalid length
183183

184184

185-
#### ABI for G2 multiexponentiation
185+
#### ABI for G2 MSM
186186

187-
G2 multiexponentiation call expects `288*k` (`k` being a **positive** integer) bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of G2 point (`256` bytes) and encoding of a scalar value (`32` bytes). Output is an encoding of multiexponentiation operation result - a single G2 point (`256` bytes).
187+
G2 MSM call expects `288*k` (`k` being a **positive** integer) bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of G2 point (`256` bytes) and encoding of a scalar value (`32` bytes). Output is an encoding of MSM operation result - a single G2 point (`256` bytes).
188188

189189
Error cases:
190190

@@ -257,9 +257,9 @@ Assuming a constant `30 MGas/second`, the following prices are suggested.
257257

258258
`45000` gas
259259

260-
#### G1/G2 Multiexponentiation
260+
#### G1/G2 MSM
261261

262-
Multiexponentiations are expected to be performed by the Pippenger algorithm (we can also say that is **must** be performed by Pippenger 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 multiexponentiation with a discount cup `max_discount` for `k > 128`.
262+
MSMs are expected to be performed by the Pippenger algorithm (we can also say that is **must** be performed by Pippenger 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 cup `max_discount` for `k > 128`.
263263

264264
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 single multiplication call cost for G1/G2.
265265

@@ -285,9 +285,9 @@ Fp2 -> G2 mapping is `75000` gas
285285

286286
#### Gas schedule clarifications for the variable-length input
287287

288-
For multiexponentiation and pairing functions, the gas cost depends on the input length. The current state of how the gas schedule is implemented in major clients (at the time of writing) is that the gas cost function does *not* perform any validation of the length of the input and never returns an error. So we present a list of rules how the gas cost functions **must** be implemented to ensure consistency between clients and safety.
288+
For MSM and pairing functions, the gas cost depends on the input length. The current state of how the gas schedule is implemented in major clients (at the time of writing) is that the gas cost function does *not* perform any validation of the length of the input and never returns an error. So we present a list of rules how the gas cost functions **must** be implemented to ensure consistency between clients and safety.
289289

290-
##### Gas schedule clarifications for G1/G2 Multiexponentiation
290+
##### Gas schedule clarifications for G1/G2 MSM
291291

292292
Define a constant `LEN_PER_PAIR` that is equal to `160` for G1 operation and to `288` for G2 operation. Define a function `discount(k)` following the rules in the corresponding section, where `k` is number of pairs.
293293

@@ -328,9 +328,9 @@ We use floor division to get the number of pairs. If the length of the input is
328328

329329
The motivation section covers a total motivation to have operations over the BLS12-381 curves available. We also extend a rationale for more specific fine points.
330330

331-
### Multiexponentiation as a separate call
331+
### MSM as a separate call
332332

333-
Explicit separate multiexponentiation operation that allows one to save execution time (so gas) by both the algorithm used (namely the Pippenger algorithm) and (usually forgotten) by the fact that `CALL` operation in Ethereum is expensive (at the time of writing), so one would have to pay non-negigible overhead if e.g. for multiexponentiation of `100` points would have to call the multipication precompile `100` times and addition for `99` times (roughly `138600` would be saved).
333+
Explicit separate MSM operation that allows one to save execution time (so gas) by both the algorithm used (namely the Pippenger algorithm) and (usually forgotten) by the fact that `CALL` operation in Ethereum is expensive (at the time of writing), so one would have to pay non-negigible overhead if e.g. for MSM of `100` points would have to call the multiplication precompile `100` times and addition for `99` times (roughly `138600` would be saved).
334334

335335
## Backwards Compatibility
336336

0 commit comments

Comments
 (0)