Skip to content

Commit f437307

Browse files
core/vm: update gascosts for BLS12-381 + use gnark instead of kilic (#29441)
This PR updates the bls contracts from our internal implementation which is an unmaintained fork of the kilic library to the gnark-crypto library that is actively maintained by consensys. It also updates the gas-costs according to the EIP
1 parent 71c78bf commit f437307

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+910
-9399
lines changed

core/vm/contracts.go

Lines changed: 138 additions & 88 deletions
Large diffs are not rendered by default.

core/vm/contracts_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func BenchmarkPrecompiledBLS12381G1MultiExpWorstCase(b *testing.B) {
372372
Name: "WorstCaseG1",
373373
NoBenchmark: false,
374374
}
375-
benchmarkPrecompiled("0c", testcase, b)
375+
benchmarkPrecompiled("f0c", testcase, b)
376376
}
377377

378378
// BenchmarkPrecompiledBLS12381G2MultiExpWorstCase benchmarks the worst case we could find that still fits a gaslimit of 10MGas.
@@ -393,5 +393,5 @@ func BenchmarkPrecompiledBLS12381G2MultiExpWorstCase(b *testing.B) {
393393
Name: "WorstCaseG2",
394394
NoBenchmark: false,
395395
}
396-
benchmarkPrecompiled("0f", testcase, b)
396+
benchmarkPrecompiled("f0f", testcase, b)
397397
}

core/vm/testdata/precompiles/blsG1Add.json

Lines changed: 104 additions & 104 deletions
Large diffs are not rendered by default.

core/vm/testdata/precompiles/blsG2Add.json

Lines changed: 104 additions & 104 deletions
Large diffs are not rendered by default.

core/vm/testdata/precompiles/blsG2Mul.json

Lines changed: 104 additions & 104 deletions
Large diffs are not rendered by default.

core/vm/testdata/precompiles/blsG2MultiExp.json

Lines changed: 173 additions & 103 deletions
Large diffs are not rendered by default.

core/vm/testdata/precompiles/blsMapG2.json

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

core/vm/testdata/precompiles/blsPairing.json

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

core/vm/testdata/precompiles/fail-blsG1Add.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
},
2222
{
2323
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
24-
"ExpectedError": "must be less than modulus",
24+
"ExpectedError": "invalid fp.Element encoding",
2525
"Name": "bls_g1add_invalid_field_element"
2626
},
2727
{
2828
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1",
29-
"ExpectedError": "point is not on curve",
29+
"ExpectedError": "invalid point: not on curve",
3030
"Name": "bls_g1add_point_not_on_curve"
3131
}
3232
]

core/vm/testdata/precompiles/fail-blsG1Mul.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
},
2222
{
2323
"Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac0000000000000000000000000000000000000000000000000000000000000007",
24-
"ExpectedError": "must be less than modulus",
24+
"ExpectedError": "invalid fp.Element encoding",
2525
"Name": "bls_g1mul_invalid_field_element"
2626
},
2727
{
2828
"Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
29-
"ExpectedError": "point is not on curve",
29+
"ExpectedError": "invalid point: not on curve",
3030
"Name": "bls_g1mul_point_not_on_curve"
3131
}
3232
]

0 commit comments

Comments
 (0)