github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/execution/solidity/big_mod.sol (about) 1 pragma solidity ^0.5; 2 3 contract BigMod { 4 function expmod(int256 base, int256 e, int256 m, int256 proof) public returns (uint256) { 5 bool success; 6 int256 o; 7 8 assembly { 9 10 let p := mload(0x40) 11 // store data assembly-favouring ways 12 mstore(p, 0x20) // Length of Base 13 mstore(add(p, 0x20), 0x20) // Length of Exponent 14 mstore(add(p, 0x40), 0x20) // Length of Modulus 15 mstore(add(p, 0x60), base) // Base 16 mstore(add(p, 0x80), e) // Exponent 17 mstore(add(p, 0xa0), m) // Modulus 18 // call modexp precompile 19 success := call(sub(gas, 2000), 0x05, 0, p, 0xc0, p, 0x20) 20 // gas fiddling 21 22 o := mload(p) 23 24 } 25 require(success); 26 if (proof == o) { 27 return 1; 28 } 29 return 0; 30 } 31 }