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
use w_naf to reduce time consume of point_mul #30
Conversation
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
In #27 you have mentioned the other repo efficient-sm2. In efficient-sm2, point multiplication use a fixed window of width 4, maybe we can modify this method to improve the performance of efficient-sm2.
The structure of the efficient-sm2 is rather complicated, so I hope you can briefly introduce the project structure in the readme.md |
naf is wonderful idea, I need some time to understand |
thanks😊 |
It's my turn to thank you. The performance of crypto lib alway determin the best tps of a blockchain system. NAF may be also a good point for efficient-sm2. But I just not have enough time to do it. My turn to say thank you. |
ok,but I also not have enough time to do it recently😂. Maybe you can check this pr fisrtly and I will modify efficient-sm2 when I have time |
Nothing serious. It's my duty to improve efficient-sm2 |
Is my pr having some problems?😂It has been on hold for over a month |
😂 |
The result of performance test: No significant improvement.
Origin: 2times test sm2::ecc::internal_benches::sm2_inv_bench ... bench: 9,631 ns/iter (+/- 99) Yours: 2times test sm2::ecc::internal_benches::sm2_inv_bench ... bench: 9,870 ns/iter (+/- 118) ps. bench environment:
|
I just wonder what mean about A & D and how to count it? |
A means ADD operation, D means double operation. In original, a point_mul operation need 128 add and 256 double operations. |
and in my test, I can see an explicit improvement in verifyfunction😂 origin: mypr: |
have mistake, yours result: |
I thought the improve is from precompute table. I push new branch: https://github.com/citahub/libsm/tree/naf_bench
|
I think that is because the number of m is too small and if you get m from the function curve.random_uint, you can see an explicit improvement in waf, like this :
|
I got it. Last you need fix typo. |
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
Co-authored-by: Yieazy <yuitta@163.com>
ok |
w-naf can effectively reduce the time consumption of point multiplication. In sm2, we set the width of the window to 5, and the except time consumption is 50A+257D where the origin time consumption is 128A+256D.