Commit 3fd8ac7
authored
[WIP] elliptic-curve: extract toplevel
This is a fairly substantial refactoring of the `elliptic-curve` crate
which extracts a toplevel `elliptic_curve::Curve` trait and redefines
all types to use it.
The `elliptic_curve::weierstrass::Curve` trait is maintained, but
relegated to a marker trait. That said, it's still used as the marker
trait for all traits/types defined in the `elliptic_curve::weierstrass`
module.
Notably the main thing this facilitates is making `SecretKey` generic
around a `C: elliptic_curve::Curve` generic type. The previous impetus
was to avoid directly associating types dependent on scalars with
specific elliptic curves (rather the curve's order), but this is
ultimately unhelpful as it precludes accounting for trait impls on the
curve in trait bounds.
With the new approach, we can use trait bounds to conditionally define
methods on `SecretKey`, e.g. bounding a `SecretKey::generate` impl on
curves which impl `Arithmetic where Self::Scalar: Generate`. This would
eliminate the need for a special `GenerateSecretKey` trait.
One other notable change is the associated type for computing type sizes
for a particular curve has been renamed to `ElementSize`, rather than
the previous `ScalarSize`. This hopefully captures that this size is for
all elements related to a particular curve, i.e. both the base and
scalar fields.Curve trait (#223)1 parent 8d67bb6 commit 3fd8ac7
File tree
6 files changed
+148
-149
lines changed- elliptic-curve/src
- weierstrass
6 files changed
+148
-149
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | | - | |
43 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
44 | 65 | | |
45 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
46 | 73 | | |
47 | 74 | | |
48 | 75 | | |
49 | 76 | | |
50 | 77 | | |
51 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 19 | + | |
23 | 20 | | |
24 | 21 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 22 | + | |
29 | 23 | | |
30 | | - | |
| 24 | + | |
31 | 25 | | |
32 | 26 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 27 | + | |
37 | 28 | | |
38 | | - | |
| 29 | + | |
39 | 30 | | |
40 | 31 | | |
41 | 32 | | |
| |||
45 | 36 | | |
46 | 37 | | |
47 | 38 | | |
48 | | - | |
| 39 | + | |
49 | 40 | | |
50 | 41 | | |
51 | 42 | | |
52 | 43 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 44 | + | |
57 | 45 | | |
58 | 46 | | |
59 | 47 | | |
60 | | - | |
| 48 | + | |
61 | 49 | | |
62 | | - | |
| 50 | + | |
63 | 51 | | |
64 | 52 | | |
65 | 53 | | |
66 | 54 | | |
67 | 55 | | |
68 | 56 | | |
69 | 57 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 58 | + | |
74 | 59 | | |
75 | | - | |
| 60 | + | |
76 | 61 | | |
77 | 62 | | |
78 | 63 | | |
79 | 64 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 65 | + | |
84 | 66 | | |
85 | 67 | | |
86 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
8 | | - | |
9 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | | - | |
32 | | - | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
36 | | - | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | | - | |
| 49 | + | |
46 | 50 | | |
This file was deleted.
0 commit comments