herumi / mcl

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

use libmclecdsa.a in SGX #215

Closed HuangMinming closed 1 month ago

HuangMinming commented 1 month ago

Hi I want to use libmclecdsa.a in SGX, and generate it through

make lib/libmclecdsa.a MCL_STATIC_CODE=1 -j CFLAGS_USER=-DMCL_DONT_USE_CSPRNG

I added it to my SGX project. However, when I call ecdsaInit(), it returned -1.

What is the exact error? How to solve this problem? Thanks.

herumi commented 1 month ago

mcl does not support SGX except for BLS12-381. https://github.com/herumi/mcl/issues/209#issuecomment-2213062455 cf. https://github.com/herumi/mcl?tab=readme-ov-file#how-to-make-a-library-for-bls12-381-without-xbyak

HuangMinming commented 1 month ago

I just want to import pub key and verify signature, is there any solution to support SGX? Thanks.

herumi commented 1 month ago

What do you want to do? mcl is mainly a library for pairing operations on BLS12 and BN curves. If you want to use ECDSA (with secp256k1), you are better off using another library. Or if you want to do it with mcl, as I wrote inhttps://github.com/herumi/mcl/issues/ 216#issuecomment-2366735197 first of all, you can try

make lib/libmclecdsa.a bin/ecdsa_c_test.exe MCL_MSM=0 MCL_USE_XBYAK=0
% bin/ecdsa_c_test.exe

to make sure sample/ecdsa_c_test.cpp works on hand, then you should try to run it on SGX. When compiling your code, you must define the same macro in building mcl libraries. Data exchange between the SGX and the host can be done using serialize() and deserialize(), but this is outside the scope of this library.

HuangMinming commented 1 month ago

Thanks for you reply. I can ran this correctly.

make lib/libmclecdsa.a bin/ecdsa_c_test.exe MCL_MSM=0 MCL_USE_XBYAK=0
% bin/ecdsa_c_test.exe

I will use OPENSSL instead.