iden3 / circomlib

Library of basic circuits for circom
605 stars 210 forks source link

Generated MiMC.sol 's solidity version #32

Closed wanseob closed 4 years ago

wanseob commented 4 years ago

https://github.com/iden3/circomlib/blob/master/src/mimcsponge_gencontract.js

The contract generated by mimcsponge_gencontracts.js is quite cheap. But because it's an external library which uses public function we have to pay more than 1400 gas compared to when if we use internal function by including the library inside the contract.

Therefore it'll be really good if we have the solidity inline-assembly version of the MiMC.sol. It is hard to make other contracts include the library with only the asm.

poma commented 4 years ago

It is hard to make other contracts include the library with only the asm.

This is the reason why it wasn't implemented as inline assembly in the first place - it does not allow instructions that control the stack

wanseob commented 4 years ago

@poma Thanks for your reply. Understood!