zksync_era_precompiles

zkSync Era Precompiles

DISCLAIMER: This implementation is still being developed and has not been reviewed or audited. Use at your own risk.

This is a precompile library implemented in Yul to speedup arithmetic operations of elliptic curves. In the next weeks we will add more optimizations and benchmarks.

Current Status

Precompile MVP Optimized
ecAdd
ecMul
ecPairing 🏗️
modexp 🏗️

Summary

Used algorithms

  Unoptimized     Optimized    
Operation ecAdd ecMul modexp ecAdd ecMul modexp
Modular Addition addmod addmod addmod addmod + Montgomery form addmod + Montgomery form addmod + Montgomery form
Modular Subtraction addmod addmod addmod addmod + Montgomery form addmod + Montgomery form addmod + Montgomery form
Modular Multiplication mulmod mulmod mulmod Montgomery multiplication Montgomery multiplication Montgomery multiplication
Modular Exponentiation Binary exponentiation Binary exponentiation Binary exponentiation Binary exponentiation + Montgomery form Binary exponentiation + Montgomery form Binary exponentiation + Montgomery form
Modular Inversion Fermat’s little theorem Fermat’s little theorem None Binary Extended GCD + Montgomery form Binary Extended GCD + Montgomery form  

Resources

Development

Follow the instructions below to setup the repo and run a development L2 node.

Setup the repo

make setup

Update the submodules (if needed)

make update

Run a development L2 node

make run

Run the tests

If you want to run all the tests:

make test

If you want to run a specific test:

make test PRECOMPILE=<precompile_name>