herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 152 forks source link

MCL not working on Linux/Windows cross platform #94

Closed MandarApte409 closed 3 years ago

MandarApte409 commented 3 years ago

Hi Team,

   I am working on an application which uses mcl library for IBE encryption/decryption. Our application need to work in cross platform where we encrypt on windows and decrypt on linux/fedora or vice-versa. I am using Fedora OS installed on Oracle Virtual Box. In this case, I have compiled the mcl library from the Git repository on Fedora virtual machine and linked the compiled libmcl.a file with my test application. The steps that I am doing to verify if encryption/decryption works on windows/Fedora is as below:
  1. I have single Test code which compiles on windows and Fedora box. It means, the APIs from mcl library used are same in Windows and Fedora OS.
  2. I have Herumi library compiled on windows which I am using in Windows test application code.
  3. I have mcl library compiled on Fedora which I am using in Linux Project in VS 2019.
  4. Firstly I execute the Windows test application code which generates the private key on windows machine. Using the generated Private key I encrypt a sample text message, then I dump the private key, the encrypted data and their respective sizes to a .dat file.
  5. Using the .dat file generated from Windows test application, I am trying to decrypt the text message on Fedora box. In this step, I read the .Windowsdat file to extract the private key generated on Windows, the encrypted text message and then pass this IBE private key to mcl APIs. Then using the generated key I am trying to decrypt the encrypted message using AES 256 encrypt/decrypt functions.

Observation: While trying to decrypt the encrypted message windows and Fedora, different values are getting generated from "pairing()", "FR::setHashOf()", "FR::sub()". The values from these 3 APIs are coming different when executed on Windows and Fedora.

It will be highly appreciate if we get any support here to figure out what is going wrong, as we are in the crunch mode of development. Expecting a kind response.

Thank you in advance.

Best Regards, Mandar M A

herumi commented 3 years ago

What code does output different values on Linux/Windows?

The sample of https://github.com/herumi/mcl/blob/master/sample/pairing_c.c outputs the same values on my Linux(Ubuntu 20.04.1 LTS) and Windows(Visual Studio 2019).

On Linux

make lib/libmcl.a lib/libmclbn384_256.a bin/pairing_c.exe && bin/pairing_c.exe
123 x 456 = 56088
123 - 456 = 52435875175126190479447740508185965837690552500527637822603658699938581184180
P = 1 d53dc985d379bac6142cbc8bbcf2d1017562af2c6b79a17f3780ade2bf85ae69d396ccb6f2adeac190fd44886befbbe 2bc3e19b5fed19facd08a60343f681164e62999471e11ef8634a577bdb368fcf7543e42e3a06e73cff46f46893b0d7a
Q = 1 c79f9de6659a5c2fc8a8ba34865875e120f29d8ac48c121cdfbe6210335c87072f2193e910e8f13bfcc4c6a0b376c47 142f4fff022124cae0d8be74eefd257aefc839a34027a52644ee2ade976acf687d6d42da7e99494ed77f943529eb3975 c8f41fcea61ea0cf0f125304ae840f7f0f2cf4a88cce60e2f8ff76ab0fdc7f0a4c510261455977199850cfd3b7219be 15870a8d311018c45f779958e1cf10ff8325411df4ba4d178152213b4ae63d2806dae81549a37061931481693cb16d24
e = 10f303ffa3a97bae498b73b256713e6ce70a51fabbace4a7ae9425c4990f628a2171a63c043064ad889946216b40b590 5797241e8fb340b552b639674672c7ea6def3c2124f3e3ce9784588205ea8c00b14f892d8cdd37c8ba7b7f5aaa9cc78 135b5b53c0a9724eda35ee02bec3d62e62479c5816da22f7030da8f56a797c9af655dc18e6f9ebdde28514f470978c9 e63608b29ae23116f8855ea43f4c3e5c811625d44d8699f38c15da9fa5d23696885b8022a35017096372429c3f7332e f1bae130654f428d5e0511afdd198ae6864500ce4292e57ffa859fa6673567da4b7b0596386001ebcf590a36c6bc747 7f877ad5107b4ab5dad9881c6af7089c3c360b74f31f99bf0cf073bc7acde7405de39f4d3218929f89ec961cb3e875b f1f9a5a42b8e7da9bcca864cf20d05dc3fbc588cc93d808b16e493f77f54c5ed46bbc878d64c4736c3d65d9c7d0b9 115a915e55f290d9160d4c4131fc0ab2e97a479fe58db1874a32ca0586f156b26861cc6bde0d34010b7feb0a4ac2e2a3 d0e8d5b7e1f678089b2a46388479c1c45ac61b09b300308352eb644529918859a948d5cb6e59a35b8ee6e5d2a24df60 b2203b90025d3698b37138c9acd722c7581d3cdd76333b760895a20b8659a3c12408f76c7801a5d9e645397606bd248 10720eab4947203ce683d8313f33bdb271eead30d2fc5307c0b304a340f6df48121d4dd48a2ae88b5439ad7538e5b653 19a23f338577a6264a0ccb28beb4d93ad573eaf94285efcf99111bb74edf41197d6e0f7ad00978905fb832534d0aea28
no err

