@staticmethod
def from_bytes(key_bytes):
    ' Generates a public key object from a byte (or hex) string.\n\n        The byte stream must be of the SEC variety\n        (http://www.secg.org/): beginning with a single byte telling\n        what key representation follows. A full, uncompressed key\n        is represented by: 0x04 followed by 64 bytes containing\n        the x and y components of the point. For compressed keys\n        with an even y component, 0x02 is followed by 32 bytes\n        containing the x component. For compressed keys with an\n        odd y component, 0x03 is followed by 32 bytes containing\n        the x component.\n\n        Args:\n            key_bytes (bytes or str): A byte stream that conforms to the above.\n\n        Returns:\n            PublicKey: A PublicKey object.\n        '
    b = get_bytes(key_bytes)
    key_bytes_len = len(b)
    key_type = b[0]
    if (key_type == 4):
        if (key_bytes_len != 65):
            raise ValueError('key_bytes must be exactly 65 bytes long when uncompressed.')
        x = int.from_bytes(b[1:33], 'big')
        y = int.from_bytes(b[33:65], 'big')
    elif ((key_type == 2) or (key_type == 3)):
        if (key_bytes_len != 33):
            raise ValueError('key_bytes must be exactly 33 bytes long when compressed.')
        x = int.from_bytes(b[1:33], 'big')
        ys = bitcoin_curve.y_from_x(x)
        last_bit = (key_type - 2)
        for y in ys:
            if ((y & 1) == last_bit):
                break
    else:
        return None
    return PublicKey(x, y)
Generates a public key object from a byte (or hex) string.

The byte stream must be of the SEC variety
(http://www.secg.org/): beginning with a single byte telling
what key representation follows. A full, uncompressed key
is represented by: 0x04 followed by 64 bytes containing
the x and y components of the point. For compressed keys
with an even y component, 0x02 is followed by 32 bytes
containing the x component. For compressed keys with an
odd y component, 0x03 is followed by 32 bytes containing
the x component.

Args:
    key_bytes (bytes or str): A byte stream that conforms to the above.

Returns:
    PublicKey: A PublicKey object.
@staticmethod
def from_bytes(key_bytes):
    ' Generates a public key object from a byte (or hex) string.\n\n        The byte stream must be of the SEC variety\n        (http://www.secg.org/): beginning with a single byte telling\n        what key representation follows. A full, uncompressed key\n        is represented by: 0x04 followed by 64 bytes containing\n        the x and y components of the point. For compressed keys\n        with an even y component, 0x02 is followed by 32 bytes\n        containing the x component. For compressed keys with an\n        odd y component, 0x03 is followed by 32 bytes containing\n        the x component.\n\n        Args:\n            key_bytes (bytes or str): A byte stream that conforms to the above.\n\n        Returns:\n            PublicKey: A PublicKey object.\n        '
    b = get_bytes(key_bytes)
    key_bytes_len = len(b)
    key_type = b[0]
    if (key_type == 4):
        if (key_bytes_len != 65):
            raise ValueError('key_bytes must be exactly 65 bytes long when uncompressed.')
        x = int.from_bytes(b[1:33], 'big')
        y = int.from_bytes(b[33:65], 'big')
    elif ((key_type == 2) or (key_type == 3)):
        if (key_bytes_len != 33):
            raise ValueError('key_bytes must be exactly 33 bytes long when compressed.')
        x = int.from_bytes(b[1:33], 'big')
        ys = bitcoin_curve.y_from_x(x)
        last_bit = (key_type - 2)
        for y in ys:
            if ((y & 1) == last_bit):
                break
    else:
        return None
    return PublicKey(x, y)