136 size_t get_p_words()
const {
return m_repr->get_p_words(); }
138 size_t get_p_bits()
const {
return m_repr->get_p_bits(); }
140 size_t get_p_bytes()
const {
return (get_p_bits() + 7) / 8; }
142 size_t get_ws_size()
const {
return m_repr->get_ws_size(); }
144 const BigInt& get_a_rep()
const {
return m_repr->get_a_rep(); }
146 const BigInt& get_b_rep()
const {
return m_repr->get_b_rep(); }
148 const BigInt& get_1_rep()
const {
return m_repr->get_1_rep(); }
150 bool a_is_minus_3()
const {
return m_repr->a_is_minus_3(); }
152 bool a_is_zero()
const {
return m_repr->a_is_zero(); }
154 bool is_one(
const BigInt& x)
const {
return m_repr->is_one(x); }
156 BigInt invert_element(
const BigInt& x, secure_vector<word>& ws)
const {
return m_repr->invert_element(x, ws); }
158 void to_rep(BigInt& x, secure_vector<word>& ws)
const { m_repr->to_curve_rep(x, ws); }
160 void from_rep(BigInt& x, secure_vector<word>& ws)
const { m_repr->from_curve_rep(x, ws); }
162 BigInt from_rep_to_tmp(
const BigInt& x, secure_vector<word>& ws)
const {
164 m_repr->from_curve_rep(xt, ws);
170 void mul(BigInt& z,
const BigInt& x,
const BigInt& y, secure_vector<word>& ws)
const {
171 m_repr->curve_mul(z, x, y, ws);
174 void mul(BigInt& z,
const word x_w[],
size_t x_size,
const BigInt& y, secure_vector<word>& ws)
const {
175 m_repr->curve_mul_words(z, x_w, x_size, y, ws);
178 void sqr(BigInt& z,
const BigInt& x, secure_vector<word>& ws)
const { m_repr->curve_sqr(z, x, ws); }
180 void sqr(BigInt& z,
const word x_w[],
size_t x_size, secure_vector<word>& ws)
const {
181 m_repr->curve_sqr_words(z, x_w, x_size, ws);
184 BigInt mul(
const BigInt& x,
const BigInt& y, secure_vector<word>& ws)
const {
return mul_to_tmp(x, y, ws); }
186 BigInt sqr(
const BigInt& x, secure_vector<word>& ws)
const {
return sqr_to_tmp(x, ws); }
188 BigInt mul_to_tmp(
const BigInt& x,
const BigInt& y, secure_vector<word>& ws)
const {
190 m_repr->curve_mul(z, x, y, ws);
194 BigInt sqr_to_tmp(
const BigInt& x, secure_vector<word>& ws)
const {
196 m_repr->curve_sqr(z, x, ws);
200 void swap(CurveGFp& other) { std::swap(m_repr, other.m_repr); }
210 if(m_repr.get() == other.m_repr.get()) {
214 return (get_p() == other.
get_p()) && (get_a() == other.
get_a()) && (get_b() == other.
get_b());
217 inline bool operator!=(
const CurveGFp& other)
const =
default;
220 static std::shared_ptr<CurveGFp_Repr> choose_repr(
const BigInt& p,
const BigInt& a,
const BigInt& b);
222 std::shared_ptr<CurveGFp_Repr> m_repr;