relic-toolkit / relic

Code
Other
452 stars 179 forks source link

ep_curve_set_map() #295

Closed 121TheShuDynasty closed 4 months ago

121TheShuDynasty commented 4 months ago

I installed the library by running 'cmake ..; make;', but when using 'ep_param_set(SM2_P256)', I encountered an ERROR in ep_curve_set_map() at /home/yang/relic/relic-main/src/ep/relic_ep_curve.c, line 180: invalid value passed as input. CAUGHT in ep_curve_set_map() at /home/yang/relic/relic-main/src/ep/relic_ep_curve.c, line 185. CAUGHT in ep_param_set() at /home/yang/relic/relic-main/src/ep/relic_ep_param.c, line 1372.

121TheShuDynasty commented 4 months ago

I have installed the GMP library on Ubuntu 18.04 and then installed the relic library following the steps below. cd relic-main mkdir relic-target cd relic-target cmake .. make make install I encountered the following issue while using relic. 微信截图_20240423224906 my program calling the relic library is as follows. 微信截图_20240423225108 Can you help me solve this problem?

dfaranha commented 4 months ago

Hi,

Support to the SM2-P256 curve is not complete and may be buggy. I suggest picking another curve for your implementation and experiments.

121TheShuDynasty commented 4 months ago

However, I encountered the same issue when I chose other curves. Could you please tell me if I missed any steps during the installation process? When using ep_param_set_any(), the displayed curve is NIST-P256, but no other curves can be used.

dfaranha commented 4 months ago

I believe the latest commit on HEAD solves the issue for curve SM2_P256. Can you please try to update, build the library+binaries and reopen the issue if it still persists?

121TheShuDynasty commented 4 months ago

I want to use the curves in 'relic_ep.h', I modified my program, but it still has errors. 86540a4712b971f3ce262ce3851ef21 3be801d70111aa3e39040c435d69d1b

121TheShuDynasty commented 4 months ago

How do I use these curves? Do I need to add../presets/.sh ../during the installation process?"

dfaranha commented 4 months ago

You cannot pass NIST-P192 because the library by default is built for 256-bit fields. You need to reconfigure+recompile for that.

Yes, the presets configure the library correctly for many parameter sets.

I will continue looking into the other error.

121TheShuDynasty commented 4 months ago

I understand that I cannot use NIST-P192, but I still don't know how to use SM2-P256. I'm new to this area, so please forgive my ignorance. And by default, can 256-bit fields only use NIST-P256?

dfaranha commented 4 months ago

I just tried the code below with the latest version and I saw no errors:

#include "relic.h"

int main() {
        ep_t p;

        core_init();
        ep_param_set(NIST_P256);
        ep_param_print();
        ep_rand(p);
        ep_print(p);

        ep_param_set(SM2_P256);
        ep_param_print();
        ep_rand(p);
        ep_print(p);
        core_clean();
        return 0;
}
121TheShuDynasty commented 4 months ago

微信截图_20240424014602 I downloaded the project again for configuration, ran your program, and encountered this error. Is it possibly due to the system?

dfaranha commented 4 months ago

I'm sorry, I had pushed the fix to another branch. Not it's back on main.

Can you please try again?

121TheShuDynasty commented 4 months ago

Thank you very much, the SM2_P256 curve is usable. I also want to ask another question, when I call the BSI_P256 curve in the same way, an error occurs. The other P256 curves do not have an error and can be called normally.

#include "relic.h"

int main() {
        ep_t p;
        core_init();
        ep_param_set(BSI_P256);
        ep_param_print();
        ep_rand(p);
        ep_print(p);
        core_clean();
        return 0;
}

image

dfaranha commented 4 months ago

BSI_P256 should be fixed now as well.