/* * Default ElGamal Decrypt Operation */ BigInt Default_ELG_Op::decrypt(const BigInt& a, const BigInt& b) const { if(a >= p || b >= p) throw Invalid_Argument("Default_ELG_Op: Invalid message"); return mod_p.multiply(b, inverse_mod(powermod_x_p(a), p)); }
SecureVector<byte> DH_KA_Operation::agree(const byte w[], size_t w_len) { BigInt input = BigInt::decode(w, w_len); if(input <= 1 || input >= p - 1) throw Invalid_Argument("DH agreement - invalid key provided"); BigInt r = blinder.unblind(powermod_x_p(blinder.blind(input))); return BigInt::encode_1363(r, p.bytes()); }
DH_KA_Operation::DH_KA_Operation(const DH_PrivateKey& dh) : p(dh.group_p()), powermod_x_p(dh.get_x(), p) { BigInt k(global_state().global_rng(), p.bits() - 1); blinder = Blinder(k, powermod_x_p(inverse_mod(k, p)), p); }