feat(backend/solidity): Implement BLS12-381 pairing precompile (0x0a). #1368 #1417
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements the BLS12-381 pairing precompile (0x0a) as specified in EIP-2537. The implementation provides a pairing check operation for BLS12-381 curve points, which is essential for various zero-knowledge proof applications and blockchain interoperability.
Key features:
Implements BLS12-381 pairing check precompile (0x0a)
Follows EIP-2537 specification for input/output format
Includes proper validation for input lengths and point formats
Performs subgroup checks for security
Returns standardized 32-byte output (1 for success, 0 for failure)
Fixes #1368
Type of change
[x] New feature (non-breaking change which adds functionality)
How has this been tested?
The implementation includes a comprehensive test suite in backend/solidity/bls12_381_pairing_test.go:
[x] Empty input test (verifies correct handling of empty input case)
[x] Invalid input length test (ensures proper error handling)
[x] Valid pairing check test (verifies correct pairing computation with generator points)
How has this been benchmarked?
The implementation uses the optimized pairing implementation from gnark-crypto library. No specific benchmarks were added as this is a standard precompile implementation following established specifications.
Checklist:
[x] I have performed a self-review of my code
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have added tests that prove my feature works
[x] I did not modify files generated from templates
[x] New and existing unit tests pass locally with my changes
[x] The implementation follows the EIP-2537 specification exactly
[x] The code handles all edge cases (empty input, invalid points, subgroup checks)