aboutsummaryrefslogtreecommitdiffstats
path: root/include/mcl/she.hpp
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-09-25 10:24:14 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-09-25 10:24:14 +0800
commit06dc69840ae1cd73ae4c9a6b34e97e79ccfb5397 (patch)
tree6cc92e6f4873e2a4272a0cb2f2da8fd1e6040aeb /include/mcl/she.hpp
parentf38c0f9667796aeadc8058c8644bc8e8395f92aa (diff)
downloaddexon-mcl-06dc69840ae1cd73ae4c9a6b34e97e79ccfb5397.tar.gz
dexon-mcl-06dc69840ae1cd73ae4c9a6b34e97e79ccfb5397.tar.zst
dexon-mcl-06dc69840ae1cd73ae4c9a6b34e97e79ccfb5397.zip
[she] use precompute miller loop for Q
Diffstat (limited to 'include/mcl/she.hpp')
-rw-r--r--include/mcl/she.hpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/mcl/she.hpp b/include/mcl/she.hpp
index 7c7fd90..b8d14f5 100644
--- a/include/mcl/she.hpp
+++ b/include/mcl/she.hpp
@@ -337,6 +337,7 @@ struct SHET {
static G2 Q;
static GT ePQ; // e(P, Q)
static GT mPQ; // millerLoop(P, Q)
+ static std::vector<bn_current::Fp6> Qcoeff_;
static local::HashTable<G1> g1HashTbl;
static mcl::fp::WindowMethod<G2> g2wm;
typedef local::InterfaceForHashTable<GT, false> GTasEC;
@@ -458,6 +459,7 @@ public:
BN::hashAndMapToG2(Q, "0");
BN::millerLoop(mPQ, P, Q);
BN::finalExp(ePQ, mPQ);
+ BN::precomputeG2(Qcoeff_, Q);
const size_t bitSize = Fr::getBitSize();
g2wm.init(Q, bitSize, local::winSize);
gtwm.init(static_cast<const GTasEC&>(mPQ), bitSize, local::winSize);
@@ -666,7 +668,7 @@ public:
rb.setRand(rg);
rc.setRand(rg);
GT e;
-#if 1 // 6.5Mclk -> 5.9Mclk
+#if 1
G1 P1, P2;
G1::mul(P1, xP, ra);
if (m) {
@@ -674,7 +676,8 @@ public:
g1HashTbl.mulByWindowMethod(P2, m);
P1 += P2;
}
- BN::millerLoop(c.g[0], P1, Q);
+// BN::millerLoop(c.g[0], P1, Q);
+ BN::precomputedMillerLoop(c.g[0], P1, Qcoeff_);
// G1::mul(P1, P, rb);
g1HashTbl.mulByWindowMethod(P1, rb);
G1::mul(P2, xP, rc);
@@ -724,7 +727,9 @@ public:
Enc(1) = (S, T) = (Q + r yQ, rQ) = (Q, 0) if r = 0
cm = c1 * (Q, 0) = (S, T) * (Q, 0) = (e(S, Q), 1, e(T, Q), 1)
*/
- doubleMillerLoop(cm.g[0], cm.g[2], c1.S, c1.T, Q);
+// doubleMillerLoop(cm.g[0], cm.g[2], c1.S, c1.T, Q);
+ BN::precomputedMillerLoop(cm.g[0], c1.S, Qcoeff_);
+ BN::precomputedMillerLoop(cm.g[2], c1.T, Qcoeff_);
cm.g[1] = 1;
cm.g[3] = 1;
}
@@ -1146,6 +1151,7 @@ template<class BN, class Fr> typename BN::G1 SHET<BN, Fr>::P;
template<class BN, class Fr> typename BN::G2 SHET<BN, Fr>::Q;
template<class BN, class Fr> typename BN::Fp12 SHET<BN, Fr>::ePQ;
template<class BN, class Fr> typename BN::Fp12 SHET<BN, Fr>::mPQ;
+template<class BN, class Fr> std::vector<bn_current::Fp6> SHET<BN, Fr>::Qcoeff_;
template<class BN, class Fr> local::HashTable<typename BN::G1> SHET<BN, Fr>::g1HashTbl;
template<class BN, class Fr> mcl::fp::WindowMethod<typename BN::G2> SHET<BN, Fr>::g2wm;
template<class BN, class Fr> mcl::fp::WindowMethod<mcl::she::local::InterfaceForHashTable<typename BN::Fp12, false> > SHET<BN, Fr>::gtwm;