|
|
@ -1091,32 +1091,32 @@ struct BNT { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static void precomputeG2(std::vector<Fp6>& Qcoeff, const G2& Q) |
|
|
|
static void precomputeG2(std::vector<Fp6>& Qcoeff, const G2& Q) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Qcoeff.clear(); |
|
|
|
Qcoeff.resize(param.precomputedQcoeffSize); |
|
|
|
Qcoeff.reserve(param.siTbl.size() * 2); |
|
|
|
precomputeG2(Qcoeff.data(), Q); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
allocate param.precomputedQcoeffSize elements of Fp6 for Qcoeff |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static void precomputeG2(Fp6 *Qcoeff, const G2& Q) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
size_t idx = 0; |
|
|
|
Q.normalize(); |
|
|
|
Q.normalize(); |
|
|
|
G2 T = Q; |
|
|
|
G2 T = Q; |
|
|
|
G2 negQ; |
|
|
|
G2 negQ; |
|
|
|
if (param.useNAF) { |
|
|
|
if (param.useNAF) { |
|
|
|
G2::neg(negQ, Q); |
|
|
|
G2::neg(negQ, Q); |
|
|
|
} |
|
|
|
} |
|
|
|
Fp6 d; |
|
|
|
|
|
|
|
dblLineWithoutP(d, T); |
|
|
|
|
|
|
|
Qcoeff.push_back(d); |
|
|
|
|
|
|
|
Fp6 e; |
|
|
|
|
|
|
|
assert(param.siTbl[1] == 1); |
|
|
|
assert(param.siTbl[1] == 1); |
|
|
|
addLineWithoutP(e, T, Q); |
|
|
|
dblLineWithoutP(Qcoeff[idx++], T); |
|
|
|
Qcoeff.push_back(e); |
|
|
|
addLineWithoutP(Qcoeff[idx++], T, Q); |
|
|
|
Fp6 l; |
|
|
|
|
|
|
|
for (size_t i = 2; i < param.siTbl.size(); i++) { |
|
|
|
for (size_t i = 2; i < param.siTbl.size(); i++) { |
|
|
|
dblLineWithoutP(l, T); |
|
|
|
dblLineWithoutP(Qcoeff[idx++], T); |
|
|
|
Qcoeff.push_back(l); |
|
|
|
|
|
|
|
if (param.siTbl[i]) { |
|
|
|
if (param.siTbl[i]) { |
|
|
|
if (param.siTbl[i] > 0) { |
|
|
|
if (param.siTbl[i] > 0) { |
|
|
|
addLineWithoutP(l, T, Q); |
|
|
|
addLineWithoutP(Qcoeff[idx++], T, Q); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
addLineWithoutP(l, T, negQ); |
|
|
|
addLineWithoutP(Qcoeff[idx++], T, negQ); |
|
|
|
} |
|
|
|
} |
|
|
|
Qcoeff.push_back(l); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
G2 Q1, Q2; |
|
|
|
G2 Q1, Q2; |
|
|
@ -1126,12 +1126,15 @@ struct BNT { |
|
|
|
if (param.z < 0) { |
|
|
|
if (param.z < 0) { |
|
|
|
G2::neg(T, T); |
|
|
|
G2::neg(T, T); |
|
|
|
} |
|
|
|
} |
|
|
|
addLineWithoutP(d, T, Q1); |
|
|
|
addLineWithoutP(Qcoeff[idx++], T, Q1); |
|
|
|
Qcoeff.push_back(d); |
|
|
|
addLineWithoutP(Qcoeff[idx++], T, Q2); |
|
|
|
addLineWithoutP(e, T, Q2); |
|
|
|
assert(idx == param.precomputedQcoeffSize); |
|
|
|
Qcoeff.push_back(e); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
static void precomputedMillerLoop(Fp12& f, const G1& P, const std::vector<Fp6>& Qcoeff) |
|
|
|
static void precomputedMillerLoop(Fp12& f, const G1& P, const std::vector<Fp6>& Qcoeff) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
precomputedMillerLoop(f, P, Qcoeff.data()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
static void precomputedMillerLoop(Fp12& f, const G1& P, const Fp6* Qcoeff) |
|
|
|
{ |
|
|
|
{ |
|
|
|
P.normalize(); |
|
|
|
P.normalize(); |
|
|
|
size_t idx = 0; |
|
|
|
size_t idx = 0; |
|
|
@ -1169,6 +1172,10 @@ struct BNT { |
|
|
|
f = MillerLoop(P1, Q1) x MillerLoop(P2, Q2) |
|
|
|
f = MillerLoop(P1, Q1) x MillerLoop(P2, Q2) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static void precomputedMillerLoop2(Fp12& f, const G1& P1, const std::vector<Fp6>& Q1coeff, const G1& P2, const std::vector<Fp6>& Q2coeff) |
|
|
|
static void precomputedMillerLoop2(Fp12& f, const G1& P1, const std::vector<Fp6>& Q1coeff, const G1& P2, const std::vector<Fp6>& Q2coeff) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
precomputedMillerLoop2(f, P1, Q1coeff.data(), P2, Q2coeff.data()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
static void precomputedMillerLoop2(Fp12& f, const G1& P1, const Fp6* Q1coeff, const G1& P2, const Fp6* Q2coeff) |
|
|
|
{ |
|
|
|
{ |
|
|
|
P1.normalize(); |
|
|
|
P1.normalize(); |
|
|
|
P2.normalize(); |
|
|
|
P2.normalize(); |
|
|
|