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

Possible to add modular exponentiation to BigNumberUtil? #57

Open
marcelgerber opened this issue Jun 27, 2020 · 2 comments
Open

Possible to add modular exponentiation to BigNumberUtil? #57

marcelgerber opened this issue Jun 27, 2020 · 2 comments

Comments

@marcelgerber
Copy link

marcelgerber commented Jun 27, 2020

Hi, I really quite enjoy working with your library, great work there!

Would it be possible to also implement efficient modular exponentiation (i.e. modPow(b, e, modulus) = (b ** e) % modulus) in BigNumberUtil? That would be very helpful for my application where I need to implement the Rabin cryptosystem, which is similar to RSA.
If modular exponentiation is already possible in any way, a pointer in the right direction would also be helpful :)

@rweather
Copy link
Owner

Unfortunately I don't have modexp at the moment as implementing general-purpose big number division with remainder is a challenge. Elliptic curves like Curve25519 can do division more efficiently because of special-case divisors like 2^255 - 19. So it wasn't a high priority to handle the general case.

Some more recent Arduino modules like the ESP32 have built-in RSA acceleration, so you might be able to make use of that.

@marcelgerber
Copy link
Author

marcelgerber commented Jun 28, 2020

Thank you for your response. Yes, I absolutely realize that implementing such a feature comes with its pitfalls and is not easy.

For anyone else looking for a similar feature, wolfSSL has an integer.h file which provides all the big-integer-general-purpose operations you could ever wish for.
It needs some getting-used-to, some configuring to run on an ESP8266, and the API is less on point than the one provided by this library here, but nonetheless I was able to implement the Rabin cryptosystem using it.

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