tornadocash / tornado-core

Tornado cash. Non-custodial private transactions on Ethereum.
https://tornado.cash
GNU General Public License v3.0
1.49k stars 561 forks source link

Library functions must be implemented if declared. #86

Closed GalaxySciTech closed 3 years ago

GalaxySciTech commented 3 years ago

https://github.com/tornadocash/tornado-core/blob/77af0c5bddfcf9d973efbc38278a249bb0173da3/contracts/MerkleTreeWithHistory.sol#L15

poma commented 3 years ago

They are implemented in a separate mimc contract: https://github.com/iden3/circomlib/blob/master/src/mimcsponge_gencontract.js

GalaxySciTech commented 3 years ago

What if I want to compile with solidity

poma commented 3 years ago

In that case you have to write the code yourself. And it will likely be 10x more gas expensive.

Federico2014 commented 3 years ago

I get the same problem, Why not publish the MiMCSponge solidity source code?

rstormsf commented 3 years ago

Please ask original MiMCSponge devs to provide Solidity version

poma commented 3 years ago

Because there is no solidity source code, and probably never will be, because it's inefficient

Federico2014 commented 3 years ago

Here is solidity version: https://gist.github.com/poma/5adb51d49057d0a0edad2cbd12945ac4 it is quite inefficient, but how can you deploy your contracts?
Furthermore, Why not use the sha256 or keccak256?

poma commented 3 years ago

sha and keccak hashes are not snark friendly.

Solidity version from the gist will probably not even fit into max contract size and spends like 5x more gas. Circomlib version is written in EVM assembly and is small and fast.