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

how to accelerate g*f by precompute? #42

Closed
huyuguang opened this issue Dec 27, 2018 · 3 comments
Closed

how to accelerate g*f by precompute? #42

huyuguang opened this issue Dec 27, 2018 · 3 comments

Comments

@huyuguang
Copy link

The speed of g*f (BN curve) in mcl is very fast, much faster than normal wNAF algorithm.

In my scenario, the g is hardcoded, so I think I can accelerate the speed of g*f by precompute and cache some data, for example, 2g, 4g, 8g,16g ... , then I can convert theg*fto test_bit&add. But to my surprise, I found the test_bit&add version only slightly faster (20%~30%) than mcl version.

So, what should I do? How can I accelerate the speed for 100% or more by precompute/cache? Could you please give some suggestions (or some URLs)?

@herumi
Copy link
Owner

herumi commented Dec 27, 2018

Use mcl/window_method.hpp as the followings:

#include <mcl/window_method.hpp>
mcl::fp::WindowMethod<G1> wm;
wm.init(P, Fr::getBitSize(), 4 /* winSize */); // precompute a table for a fixed P with 4-bit window size
Fr x;
wm.mul(P1, x); // instead of G1::mul(P1, P, x);

If increasing winSize then it requires more memory and computes more faster.

@huyuguang
Copy link
Author

Very thanks, I will try it.

@huyuguang
Copy link
Author

It works fine. I use init(g, bit_size, 8) and got 500% speed. Thanks again.

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