On Windows

cd mcl
mklib
mk -s sample\pairing_c.c && bin/pairing_c.exe
123 x 456 = 56088
123 - 456 = 52435875175126190479447740508185965837690552500527637822603658699938581184180
P = 1 d53dc985d379bac6142cbc8bbcf2d1017562af2c6b79a17f3780ade2bf85ae69d396ccb6f2adeac190fd44886befbbe 2bc3e19b5fed19facd08a60343f681164e62999471e11ef8634a577bdb368fcf7543e42e3a06e73cff46f46893b0d7a
Q = 1 c79f9de6659a5c2fc8a8ba34865875e120f29d8ac48c121cdfbe6210335c87072f2193e910e8f13bfcc4c6a0b376c47 142f4fff022124cae0d8be74eefd257aefc839a34027a52644ee2ade976acf687d6d42da7e99494ed77f943529eb3975 c8f41fcea61ea0cf0f125304ae840f7f0f2cf4a88cce60e2f8ff76ab0fdc7f0a4c510261455977199850cfd3b7219be 15870a8d311018c45f779958e1cf10ff8325411df4ba4d178152213b4ae63d2806dae81549a37061931481693cb16d24
e = 10f303ffa3a97bae498b73b256713e6ce70a51fabbace4a7ae9425c4990f628a2171a63c043064ad889946216b40b590 5797241e8fb340b552b639674672c7ea6def3c2124f3e3ce9784588205ea8c00b14f892d8cdd37c8ba7b7f5aaa9cc78 135b5b53c0a9724eda35ee02bec3d62e62479c5816da22f7030da8f56a797c9af655dc18e6f9ebdde28514f470978c9 e63608b29ae23116f8855ea43f4c3e5c811625d44d8699f38c15da9fa5d23696885b8022a35017096372429c3f7332e f1bae130654f428d5e0511afdd198ae6864500ce4292e57ffa859fa6673567da4b7b0596386001ebcf590a36c6bc747 7f877ad5107b4ab5dad9881c6af7089c3c360b74f31f99bf0cf073bc7acde7405de39f4d3218929f89ec961cb3e875b f1f9a5a42b8e7da9bcca864cf20d05dc3fbc588cc93d808b16e493f77f54c5ed46bbc878d64c4736c3d65d9c7d0b9 115a915e55f290d9160d4c4131fc0ab2e97a479fe58db1874a32ca0586f156b26861cc6bde0d34010b7feb0a4ac2e2a3 d0e8d5b7e1f678089b2a46388479c1c45ac61b09b300308352eb644529918859a948d5cb6e59a35b8ee6e5d2a24df60 b2203b90025d3698b37138c9acd722c7581d3cdd76333b760895a20b8659a3c12408f76c7801a5d9e645397606bd248 10720eab4947203ce683d8313f33bdb271eead30d2fc5307c0b304a340f6df48121d4dd48a2ae88b5439ad7538e5b653 19a23f338577a6264a0ccb28beb4d93ad573eaf94285efcf99111bb74edf41197d6e0f7ad00978905fb832534d0aea28
no err
MandarApte409 commented 3 years ago

