dalek-cryptography / curve25519-dalek

A pure-Rust implementation of group operations on Ristretto and Curve25519
Other
850 stars 416 forks source link

curve: use `subtle::Choice` for constant-time fixes #665

Open tarcieri opened 2 weeks ago

tarcieri commented 2 weeks ago

Alternative to #659/#661 and #662 which leverages subtle::Choice and subtle::ConditionallySelectable as the optimization barriers.

Really the previous masking was there to conditionally add the scalar field modulus on underflow, so instead of that, we can conditionally select zero or the modulus using a Choice constructed from the underflow bit.

TODO: verify codegen and check benchmarks