def get_addresses(self, target): buckets_, addresses_ = self.server.get_addresses(target) buckets = copy.deepcopy(buckets_) addresses = copy.deepcopy(addresses_) for i in range(len(buckets)): for j in range(self.blocks_per_bucket): if addresses[i][j] < 0: continue p = Payload(addresses[i][j], self.public_key, 1, 2) addresses[i][j] = p.get_plaintext(self.private_key).payload return buckets, addresses
def get_block(self, bucket_id, block_id): block = copy.deepcopy(self.server.buckets[bucket_id].blocks[block_id]) metadata = self.get_metadata(bucket_id, block_id) # decrypt the metadata of this block block.address = metadata[0] block.bucket_leaf_target = metadata[1] block.chunks_per_block = metadata[2] onion_layers = self.__onions(bucket_id) # decrypt all chunks of this block for c in range(block.chunks_per_block): p = Payload(block.chunks[c], self.public_key, self.root_plain_space, self.root_plain_space + onion_layers) block.chunks[c] = p.get_plaintext(self.private_key).payload return block