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

Faster decoding for UInt #110

Merged
merged 1 commit into from
Aug 15, 2022

Conversation

andrewwhitehead
Copy link
Contributor

On this machine these changes take Encoding::from_{le|be}_bytes from around 200ns to around 3ns for a U256. It adds non-const (but still constant-time) methods for decoding UInts from a byte array.

Restricting the input to an array allows the assert to be optimized out, as is the unreachable!() panicking according to godbolt. But there may be a cleaner way to obtain the fixed-size chunks (for example, copying into an intermediate buffer), and in future slice::as_chunks could be applicable.

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
@tarcieri tarcieri merged commit 6f62459 into RustCrypto:master Aug 15, 2022
@tarcieri
Copy link
Member

Thanks!

@tarcieri tarcieri mentioned this pull request Oct 11, 2022
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