diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp index 78785ef18df..681060ed296 100644 --- a/src/lib/pubkey/ecies/ecies.cpp +++ b/src/lib/pubkey/ecies/ecies.cpp @@ -66,17 +66,12 @@ class ECIES_ECDH_KA_Operation final : public PK_Ops::Key_Agreement_with_KDF { secure_vector raw_agree(const uint8_t w[], size_t w_len) override { const EC_Group& group = m_key.domain(); - - EC_Point input_point = group.OS2ECP(w, w_len); - input_point.randomize_repr(m_rng); - - const EC_Point S = group.blinded_var_point_multiply(input_point, m_key.private_value(), m_rng, m_ws); - - if(S.on_the_curve() == false) { - throw Internal_Error("ECDH agreed value was not on the curve"); + const auto x = EC_Scalar::from_bigint(group, m_key.private_value()); + if(auto input_point = EC_AffinePoint::deserialize(group, {w, w_len})) { + return input_point->mul(x, m_rng, m_ws).x_bytes(); + } else { + throw Decoding_Error("ECIES - Invalid elliptic curve point"); } - - return S.x_bytes(); } private: