We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
EllipticCurvePrivateNumbers and EllipticCurvePublicNumbers should have an __repr__


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cryptography/hazmat/primitives/asymmetric/ec.py`
Content:
```
1 # This file is dual licensed under the terms of the Apache License, Version
2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3 # for complete details.
4 
5 from __future__ import absolute_import, division, print_function
6 
7 import abc
8 
9 import six
10 
11 from cryptography import utils
12 
13 
14 @six.add_metaclass(abc.ABCMeta)
15 class EllipticCurve(object):
16     @abc.abstractproperty
17     def name(self):
18         """
19         The name of the curve. e.g. secp256r1.
20         """
21 
22     @abc.abstractproperty
23     def key_size(self):
24         """
25         The bit length of the base point of the curve.
26         """
27 
28 
29 @six.add_metaclass(abc.ABCMeta)
30 class EllipticCurveSignatureAlgorithm(object):
31     @abc.abstractproperty
32     def algorithm(self):
33         """
34         The digest algorithm used with this signature.
35         """
36 
37 
38 @six.add_metaclass(abc.ABCMeta)
39 class EllipticCurvePrivateKey(object):
40     @abc.abstractmethod
41     def signer(self, signature_algorithm):
42         """
43         Returns an AsymmetricSignatureContext used for signing data.
44         """
45 
46     @abc.abstractmethod
47     def exchange(self, algorithm, peer_public_key):
48         """
49         Performs a key exchange operation using the provided algorithm with the
50         provided peer's public key.
51         """
52 
53     @abc.abstractmethod
54     def public_key(self):
55         """
56         The EllipticCurvePublicKey for this private key.
57         """
58 
59     @abc.abstractproperty
60     def curve(self):
61         """
62         The EllipticCurve that this key is on.
63         """
64 
65 
66 @six.add_metaclass(abc.ABCMeta)
67 class EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey):
68     @abc.abstractmethod
69     def private_numbers(self):
70         """
71         Returns an EllipticCurvePrivateNumbers.
72         """
73 
74     @abc.abstractmethod
75     def private_bytes(self, encoding, format, encryption_algorithm):
76         """
77         Returns the key serialized as bytes.
78         """
79 
80 
81 @six.add_metaclass(abc.ABCMeta)
82 class EllipticCurvePublicKey(object):
83     @abc.abstractmethod
84     def verifier(self, signature, signature_algorithm):
85         """
86         Returns an AsymmetricVerificationContext used for signing data.
87         """
88 
89     @abc.abstractproperty
90     def curve(self):
91         """
92         The EllipticCurve that this key is on.
93         """
94 
95     @abc.abstractmethod
96     def public_numbers(self):
97         """
98         Returns an EllipticCurvePublicNumbers.
99         """
100 
101     @abc.abstractmethod
102     def public_bytes(self, encoding, format):
103         """
104         Returns the key serialized as bytes.
105         """
106 
107 
108 EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey
109 
110 
111 @utils.register_interface(EllipticCurve)
112 class SECT571R1(object):
113     name = "sect571r1"
114     key_size = 571
115 
116 
117 @utils.register_interface(EllipticCurve)
118 class SECT409R1(object):
119     name = "sect409r1"
120     key_size = 409
121 
122 
123 @utils.register_interface(EllipticCurve)
124 class SECT283R1(object):
125     name = "sect283r1"
126     key_size = 283
127 
128 
129 @utils.register_interface(EllipticCurve)
130 class SECT233R1(object):
131     name = "sect233r1"
132     key_size = 233
133 
134 
135 @utils.register_interface(EllipticCurve)
136 class SECT163R2(object):
137     name = "sect163r2"
138     key_size = 163
139 
140 
141 @utils.register_interface(EllipticCurve)
142 class SECT571K1(object):
143     name = "sect571k1"
144     key_size = 571
145 
146 
147 @utils.register_interface(EllipticCurve)
148 class SECT409K1(object):
149     name = "sect409k1"
150     key_size = 409
151 
152 
153 @utils.register_interface(EllipticCurve)
154 class SECT283K1(object):
155     name = "sect283k1"
156     key_size = 283
157 
158 
159 @utils.register_interface(EllipticCurve)
160 class SECT233K1(object):
161     name = "sect233k1"
162     key_size = 233
163 
164 
165 @utils.register_interface(EllipticCurve)
166 class SECT163K1(object):
167     name = "sect163k1"
168     key_size = 163
169 
170 
171 @utils.register_interface(EllipticCurve)
172 class SECP521R1(object):
173     name = "secp521r1"
174     key_size = 521
175 
176 
177 @utils.register_interface(EllipticCurve)
178 class SECP384R1(object):
179     name = "secp384r1"
180     key_size = 384
181 
182 
183 @utils.register_interface(EllipticCurve)
184 class SECP256R1(object):
185     name = "secp256r1"
186     key_size = 256
187 
188 
189 @utils.register_interface(EllipticCurve)
190 class SECP256K1(object):
191     name = "secp256k1"
192     key_size = 256
193 
194 
195 @utils.register_interface(EllipticCurve)
196 class SECP224R1(object):
197     name = "secp224r1"
198     key_size = 224
199 
200 
201 @utils.register_interface(EllipticCurve)
202 class SECP192R1(object):
203     name = "secp192r1"
204     key_size = 192
205 
206 
207 _CURVE_TYPES = {
208     "prime192v1": SECP192R1,
209     "prime256v1": SECP256R1,
210 
211     "secp192r1": SECP192R1,
212     "secp224r1": SECP224R1,
213     "secp256r1": SECP256R1,
214     "secp384r1": SECP384R1,
215     "secp521r1": SECP521R1,
216     "secp256k1": SECP256K1,
217 
218     "sect163k1": SECT163K1,
219     "sect233k1": SECT233K1,
220     "sect283k1": SECT283K1,
221     "sect409k1": SECT409K1,
222     "sect571k1": SECT571K1,
223 
224     "sect163r2": SECT163R2,
225     "sect233r1": SECT233R1,
226     "sect283r1": SECT283R1,
227     "sect409r1": SECT409R1,
228     "sect571r1": SECT571R1,
229 }
230 
231 
232 @utils.register_interface(EllipticCurveSignatureAlgorithm)
233 class ECDSA(object):
234     def __init__(self, algorithm):
235         self._algorithm = algorithm
236 
237     algorithm = utils.read_only_property("_algorithm")
238 
239 
240 def generate_private_key(curve, backend):
241     return backend.generate_elliptic_curve_private_key(curve)
242 
243 
244 class EllipticCurvePublicNumbers(object):
245     def __init__(self, x, y, curve):
246         if (
247             not isinstance(x, six.integer_types) or
248             not isinstance(y, six.integer_types)
249         ):
250             raise TypeError("x and y must be integers.")
251 
252         if not isinstance(curve, EllipticCurve):
253             raise TypeError("curve must provide the EllipticCurve interface.")
254 
255         self._y = y
256         self._x = x
257         self._curve = curve
258 
259     def public_key(self, backend):
260         return backend.load_elliptic_curve_public_numbers(self)
261 
262     def encode_point(self):
263         # key_size is in bits. Convert to bytes and round up
264         byte_length = (self.curve.key_size + 7) // 8
265         return (
266             b'\x04' + utils.int_to_bytes(self.x, byte_length) +
267             utils.int_to_bytes(self.y, byte_length)
268         )
269 
270     @classmethod
271     def from_encoded_point(cls, curve, data):
272         if not isinstance(curve, EllipticCurve):
273             raise TypeError("curve must be an EllipticCurve instance")
274 
275         if data.startswith(b'\x04'):
276             # key_size is in bits. Convert to bytes and round up
277             byte_length = (curve.key_size + 7) // 8
278             if len(data) == 2 * byte_length + 1:
279                 x = utils.int_from_bytes(data[1:byte_length + 1], 'big')
280                 y = utils.int_from_bytes(data[byte_length + 1:], 'big')
281                 return cls(x, y, curve)
282             else:
283                 raise ValueError('Invalid elliptic curve point data length')
284         else:
285             raise ValueError('Unsupported elliptic curve point type')
286 
287     curve = utils.read_only_property("_curve")
288     x = utils.read_only_property("_x")
289     y = utils.read_only_property("_y")
290 
291     def __eq__(self, other):
292         if not isinstance(other, EllipticCurvePublicNumbers):
293             return NotImplemented
294 
295         return (
296             self.x == other.x and
297             self.y == other.y and
298             self.curve.name == other.curve.name and
299             self.curve.key_size == other.curve.key_size
300         )
301 
302     def __ne__(self, other):
303         return not self == other
304 
305 
306 class EllipticCurvePrivateNumbers(object):
307     def __init__(self, private_value, public_numbers):
308         if not isinstance(private_value, six.integer_types):
309             raise TypeError("private_value must be an integer.")
310 
311         if not isinstance(public_numbers, EllipticCurvePublicNumbers):
312             raise TypeError(
313                 "public_numbers must be an EllipticCurvePublicNumbers "
314                 "instance."
315             )
316 
317         self._private_value = private_value
318         self._public_numbers = public_numbers
319 
320     def private_key(self, backend):
321         return backend.load_elliptic_curve_private_numbers(self)
322 
323     private_value = utils.read_only_property("_private_value")
324     public_numbers = utils.read_only_property("_public_numbers")
325 
326     def __eq__(self, other):
327         if not isinstance(other, EllipticCurvePrivateNumbers):
328             return NotImplemented
329 
330         return (
331             self.private_value == other.private_value and
332             self.public_numbers == other.public_numbers
333         )
334 
335     def __ne__(self, other):
336         return not self == other
337 
338 
339 class ECDH(object):
340     pass
341
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py
--- a/src/cryptography/hazmat/primitives/asymmetric/ec.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py
@@ -302,6 +302,12 @@
     def __ne__(self, other):
         return not self == other
 
+    def __repr__(self):
+        return (
+            "<EllipticCurvePublicNumbers(curve={0.curve.name}, x={0.x}, "
+            "y={0.y}>".format(self)
+        )
+
 
 class EllipticCurvePrivateNumbers(object):
     def __init__(self, private_value, public_numbers):

{"golden_diff": "diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py\n--- a/src/cryptography/hazmat/primitives/asymmetric/ec.py\n+++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py\n@@ -302,6 +302,12 @@\n     def __ne__(self, other):\n         return not self == other\n \n+    def __repr__(self):\n+        return (\n+            \"<EllipticCurvePublicNumbers(curve={0.curve.name}, x={0.x}, \"\n+            \"y={0.y}>\".format(self)\n+        )\n+\n \n class EllipticCurvePrivateNumbers(object):\n     def __init__(self, private_value, public_numbers):\n", "issue": "EllipticCurvePrivateNumbers and EllipticCurvePublicNumbers should have an __repr__\n\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport abc\n\nimport six\n\nfrom cryptography import utils\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurve(object):\n    @abc.abstractproperty\n    def name(self):\n        \"\"\"\n        The name of the curve. e.g. secp256r1.\n        \"\"\"\n\n    @abc.abstractproperty\n    def key_size(self):\n        \"\"\"\n        The bit length of the base point of the curve.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurveSignatureAlgorithm(object):\n    @abc.abstractproperty\n    def algorithm(self):\n        \"\"\"\n        The digest algorithm used with this signature.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurvePrivateKey(object):\n    @abc.abstractmethod\n    def signer(self, signature_algorithm):\n        \"\"\"\n        Returns an AsymmetricSignatureContext used for signing data.\n        \"\"\"\n\n    @abc.abstractmethod\n    def exchange(self, algorithm, peer_public_key):\n        \"\"\"\n        Performs a key exchange operation using the provided algorithm with the\n        provided peer's public key.\n        \"\"\"\n\n    @abc.abstractmethod\n    def public_key(self):\n        \"\"\"\n        The EllipticCurvePublicKey for this private key.\n        \"\"\"\n\n    @abc.abstractproperty\n    def curve(self):\n        \"\"\"\n        The EllipticCurve that this key is on.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey):\n    @abc.abstractmethod\n    def private_numbers(self):\n        \"\"\"\n        Returns an EllipticCurvePrivateNumbers.\n        \"\"\"\n\n    @abc.abstractmethod\n    def private_bytes(self, encoding, format, encryption_algorithm):\n        \"\"\"\n        Returns the key serialized as bytes.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurvePublicKey(object):\n    @abc.abstractmethod\n    def verifier(self, signature, signature_algorithm):\n        \"\"\"\n        Returns an AsymmetricVerificationContext used for signing data.\n        \"\"\"\n\n    @abc.abstractproperty\n    def curve(self):\n        \"\"\"\n        The EllipticCurve that this key is on.\n        \"\"\"\n\n    @abc.abstractmethod\n    def public_numbers(self):\n        \"\"\"\n        Returns an EllipticCurvePublicNumbers.\n        \"\"\"\n\n    @abc.abstractmethod\n    def public_bytes(self, encoding, format):\n        \"\"\"\n        Returns the key serialized as bytes.\n        \"\"\"\n\n\nEllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT571R1(object):\n    name = \"sect571r1\"\n    key_size = 571\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT409R1(object):\n    name = \"sect409r1\"\n    key_size = 409\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT283R1(object):\n    name = \"sect283r1\"\n    key_size = 283\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT233R1(object):\n    name = \"sect233r1\"\n    key_size = 233\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT163R2(object):\n    name = \"sect163r2\"\n    key_size = 163\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT571K1(object):\n    name = \"sect571k1\"\n    key_size = 571\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT409K1(object):\n    name = \"sect409k1\"\n    key_size = 409\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT283K1(object):\n    name = \"sect283k1\"\n    key_size = 283\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT233K1(object):\n    name = \"sect233k1\"\n    key_size = 233\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT163K1(object):\n    name = \"sect163k1\"\n    key_size = 163\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP521R1(object):\n    name = \"secp521r1\"\n    key_size = 521\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP384R1(object):\n    name = \"secp384r1\"\n    key_size = 384\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP256R1(object):\n    name = \"secp256r1\"\n    key_size = 256\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP256K1(object):\n    name = \"secp256k1\"\n    key_size = 256\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP224R1(object):\n    name = \"secp224r1\"\n    key_size = 224\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP192R1(object):\n    name = \"secp192r1\"\n    key_size = 192\n\n\n_CURVE_TYPES = {\n    \"prime192v1\": SECP192R1,\n    \"prime256v1\": SECP256R1,\n\n    \"secp192r1\": SECP192R1,\n    \"secp224r1\": SECP224R1,\n    \"secp256r1\": SECP256R1,\n    \"secp384r1\": SECP384R1,\n    \"secp521r1\": SECP521R1,\n    \"secp256k1\": SECP256K1,\n\n    \"sect163k1\": SECT163K1,\n    \"sect233k1\": SECT233K1,\n    \"sect283k1\": SECT283K1,\n    \"sect409k1\": SECT409K1,\n    \"sect571k1\": SECT571K1,\n\n    \"sect163r2\": SECT163R2,\n    \"sect233r1\": SECT233R1,\n    \"sect283r1\": SECT283R1,\n    \"sect409r1\": SECT409R1,\n    \"sect571r1\": SECT571R1,\n}\n\n\n@utils.register_interface(EllipticCurveSignatureAlgorithm)\nclass ECDSA(object):\n    def __init__(self, algorithm):\n        self._algorithm = algorithm\n\n    algorithm = utils.read_only_property(\"_algorithm\")\n\n\ndef generate_private_key(curve, backend):\n    return backend.generate_elliptic_curve_private_key(curve)\n\n\nclass EllipticCurvePublicNumbers(object):\n    def __init__(self, x, y, curve):\n        if (\n            not isinstance(x, six.integer_types) or\n            not isinstance(y, six.integer_types)\n        ):\n            raise TypeError(\"x and y must be integers.\")\n\n        if not isinstance(curve, EllipticCurve):\n            raise TypeError(\"curve must provide the EllipticCurve interface.\")\n\n        self._y = y\n        self._x = x\n        self._curve = curve\n\n    def public_key(self, backend):\n        return backend.load_elliptic_curve_public_numbers(self)\n\n    def encode_point(self):\n        # key_size is in bits. Convert to bytes and round up\n        byte_length = (self.curve.key_size + 7) // 8\n        return (\n            b'\\x04' + utils.int_to_bytes(self.x, byte_length) +\n            utils.int_to_bytes(self.y, byte_length)\n        )\n\n    @classmethod\n    def from_encoded_point(cls, curve, data):\n        if not isinstance(curve, EllipticCurve):\n            raise TypeError(\"curve must be an EllipticCurve instance\")\n\n        if data.startswith(b'\\x04'):\n            # key_size is in bits. Convert to bytes and round up\n            byte_length = (curve.key_size + 7) // 8\n            if len(data) == 2 * byte_length + 1:\n                x = utils.int_from_bytes(data[1:byte_length + 1], 'big')\n                y = utils.int_from_bytes(data[byte_length + 1:], 'big')\n                return cls(x, y, curve)\n            else:\n                raise ValueError('Invalid elliptic curve point data length')\n        else:\n            raise ValueError('Unsupported elliptic curve point type')\n\n    curve = utils.read_only_property(\"_curve\")\n    x = utils.read_only_property(\"_x\")\n    y = utils.read_only_property(\"_y\")\n\n    def __eq__(self, other):\n        if not isinstance(other, EllipticCurvePublicNumbers):\n            return NotImplemented\n\n        return (\n            self.x == other.x and\n            self.y == other.y and\n            self.curve.name == other.curve.name and\n            self.curve.key_size == other.curve.key_size\n        )\n\n    def __ne__(self, other):\n        return not self == other\n\n\nclass EllipticCurvePrivateNumbers(object):\n    def __init__(self, private_value, public_numbers):\n        if not isinstance(private_value, six.integer_types):\n            raise TypeError(\"private_value must be an integer.\")\n\n        if not isinstance(public_numbers, EllipticCurvePublicNumbers):\n            raise TypeError(\n                \"public_numbers must be an EllipticCurvePublicNumbers \"\n                \"instance.\"\n            )\n\n        self._private_value = private_value\n        self._public_numbers = public_numbers\n\n    def private_key(self, backend):\n        return backend.load_elliptic_curve_private_numbers(self)\n\n    private_value = utils.read_only_property(\"_private_value\")\n    public_numbers = utils.read_only_property(\"_public_numbers\")\n\n    def __eq__(self, other):\n        if not isinstance(other, EllipticCurvePrivateNumbers):\n            return NotImplemented\n\n        return (\n            self.private_value == other.private_value and\n            self.public_numbers == other.public_numbers\n        )\n\n    def __ne__(self, other):\n        return not self == other\n\n\nclass ECDH(object):\n    pass\n", "path": "src/cryptography/hazmat/primitives/asymmetric/ec.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport abc\n\nimport six\n\nfrom cryptography import utils\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurve(object):\n    @abc.abstractproperty\n    def name(self):\n        \"\"\"\n        The name of the curve. e.g. secp256r1.\n        \"\"\"\n\n    @abc.abstractproperty\n    def key_size(self):\n        \"\"\"\n        The bit length of the base point of the curve.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurveSignatureAlgorithm(object):\n    @abc.abstractproperty\n    def algorithm(self):\n        \"\"\"\n        The digest algorithm used with this signature.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurvePrivateKey(object):\n    @abc.abstractmethod\n    def signer(self, signature_algorithm):\n        \"\"\"\n        Returns an AsymmetricSignatureContext used for signing data.\n        \"\"\"\n\n    @abc.abstractmethod\n    def exchange(self, algorithm, peer_public_key):\n        \"\"\"\n        Performs a key exchange operation using the provided algorithm with the\n        provided peer's public key.\n        \"\"\"\n\n    @abc.abstractmethod\n    def public_key(self):\n        \"\"\"\n        The EllipticCurvePublicKey for this private key.\n        \"\"\"\n\n    @abc.abstractproperty\n    def curve(self):\n        \"\"\"\n        The EllipticCurve that this key is on.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey):\n    @abc.abstractmethod\n    def private_numbers(self):\n        \"\"\"\n        Returns an EllipticCurvePrivateNumbers.\n        \"\"\"\n\n    @abc.abstractmethod\n    def private_bytes(self, encoding, format, encryption_algorithm):\n        \"\"\"\n        Returns the key serialized as bytes.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass EllipticCurvePublicKey(object):\n    @abc.abstractmethod\n    def verifier(self, signature, signature_algorithm):\n        \"\"\"\n        Returns an AsymmetricVerificationContext used for signing data.\n        \"\"\"\n\n    @abc.abstractproperty\n    def curve(self):\n        \"\"\"\n        The EllipticCurve that this key is on.\n        \"\"\"\n\n    @abc.abstractmethod\n    def public_numbers(self):\n        \"\"\"\n        Returns an EllipticCurvePublicNumbers.\n        \"\"\"\n\n    @abc.abstractmethod\n    def public_bytes(self, encoding, format):\n        \"\"\"\n        Returns the key serialized as bytes.\n        \"\"\"\n\n\nEllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT571R1(object):\n    name = \"sect571r1\"\n    key_size = 571\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT409R1(object):\n    name = \"sect409r1\"\n    key_size = 409\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT283R1(object):\n    name = \"sect283r1\"\n    key_size = 283\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT233R1(object):\n    name = \"sect233r1\"\n    key_size = 233\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT163R2(object):\n    name = \"sect163r2\"\n    key_size = 163\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT571K1(object):\n    name = \"sect571k1\"\n    key_size = 571\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT409K1(object):\n    name = \"sect409k1\"\n    key_size = 409\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT283K1(object):\n    name = \"sect283k1\"\n    key_size = 283\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT233K1(object):\n    name = \"sect233k1\"\n    key_size = 233\n\n\n@utils.register_interface(EllipticCurve)\nclass SECT163K1(object):\n    name = \"sect163k1\"\n    key_size = 163\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP521R1(object):\n    name = \"secp521r1\"\n    key_size = 521\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP384R1(object):\n    name = \"secp384r1\"\n    key_size = 384\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP256R1(object):\n    name = \"secp256r1\"\n    key_size = 256\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP256K1(object):\n    name = \"secp256k1\"\n    key_size = 256\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP224R1(object):\n    name = \"secp224r1\"\n    key_size = 224\n\n\n@utils.register_interface(EllipticCurve)\nclass SECP192R1(object):\n    name = \"secp192r1\"\n    key_size = 192\n\n\n_CURVE_TYPES = {\n    \"prime192v1\": SECP192R1,\n    \"prime256v1\": SECP256R1,\n\n    \"secp192r1\": SECP192R1,\n    \"secp224r1\": SECP224R1,\n    \"secp256r1\": SECP256R1,\n    \"secp384r1\": SECP384R1,\n    \"secp521r1\": SECP521R1,\n    \"secp256k1\": SECP256K1,\n\n    \"sect163k1\": SECT163K1,\n    \"sect233k1\": SECT233K1,\n    \"sect283k1\": SECT283K1,\n    \"sect409k1\": SECT409K1,\n    \"sect571k1\": SECT571K1,\n\n    \"sect163r2\": SECT163R2,\n    \"sect233r1\": SECT233R1,\n    \"sect283r1\": SECT283R1,\n    \"sect409r1\": SECT409R1,\n    \"sect571r1\": SECT571R1,\n}\n\n\n@utils.register_interface(EllipticCurveSignatureAlgorithm)\nclass ECDSA(object):\n    def __init__(self, algorithm):\n        self._algorithm = algorithm\n\n    algorithm = utils.read_only_property(\"_algorithm\")\n\n\ndef generate_private_key(curve, backend):\n    return backend.generate_elliptic_curve_private_key(curve)\n\n\nclass EllipticCurvePublicNumbers(object):\n    def __init__(self, x, y, curve):\n        if (\n            not isinstance(x, six.integer_types) or\n            not isinstance(y, six.integer_types)\n        ):\n            raise TypeError(\"x and y must be integers.\")\n\n        if not isinstance(curve, EllipticCurve):\n            raise TypeError(\"curve must provide the EllipticCurve interface.\")\n\n        self._y = y\n        self._x = x\n        self._curve = curve\n\n    def public_key(self, backend):\n        return backend.load_elliptic_curve_public_numbers(self)\n\n    def encode_point(self):\n        # key_size is in bits. Convert to bytes and round up\n        byte_length = (self.curve.key_size + 7) // 8\n        return (\n            b'\\x04' + utils.int_to_bytes(self.x, byte_length) +\n            utils.int_to_bytes(self.y, byte_length)\n        )\n\n    @classmethod\n    def from_encoded_point(cls, curve, data):\n        if not isinstance(curve, EllipticCurve):\n            raise TypeError(\"curve must be an EllipticCurve instance\")\n\n        if data.startswith(b'\\x04'):\n            # key_size is in bits. Convert to bytes and round up\n            byte_length = (curve.key_size + 7) // 8\n            if len(data) == 2 * byte_length + 1:\n                x = utils.int_from_bytes(data[1:byte_length + 1], 'big')\n                y = utils.int_from_bytes(data[byte_length + 1:], 'big')\n                return cls(x, y, curve)\n            else:\n                raise ValueError('Invalid elliptic curve point data length')\n        else:\n            raise ValueError('Unsupported elliptic curve point type')\n\n    curve = utils.read_only_property(\"_curve\")\n    x = utils.read_only_property(\"_x\")\n    y = utils.read_only_property(\"_y\")\n\n    def __eq__(self, other):\n        if not isinstance(other, EllipticCurvePublicNumbers):\n            return NotImplemented\n\n        return (\n            self.x == other.x and\n            self.y == other.y and\n            self.curve.name == other.curve.name and\n            self.curve.key_size == other.curve.key_size\n        )\n\n    def __ne__(self, other):\n        return not self == other\n\n    def __repr__(self):\n        return (\n            \"<EllipticCurvePublicNumbers(curve={0.curve.name}, x={0.x}, \"\n            \"y={0.y}>\".format(self)\n        )\n\n\nclass EllipticCurvePrivateNumbers(object):\n    def __init__(self, private_value, public_numbers):\n        if not isinstance(private_value, six.integer_types):\n            raise TypeError(\"private_value must be an integer.\")\n\n        if not isinstance(public_numbers, EllipticCurvePublicNumbers):\n            raise TypeError(\n                \"public_numbers must be an EllipticCurvePublicNumbers \"\n                \"instance.\"\n            )\n\n        self._private_value = private_value\n        self._public_numbers = public_numbers\n\n    def private_key(self, backend):\n        return backend.load_elliptic_curve_private_numbers(self)\n\n    private_value = utils.read_only_property(\"_private_value\")\n    public_numbers = utils.read_only_property(\"_public_numbers\")\n\n    def __eq__(self, other):\n        if not isinstance(other, EllipticCurvePrivateNumbers):\n            return NotImplemented\n\n        return (\n            self.private_value == other.private_value and\n            self.public_numbers == other.public_numbers\n        )\n\n    def __ne__(self, other):\n        return not self == other\n\n\nclass ECDH(object):\n    pass\n", "path": "src/cryptography/hazmat/primitives/asymmetric/ec.py"}]}