What code does output different values on Linux/Windows?

The sample of https://github.com/herumi/mcl/blob/master/sample/pairing_c.c outputs the same values on my Linux(Ubuntu 20.04.1 LTS) and Windows(Visual Studio 2019).

On Linux

make lib/libmcl.a lib/libmclbn384_256.a bin/pairing_c.exe && bin/pairing_c.exe
123 x 456 = 56088
123 - 456 = 52435875175126190479447740508185965837690552500527637822603658699938581184180
P = 1 d53dc985d379bac6142cbc8bbcf2d1017562af2c6b79a17f3780ade2bf85ae69d396ccb6f2adeac190fd44886befbbe 2bc3e19b5fed19facd08a60343f681164e62999471e11ef8634a577bdb368fcf7543e42e3a06e73cff46f46893b0d7a
Q = 1 c79f9de6659a5c2fc8a8ba34865875e120f29d8ac48c121cdfbe6210335c87072f2193e910e8f13bfcc4c6a0b376c47 142f4fff022124cae0d8be74eefd257aefc839a34027a52644ee2ade976acf687d6d42da7e99494ed77f943529eb3975 c8f41fcea61ea0cf0f125304ae840f7f0f2cf4a88cce60e2f8ff76ab0fdc7f0a4c510261455977199850cfd3b7219be 15870a8d311018c45f779958e1cf10ff8325411df4ba4d178152213b4ae63d2806dae81549a37061931481693cb16d24
e = 10f303ffa3a97bae498b73b256713e6ce70a51fabbace4a7ae9425c4990f628a2171a63c043064ad889946216b40b590 5797241e8fb340b552b639674672c7ea6def3c2124f3e3ce9784588205ea8c00b14f892d8cdd37c8ba7b7f5aaa9cc78 135b5b53c0a9724eda35ee02bec3d62e62479c5816da22f7030da8f56a797c9af655dc18e6f9ebdde28514f470978c9 e63608b29ae23116f8855ea43f4c3e5c811625d44d8699f38c15da9fa5d23696885b8022a35017096372429c3f7332e f1bae130654f428d5e0511afdd198ae6864500ce4292e57ffa859fa6673567da4b7b0596386001ebcf590a36c6bc747 7f877ad5107b4ab5dad9881c6af7089c3c360b74f31f99bf0cf073bc7acde7405de39f4d3218929f89ec961cb3e875b f1f9a5a42b8e7da9bcca864cf20d05dc3fbc588cc93d808b16e493f77f54c5ed46bbc878d64c4736c3d65d9c7d0b9 115a915e55f290d9160d4c4131fc0ab2e97a479fe58db1874a32ca0586f156b26861cc6bde0d34010b7feb0a4ac2e2a3 d0e8d5b7e1f678089b2a46388479c1c45ac61b09b300308352eb644529918859a948d5cb6e59a35b8ee6e5d2a24df60 b2203b90025d3698b37138c9acd722c7581d3cdd76333b760895a20b8659a3c12408f76c7801a5d9e645397606bd248 10720eab4947203ce683d8313f33bdb271eead30d2fc5307c0b304a340f6df48121d4dd48a2ae88b5439ad7538e5b653 19a23f338577a6264a0ccb28beb4d93ad573eaf94285efcf99111bb74edf41197d6e0f7ad00978905fb832534d0aea28
no err

On Windows

