Skip to content

Conversation

@fjarri
Copy link
Contributor

@fjarri fjarri commented Dec 2, 2023

A part of #268:

  • make all shift arguments in various bit shifts use u32
  • the corresponding constants (e.g. BITS) and methods (e.g. bit_precision()) return u32. Note that the methods and constants that are used for indexing (LIMBS and BYTES) are still usize.
  • added some methods to CtChoice (working on u32 arguments) and normalized their names.

Notes:

  • I also added inline to all the CtChoice methods which bumped performance quite a bit in my tests (tens of percents in various benchmarks).
  • I tried using u8 and u32 in CtChoice, but it seems to marginally decrease performance, so Word stays for now.

@tarcieri
Copy link
Member

tarcieri commented Dec 2, 2023

I'm definitely in favor of this since I found our use of usize oddly inconsistent with core/std. Also as-is subtle has no trait impls for usize which meant casting back to u32 from usize (which is not guaranteed to be lossless).

Looks like it needs a rebase though.

@fjarri fjarri force-pushed the bit-ops-u32 branch 2 times, most recently from 6333adb to c4dbb25 Compare December 2, 2023 18:07
@fjarri
Copy link
Contributor Author

fjarri commented Dec 2, 2023

Rebased

@tarcieri tarcieri merged commit 6083555 into RustCrypto:master Dec 2, 2023
@fjarri fjarri deleted the bit-ops-u32 branch December 2, 2023 18:25
@tarcieri tarcieri mentioned this pull request Jan 22, 2025
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.

2 participants