Skip to content

Commit

Permalink
Use new EC types in ECIES
Browse files Browse the repository at this point in the history
  • Loading branch information
randombit committed Jul 10, 2024
1 parent 4b19dd2 commit 95b80ba
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/lib/pubkey/ecies/ecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,12 @@ class ECIES_ECDH_KA_Operation final : public PK_Ops::Key_Agreement_with_KDF {

secure_vector<uint8_t> 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:
Expand Down

0 comments on commit 95b80ba

Please sign in to comment.