diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index b5824ce..c0d37b5 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -425,7 +425,7 @@ public: } static inline void invG(Unit *y, const Unit *x) { - op_.invG(y, x, op_.p); + op_.invG(y, x, op_); } private: static inline void inFromStr(mpz_class& x, bool *isMinus, const std::string& str, int base) diff --git a/include/mcl/fp_base.hpp b/include/mcl/fp_base.hpp index fa6f6e6..9f986a4 100644 --- a/include/mcl/fp_base.hpp +++ b/include/mcl/fp_base.hpp @@ -35,8 +35,11 @@ typedef uint32_t Unit; typedef uint64_t Unit; #endif +struct Op; + typedef void (*void1op)(Unit*); typedef void (*void2op)(Unit*, const Unit*); +typedef void (*void2opOp)(Unit*, const Unit*, const Op&); typedef void (*void3op)(Unit*, const Unit*, const Unit*); typedef void (*void4op)(Unit*, const Unit*, const Unit*, const Unit*); typedef int (*int2op)(Unit*, const Unit*); @@ -159,7 +162,7 @@ struct Op { void2op fromMont; // require p void3op negG; - void3op invG; + void2opOp invG; void4op addG; void4op subG; void3op mulPreG; diff --git a/src/fp.cpp b/src/fp.cpp index 77b988d..01f903a 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -122,12 +122,12 @@ struct OpeFunc { mpz_mod(my, mx, mp); local::clearArray(y, my->_mp_size, N); } - static inline void invC(Unit *y, const Unit *x, const Unit *p) + static inline void invC(Unit *y, const Unit *x, const Op& op) { mpz_class my; mpz_t mx, mp; set_mpz_t(mx, x); - set_mpz_t(mp, p); + set_mpz_t(mp, op.p); mpz_invert(my.get_mpz_t(), mx, mp); local::toArray(y, N, my.get_mpz_t()); }