Skip to content

add usize/isize to generated trait impls#97

Open
cosmicexplorer wants to merge 1 commit intodalek-cryptography:mainfrom
cosmicexplorer:add-usize-to-trait-impls
Open

add usize/isize to generated trait impls#97
cosmicexplorer wants to merge 1 commit intodalek-cryptography:mainfrom
cosmicexplorer:add-usize-to-trait-impls

Conversation

@cosmicexplorer
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

See also previous rationale on #83

@tarcieri
Copy link
Copy Markdown
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