Optimize publicKey method by precomputing G powers
Contract deployed to ROPSTEN network was initialized with 6 calls of prepare(50), took up to 4M gas each: https://ropsten.etherscan.io/address/0xe2ceefb2b9010864f9b103d78dc5eac3d32c64b0
Random case: 0xdb5ea2d092201b3e85426f80d6fd6c2cf25120c4c2f7afa5cdb56638cdb56638
- 779K gas
+ 483K gas
Average case: 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- 782K gas
+ 487K gas
Worst case: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
- 998K gas
+ 891K gas
Vitalik Buterin found a way to abuse ecrecover to perform ecmul to get 25x gas profit on this operation: https://ethresear.ch/t/you-can-kinda-abuse-ecrecover-to-do-ecmul-in-secp256k1-today/2384
Implemented this trick in the fork: https://github.com/1Address/ecsol