128 explicit EC_Group(std::span<const uint8_t> ber);
152 static
EC_Group from_PEM(std::string_view pem);
165 return EC_Group::from_PEM(pem);
204 static const std::set<std::string>& known_named_groups();
218 std::vector<uint8_t> DER_encode() const;
224 std::
string PEM_encode() const;
229 size_t get_p_bits() const;
234 size_t get_p_bytes() const;
239 size_t get_order_bits() const;
244 size_t get_order_bytes() const;
252 bool verify_public_element(const
EC_Point& y) const;
271 std::optional<EC_AffinePoint> mul2_vartime(
const EC_Scalar& x,
const EC_Scalar& y)
const;
293 bool mul2_vartime_x_mod_order_eq(
const EC_Scalar& v,
301 std::unique_ptr<EC_Mul2Table_Data> m_tbl;
308 const OID& get_curve_oid()
const;
313 const BigInt& get_p()
const;
318 const BigInt& get_a()
const;
323 const BigInt& get_b()
const;
328 const BigInt& get_g_x()
const;
333 const BigInt& get_g_y()
const;
339 const BigInt& get_order()
const;
345 const BigInt& get_cofactor()
const;
350 bool has_cofactor()
const;
355 static std::shared_ptr<EC_Group_Data> EC_group_info(
const OID& oid);
360 static size_t clear_registered_curve_data();
365 static OID EC_group_identity_from_order(
const BigInt& order);
370 const std::shared_ptr<EC_Group_Data>&
_data()
const {
return m_data; }
378 return EC_AffinePoint(*
this, std::span{bits, len}).to_legacy_point();
405 auto x = EC_Scalar::from_bigint(*
this, x_bn);
406 auto y = EC_Scalar::from_bigint(*
this, y_bn);
412 return r->to_legacy_point();
414 return EC_AffinePoint::identity(*this).to_legacy_point();
428 auto k = EC_Scalar::from_bigint(*
this, k_bn);
429 auto pt = EC_AffinePoint::g_mul(k, rng, ws);
430 return pt.to_legacy_point();
445 auto k = EC_Scalar::from_bigint(*
this, k_bn);
446 return BigInt(EC_AffinePoint::g_mul(k, rng, ws).x_bytes());
461 std::vector<
BigInt>& ws)
const {
462 auto k = EC_Scalar::from_bigint(*
this, k_bn);
464 return pt.mul(k, rng, ws).to_legacy_point();
471 return EC_Scalar::random(*
this, rng).to_bigint();
489 const uint8_t input[],
491 const uint8_t domain_sep[],
492 size_t domain_sep_len,
493 bool random_oracle = true)
const {
494 auto inp = std::span{input, input_len};
495 auto dst = std::span{domain_sep, domain_sep_len};
498 return EC_AffinePoint::hash_to_curve_ro(*
this, hash_fn, inp, dst).to_legacy_point();
500 return EC_AffinePoint::hash_to_curve_nu(*
this, hash_fn, inp, dst).to_legacy_point();
518 const uint8_t input[],
520 std::string_view domain_sep,
521 bool random_oracle = true)
const {
522 auto inp = std::span{input, input_len};
523 auto dst = std::span{
reinterpret_cast<const uint8_t*
>(domain_sep.data()), domain_sep.size()};
526 return EC_AffinePoint::hash_to_curve_ro(*
this, hash_fn, inp, dst).to_legacy_point();
528 return EC_AffinePoint::hash_to_curve_nu(*
this, hash_fn, inp, dst).to_legacy_point();
535 BOTAN_DEPRECATED(
"Deprecated no replacement") bool a_is_minus_3()
const {
return get_a() + 3 == get_p(); }
540 BOTAN_DEPRECATED(
"Deprecated no replacement") bool a_is_zero()
const {
return get_a().is_zero(); }
551 return EC_Scalar::from_bigint(*
this, x).invert().to_bigint();
558 auto xs = EC_Scalar::from_bigint(*
this, x);
560 return xs.to_bigint();
567 auto xs = EC_Scalar::from_bigint(*
this, x);
568 auto ys = EC_Scalar::from_bigint(*
this, y);
569 return (xs * ys).to_bigint();
577 auto xs = EC_Scalar::from_bigint(*
this, x);
578 auto ys = EC_Scalar::from_bigint(*
this, y);
579 auto zs = EC_Scalar::from_bigint(*
this, z);
580 return (xs * ys * zs).to_bigint();
587 auto xs = EC_Scalar::from_bigint(*
this, x);
588 return (xs * xs * xs).to_bigint();
595 if(
auto pt = EC_AffinePoint::from_bigint_xy(*
this, x, y)) {
596 return pt->to_legacy_point();
598 throw Decoding_Error(
"Invalid x/y coordinates for elliptic curve point");
606 return EC_AffinePoint::identity(*this).to_legacy_point();
611 if(format == EC_Point_Format::Compressed) {
612 return (1 + get_p_bytes());
614 return (1 + 2 * get_p_bytes());
619 static EC_Group_Data_Map& ec_group_data();
621 EC_Group(std::shared_ptr<EC_Group_Data>&& data);
623 static std::pair<std::shared_ptr<EC_Group_Data>,
bool> BER_decode_EC_group(std::span<const uint8_t> ber,
626 static std::shared_ptr<EC_Group_Data> load_EC_group_info(
const char* p,
637 std::shared_ptr<EC_Group_Data> m_data;
638 bool m_explicit_encoding =
false;