7#ifndef BOTAN_EC_INNER_DATA_H_
8#define BOTAN_EC_INNER_DATA_H_
10#include <botan/ec_group.h>
12#include <botan/asn1_obj.h>
13#include <botan/bigint.h>
14#include <botan/reducer.h>
15#include <botan/internal/stl_util.h>
21class EC_Point_Base_Point_Precompute;
35 virtual const std::shared_ptr<const EC_Group_Data>&
group()
const = 0;
37 virtual size_t bytes()
const = 0;
39 virtual std::unique_ptr<EC_Scalar_Data>
clone()
const = 0;
49 virtual std::unique_ptr<EC_Scalar_Data>
negate()
const = 0;
51 virtual std::unique_ptr<EC_Scalar_Data>
invert()
const = 0;
66 virtual const std::shared_ptr<const EC_Group_Data>&
group()
const = 0;
68 virtual std::unique_ptr<EC_AffinePoint_Data>
clone()
const = 0;
93 std::vector<BigInt>& ws)
const = 0;
162 size_t p_bits()
const {
return m_p_bits; }
164 size_t p_bytes()
const {
return (m_p_bits + 7) / 8; }
200 std::unique_ptr<EC_Scalar_Data>
scalar_deserialize(std::span<const uint8_t> bytes)
const;
224 std::unique_ptr<EC_Scalar_Data>
scalar_zero()
const;
226 std::unique_ptr<EC_Scalar_Data>
scalar_one()
const;
230 std::vector<BigInt>& ws)
const;
235 std::unique_ptr<EC_AffinePoint_Data>
point_deserialize(std::span<const uint8_t> bytes)
const;
238 std::span<const uint8_t> input,
239 std::span<const uint8_t> domain_sep)
const;
242 std::span<const uint8_t> input,
243 std::span<const uint8_t> domain_sep)
const;
247 std::vector<BigInt>& ws)
const;
258 std::shared_ptr<const PCurve::PrimeOrderCurve> m_pcurve;
261 std::unique_ptr<EC_Point_Base_Point_Precompute> m_base_mult;
272 std::vector<uint8_t> m_der_named_curve;
275 size_t m_order_bytes;
279 bool m_order_is_less_than_p;
#define BOTAN_ASSERT_NONNULL(ptr)
const BigInt & get_a() const
const BigInt & get_p() const
const BigInt & get_b() const
virtual void serialize_compressed_to(std::span< uint8_t > bytes) const =0
virtual ~EC_AffinePoint_Data()=default
virtual void serialize_y_to(std::span< uint8_t > bytes) const =0
virtual std::unique_ptr< EC_AffinePoint_Data > clone() const =0
virtual size_t field_element_bytes() const =0
virtual void serialize_uncompressed_to(std::span< uint8_t > bytes) const =0
virtual void serialize_x_to(std::span< uint8_t > bytes) const =0
virtual const std::shared_ptr< const EC_Group_Data > & group() const =0
virtual EC_Point to_legacy_point() const =0
virtual bool is_identity() const =0
virtual void serialize_xy_to(std::span< uint8_t > bytes) const =0
virtual std::unique_ptr< EC_AffinePoint_Data > mul(const EC_Scalar_Data &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &ws) const =0
const BigInt & g_x() const
std::unique_ptr< EC_Scalar_Data > gk_x_mod_order(const EC_Scalar_Data &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &ws) const
std::unique_ptr< EC_Scalar_Data > scalar_from_bytes_mod_order(std::span< const uint8_t > bytes) const
std::unique_ptr< EC_AffinePoint_Data > point_deserialize(std::span< const uint8_t > bytes) const
bool a_is_minus_3() const
std::unique_ptr< EC_Scalar_Data > scalar_random(RandomNumberGenerator &rng) const
std::unique_ptr< EC_Scalar_Data > scalar_zero() const
bool has_cofactor() const
std::unique_ptr< EC_Scalar_Data > scalar_deserialize(std::span< const uint8_t > bytes) const
bool params_match(const BigInt &p, const BigInt &a, const BigInt &b, const BigInt &g_x, const BigInt &g_y, const BigInt &order, const BigInt &cofactor) const
const PCurve::PrimeOrderCurve & pcurve() const
EC_Group_Data(const BigInt &p, const BigInt &a, const BigInt &b, const BigInt &g_x, const BigInt &g_y, const BigInt &order, const BigInt &cofactor, const OID &oid, EC_Group_Source source)
std::unique_ptr< EC_Scalar_Data > scalar_from_bytes_with_trunc(std::span< const uint8_t > bytes) const
std::unique_ptr< EC_Mul2Table_Data > make_mul2_table(const EC_AffinePoint_Data &pt) const
std::unique_ptr< EC_Scalar_Data > scalar_one() const
const EC_Point & base_point() const
size_t order_bits() const
const BigInt & cofactor() const
std::unique_ptr< EC_AffinePoint_Data > point_g_mul(const EC_Scalar_Data &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &ws) const
const CurveGFp & curve() const
BigInt inverse_mod_order(const BigInt &x) const
BigInt multiply_mod_order(const BigInt &x, const BigInt &y) const
BigInt multiply_mod_order(const BigInt &x, const BigInt &y, const BigInt &z) const
const std::vector< uint8_t > & der_named_curve() const
bool order_is_less_than_p() const
EC_Group_Source source() const
void set_oid(const OID &oid)
BigInt square_mod_order(const BigInt &x) const
const BigInt & g_y() const
size_t order_bytes() const
std::unique_ptr< EC_Scalar_Data > scalar_from_bigint(const BigInt &bn) const
std::unique_ptr< EC_AffinePoint_Data > point_hash_to_curve_ro(std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep) const
BigInt mod_order(const BigInt &x) const
std::unique_ptr< EC_AffinePoint_Data > point_hash_to_curve_nu(std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep) const
const BigInt & order() const
virtual ~EC_Mul2Table_Data()=default
virtual bool mul2_vartime_x_mod_order_eq(const EC_Scalar_Data &v, const EC_Scalar_Data &x, const EC_Scalar_Data &y) const =0
virtual std::unique_ptr< EC_AffinePoint_Data > mul2_vartime(const EC_Scalar_Data &x, const EC_Scalar_Data &y) const =0
virtual void assign(const EC_Scalar_Data &y)=0
virtual const std::shared_ptr< const EC_Group_Data > & group() const =0
virtual size_t bytes() const =0
virtual std::unique_ptr< EC_Scalar_Data > sub(const EC_Scalar_Data &other) const =0
virtual std::unique_ptr< EC_Scalar_Data > invert() const =0
virtual void serialize_to(std::span< uint8_t > bytes) const =0
virtual std::unique_ptr< EC_Scalar_Data > negate() const =0
virtual std::unique_ptr< EC_Scalar_Data > clone() const =0
virtual std::unique_ptr< EC_Scalar_Data > add(const EC_Scalar_Data &other) const =0
virtual void square_self()=0
virtual bool is_eq(const EC_Scalar_Data &y) const =0
virtual bool is_zero() const =0
virtual ~EC_Scalar_Data()=default
virtual std::unique_ptr< EC_Scalar_Data > mul(const EC_Scalar_Data &other) const =0
BigInt square(const BigInt &x) const
BigInt multiply(const BigInt &x, const BigInt &y) const
BigInt reduce(const BigInt &x) const
int(* final)(unsigned char *, CTX *)
BigInt inverse_mod(const BigInt &n, const BigInt &mod)