diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index f53c7a6..b85b691 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -165,6 +165,8 @@ public: if (sqr == 0) sqr = sqrC; mul2 = fp::func_ptr_cast(op_.fp_mul2A_); if (mul2 == 0) mul2 = mul2C; + mul9 = fp::func_ptr_cast(op_.fp_mul9A_); + if (mul9 == 0) mul9 = mul9C; #endif *pb = true; } @@ -499,6 +501,8 @@ public: static inline void sqrC(FpT& y, const FpT& x) { op_.fp_sqr(y.v_, x.v_, op_.p); } static void (*mul2)(FpT& y, const FpT& x); static inline void mul2C(FpT& y, const FpT& x) { op_.fp_mul2(y.v_, x.v_, op_.p); } + static void (*mul9)(FpT& y, const FpT& x); + static inline void mul9C(FpT& y, const FpT& x) { mulSmall(y, x, 9); } #else static inline void add(FpT& z, const FpT& x, const FpT& y) { op_.fp_add(z.v_, x.v_, y.v_, op_.p); } static inline void sub(FpT& z, const FpT& x, const FpT& y) { op_.fp_sub(z.v_, x.v_, y.v_, op_.p); } @@ -506,6 +510,7 @@ public: static inline void mul(FpT& z, const FpT& x, const FpT& y) { op_.fp_mul(z.v_, x.v_, y.v_, op_.p); } static inline void sqr(FpT& y, const FpT& x) { op_.fp_sqr(y.v_, x.v_, op_.p); } static inline void mul2(FpT& y, const FpT& x) { op_.fp_mul2(y.v_, x.v_, op_.p); } + static inline void mul9(FpT& y, const FpT& x) { mulSmall(y, x, 9); } #endif static inline void addPre(FpT& z, const FpT& x, const FpT& y) { op_.fp_addPre(z.v_, x.v_, y.v_); } static inline void subPre(FpT& z, const FpT& x, const FpT& y) { op_.fp_subPre(z.v_, x.v_, y.v_); } @@ -756,6 +761,7 @@ template void (*FpT::neg)(FpT& y, template void (*FpT::mul)(FpT& z, const FpT& x, const FpT& y); template void (*FpT::sqr)(FpT& y, const FpT& x); template void (*FpT::mul2)(FpT& y, const FpT& x); +template void (*FpT::mul9)(FpT& y, const FpT& x); #endif } // mcl diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index 2dd358c..4fa8941 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -216,6 +216,7 @@ struct Op { void3u fp_mulA_; void2u fp_sqrA_; void2u fp_mul2A_; + void2u fp_mul9A_; void3u fp2_addA_; void3u fp2_subA_; void2u fp2_negA_; @@ -305,6 +306,7 @@ struct Op { fp_mulA_ = 0; fp_sqrA_ = 0; fp_mul2A_ = 0; + fp_mul9A_ = 0; fp2_addA_ = 0; fp2_subA_ = 0; fp2_negA_ = 0; diff --git a/test/bench.hpp b/test/bench.hpp index 8378674..11ced31 100644 --- a/test/bench.hpp +++ b/test/bench.hpp @@ -118,7 +118,7 @@ void testBench(const G1& P, const G2& Q) CYBOZU_BENCH_C("Fp::mul2 ", C3, Fp::mul2, x, x); CYBOZU_BENCH_C("Fp::mulSmall8 ", C3, Fp::mulSmall, x, x, 8); CYBOZU_BENCH_C("Fp::mulUnit8 ", C3, Fp::mulUnit, x, x, 8); - CYBOZU_BENCH_C("Fp::mulSmall9 ", C3, Fp::mulSmall, x, x, 9); + CYBOZU_BENCH_C("Fp::mul9 ", C3, Fp::mul9, x, x); CYBOZU_BENCH_C("Fp::mulUnit9 ", C3, Fp::mulUnit, x, x, 9); CYBOZU_BENCH_C("Fp::neg ", C3, Fp::neg, x, x); CYBOZU_BENCH_C("Fp::mul ", C3, Fp::mul, x, x, y);