Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ep_curve_set_map() #295

Closed
121TheShuDynasty opened this issue Apr 22, 2024 · 13 comments
Closed

ep_curve_set_map() #295

121TheShuDynasty opened this issue Apr 22, 2024 · 13 comments

Comments

@121TheShuDynasty
Copy link

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

121TheShuDynasty commented Apr 23, 2024

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
Copy link
Contributor

dfaranha commented Apr 23, 2024

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
Copy link
Author

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

@121TheShuDynasty
Copy link
Author

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

@dfaranha
Copy link
Contributor

dfaranha commented Apr 23, 2024

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
Copy link
Author

121TheShuDynasty commented Apr 23, 2024

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
Copy link
Contributor

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
Copy link
Author

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

@dfaranha
Copy link
Contributor

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

Can you please try again?

@121TheShuDynasty
Copy link
Author

121TheShuDynasty commented Apr 23, 2024

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
Copy link
Contributor

BSI_P256 should be fixed now as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants