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

mul_wide inconsistencies #4

Closed
tarcieri opened this issue Sep 8, 2021 · 0 comments · Fixed by #34
Closed

mul_wide inconsistencies #4

tarcieri opened this issue Sep 8, 2021 · 0 comments · Fixed by #34

Comments

@tarcieri
Copy link
Member

tarcieri commented Sep 8, 2021

RustCrypto/utils#563 corrected a bug in wrapping_mul, however it seems the real issue might've been in the return value of mul_wide

Right now the return values are the following:

  • UInt::mul_wide -> (hi, lo)
  • Limb::mul_wide -> (lo, hi)

It seems RustCrypto/utils#563 might've been caused by assuming the latter worked like the former. This ordering reflects the little endian internals of this library.

Ideally these would return a UInt which is twice the width using a const impl Concat to prevent this sort of confusion, but since mul_wide is a const fn that isn't currently possible.

Alternatively we could use a struct with lo and hi fields to prevent this confusion.

At the very least, however, the UInt and Limb versions should be consistent.

@tarcieri tarcieri transferred this issue from RustCrypto/utils Sep 14, 2021
@tarcieri tarcieri changed the title crypto-bigint: mul_wide inconsistencies mul_wide inconsistencies Sep 14, 2021
@tarcieri tarcieri mentioned this issue Sep 21, 2021
4 tasks
tarcieri added a commit that referenced this issue Nov 13, 2021
Fixes the inconsistency between `UInt::mul_wide` and `Limb::mul_wide` by
reversing the order of the `UInt` version so it returns `(lo, hi)`.

This follows the "little endian" approach used in the rest of this
crate for consistency.

Closes #4
tarcieri added a commit that referenced this issue Nov 13, 2021
Fixes the inconsistency between `UInt::mul_wide` and `Limb::mul_wide` by
reversing the order of the `UInt` version so it returns `(lo, hi)`.

This follows the "little endian" approach used in the rest of this
crate for consistency.

Closes #4
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 a pull request may close this issue.

1 participant