Open PopcornPaws opened 2 years ago
Note that https://github.com/RustCrypto/crypto-bigint/pull/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.
Thanks for the heads up @haslersn , I didn't thoroughly read your premise. Unfortunately this is not the case for us.
Description
Since there's no modular multiplication implemented in the
crypto-bigint
library yet , we initially usedmul_wide
when multiplying twoUint256
types to get anUint512
. 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 abigint
type and performing the modular multiplication on that value proved to be much faster, regardless of the type conversions. However, sincebigint
usesVec
s to represent big integer bytes, allocation and deallocation of vectors take up most time spent in a modular multiplication.