gpt4 book ai didi

java - 椭圆曲线ElGamal Java实现

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:32:29 28 4
gpt4 key购买 nike

有没有简单实现(使用Java BigInteger)的ElGamal椭圆曲线密码系统,具有 key 生成、加密和解密功能;一个可以用来在讲座中向大学生解释的?

例如,Paillier 加密函数可以编码为:

public BigInteger encrypt(BigInteger input) throws PaillierException  {
if(!isInZN(input)) {
throw new PaillierException(PaillierException.TYPE_PLAINTEXT_NOT_IN_ZN, input);
}
BigInteger plaintext = handleNegative(input);
BigInteger r = randomInZStarN();
return (((n.multiply(plaintext).add(BigInteger.ONE)).multiply(r.modPow(n, nSquared)))).mod(nSquared);
}

其中包含优化 g=(1+n),使密文 c = (1 + mn) r^n mod n^2。

不要建议 Java 7 native 实现或 BouncyCaSTLe 实现,因为我不需要现实世界中符合 JCA 的复杂实现。

谢谢。

最佳答案

关于java - 椭圆曲线ElGamal Java实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12209769/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com