fix bls12_test for static code

update-fork
MITSUNARI Shigeo 4 years ago
parent 938e15432a
commit ad7b7891fa
  1. 6
      include/mcl/bn.hpp
  2. 17
      src/fp_static_code.hpp
  3. 3
      test/bls12_test.cpp

@ -854,6 +854,12 @@ struct Param {
{
this->cp = cp;
isBLS12 = cp.curveType == MCL_BLS12_381;
#ifdef MCL_STATIC_CODE
if (!isBLS12) {
*pb = false;
return;
}
#endif
gmp::setStr(pb, z, cp.z);
if (!*pb) return;
isNegative = z < 0;

@ -20,17 +20,15 @@ void mclx_Fp_add(Unit*, const Unit*, const Unit*);
void mclx_Fp_sub(Unit*, const Unit*, const Unit*);
void mclx_Fp_shr1(Unit*, const Unit*);
void mclx_Fp_neg(Unit*, const Unit*);
void mclx_FpDbl_mod(Unit*, const Unit*);
void mclx_Fp_mul(Unit*, const Unit*, const Unit*);
void mclx_Fp_sqr(Unit*, const Unit*);
void mclx_FpDbl_add(Unit*, const Unit*, const Unit*);
void mclx_FpDbl_sub(Unit*, const Unit*, const Unit*);
void mclx_FpDbl_add(Unit*, const Unit*, const Unit*);
void mclx_FpDbl_sub(Unit*, const Unit*, const Unit*);
Unit mclx_FpDbl_addPre(Unit*, const Unit*, const Unit*);
Unit mclx_FpDbl_subPre(Unit*, const Unit*, const Unit*);
void mclx_FpDbl_mulPre(Unit*, const Unit*, const Unit*);
void mclx_FpDbl_sqrPre(Unit*, const Unit*);
void mclx_FpDbl_mod(Unit*, const Unit*);
void mclx_Fp2_add(Unit*, const Unit*, const Unit*);
void mclx_Fp2_sub(Unit*, const Unit*, const Unit*);
void mclx_Fp2_neg(Unit*, const Unit*);
@ -59,15 +57,22 @@ void setStaticCode(mcl::fp::Op& op)
op.fp_subA_ = mclx_Fp_sub;
op.fp_shr1 = mclx_Fp_shr1;
op.fp_negA_ = mclx_Fp_neg;
op.fpDbl_modA_ = mclx_FpDbl_mod;
op.fp_mulA_ = mclx_Fp_mul;
op.fp_sqrA_ = mclx_Fp_sqr;
op.fpDbl_addA_ = mclx_FpDbl_add;
op.fpDbl_subA_ = mclx_FpDbl_sub;
op.fpDbl_addPre = mclx_FpDbl_addPre;
op.fpDbl_subPre = mclx_FpDbl_subPre;
op.fpDbl_mulPreA_ = mclx_FpDbl_mulPre;
op.fpDbl_sqrPreA_ = mclx_FpDbl_sqrPre;
op.fpDbl_modA_ = mclx_FpDbl_mod;
op.fp_mulA_ = mclx_Fp_mul;
op.fp_sqrA_ = mclx_Fp_sqr;
op.fp2_addA_ = mclx_Fp2_add;
op.fp2_subA_ = mclx_Fp2_sub;
op.fp2_negA_ = mclx_Fp2_neg;
op.fp2_mulNF = 0;
op.fp2_mulA_ = mclx_Fp2_mul;
op.fp2_sqrA_ = mclx_Fp2_sqr;
op.fp2_mul_xiA_ = mclx_Fp2_mul_xi;
} else {
// Fr, sizeof(Fr) = 32
op.fp_addPre = mclx_Fr_addPre;

@ -688,6 +688,8 @@ CYBOZU_TEST_AUTO(multi)
G1 P;
G2 Q;
int i;
#ifndef MCL_STATIC_CODE
puts("BN254");
testCurve(mcl::BN254);
i = 1;
@ -695,6 +697,7 @@ CYBOZU_TEST_AUTO(multi)
CYBOZU_BENCH_C("naiveG2", 100, (BN::param.mapTo.naiveMapTo<G1, Fp>), P, i++);
CYBOZU_BENCH_C("calcBN2", 100, (BN::param.mapTo.calcBN<G2, Fp2>), Q, i++);
CYBOZU_BENCH_C("naiveG2", 100, (BN::param.mapTo.naiveMapTo<G2, Fp2>), Q, i++);
#endif
puts("BLS12_381");
testCurve(mcl::BLS12_381);
i = 1;

Loading…
Cancel
Save