cd mcl
mklib
mk -s sample\pairing_c.c && bin/pairing_c.exe
123 x 456 = 56088
123 - 456 = 52435875175126190479447740508185965837690552500527637822603658699938581184180
P = 1 d53dc985d379bac6142cbc8bbcf2d1017562af2c6b79a17f3780ade2bf85ae69d396ccb6f2adeac190fd44886befbbe 2bc3e19b5fed19facd08a60343f681164e62999471e11ef8634a577bdb368fcf7543e42e3a06e73cff46f46893b0d7a
Q = 1 c79f9de6659a5c2fc8a8ba34865875e120f29d8ac48c121cdfbe6210335c87072f2193e910e8f13bfcc4c6a0b376c47 142f4fff022124cae0d8be74eefd257aefc839a34027a52644ee2ade976acf687d6d42da7e99494ed77f943529eb3975 c8f41fcea61ea0cf0f125304ae840f7f0f2cf4a88cce60e2f8ff76ab0fdc7f0a4c510261455977199850cfd3b7219be 15870a8d311018c45f779958e1cf10ff8325411df4ba4d178152213b4ae63d2806dae81549a37061931481693cb16d24
e = 10f303ffa3a97bae498b73b256713e6ce70a51fabbace4a7ae9425c4990f628a2171a63c043064ad889946216b40b590 5797241e8fb340b552b639674672c7ea6def3c2124f3e3ce9784588205ea8c00b14f892d8cdd37c8ba7b7f5aaa9cc78 135b5b53c0a9724eda35ee02bec3d62e62479c5816da22f7030da8f56a797c9af655dc18e6f9ebdde28514f470978c9 e63608b29ae23116f8855ea43f4c3e5c811625d44d8699f38c15da9fa5d23696885b8022a35017096372429c3f7332e f1bae130654f428d5e0511afdd198ae6864500ce4292e57ffa859fa6673567da4b7b0596386001ebcf590a36c6bc747 7f877ad5107b4ab5dad9881c6af7089c3c360b74f31f99bf0cf073bc7acde7405de39f4d3218929f89ec961cb3e875b f1f9a5a42b8e7da9bcca864cf20d05dc3fbc588cc93d808b16e493f77f54c5ed46bbc878d64c4736c3d65d9c7d0b9 115a915e55f290d9160d4c4131fc0ab2e97a479fe58db1874a32ca0586f156b26861cc6bde0d34010b7feb0a4ac2e2a3 d0e8d5b7e1f678089b2a46388479c1c45ac61b09b300308352eb644529918859a948d5cb6e59a35b8ee6e5d2a24df60 b2203b90025d3698b37138c9acd722c7581d3cdd76333b760895a20b8659a3c12408f76c7801a5d9e645397606bd248 10720eab4947203ce683d8313f33bdb271eead30d2fc5307c0b304a340f6df48121d4dd48a2ae88b5439ad7538e5b653 19a23f338577a6264a0ccb28beb4d93ad573eaf94285efcf99111bb74edf41197d6e0f7ad00978905fb832534d0aea28
no err

As mentioned in my previous comment, "pairing()", "FR::setHashOf()", "FR::sub()", the values from these 3 functions are coming different. I invoke initPairing(mcl::BN254, mcl::fp::FP_GMP); before calling the above mentioned functions, where-in there is no problem with InitPairing(). I am debugging the issue right now, let me see if I can provide you some proofs of what values are coming different from these 3 functions. Meantime, can you please let me know, is there any special compiler/linker/preprocessor flag that needs to be provided while compiling the mcl library on Linux/Windows ? What factors might cause the cross platform thing to not work ? Endianness, characterset something of these kinds which might be effecting the values computation in mcl library ?

herumi commented 3 years ago

initPairing(mcl::BN254, mcl::fp::FP_GMP);

You dont speficy mcl::fp::FP_GMP because it is slower than the default parameter.

I tried as the followings:

>cd mcl
>git branch -v
>* master 8befb75 sample/pairing.exe uses Fr::setHashOf

>make clean
>make lib/libmcl.a lib/libmclbn384_256.a bin/pairing.exe && bin/pairing.exe 1

