Skip to content

Commit 3afdc81

Browse files
authored
Bls Pairing check optimisation: skip exp for infinity (#7883)
1 parent 31e03ca commit 3afdc81

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Nethermind/Nethermind.Evm/Precompiles/Bls/PairingCheckPrecompile.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private PairingCheckPrecompile() { }
4646
var acc = GT.One(buf.AsSpan());
4747
GT p = new(buf.AsSpan()[GT.Sz..]);
4848

49+
bool hasInf = false;
4950
for (int i = 0; i < inputData.Length / PairSize; i++)
5051
{
5152
int offset = i * PairSize;
@@ -61,14 +62,15 @@ private PairingCheckPrecompile() { }
6162
// x == inf || y == inf -> e(x, y) = 1
6263
if (x.IsInf() || y.IsInf())
6364
{
65+
hasInf = true;
6466
continue;
6567
}
6668

6769
p.MillerLoop(y, x);
6870
acc.Mul(p);
6971
}
7072

71-
bool verified = acc.FinalExp().IsOne();
73+
bool verified = hasInf || acc.FinalExp().IsOne();
7274
byte[] res = new byte[32];
7375
if (verified)
7476
{

0 commit comments

Comments
 (0)