Skip to content

Add constant-time Uint::shr() and Uint::shl()#267

Merged
tarcieri merged 1 commit into
RustCrypto:masterfrom
fjarri:ct-shifts
Aug 28, 2023
Merged

Add constant-time Uint::shr() and Uint::shl()#267
tarcieri merged 1 commit into
RustCrypto:masterfrom
fjarri:ct-shifts

Conversation

@fjarri

@fjarri fjarri commented Aug 25, 2023

Copy link
Copy Markdown
Contributor

This overrides the shr() implementation in #263 - this one is more efficient (O(LIMBS * log2(BITS)) instead of O(LIMBS^2)). For U2048 it's ~10x slower than the vartime equivalent.

Question for @tarcieri : what behavior do we want on overflow? shl()/shr() currently return 0, their vartime equivalents return the original value. I wonder if it would be better to return a pair (Self, CtChoice) where the second element indicates the overflow.

@fjarri fjarri force-pushed the ct-shifts branch 7 times, most recently from fe6f087 to 54e9f8f Compare August 28, 2023 06:07
@tarcieri tarcieri merged commit e0d71af into RustCrypto:master Aug 28, 2023
@fjarri fjarri deleted the ct-shifts branch August 28, 2023 20:25
@tarcieri tarcieri mentioned this pull request Sep 4, 2023
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