如何解决ElGamal 阈值密码学 - 非确定性解密问题
我正在用 Java 实现一个 ElGamal 阈值加密库。到目前为止,我能够生成公钥和私钥;用公钥加密一段数据;建立私钥份额,然后用私钥份额计算解密份额;然后聚合解密共享以恢复加密数据,而不会泄露有关私钥的信息。
我的问题是加密数据的解密不是确定性的。这意味着根据私钥的值,我的解密是否有效。经过仔细测试,我知道私钥共享和插值是正确的,因为我总是能够从中重建私钥。
这是我使用的代码:
// Assuming any keysize
int keysizeBits;
// Assuming constant modulus
BigInteger modulus = publicParameters.getParameters().getP();
// Assuming a cipher text composed of c1 and c2
byte[] cipherText;
// Assuming correct public and private key shares I start with a set of decryption shares
BCElGamalPublicKey publicKey;
List<DecryptionShare> decryptionShares;
// Getting the c2 part of the cipherText
List<byte[]> c1c2 = splitCipherText(cipherText,keysizeBits);
BigInteger c2BI = new BigInteger(1,c1c2.get(1));
// Interpolate the decryption shares to get the Lagrange coefficients.
// The HashMap keys are a unique identifier of the DecryptionShare class
HashMap<Integer,BigInteger> termDictionary = interpolate(DecryptionShares);
// Computing the weighted product to decrypt the data
BigInteger product = BigInteger.ONE;
for (DecryptionShare decryptionShare : decryptionShares) {
BigInteger factor =
decryptionShare.getValue()
.modPow(
termDictionary.get(decryptionShare.getIdentifier()),modulus
);
product = product.multiply(factor);
}
BigInteger plaintext = product.modePow(new BigInteger("-1"),modulus)
.multiply(c2Bi).mod(modulus);
如前所述,我很确定问题来自上面的 for 循环。
感谢您的帮助,如果装修不够,请随时询问更多详情。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。