herumi / bls

288 stars 132 forks source link

mismatched MCLBN_COMPILED_TIME_VAR definition #105

Closed t57root closed 4 months ago

t57root commented 6 months ago

Hi, I run the sample bls12_381_smpl.cpp with the following command:

# sh install.sh && cd sample
# g++ bls12_381_smpl.cpp -I../include -I../mcl/include -L../build/lib/ -lbls384
# LD_PRELOAD=../build/lib/libbls384.so ./a.out

But the last command gives out an error says err -66046 which is returned by the follow code.

        if (compiledTimeVar != MCLBN_COMPILED_TIME_VAR) {
                return -(compiledTimeVar + (MCLBN_COMPILED_TIME_VAR * 1000));
        }

But in the sample MCLBN_COMPILED_TIME_VAR is indeed passed into the blsInit as the second argument. It seems the value of MCLBN_COMPILED_TIME_VAR is 46 while it's 66 in the library.

Is there something I did wrong? Thanks in advance!

herumi commented 6 months ago

mcl/bls has two mode of BLS signature. The built library and the mode of use must be the same. If you use a library libbls384_256.a built with BLS_ETH=1, then you compile bls12_381_smpl.cpp with -DBLS_ETH. see https://github.com/herumi/bls#choice-of-groups