BN254
P = ba1c2d0b6a0c2513889b79a1f7ee5e9b7956e8711f5ecd0e48508fcb33cfc224
Q = 1f7749e5aa22ad27563f1f88c5c6ab662571615f44063c9fe4981b8f563b360bec26bea1dd19e1e76d8600e7ac9c0e16922c4d63ccaacab9918bc4c686a6a096
a = d1500f261ff10b49c7a1796a36103b02322ae5dde404141eacf018fbf1678ba
a - b = d1500f261ff10b49c7a1796a36103b02322ae5dde404141eacf018fbf1676f2
pairing = 219657f7949989778a171b0736edf8a1c8b396645d941b137873e8b97fb55a28 1e2d498ffd29b58feac84882ed2cdbe122cf5df6e3f21d0e631af7a9731b2ed5 63e3878c096899c3abc5e306a7461c50e93bae4cbce387be9fde6401a83f15d f179183bf76309d00ed49a4945b3b5e7eda83a64a3f22198d96d37cd9c17a6b 79810b81ded5ac7701d9ecdf9bac4b2c109a916f7cf0f16ff3eae86349bba35 1224b7a0b516316115679a4091eb796caecec42ab430f9d1b861e7fd8f809d6f 1505c61d8ab4966d05a1e280f841448cc31b62bf43d4d7ab459f6567b9372d1d 10a8ec160ddbd6c0540e8cc2bbe46aeb1f9eccad1f10c56a3981863349e3b022 1679f0789db68e5c32dcb8b247d97ac5c7ac34e60c4650709bb7c30cb29f66c7 d043c97376f2d2ac5ed47c39054f65c299618a9d5207c521a1e2d0e6e45df59 149f92018e1e909aa30d2c47dba01116ebb5cd07868f8dc9ee7eb94c35edf364 87daa7cb4ffd6005eb7c42c565a20068b5e51502c91854aabbdd4cfb0b0ce13
ok
ok
ok
cd mcl
mklib
mk -s sample/pairing.cpp && bin/pairing.exe 1

outputs the same values as the above

What CPU does you use? and could you try the commands?

MandarApte409 commented 3 years ago

initPairing(mcl::BN254, mcl::fp::FP_GMP);

You dont speficy mcl::fp::FP_GMP because it is slower than the default parameter. Ok will remove that. But, my project uses a bit older version of Herumi. So will it work if I remove mcl::fp::FP_GMP flag from initPairing() API ?

I tried as the followings:

  • sample.cpp
  • Intel Core i5-8250U CPU @ 1.60GHz
  • gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 on Linux
>cd mcl
>git branch -v
>* master 8befb75 sample/pairing.exe uses Fr::setHashOf

>make clean
>make lib/libmcl.a lib/libmclbn384_256.a bin/pairing.exe && bin/pairing.exe 1

BN254
P = ba1c2d0b6a0c2513889b79a1f7ee5e9b7956e8711f5ecd0e48508fcb33cfc224
Q = 1f7749e5aa22ad27563f1f88c5c6ab662571615f44063c9fe4981b8f563b360bec26bea1dd19e1e76d8600e7ac9c0e16922c4d63ccaacab9918bc4c686a6a096
a = d1500f261ff10b49c7a1796a36103b02322ae5dde404141eacf018fbf1678ba
a - b = d1500f261ff10b49c7a1796a36103b02322ae5dde404141eacf018fbf1676f2
pairing = 219657f7949989778a171b0736edf8a1c8b396645d941b137873e8b97fb55a28 1e2d498ffd29b58feac84882ed2cdbe122cf5df6e3f21d0e631af7a9731b2ed5 63e3878c096899c3abc5e306a7461c50e93bae4cbce387be9fde6401a83f15d f179183bf76309d00ed49a4945b3b5e7eda83a64a3f22198d96d37cd9c17a6b 79810b81ded5ac7701d9ecdf9bac4b2c109a916f7cf0f16ff3eae86349bba35 1224b7a0b516316115679a4091eb796caecec42ab430f9d1b861e7fd8f809d6f 1505c61d8ab4966d05a1e280f841448cc31b62bf43d4d7ab459f6567b9372d1d 10a8ec160ddbd6c0540e8cc2bbe46aeb1f9eccad1f10c56a3981863349e3b022 1679f0789db68e5c32dcb8b247d97ac5c7ac34e60c4650709bb7c30cb29f66c7 d043c97376f2d2ac5ed47c39054f65c299618a9d5207c521a1e2d0e6e45df59 149f92018e1e909aa30d2c47dba01116ebb5cd07868f8dc9ee7eb94c35edf364 87daa7cb4ffd6005eb7c42c565a20068b5e51502c91854aabbdd4cfb0b0ce13
ok
ok
ok
  • Microsoft(R) C/C++ Optimizing Compiler Version 19.28.29335 for x64 on Windows

