【问题标题】:Can we perform division operation on encrypted data using Microsoft SEAL / PySEAL library我们可以使用 Microsoft SEAL / PySEAL 库对加密数据执行除法运算吗
【发布时间】:2019-07-13 06:55:00
【问题描述】:

我正在使用PySEAL 库,它是Microsoft SEAL 同态加密库的一个分支,用于在加密数据上实现机器学习算法。为此,我需要除数。在examples.py 源代码中有执行加法、减法和乘法的示例,但不能执行除法。是否可以使用 PySEAL 库进行除法?如果没有,有没有什么办法可以解决这个问题,比如使用这个库中的其他算术运算来划分两个数字?

【问题讨论】:

    标签: python c++ math seal


    【解决方案1】:

    SEAL 不支持密文之间的划分。但是,如果您希望将密文除以明文,则可以使用逆乘法,如下所示:

    from seal import *
    
    # context is a SEALContext object
    # encoder is a FractionalEncoder object
    # encryptor is an Encryptor object
    # evaluator is an Evaluator object
    # decryptor is a Decryptor object
    
    # Encrypt a float
    cipher = Ciphertext()
    encryptor.encrypt(encoder.encode(7.0), cipher)
    
    # Divide that float by 10
    div_by_ten = encoder.encode(0.1)
    evaluator.multiply_plain(cipher, div_by_ten)
    
    # Decrypt result
    plain = Plaintext()
    decryptor.decrypt(cipher, plain)
    result = encoder.decode(plain)
    print(result)
    >> 0.6999999999999996
    

    参见PySEAL Python examples 中的example_weighted_average 函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-27
      • 2021-08-16
      • 1970-01-01
      • 2023-03-04
      • 2019-05-25
      • 1970-01-01
      相关资源
      最近更新 更多