Skip to content

Add draft TIP: Native BN254 Precompiles via Rust FFI#847

Open
anishnarang9 wants to merge 1 commit intotronprotocol:masterfrom
anishnarang9:anishnarang9/native-bn254-rust-ffi-tip
Open

Add draft TIP: Native BN254 Precompiles via Rust FFI#847
anishnarang9 wants to merge 1 commit intotronprotocol:masterfrom
anishnarang9:anishnarang9/native-bn254-rust-ffi-tip

Conversation

@anishnarang9
Copy link
Copy Markdown

Summary

  • add a draft VM TIP for a native Rust-backed BN254 implementation at 0x06, 0x07, and 0x08
  • preserve the existing precompile interface while specifying EIP-196 / EIP-197 calldata semantics and deterministic governance activation
  • include fresh benchmark and proof-validation results, with companion implementation and evidence links in the draft

Discussion

Companion Material

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new draft VM TIP proposing a Rust FFI–backed native BN254 precompile implementation for addresses 0x06, 0x07, and 0x08, aligning calldata semantics with EIP-196/EIP-197 and specifying deterministic governance activation.

Changes:

  • Introduces a draft TIP describing native BN254 precompiles and their calldata/validation semantics.
  • Defines governance activation behavior via a committee parameter and maintenance-period boundary rules.
  • Documents benchmark and proof-validation evidence with links to companion materials.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +10
---
tip: <to be assigned>
title: Native BN254 Precompiles via Rust FFI
author: Anish Narang (@anishnarang9), Blockchain@Maryland
discussions-to: https://github.com/tronprotocol/tips/issues/846
status: Draft
type: Standards Track
category: VM
created: 2026-03-24
---
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TIP front-matter is using YAML-style --- delimiters. In this repository, TIP metadata blocks are consistently wrapped in a fenced code block (...), per template.md. Please switch to the fenced-code metadata format to match existing TIP conventions and tooling expectations.

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +33
| Operation | Java (current generic path) | Rust (proposed path) | Speedup |
|-----------|-----------------------------|----------------------|---------|
| ecAdd (`0x06`) | `93 us` | `5 us` | **18.6x** |
| ecMul (`0x07`) | `4,606.5 us` | `63.8 us` | **72.2x** |
| ecPairing (`0x08`) | `98,203 us` | `1,406.8 us` | **69.8x** |

Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markdown table rows here start with || (double leading pipe), which renders as an extra empty column in GitHub-flavored Markdown. Replace the leading || with a single | for correct table formatting.

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +65
| Address | Operation | Input | Output |
|---------|-----------|-------|--------|
| `0x06` | BN254 G1 Addition | two G1 points | one G1 point |
| `0x07` | BN254 G1 Scalar Multiplication | one G1 point and one scalar | one G1 point |
| `0x08` | BN254 Pairing Check | `k` G1/G2 pairs | 32-byte boolean |

Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Precompile Addresses" table uses || at the start of rows, which renders with an unintended extra blank column on GitHub. Use a single leading | for each row.

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +114
| Operation | Energy Cost | Ethereum Gas (EIP-1108) |
|-----------|-------------|--------------------------|
| ecAdd | `150` | `150` |
| ecMul | `6,000` | `6,000` |
| ecPairing | `80,000 * k + 100,000` | `34,000 * k + 45,000` |

Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Energy Costs" table also uses || prefixes, which breaks GitHub table rendering by adding an empty first column. Please change these rows to start with a single |.

Copilot uses AI. Check for mistakes.
Comment on lines +181 to +188
| Application Class | Why This Matters |
|-------------------|------------------|
| ZK rollups | Batch-validity verification depends on practical pairing performance |
| Shielded transfer systems | Merkle-membership and nullifier-style Groth16 verification becomes viable on the generic path |
| Cross-chain zk verification | On-chain proof verification becomes feasible without the current generic-path timeout profile |
| Identity / credential proofs | Generic BN254 verifiers become realistic building blocks instead of benchmark-only experiments |
| Verifiable computation | Generic Groth16 proof verification becomes part of the usable VM surface |

Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "What This Unlocks" table is formatted with double leading pipes (||), which renders with an unintended extra empty column on GitHub. Update the table rows to start with a single |.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants