bls12::mapToG1 is ok

dev
MITSUNARI Shigeo 7 years ago
parent fa653e858f
commit 6e366d2454
  1. 1
      .gitignore
  2. 14
      include/mcl/bls12.hpp
  3. 2
      test/bls12_test.cpp

1
.gitignore vendored

@ -10,3 +10,4 @@ GTAGS
*.d
*.exe
*.swp
.cvsignore

@ -21,6 +21,15 @@ struct MapToT {
typedef mcl::EcT<Fp2> G2;
typedef util::HaveFrobenius<G2> G2withF;
mpz_class z_;
mpz_class cofactor1_;
/*
#(Fp) / r = (z + 1 - t) / r = (z - 1)^2 / 3
*/
void mulByCofactor(G1& Q, const G1& P) const
{
assert(cofactor1_ != 0);
G1::mulGeneric(Q, P, cofactor1_);
}
/*
Q = (z(z-1)-1)P + Frob((z-1)P) + Frob^2(2P)
*/
@ -39,6 +48,7 @@ struct MapToT {
void init(const mpz_class& z)
{
z_ = z;
cofactor1_ = (z - 1) * (z - 1) / 3;
}
template<class G, class F>
void calc(G& P, const F& t) const
@ -57,7 +67,7 @@ struct MapToT {
void calcG1(G1& P, const Fp& t) const
{
calc<G1, Fp>(P, t);
assert(P.isValid());
mulByCofactor(P, P);
}
/*
get the element in G2 by multiplying the cofactor
@ -65,9 +75,7 @@ struct MapToT {
void calcG2(G2& P, const Fp2& t) const
{
calc<G2, Fp2>(P, t);
assert(cofactor_ != 0);
mulByCofactor(P, P);
assert(!P.isZero());
}
};

@ -339,7 +339,7 @@ CYBOZU_TEST_AUTO(naive)
// testFp12pow(P, Q);
testTrivial(P, Q);
testSetStr(Q);
// testMapToG1();
testMapToG1();
testMapToG2();
testPairing(P, Q, ts.e);
testPrecomputed(P, Q);

Loading…
Cancel
Save