cd mcl
mklib
mk -s sample/pairing.cpp && bin/pairing.exe 1
    After running this I am not able to get the output as you have indicated. I mean like P, Q, a, a-b values. I get the following output as below on Windows. I executed the commands you mentioned from "VS 2019 Dev cmd Prompt".
mk -s sample\pairing.cpp && bin\pairing.exe 1

use static lib cl /MT /DNOMINMAX /Ox /DNDEBUG /openmp /W4 /Zi /EHsc /nologo -I./include -I../cybozulib_ext/include -DMCL_DONT_USE_OPENSSL -DMCL_USE_VINT -DMCL_SIZEOF_UNIT=8 -DMCL_VINT_FIXED_BUFFER -DMCL_MAX_BIT_SIZE=384 /DMCLBN_DONT_EXPORT sample\pairing.cpp /Fe:bin\pairing.exe /link /LIBPATH:.\lib pairing.cpp ok ok ok

outputs the same values as the above



What CPU does you use? and could you try the commands?
I use Intel(R) Core(TM) i5-8365 CPU @ 1.60GHz 1.90GHz

Additionally, I figured out that, using a constant master key, the Private and Public key values are generated differently on both Windows and Fedora machine. Hence, I believe there is some problem with way of using the library in my project. Either I need to compile it properly and link the mcl library or else some data type problem. Kindly let me know, if there is any test utility which I can run from both windows and linux to check if mcl library is working fine on both Windows and Fedora machines ?

Thank you very much in advance for quick response. I really appreciate the gesture.

MandarApte409 commented 3 years ago

Alright, finally I got the similar output as mentioned in the above comments. I am able to view the same output while running pairing_c.c and not for pairing.cpp file. I executed the below commands.

On Linux : make lib/libmcl.a lib/libmclbn384_256.a bin/pairing_c.exe && bin/pairing_c.exe The execution of the above command gives below output. 123 x 456 = 56088 P = 1 d53dc985d379bac6142cbc8bbcf2d1017562af2c6b79a17f3780ade2bf85ae69d396ccb6f2adeac190fd44886befbbe 2bc3e19b5fed19facd08a60343f681164e62999471e11ef8634a577bdb368fcf7543e42e3a06e73cff46f46893b0d7a Q = 1 c79f9de6659a5c2fc8a8ba34865875e120f29d8ac48c121cdfbe6210335c87072f2193e910e8f13bfcc4c6a0b376c47 142f4fff022124cae0d8be74eefd257aefc839a34027a52644ee2ade976acf687d6d42da7e99494ed77f943529eb3975 c8f41fcea61ea0cf0f125304ae840f7f0f2cf4a88cce60e2f8ff76ab0fdc7f0a4c510261455977199850cfd3b7219be 15870a8d311018c45f779958e1cf10ff8325411df4ba4d178152213b4ae63d2806dae81549a37061931481693cb16d24 e = 10f303ffa3a97bae498b73b256713e6ce70a51fabbace4a7ae9425c4990f628a2171a63c043064ad889946216b40b590 5797241e8fb340b552b639674672c7ea6def3c2124f3e3ce9784588205ea8c00b14f892d8cdd37c8ba7b7f5aaa9cc78 135b5b53c0a9724eda35ee02bec3d62e62479c5816da22f7030da8f56a797c9af655dc18e6f9ebdde28514f470978c9 e63608b29ae23116f8855ea43f4c3e5c811625d44d8699f38c15da9fa5d23696885b8022a35017096372429c3f7332e f1bae130654f428d5e0511afdd198ae6864500ce4292e57ffa859fa6673567da4b7b0596386001ebcf590a36c6bc747 7f877ad5107b4ab5dad9881c6af7089c3c360b74f31f99bf0cf073bc7acde7405de39f4d3218929f89ec961cb3e875b f1f9a5a42b8e7da9bcca864cf20d05dc3fbc588cc93d808b16e493f77f54c5ed46bbc878d64c4736c3d65d9c7d0b9 115a915e55f290d9160d4c4131fc0ab2e97a479fe58db1874a32ca0586f156b26861cc6bde0d34010b7feb0a4ac2e2a3 d0e8d5b7e1f678089b2a46388479c1c45ac61b09b300308352eb644529918859a948d5cb6e59a35b8ee6e5d2a24df60 b2203b90025d3698b37138c9acd722c7581d3cdd76333b760895a20b8659a3c12408f76c7801a5d9e645397606bd248 10720eab4947203ce683d8313f33bdb271eead30d2fc5307c0b304a340f6df48121d4dd48a2ae88b5439ad7538e5b653 19a23f338577a6264a0ccb28beb4d93ad573eaf94285efcf99111bb74edf41197d6e0f7ad00978905fb832534d0aea28 no err

