Ethereum: How to reduce gas consumption in ZKP function