114 friend class EC_Group_Data;
135 size_t get_p_words()
const {
return m_repr->get_p_words(); }
137 size_t get_p_bits()
const {
return m_repr->get_p_bits(); }
139 size_t get_p_bytes()
const {
return (get_p_bits() + 7) / 8; }
141 size_t get_ws_size()
const {
return m_repr->get_ws_size(); }
143 const BigInt& get_a_rep()
const {
return m_repr->get_a_rep(); }
145 const BigInt& get_b_rep()
const {
return m_repr->get_b_rep(); }
147 const BigInt& get_1_rep()
const {
return m_repr->get_1_rep(); }
149 bool a_is_minus_3()
const {
return m_repr->a_is_minus_3(); }
151 bool a_is_zero()
const {
return m_repr->a_is_zero(); }
153 bool is_one(
const BigInt& x)
const {
return m_repr->is_one(x); }
155 BigInt invert_element(
const BigInt& x, secure_vector<word>& ws)
const {
return m_repr->invert_element(x, ws); }
157 void to_rep(BigInt& x, secure_vector<word>& ws)
const { m_repr->to_curve_rep(x, ws); }
159 void from_rep(BigInt& x, secure_vector<word>& ws)
const { m_repr->from_curve_rep(x, ws); }
161 BigInt from_rep_to_tmp(
const BigInt& x, secure_vector<word>& ws)
const {
163 m_repr->from_curve_rep(xt, ws);
169 void mul(BigInt& z,
const BigInt& x,
const BigInt& y, secure_vector<word>& ws)
const {
170 m_repr->curve_mul(z, x, y, ws);
173 void mul(BigInt& z,
const word x_w[],
size_t x_size,
const BigInt& y, secure_vector<word>& ws)
const {
174 m_repr->curve_mul_words(z, x_w, x_size, y, ws);
177 void sqr(BigInt& z,
const BigInt& x, secure_vector<word>& ws)
const { m_repr->curve_sqr(z, x, ws); }
179 void sqr(BigInt& z,
const word x_w[],
size_t x_size, secure_vector<word>& ws)
const {
180 m_repr->curve_sqr_words(z, x_w, x_size, ws);
183 BigInt mul(
const BigInt& x,
const BigInt& y, secure_vector<word>& ws)
const {
return mul_to_tmp(x, y, ws); }
185 BigInt sqr(
const BigInt& x, secure_vector<word>& ws)
const {
return sqr_to_tmp(x, ws); }
187 BigInt mul_to_tmp(
const BigInt& x,
const BigInt& y, secure_vector<word>& ws)
const {
189 m_repr->curve_mul(z, x, y, ws);
193 BigInt sqr_to_tmp(
const BigInt& x, secure_vector<word>& ws)
const {
195 m_repr->curve_sqr(z, x, ws);
199 void swap(CurveGFp& other) { std::swap(m_repr, other.m_repr); }
209 if(m_repr.get() == other.m_repr.get()) {
213 return (get_p() == other.
get_p()) && (get_a() == other.
get_a()) && (get_b() == other.
get_b());
216 inline bool operator!=(
const CurveGFp& other)
const =
default;
219 static std::shared_ptr<CurveGFp_Repr> choose_repr(
const BigInt& p,
const BigInt& a,
const BigInt& b);
221 std::shared_ptr<CurveGFp_Repr> m_repr;