Closed guidovranken closed 2 years ago
What type is the value B? The type y of G1::mul(z, x, y) should be Fr or mpz_class. (Fp is not accepted. This is breaking backward compatibility. I forgot it.) The value is larger than r (= the order of G1), so could you use mpz_class or set (B % r, which can be computed by Fr::setLittleEndianMod). Using Fr is better than because it is faster than using mpz_class.
int main()
{
initPairing(mcl::BLS12_381);
G1 A, P;
A.x.setStr("2674736064367537260466998576948875816092530018012391451554681294626372801079300749663553872848166173052838590852969", 10);
A.y.setStr("3619055641023526422433505315233071744479608227444754666537459325486807540183936935747247430414964574839706132741773", 10);
A.z = 1;
const char *str = "3638679436378936848011985967149037743560824448519656435014878498369902353448401626833740454655344039476234037291460";
mpz_class B1;
mcl::gmp::setStr(B1, str, 10);
G1::mul(P, A, B1);
P.normalize();
std::cout << "P.x=" << P.x << std::endl;
std::cout << "P.y=" << P.y << std::endl;
P.clear();
Fr B2;
// this value is B1 % r
B2.setStr("38284638566776436211710320506911110215984697616190089678472849175738187020541", 10);
G1::mul(P, A, B2);
P.normalize();
std::cout << "P.x=" << P.x << std::endl;
std::cout << "P.y=" << P.y << std::endl;
}
I'll fix this issue. Please wait a moment.
mul supports Fp as scalar type at https://github.com/herumi/mcl/tree/dev . Thank you for your report. Could you try it?
Confirmed fixed as far as I can tell. Thanks!
E.g.
This was broken by a recent modification, possibly in this commit range: https://github.com/herumi/mcl/compare/fcc447f62392aa97e832164426befabec540bc57...12eec0345b57b8413a53bf58c6756601e43009cb