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

Optimize modular multiplication #32

Open
PopcornPaws opened this issue Jun 28, 2022 · 3 comments
Open

Optimize modular multiplication #32

PopcornPaws opened this issue Jun 28, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@PopcornPaws
Copy link
Contributor

Description

Since there's no modular multiplication implemented in the crypto-bigint library yet , we initially used mul_wide when multiplying two Uint256 types to get an Uint512. This number was then modulo divided by the prime modulus/order to obtain the result of the modular multiplication. However, this proved to be extremely slow.

After experimenting a bit, we found that converting the Uint256 type into a bigint type and performing the modular multiplication on that value proved to be much faster, regardless of the type conversions. However, since bigint uses Vecs to represent big integer bytes, allocation and deallocation of vectors take up most time spent in a modular multiplication.

@PopcornPaws PopcornPaws self-assigned this Jun 28, 2022
@PopcornPaws PopcornPaws added enhancement New feature or request help wanted Extra attention is needed labels Aug 1, 2022
@PopcornPaws
Copy link
Contributor Author

@haslersn
Copy link

haslersn commented Aug 8, 2022

Note that RustCrypto/crypto-bigint#108 can only be used if your modulus has 0xffffffffffffffff in all limbs except for the least significant limb. I don't know if this is the case here, since I'm not familiar with this project.

@PopcornPaws
Copy link
Contributor Author

PopcornPaws commented Aug 8, 2022

Thanks for the heads up @haslersn , I didn't thoroughly read your premise. Unfortunately this is not the case for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants