def int_to_hex(x: int, size) ->bytes:
    """Encode a long value as a hex string, 0-padding to size.

    Note that size is the size of the resulting hex string. So, for a 32Byte
    long size should be 64 (two hex characters per byte"."""
    f_str = '{0:0%sx}' % size
    return f_str.format(x).lower().encode()
