#ifndef ELL_H
#define ELL_H
class ell_pEInfoT {
private:
ell_pEInfoT();
ell_pEInfoT(const ell_pEInfoT&);
void operator=(const ell_pEInfoT&);
public:
long ref_count;
ell_pEInfoT(const zz_pE& new_a4, const zz_pE& new_a6);
~ell_pEInfoT();
zz_pE a4, a6;
long q;
};
typedef ell_pEInfoT *ell_pEInfoPtr;
class ell_pEContext {
private:
ell_pEInfoT *ptr;
public:
void save();
void restore() const;
ell_pEContext() { ptr = NULL; }
ell_pEContext(const zz_pE& a4, const zz_pE& a6);
ell_pEContext(const ell_pEContext&);
ell_pEContext& operator=(const ell_pEContext&);
~ell_pEContext();
};
extern ell_pEInfoPtr ell_pEInfo;
class ell_pE {
public:
static void init(zz_pE& a4, zz_pE& a6);
static long order();
};
class ellpoint_pE {
private:
public:
zz_pE x, y;
int identity_f;
ellpoint_pE();
ellpoint_pE(const zz_pE& x, const zz_pE& y);
inline int on_curve()
{ return sqr(y) == ((sqr(x)+ell_pEInfo->a4)*x + ell_pEInfo->a6); }
inline void set() { identity_f = 1; }
inline void set(const zz_pE& _x, const zz_pE& _y)
{ identity_f = 0; x = _x; y = _y; }
long order();
};
void neg(ellpoint_pE& Q, const ellpoint_pE& P);
void add(ellpoint_pE& R, const ellpoint_pE& P, const ellpoint_pE& Q);
void sub(ellpoint_pE& R, const ellpoint_pE& P, const ellpoint_pE& Q);
ellpoint_pE operator-(const ellpoint_pE& P);
ellpoint_pE operator+(const ellpoint_pE& P, const ellpoint_pE& Q);
ellpoint_pE operator-(const ellpoint_pE& P, const ellpoint_pE& Q);
ellpoint_pE& operator+=(ellpoint_pE& P, const ellpoint_pE& Q);
ellpoint_pE& operator-=(ellpoint_pE& P, const ellpoint_pE& Q);
ellpoint_pE operator*(int m, const ellpoint_pE& P);
int is_zero(const ellpoint_pE& P);
long operator==(const ellpoint_pE& P, const ellpoint_pE& Q);
long operator<( ellpoint_pE& P, ellpoint_pE& Q);
long operator>( ellpoint_pE& P, ellpoint_pE& Q);
long operator<=(ellpoint_pE& P, ellpoint_pE& Q);
long operator>=(ellpoint_pE& P, ellpoint_pE& Q);
ostream& operator<<(ostream& s, const ellpoint_pE& P);
unsigned long* to_ulong(ellpoint_pE& P);
void ell_cleanup();
#endif