mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Implementation of EXP with gmp
This commit is contained in:
parent
100de855ec
commit
939e94a101
1 changed files with 11 additions and 4 deletions
|
|
@ -260,10 +260,17 @@ extern "C"
|
||||||
|
|
||||||
EXPORT void arith_exp(i256* _arg1, i256* _arg2, i256* o_result)
|
EXPORT void arith_exp(i256* _arg1, i256* _arg2, i256* o_result)
|
||||||
{
|
{
|
||||||
bigint left = llvm2eth(*_arg1);
|
*o_result = {};
|
||||||
bigint right = llvm2eth(*_arg2);
|
|
||||||
auto ret = static_cast<u256>(boost::multiprecision::powm(left, right, bigint(2) << 256));
|
static mp_limb_t mod_limbs[nLimbs + 1] = {};
|
||||||
*o_result = eth2llvm(ret);
|
mod_limbs[nLimbs] = 1;
|
||||||
|
static const mpz_t mod{nLimbs + 1, nLimbs + 1, &mod_limbs[0]};
|
||||||
|
|
||||||
|
mpz_t x{nLimbs, countLimbs(_arg1), reinterpret_cast<mp_limb_t*>(_arg1)};
|
||||||
|
mpz_t y{nLimbs, countLimbs(_arg2), reinterpret_cast<mp_limb_t*>(_arg2)};
|
||||||
|
mpz_t z{nLimbs, 0, reinterpret_cast<mp_limb_t*>(o_result)};
|
||||||
|
|
||||||
|
mpz_powm(z, x, y, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT void arith_mulmod(i256* _arg1, i256* _arg2, i256* _arg3, i256* o_result)
|
EXPORT void arith_mulmod(i256* _arg1, i256* _arg2, i256* _arg3, i256* o_result)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue