RustCrypto / RustCrypto/crypto-bigint
Vartime methods should return `Option` instead of `CtOption`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 309
- Forks
- 96
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Description
We have several methods that are advertised as variable-time which are returning CtOption instead of Option.
This is a bit suboptimal: CtOption eagerly evaluates its combinators, whereas Option uses lazy evaluation. It would generally be more efficient to use Option.
Perhaps a reason why this was the case originally was trouble converting from ConstCtOption to Option inside a const fn in the past, but there's now ctutils::CtOption::into_option_copied which can be used as a const fn, in cases where there's some shared code between the constant-time and non-constant-time versions of a function.
cc @andrewwhitehead @fjarri
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the variable-time methods that return CtOption and inspect how ctutils::CtOption::into_option_copied is used for shared constant-time and non-constant-time code. Update the relevant return paths to use Option while preserving constant-time variants, then run the existing tests for those methods to verify behavior and compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100