3

I tried to build a wrapper around the precompiled contracts as follows: https://gist.github.com/AlexXiong97/9c24bbd4541323a61fa63100860a5f89

If you paste it into Remix and deploy it, inputting any (valid) scalar into scalarBaseMult function would result in a VM revert, which indicates a failure in parameters provided to the precompiled contract.

However, I'm pretty confident the parameters are correct as I generate them directly from Cloudflare's bn256 library which is exactly what Geth uses. Here's my script: https://gist.github.com/AlexXiong97/217f42ee4d0dedc6182b182134caeed9

If you input (1, 2, 3) into scalarMult, the correct result will be returned which makes sense as (1,2) is indeed a point on the bn256 curve y^2 = x^3 +3

I once suspect my computed generator coordinates are wrong, but as specified here: the generator is (1, -2) mod p, where p's value is here, thus I'm quite sure there's nothing wrong with their value.

Can anyone help me understand what might cause the VM exception?

  • Could you provide a link to a failed transaction on one of the public test networks, please? It might help with troubleshooting. – Thomas Apr 9 at 13:59
  • @Thomas I didn't deploy it to the live network. I don't think we need to in order to test its functionality. poking it inside Remix or just in a ganache sandbox is pretty much the amount of info you will get even when you deploy them on chain. – Alex Xiong Apr 10 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.