Closed xfap closed 1 year ago
Sorry, it's confusing for historical reasons and backward compatibility. What parameters of the pairing do you want to use? If you want to use only BLS12_381, make MCL_MAX_BIT_SIZE=384 lib/libmcl.a and use it with -DMCL_MAX_BIT_SIZE=384 and "including bls12_381.hpp".
MCL_MAX_BIT_SIZE
is the maximum bit length of the characteristic of a finite field that libmcl can handle.
MCL_MAX_FP_BIT_SIZE
is the maximum bit length defined mcl::bn::Fp for the defined field of an elliptic curve for a pairing.MCL_MAX_FR_BIT_SIZE
is the maximum bit length defined mcl::bn::Fr for the group order of an elliptic curve for a pairing.For BLS12_381, sizeof(Fp) = 384/8, sizeof(Fr) = 256/8.
@herumi Thanks. Sorry for further some more questions.
I see an example for multi instances for pairing in sample/multi.cpp
. If we can use this method to have all pairing instance?
BTW, notice api.md
only describes four kinds of pairing curves BN254 BN_SNARK1 BN381_1 BLS12_381
, and in include/mcl/curve_type.h
have already params for all curve declared by enum
.
So if the lib could actually support these pairings?
Would you like to use all pairing instances simultaneously?
Could you tell me the reason?
I don't recommend sample/multi.cpp
because it's a special usage.
We can compute all pairings defined in the enum, but mcl supports only BLS12-381 for the standard hash-to-G1/G2 functions defined in IRTF.
Cause I want to make a universal wrapper for different paring libs, so pairing curve switching needs happen over the wrapper(where requiring support of pairing instances simultaneously), but not over the underlying lib's building args.
I don't think mcl suits that purpose, though you can make two or three instances by sample/multi.cpp
.
The parameters other than BLS12_381 are not standard, but what kind of application are you thinking of?
Wanner be a part for a more user-friendly crypto lib.
AND another question from building error about MCL_MAX_BIT_SIZE, may you could help?
When setting building args -DMCL_MAX_BIT_SIZE=1024
, and initCurve
will fail for curves like:
mcl::initCurve< mcl::EcT<mcl::FpT<::mcl::FpTag, 256>>,mcl::FpT<::mcl::ZnTag, 256> >(...)
mcl::initCurve< mcl::EcT<mcl::FpT<::mcl::FpTag, 521>>,mcl::FpT<::mcl::ZnTag, 521> >(...);
Wanner be a part for a more user-friendly crypto lib.
mcl basically assumes single instance pairing, so could you use the other library?
-DMCL_MAX_BIT_SIZE=1024 Now mcl does not support the size. The max is 512.
MCL_SECP521R1 and MCL_SECP521R1 are not parameters for pairing.
Yes, not for pairing, I set MCL_MAX_BIT_SIZE
for purpose of using ecc MCL_SECP521R1
. But it seems not working right.
BTW, I'm working for a universal wrapper for ecc & pairing, not just pairing.
mcl basically assumes single instance pairing, so could you use the other library?
OK... maybe that's the way and I should just include only BLS12_381
except others pairing for libmcl
.
Now mcl does not support the size. The max is 512.
wait...max is 512? but how could we instantiate curveMCL_SECP521R1
?
Yes, not for pairing, I set
MCL_MAX_BIT_SIZE
for purpose of using eccMCL_SECP521R1
. But it seems not working right.
The old version supported MCL_SECP521R1, but I gave up on it now. I'll fix it later if I can afford it.
OK, very thanks for your helpful answers!
@xfap
requiring support of pairing instances simultaneously
By the way, in what situations do you need different pairings for multiple threads?
Beginner for this repo.
A little confused about the role of macros
MCL_MAX_FP_BIT_SIZE
,MCL_MAX_BIT_SIZE
, etc. Seems they are only for checking bounds or being consistent with C.My final aim here: want to make a more unified C++ wrapper upon
libmcl
for pairing & ecc curve instead of including different header file for different macro.