On Windows :

  mk -s sample\pairing_c.c && bin\pairing_c.exe 1

  After executing above command it gives below output.

123 x 456 = 56088 P = 1 d53dc985d379bac6142cbc8bbcf2d1017562af2c6b79a17f3780ade2bf85ae69d396ccb6f2adeac190fd44886befbbe 2bc3e19b5fed19facd08a60343f681164e62999471e11ef8634a577bdb368fcf7543e42e3a06e73cff46f46893b0d7a Q = 1 c79f9de6659a5c2fc8a8ba34865875e120f29d8ac48c121cdfbe6210335c87072f2193e910e8f13bfcc4c6a0b376c47 142f4fff022124cae0d8be74eefd257aefc839a34027a52644ee2ade976acf687d6d42da7e99494ed77f943529eb3975 c8f41fcea61ea0cf0f125304ae840f7f0f2cf4a88cce60e2f8ff76ab0fdc7f0a4c510261455977199850cfd3b7219be 15870a8d311018c45f779958e1cf10ff8325411df4ba4d178152213b4ae63d2806dae81549a37061931481693cb16d24 e = 10f303ffa3a97bae498b73b256713e6ce70a51fabbace4a7ae9425c4990f628a2171a63c043064ad889946216b40b590 5797241e8fb340b552b639674672c7ea6def3c2124f3e3ce9784588205ea8c00b14f892d8cdd37c8ba7b7f5aaa9cc78 135b5b53c0a9724eda35ee02bec3d62e62479c5816da22f7030da8f56a797c9af655dc18e6f9ebdde28514f470978c9 e63608b29ae23116f8855ea43f4c3e5c811625d44d8699f38c15da9fa5d23696885b8022a35017096372429c3f7332e f1bae130654f428d5e0511afdd198ae6864500ce4292e57ffa859fa6673567da4b7b0596386001ebcf590a36c6bc747 7f877ad5107b4ab5dad9881c6af7089c3c360b74f31f99bf0cf073bc7acde7405de39f4d3218929f89ec961cb3e875b f1f9a5a42b8e7da9bcca864cf20d05dc3fbc588cc93d808b16e493f77f54c5ed46bbc878d64c4736c3d65d9c7d0b9 115a915e55f290d9160d4c4131fc0ab2e97a479fe58db1874a32ca0586f156b26861cc6bde0d34010b7feb0a4ac2e2a3 d0e8d5b7e1f678089b2a46388479c1c45ac61b09b300308352eb644529918859a948d5cb6e59a35b8ee6e5d2a24df60 b2203b90025d3698b37138c9acd722c7581d3cdd76333b760895a20b8659a3c12408f76c7801a5d9e645397606bd248 10720eab4947203ce683d8313f33bdb271eead30d2fc5307c0b304a340f6df48121d4dd48a2ae88b5439ad7538e5b653 19a23f338577a6264a0ccb28beb4d93ad573eaf94285efcf99111bb74edf41197d6e0f7ad00978905fb832534d0aea28 no err

    Output looks same on Windows and Fedora machine. But, then how do I figure out why is the key generation on Windows and Fedora machine are different and why is the algorithm not generating same key for constant "MASTER SECRET KEY" ?  
      Another point to note here is, for constant master key value, the public & private key generated is same for every execution cycle. And also the encryption done on Windows/Fedora decrypts successfully on its respective machines. 

Only cross platform encryption and decryption is not working.

herumi commented 3 years ago

You need not quote all my messages.

I am able to view the same output while running pairing_c.c and not for pairing.cpp file.

Have you used the latest version of pairing.cpp? https://github.com/herumi/mcl/commit/8befb75daa075ddbdbff814e4aaacd8caa172a7d

