Commit d69d5b9
authored
elliptic-curve: consolidate
See RustCrypto/elliptic-curves#50 for some historic context.
After being able to get by on `AffineXCoordinate` for generic ECDH and
ECDSA, RustCrypto#1199 added an `AffineYIsOdd` trait which was needed to enable
the generic ECDSA implementation in the `ecdsa` crate to compute the
"recovery ID" for signatures (which is effectively point compression for
the `R` curve point).
This commit consolidates `AffineXCoordinate` and `AffineYIsOdd` into
an `AffineCoordinates` trait.
Some observations since prior discussion in
RustCrypto/elliptic-curves#50:
- Access to coordinates is through bytes, namely `FieldBytes`. This is
so as to avoid exposing a crate's field element type. This approach
isn't type safe (base field elements and scalar field elements share
the same serialization) but does make ECDSA's weird reduction of a
base field element into the scalar field straightforward in generic
code.
- Prior to this attempts were made to extract ECDSA-specific bits into a
trait to handle these conversions, but it complicates both writing
generic code and optimizing performance. While this still might be
worth exploring, so far those explorations have largely failed.
- Generally there have been a lot of requests for coordinate access
specifically for things like point serialization formats. We ended up
adding "compaction" support upstream but we have had requests for
several other formats (e.g. Elligator Squared) where direct coordinate
access would be useful.
This trait can hopefully be replaced by a coordinate access API provided
by the `group` crate in the future. See zkcrypto/group#30AffineCoordinates trait (RustCrypto#1237)1 parent 4ad2fc1 commit d69d5b9
4 files changed
+8
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
| 418 | + | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
425 | 424 | | |
426 | | - | |
427 | 425 | | |
428 | 426 | | |
429 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| |||
0 commit comments