crypto-bigint icon indicating copy to clipboard operation
crypto-bigint copied to clipboard

Vartime methods should return `Option` instead of `CtOption`

Open tarcieri opened this issue 2 months ago • 2 comments

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

tarcieri avatar Dec 27 '25 21:12 tarcieri