But, It seems that my library runs well on your Linux/Windows.

Only cross platform encryption and decryption is not working.

If you show me the minimum code to produce the difference, I may be able to advise.

MandarApte409 commented 3 years ago

Finally, even I am able to view the same output for windows/Fedora after executing the make commands for pairing_c.c and pairing.cpp file. After using the latest pairing.cpp file, I am able to view the output values. Looks like there was some issue which is fixed in this pairing.cpp file. Yes, I am trying to give you the best possible sample code as I am testing with the production code which has consumed Herumi library APIs. I will post the example code once I have it ready as I cannot provide you the production code as per the company policy. Let me try creating a sample code which uses Herumi APIs directly and which can be executed as it in Windows as well as Fedora/Linux machine. Please stay with me as I would need some time for creating such sample. I really appreciate your quick response sir.

Please stay with me, I will put the code by late today (IST time) or latest tomorrow IST time.

MandarApte409 commented 3 years ago

Meantime, I got a doubt. If I use older version of mcl on Windows and the current version of mcl on Fedora, or vice-versa, will there be a mismatch in the values generation ? Would that be the problem in my case ?

herumi commented 3 years ago

There may be differences if you use too old a version. But what does mean values generation? setByCPRNG() always generate difference values.

MandarApte409 commented 3 years ago

By "Values generation" I mean will there be difference in the computation/calculations done by the code from one version to another ? Means, the calculation/computation part of the code in mcl library, can be controlled via some compiler/Linker flags ?

Meanwhile, update regarding the sample code which I mentioned to provide you, I tried some sample code, I am able to get the same output from the MCL library APIs on Windows/Fedora.

I think the problem in my case is, I am using older Herumi/mcl library on Windows side, and using the latest mcl library on Fedora, due to which the pairing of the values is yielding different results when I try to use the public/private keys generated on Windows and vice-versa.

BTW, how can I know the version details of Herumi/mcl library from the package ?

MandarApte409 commented 3 years ago

How can I find the version details of the mcl library from the package ? I think the problem in my case is I am using older version of mcl library and trying to use newer mcl library on Fedora machine. That is the reason I am seeing difference in the output when I execute the windows application (using older Herumi library) and Fedora application (using new mcl library).

Could you kindly let me know how do I know the version of the mcl library.

herumi commented 3 years ago

You can get mcl::version(C++) or mclBn_getVersion(C).

https://github.com/herumi/mcl/blob/master/include/mcl/op.hpp#L29 https://github.com/herumi/mcl/blob/master/include/mcl/bn.h#L130

If you use serialize and deserialize or getStr and setStr, then mcl returns the same values on all OS/architectures.

MandarApte409 commented 3 years ago

Thank you for your response herumi. While using the mcl::version with the latest mcl library, I am able to get the version information. But when I try to use the statement "mcl::version" for old Herumi\mcl library, I am getting a below mentioned compilation error error C2039: 'version': is not a member of 'mcl'

I searched through the entire Herumi\mcl folder for string version. But neither I found the "version" variable in the "Herumi\mcl\include\mcl\op.hpp" nor I found "mclBn_getVersion" in the entire code folder. Instead I found the "VERSION" definition in "Herumi\mcl\src\xbyak\xbyak.h" file. That is the only file which has the "VERSION" variable defined, that too inside an enum.

Does it conclude that I am using very old Herumi library, which is not going to work in co-ordination with the latest mcl library ? Kindly suggest, the way, where I can make the older MCL library that I have, work with latest MCL library or make the latest mcl library work like older MCL library. If I modify older version of MCL library I will get backward compatibility issues, as this library is already in field, so making the older MCL library work differently might cause problem while working with already installed application in customer environment. Hence, It would be really good if you could suggest me to modify latest MCL library to make it work with older version of MCL library.

I really need some huge help here. Looks like things are messed up now on my side.

How can I make the latest MCL library work like older MCL library ?

herumi commented 3 years ago

error C2039: 'version': is not a member of 'mcl'

It's more than two years old. It's too old.

How can I make the latest MCL library work like the MCL library ?

I think that you can use the latest version like the old version, but I'm not sure. Please try it.