Week 14 Update 14.1

This is the first week since the start of the program that I slowed down a bit. I spent the week rereading the yellow paper to make a proposal of the gas cost of a potential Poseidon precompile.

Some precompiles have a fixed gas cost, while others have a dependency on the input size. Te table below summarizes the gas costs for each precompile contract. See the the yellow paper for details.

Precompile Gas cost
ECREC 3000
SHA256 60+12Id32
RIPEMD160 60+120Id32
ID 15+3Id32
EXMOD gexmod
BN_ADD 150
BN_MUL 6000
SNARKV 34000Id192+45000
BLAKE2_F number of rounds r, maximum 4 bytes

In the table above Id is the input size in bits. The gas costs for the modular exponentiation contract is given by
gexmod=max(200,f(max(M,B))max(E,1)3),
where f(x)=x/82, M and B are positive integers of 4 bytes denoting the lenght in bits of the modulus and the basis, and
E={0if E32 and E=0log2Eif E32 and E08(E32)+log2(i[(96+B)(127+B)])if 32<E and i[(96+B)(127+B)]08(E32)otherwise.
The subvector i[(96+B)(127+B)] of the input i is the exponent whose size is given by E.