Add BigNum::mod_inv.

GitOrigin-RevId: 98733421e0b8a6924724a4c13f2cd9ad937e3b0d
This commit is contained in:
levlam 2018-08-08 22:56:23 +03:00
parent cdecbe9b3e
commit 7e1d116d70
2 changed files with 7 additions and 0 deletions

View File

@ -220,6 +220,11 @@ void BigNum::mod_mul(BigNum &r, BigNum &a, BigNum &b, const BigNum &m, BigNumCon
LOG_IF(FATAL, result != 1);
}
void BigNum::mod_inv(BigNum &r, BigNum &a, const BigNum &m, BigNumContext &context) {
BIGNUM *result = BN_mod_inverse(r.impl_->big_num, a.impl_->big_num, m.impl_->big_num, context.impl_->big_num_context);
LOG_IF(FATAL, result == nullptr);
}
void BigNum::div(BigNum *quotient, BigNum *remainder, const BigNum &dividend, const BigNum &divisor,
BigNumContext &context) {
auto q = quotient == nullptr ? nullptr : quotient->impl_->big_num;

View File

@ -87,6 +87,8 @@ class BigNum {
static void mod_mul(BigNum &r, BigNum &a, BigNum &b, const BigNum &m, BigNumContext &context);
static void mod_inv(BigNum &r, BigNum &a, const BigNum &m, BigNumContext &context);
static void div(BigNum *quotient, BigNum *remainder, const BigNum &dividend, const BigNum &divisor,
BigNumContext &context);