@staticmethod
def encode(value):
    """Encode a DER integer value"""
    l = value.bit_length()
    l = l // 8 + 1 if l % 8 == 0 else (l + 7) // 8
    result = value.to_bytes(l, 'big', signed=True)
    return result[1:] if result.startswith(b'\xff\x80') else result
