From 602a3d5a7446c9e8ea45a3ef3e3b35a8e4810994 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Thu, 22 Jun 2023 13:55:51 -0600 Subject: [PATCH] linter fix --- EIPS/eip-2537.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/EIPS/eip-2537.md b/EIPS/eip-2537.md index 005b27e86a0cee..14b9858c8eb210 100644 --- a/EIPS/eip-2537.md +++ b/EIPS/eip-2537.md @@ -122,6 +122,7 @@ Certain operations have variable length input, such as multiexponentiations (tak G1 addition call expects `256` bytes as an input that is interpreted as byte concatenation of two G1 points (`128` bytes each). Output is an encoding of addition operation result - single G1 point (`128` bytes). Error cases: + - Either of points being not on the curve must result in error - Field elements encoding rules apply (obviously) - Input has invalid length @@ -131,6 +132,7 @@ Error cases: G1 multiplication call expects `160` bytes as an input that is interpreted as byte concatenation of encoding of G1 point (`128` bytes) and encoding of a scalar value (`32` bytes). Output is an encoding of multiplication operation result - single G1 point (`128` bytes). Error cases: + - Point being not on the curve must result in error - Field elements encoding rules apply (obviously) - Input has invalid length @@ -140,6 +142,7 @@ Error cases: G1 multiexponentiation call expects `160*k` bytes as an input that is interpreted as byte concatenation of `k` slices each of them being a byte concatenation of encoding of G1 point (`128` bytes) and encoding of a scalar value (`32` bytes). Output is an encoding of multiexponentiation operation result - single G1 point (`128` bytes). Error cases: + - Any of G1 points being not on the curve must result in error - Field elements encoding rules apply (obviously) - Input has invalid length @@ -150,6 +153,7 @@ Error cases: G2 addition call expects `512` bytes as an input that is interpreted as byte concatenation of two G2 points (`256` bytes each). Output is an encoding of addition operation result - single G2 point (`256` bytes). Error cases: + - Either of points being not on the curve must result in error - Field elements encoding rules apply (obviously) - Input has invalid length @@ -159,6 +163,7 @@ Error cases: G2 multiplication call expects `288` bytes as an input that is interpreted as byte concatenation of encoding of G2 point (`256` bytes) and encoding of a scalar value (`32` bytes). Output is an encoding of multiplication operation result - single G2 point (`256` bytes). Error cases: + - Point being not on the curve must result in error - Field elements encoding rules apply (obviously) - Input has invalid length @@ -168,6 +173,7 @@ Error cases: G2 multiexponentiation call expects `288*k` 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 - single G2 point (`256` bytes). Error cases: + - Any of G2 points being not on the curve must result in error - Field elements encoding rules apply (obviously) - Input has invalid length @@ -176,12 +182,14 @@ Error cases: #### ABI for pairing Pairing call expects `384*k` bytes as an inputs that is interpreted as byte concatenation of `k` slices. Each slice has the following structure: + - `128` bytes of G1 point encoding - `256` bytes of G2 point encoding Output is a `32` bytes where first `31` bytes are equal to `0x00` and the last byte is `0x01` if pairing result is equal to multiplicative identity in a pairing target field and `0x00` otherwise. Error cases: + - Any of G1 or G2 points being not on the curve must result in error - Any of G1 or G2 points are not in the correct subgroup - Field elements encoding rules apply (obviously) @@ -193,6 +201,7 @@ Error cases: Field-to-curve call expects `64` bytes an an input that is interpreted as a an element of the base field. Output of this call is `128` bytes and is G1 point following respective encoding rules. Error cases: + - Input has invalid length - Input is not a valid field element @@ -201,6 +210,7 @@ Error cases: Field-to-curve call expects `128` bytes an an input that is interpreted as a an element of the quadratic extension field. Output of this call is `256` bytes and is G2 point following respective encoding rules. Error cases: + - Input has invalid length - Input is not a valid field element @@ -267,6 +277,7 @@ For multiexponentiation and pairing functions gas cost depends on the input leng 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. The following pseudofunction reflects how gas should be calculated: + ``` k = floor(len(input) / LEN_PER_PAIR); if k == 0 { @@ -286,6 +297,7 @@ We use floor division to get number of pairs. If length of the input is not divi Define a constant `LEN_PER_PAIR = 384`; The following pseudofunction reflects how gas should be calculated: + ``` k = floor(len(input) / LEN_PER_PAIR); @@ -334,6 +346,7 @@ Required properties for basic ops (add/multiply): - Multiplication by the unnormalized scalar `(scalar + group_order) * P = scalar * P` Required properties for pairing operation: + - Degeneracy `e(P, 0*Q) = e(0*P, Q) = 1` - Bilinearity `e(a*P, b*Q) = e(a*b*P, Q) = e(P, a*b*Q)` (internal test, not visible through ABI) @@ -344,6 +357,7 @@ A set of test vectors for quick benchmarking on new implementations is located i ## Reference Implementation There are two fully spec compatible implementations on the day of writing: + - One in Rust language that is based on the EIP1962 code and integrated with OpenEthereum for this library - One implemented specifically for Geth as a part of the current codebase @@ -354,4 +368,5 @@ Strictly following the spec will eliminate security implications or consensus im Important topic is a "constant time" property for performed operations. We explicitly state that this precompile **IS NOT REQUIRED** to perform all the operations using constant time algorithms. ## Copyright + Copyright and related rights waived via [CC0](../LICENSE.md).