aboutsummaryrefslogtreecommitdiffstats
path: root/include/mcl/fp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mcl/fp.hpp')
-rw-r--r--include/mcl/fp.hpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp
index b159e2b..b6f4df8 100644
--- a/include/mcl/fp.hpp
+++ b/include/mcl/fp.hpp
@@ -270,12 +270,16 @@ public:
}
static inline void powerArray(FpT& z, const FpT& x, const Unit *y, size_t yn, bool isNegative)
{
- FpT out(1);
- fp::powerGeneric(out, x, y, yn, FpT::mul, FpT::square);
+ FpT tmp;
+ const FpT *px = &x;
+ if (&z == &x) {
+ tmp = x;
+ px = &tmp;
+ }
+ z = 1;
+ fp::powerGeneric(z, *px, y, yn, FpT::mul, FpT::square);
if (isNegative) {
- FpT::inv(z, out);
- } else {
- z = out;
+ FpT::inv(z, z);
}
}
template<class tag2, size_t maxBitSize2>