add compareRaw

dev
MITSUNARI Shigeo 10 years ago
parent eeac37c10d
commit e7ce730485
  1. 11
      include/mcl/ec.hpp
  2. 17
      include/mcl/fp.hpp

@ -29,9 +29,10 @@ namespace mcl {
y^2 = x^3 + az^4 + bz^6 (Jacobi) x = X/Z^2, y = Y/Z^3
*/
template<class _Fp>
//class EcT : public ope::addsub<EcT<_Fp>,
// ope::comparable<EcT<_Fp>,
class EcT : public ope::addsub<EcT<_Fp>,
ope::comparable<EcT<_Fp>,
ope::hasNegative<EcT<_Fp> > > > {
ope::comparable<EcT<_Fp> > > {
enum {
zero,
minus3,
@ -379,11 +380,12 @@ public:
{
P.normalize();
Q.normalize();
const bool QisZero = Q.isZero();
if (P.isZero()) {
if (Q.isZero()) return 0;
if (QisZero) return 0;
return -1;
}
if (Q.isZero()) return 1;
if (Q.isZero) return 1;
int c = _Fp::compare(P.x, Q.x);
if (c > 0) return 1;
if (c < 0) return -1;
@ -457,6 +459,7 @@ public:
Fp::neg(y, y);
}
}
EcT operator-() const { EcT x; neg(x, *this); return x; }
};
template<class T>

@ -306,18 +306,23 @@ public:
return is;
}
/*
not support
getBitLen, operator<, >
*/
/*
QQQ : should be removed
@note
this compare functions is slow because of calling mul if useMont is true.
*/
static inline int compare(const FpT& x, const FpT& y)
{
fp::Block xb, yb;
x.getBlock(xb);
y.getBlock(yb);
return fp::compareArray(xb.p, yb.p, xb.n);
return fp::compareArray(xb.p, yb.p, op_.N);
}
/*
@note
return unexpected order if useMont is set.
*/
static inline int compareRaw(const FpT& x, const FpT& y)
{
return fp::compareArray(x.v_, y.v_, op_.N);
}
/*
wrapper function for generic p

Loading…
Cancel
Save