Skip to content

Conversation

@tarcieri
Copy link
Member

@tarcieri tarcieri commented Dec 10, 2023

This was previously written using raw Words to ensure maximum performance, however it precludes access to the constant-time helper functions implemented on Limb.

This carefully rewrites the implementation to using Limb instead of Word while avoiding any performance impacts.

Benchmarks (unchanged)

Montgomery arithmetic/modpow, BoxedUint^BoxedUint
                        time:   [24.424 ms 24.444 ms 24.465 ms]
                        change: [-0.1629% -0.0399% +0.0760%] (p = 0.52 > 0.05)
                        No change in performance detected.

@tarcieri
Copy link
Member Author

@dignifiedquire I suspect what was hitting us before were the places there are currently branches, namely the comparisons between words/limbs. I suspect that subtle has a rather slow constant-time impl of integer comparisons which made things massively slower.

The data-dependent branching still needs to be addressed but I have some ideas.

This was previously written using raw `Word`s to ensure maximum
performance, however it precludes access to the constant-time helper
functions implemented on `Limb`.

This carefully rewrites the implementation to using `Limb` instead of
`Word` while avoiding any performance impacts.
@tarcieri tarcieri force-pushed the boxed-uint/use-limbs-for-montgomery-mul branch from d9d7e89 to 4eb3182 Compare December 10, 2023 19:02
@tarcieri tarcieri merged commit 8263c76 into master Dec 10, 2023
@tarcieri tarcieri deleted the boxed-uint/use-limbs-for-montgomery-mul branch December 10, 2023 19:05
@dignifiedquire
Copy link
Member

cool, I am glad this is possilbe

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

Successfully merging this pull request may close these issues.

3 participants