(self, pack_num: int, pack_num_range: list, encrypt_mode_calculator: EncryptModeCalculator,
                 sync_para=True)
max_int: max int allowed for packing result
        pack_num: number of int to pack, they must be POSITIVE integer
        pack_num_range: list of integer, it gives range of every integer to pack
        need_cipher_compress: if dont need cipher compress, related parameter will be set to 1
max_int: max int allowed for packing result
        pack_num: number of int to pack, they must be POSITIVE integer
        pack_num_range: list of integer, it gives range of every integer to pack
        need_cipher_compress: if dont need cipher compress, related parameter will be set to 1
max_int : max int allowed for packing result pack_num : number of int to pack they must be POSITIVE integer pack_num_range : list of integer it gives range of every integer to pack need_cipher_compress : if dont need cipher compress related parameter will be set to 1
def __init__(self, pack_num: int, pack_num_range: list, encrypt_mode_calculator: EncryptModeCalculator,
                 sync_para=True):
        """
        max_int: max int allowed for packing result
        pack_num: number of int to pack, they must be POSITIVE integer
        pack_num_range: list of integer, it gives range of every integer to pack
        need_cipher_compress: if dont need cipher compress, related parameter will be set to 1
        """

        self._pack_num = pack_num
        assert len(pack_num_range) == self._pack_num, 'list len must equal to pack_num'
        self._pack_num_range = pack_num_range
        self._pack_num_bit = [i.bit_length() for i in pack_num_range]
        self.calculator = encrypt_mode_calculator

        max_pos_int, _ = get_homo_encryption_max_int(self.calculator.encrypter)
        self._max_int = max_pos_int
        self._max_bit = self._max_int.bit_length() - 1  # reserve 1 bit, in case overflow

        # sometimes max_int is not able to hold all num need to be packed, so we
        # use more than one large integer to pack them all
        self._bit_assignment = []
        tmp_list = []
        bit_count = 0
        for bit_len in self._pack_num_bit:
            if bit_count + bit_len >= self._max_bit:
                if bit_count == 0:
                    raise ValueError('unable to pack this num using in current int capacity')
                self._bit_assignment.append(tmp_list)
                tmp_list = []
                bit_count = 0
            bit_count += bit_len
            tmp_list.append(bit_len)

        if len(tmp_list) != 0:
            self._bit_assignment.append(tmp_list)
        self._pack_int_needed = len(self._bit_assignment)

        # transfer variable
        compress_parameter = self.cipher_compress_suggest()

        if sync_para:
            self.trans_var = CipherCompressorTransferVariable()
            self.trans_var.compress_para.remote(compress_parameter, role=consts.HOST, idx=-1)

        LOGGER.debug('int packer init done, bit assign is {}, compress para is {}'.format(self._bit_assignment,
                                                                                          compress_parameter))
def __init__ ( self , pack_num : int , pack_num_range : list , encrypt_mode_calculator : EncryptModeCalculator , sync_para = True ) : self . _pack_num = pack_num assert len ( pack_num_range ) == self . _pack_num , 'list len must equal to pack_num' self . _pack_num_range = pack_num_range self . _pack_num_bit = [ i . bit_length ( ) for i in pack_num_range ] self . calculator = encrypt_mode_calculator max_pos_int , _ = get_homo_encryption_max_int ( self . calculator . encrypter ) self . _max_int = max_pos_int self . _max_bit = self . _max_int . bit_length ( ) - 1 # reserve 1 bit, in case overflow # sometimes max_int is not able to hold all num need to be packed, so we # use more than one large integer to pack them all self . _bit_assignment = [ ] tmp_list = [ ] bit_count = 0 for bit_len in self . _pack_num_bit : if bit_count + bit_len >= self . _max_bit : if bit_count == 0 : raise ValueError ( 'unable to pack this num using in current int capacity' ) self . _bit_assignment . append ( tmp_list ) tmp_list = [ ] bit_count = 0 bit_count += bit_len tmp_list . append ( bit_len ) if len ( tmp_list ) != 0 : self . _bit_assignment . append ( tmp_list ) self . _pack_int_needed = len ( self . _bit_assignment ) # transfer variable compress_parameter = self . cipher_compress_suggest ( ) if sync_para : self . trans_var = CipherCompressorTransferVariable ( ) self . trans_var . compress_para . remote ( compress_parameter , role = consts . HOST , idx = - 1 ) LOGGER . debug ( 'int packer init done, bit assign is {}, compress para is {}' . format ( self . _bit_assignment , compress_parameter ) )