简单的同态加密包含加法同态和乘法同态加法同态算法最经典的是Paillier算法乘法同态算法最经典的是RSA算法。以下是RSA算法同态验证说明: 设: ab=c 基础等式其中:加密函数e解密函数d enctrypt:加密;decrypt:解密 乘法同态特为:eaeb=ecc=dec=deaeb验证c 是否等于ab 生成验证代码
:
plaintext = 10 plaintext2 = 5
加密
encrypted_plaintext = encrypt(plaintext) encrypted_plaintext2 = encrypt(plaintext2)
乘法同态
encrypted_result = encrypted_plaintext * encrypted_plaintext2
解密
decrypted_result = decrypt(encrypted_result)
验证结果是否正确
if decrypted_result == plaintext * plaintext2: print("同态验证通过") else: print("同态验证失败")
原文地址: https://www.cveoy.top/t/topic/gAbK 著作权归作者所有。请勿转载和采集!