def _encrypt_with_shares(cls, plaintext, key_id, vis_expr):
'''
Arguments:
plaintext - plaintext portion of the cell to be encrypted
key_id - the keytor object,contains a key_id and handle on the key_objection
to obtain the keys.
vis_expr - visibility expression of the cell to be encrypted
Returns - the encrypted shares concatenated with the ciphertext
or the field of the cell being encrypted
'''
#generate a random key for the cell
cell_key = Random.get_random_bytes(key_id.cell_key_length)
#break into shares and then encrypt
encrypted_shares = SecretVisTreeEncryptor.encrypt_secret_shares(vis_expr,
cell_key,
key_id,
cls.leaf_class)
#encrypt the plaintext
ciphertext = cls._encrypt(plaintext, cell_key)
return encrypted_shares + "#" + ciphertext
评论列表
文章目录