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

add usize/isize to generated trait impls #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cosmicexplorer
Copy link

It seems like usize and isize could reasonably be allowed to implement ConstantTime{Greater,Less} via the macros that are already used for other integer types. I assumed it was an oversight that this wasn't already done.

Copy link
Member

@isislovecruft isislovecruft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cosmicexplorer! This looks fine, but generally in cryptographic code we don't really see usage of integer types of platform-defined sizes, so I am curious what the use-case is for this?

@isislovecruft
Copy link
Member

See also previous rationale on #83

@tarcieri
Copy link
Contributor

I've encountered a use case for this: when you are using usize as an index, looping over every item of a n-length collection.

In my particular case, it involves computing a value on an entry at a given index, and then selecting whether to store or discard the result based on whether or not the index matches a specified value.

Here's a real-world example: https://github.com/RustCrypto/crypto-bigint/blob/4aee8ce1e185f9c1156a162ecce6164bf80ab915/src/uint/boxed/bits.rs#L40

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