LFDT-Lockness / generic-ec

Generic elliptic curve cryptography in Rust
Apache License 2.0
2 stars 2 forks source link

Optimize `Scalar::from_bytes_{le|be}_mod_order` #31

Closed survived closed 4 months ago

survived commented 5 months ago

Scalar::from_{le|be}_bytes_mod_order are implemented generically for any scalar using scalar arithmetic. However, curve library might have a more optimized conversion function. For instance, curve25519_dalek has a functions from_bytes_mod_order and from_bytes_mod_order_wide which are significantly faster.

ed25519/512/generic-ec  time:   [13.040 µs 13.048 µs 13.057 µs]
ed25519/512/dalek::from_bytes_mod_order_wide
                        time:   [103.11 ns 103.23 ns 103.44 ns]

We should leverage this backend optimization.