Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for BLS12-381 curve operations (EIP-2537) #1927

Open
cburgdorf opened this issue May 18, 2020 · 8 comments
Open

Add support for BLS12-381 curve operations (EIP-2537) #1927

cburgdorf opened this issue May 18, 2020 · 8 comments

Comments

@cburgdorf
Copy link
Contributor

What is wrong?

The EIP defines nine pre-compiles that Py-EVM currently does not support.

How can it be fixed

Need to dig into the EIP to find out how to add support for this.

@ralexstokes
Copy link
Member

implementations exist in py_ecc however, i expect that to be unaffordably slow in the context of chain processing in block time.

@pipermerriam
Copy link
Member

Would milagro-bls be the place to look? I recently figured out that the test runs I was doing in the eth2 codebase went from 7s per test to 0.1s per test when I got that optional dependency installed.

@ralexstokes
Copy link
Member

anyone touching this issue should be aware there are two "BLS" (!)

One is a signature scheme and one is a particular elliptic curve. The signature crypto in eth2 uses the BLS signature scheme (that is efficiently aggregatable) on top of the BLS12-381 curve.

EIP-2537 adds precompiles for elliptic curve operations over BLS12-381. We have the curve and the signature algo in py_ecc.

As far as I can tell the curve ops are not exposed in the bindings we use (should be here: https://github.com/ChihChengLiang/milagro_bls_binding/blob/master/src/lib.rs#L146) but if poke thru to the underlying library, it looks like they could be. with some possible coordination w/ sigma prime who maintains the rust bindings...

@ralexstokes
Copy link
Member

if we wanted a more direct binding, i believe these are accurate implementations of the precompiles in Rust: https://github.com/matter-labs/eip1962/blob/master/src/public_interface/eip2537/mod.rs

i can find a link to the bindings going into Geth as well if we want

@ralexstokes
Copy link
Member

given how lightweight the wrapper looks in milagro_bls_binding, we possibly just make py-bindings over the above rust file? or at least start there -- we could quickly hit complicating dependencies....

@pipermerriam
Copy link
Member

We historically made eth-keys to allow a backend agnostic way to do SECPK1 keys stuff agnostic of the implementation, allowing the slow pure-pythong or the fast but slightly harder to install implementations.

Without having any context on the actual code part, this pattern might be appropriate here as well. An eth-bls library that wraps py_ecc and milagro-bls as backends, unifying the API while allowing easy to install vs fast but slightly harder to install backends.

@ralexstokes
Copy link
Member

Yep, we started w/ something in this direction here: https://github.com/ethereum/trinity/blob/master/eth2/_utils/bls/__init__.py

That module could definitely be clean up and factored out into a separate library if we think its worthwhile.

@carver
Copy link
Contributor

carver commented Feb 19, 2021

Looks like #1933 has some steps toward BLS support, though that seems to not be in the Berlin roadmap anymore.

@carver carver changed the title Add support for BLS12-381 curve operations (EIP-2537, scheduled for Berlin) Add support for BLS12-381 curve operations (EIP-2537) Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants