Skip to content

Use wide arithmetic in CtChoice #418

Description

@fjarri

We are currently using two different algorithms for constant-time comparison of Words:

  • the one in CtChoice (e.g. from_word_lt()), using arithmetic on Word
  • the one in Limb's implementations of subtle traits, using arithmetic on WideWord

The latter seems to be faster than the former (from the limb.rs benchmarks). We should use just one version of the algorithms both for performance reasons, and for simplicity. Probably should be implemented in CtChoice, and the Limb's impls should call it and convert CtChoice to Choice.

Also there is a third way to do it, by using the built-in overflowing_sub() method instead of sbb. Seems to be producing branch-free assembly, according to Godbolt - how safe is it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions