ethereumjs-monorepo icon indicating copy to clipboard operation
ethereumjs-monorepo copied to clipboard

VM: Analyze rustbn.js native implementation possibility

Open holgerd77 opened this issue 3 years ago • 4 comments

The rustbn.js is rather somewhat of a submodule of the VM and is used for the ECADD, ECMUL and ECPAIRING precompiles.

This is realized as a WASM precompile from Rust and there is atm no one to really maintain this library.

Since this decision to go this way (and the subsequent implementation) has been made 4 years ago along the Byzantium hardfork implementation we might want to re-analyze the current native JS library situation and if more direct/native integration in the VM is possible.

Otherwise it might also be useful to integrate the package into the monorepo (it's rather not much code + no tests to be run I guess).

holgerd77 avatar Jan 29 '22 09:01 holgerd77

So the question is either we move the WASM into our repo, or we write this ourselves in JS?

jochem-brouwer avatar Feb 07 '22 11:02 jochem-brouwer

The rustbn.js is rather somewhat of a submodule of the VM and is used for the ECADD, ECMUL and ECRECOVER precompiles.

Typo: it is used for ecadd/ecmul/ecpairing. ecrecover is a different curve.

This is realized as a WASM precompile from Rust and there is atm no one to really maintain this library.

Well, the thing is it required no changes, hence no updates to it.

My 5 cents: I think it will be quite a challenge writing a bn128 implementation, including pairing, in native Javascript. Can't comment about the speed, but I'd expect the pairing to be likely on the edge regarding speed.

axic avatar Feb 07 '22 11:02 axic

Could consider using iden3's webassembly implementation (https://github.com/iden3/wasmsnark), if this is still driven by the licensing question. It is not a drop-in replacement though.

axic avatar Feb 07 '22 12:02 axic

@axic thanks, that helps a lot! We'll be more cautious here on an eventual decision.

holgerd77 avatar Feb 07 '22 19:02 holgerd77

Will close this after the feedback from @axic

holgerd77 avatar Sep 20 '22 08:09 holgerd77