fix clear GLV for BLS12

dev
MITSUNARI Shigeo 7 years ago
parent 16babbe104
commit 0d9e994f57
  1. 7
      include/mcl/bn.hpp
  2. 30
      test/bls12_test.cpp
  3. 8
      test/bn384_test.cpp

@ -991,7 +991,12 @@ struct BNT {
{
param.init(cp, mode);
G2withF::init(cp.isMtype);
if (!param.isBLS12) {
if (param.isBLS12) {
// not supported yet
G1::setMulArrayGLV(0);
G2::setMulArrayGLV(0);
Fp12::setPowArrayGLV(0);
} else {
G1::setMulArrayGLV(mulArrayGLV1);
G2::setMulArrayGLV(mulArrayGLV2);
Fp12::setPowArrayGLV(powArrayGLV2);

@ -592,6 +592,36 @@ const char *eStr =
CYBOZU_TEST_EQUAL(e1, e2);
}
void testCurve(const mcl::CurveParam& cp)
{
initPairing(cp, g_mode);
G1 P;
G2 Q;
BLS12::mapToG1(P, 1);
BLS12::mapToG2(Q, 1);
GT e1, e2;
BLS12::pairing(e1, P, Q);
cybozu::XorShift rg;
mpz_class a, b;
Fr r;
r.setRand(rg); a = r.getMpz();
r.setRand(rg); b = r.getMpz();
G1 aP;
G2 bQ;
G1::mul(aP, P, a);
G2::mul(bQ, Q, b);
BLS12::pairing(e2, aP, bQ);
GT::pow(e1, e1, a * b);
CYBOZU_TEST_EQUAL(e1, e2);
}
CYBOZU_TEST_AUTO(multi)
{
puts("BN254BNb");
testCurve(mcl::BN254BNb);
puts("BLS12_381");
testCurve(mcl::BLS12_381);
}
int main(int argc, char *argv[])
try
{

@ -38,13 +38,15 @@ void testCurve(const mcl::CurveParam& cp)
CYBOZU_TEST_AUTO(pairing)
{
puts("CurveFp254BNb");
puts("BN254BNb");
// support 256-bit pairing
testCurve(mcl::BN254BNb);
puts("CurveFp382_1");
puts("BN382_1");
testCurve(mcl::BN382_1);
puts("CurveFp382_2");
puts("BN382_2");
testCurve(mcl::BN382_2);
puts("BLS12_381");
testCurve(mcl::BLS12_381);
// Q is not on EcT, but bad order
{
const char *s = "1 18d3d8c085a5a5e7553c3a4eb628e88b8465bf4de2612e35a0a4eb018fb0c82e9698896031e62fd7633ffd824a859474 1dc6edfcf33e29575d4791faed8e7203832217423bf7f7fbf1f6b36625b12e7132c15fbc15562ce93362a322fb83dd0d 65836963b1f7b6959030ddfa15ab38ce056097e91dedffd996c1808624fa7e2644a77be606290aa555cda8481cfb3cb 1b77b708d3d4f65aeedf54b58393463a42f0dc5856baadb5ce608036baeca398c5d9e6b169473a8838098fd72fd28b50";

Loading…
Cancel
Save