EspressoSystems / cape

Configurable Asset Privacy for Ethereum
https://cape.docs.espressosys.com/
GNU General Public License v3.0
97 stars 16 forks source link

Solidity transcripts optimization, improvements #43

Open philippecamacho opened 2 years ago

philippecamacho commented 2 years ago

https://gitlab.com/translucence/cap-on-ethereum/cape/-/issues/122

alxiong commented 2 years ago

another potential source to be optimized:

    function fromLeBytesModOrder(bytes memory leBytes) internal pure returns (uint256 ret) {
        // TODO (optimization): Can likely be gas optimized by copying the first 31 bytes directly.
        for (uint256 i = 0; i < leBytes.length; i++) {
            ret = mulmod(ret, 256, R_MOD);
            ret = addmod(ret, uint256(uint8(leBytes[leBytes.length - 1 - i])), R_MOD);
        }
    }

(since Transcript.sol depends on BN254.fromLeBytesModOrder())