我正在研究有关RSA盲签名的Wiki。据我了解,这是我的方法,其中r是致盲因子,m是消息,d是私钥,e是指数,n是公钥:
public BigInteger sign(BigInteger m, BigInteger d, BigInteger n)
{
return m.modPow(d, n);
}
public BigInteger blindMessage(BigInteger m, BigInteger r, BigInteger e, BigInteger n)
{
return m.multiply(r.modPow(e, n));
}
public BigInteger unblindMessage(BigInteger m, BigInteger r, BigInteger n)
{
return m.multiply(r.modPow(BigInteger.ONE.negate(), n));
}
我已经验证了我实际的RSA实施工作;但是,“正常”签名和盲签名之间存在差异。我担心我没有正确编写方程式,因为我以前从未使用过BigIntegers。
我的演示代码是:
RSA rsa = new RSA();
RSAobject alice = rsa.keygen(32);
RSAobject bank = rsa.keygen(32);;
BigInteger message = new BigInteger("123");
System.out.println("Message: " + message.toString());
BigInteger cyphertext = rsa.encrypt(message, alice.n, alice.e);
System.out.println("Cyphertext: " + cyphertext.toString());
BigInteger decrypted = rsa.decrypt(cyphertext, alice.d, alice.n);
System.out.println("Plaintext: " + decrypted.toString());
BigInteger normalSign = rsa.sign(message, bank.d, bank.n);
System.out.println("Normal Signature: " + normalSign.toString());
BigInteger blindingFactor = rsa.getBlindingFactor(alice.n);
System.out.println("Blinding factor: " + blindingFactor.toString());
BigInteger blindedMessage = rsa.blindMessage(message, blindingFactor, alice.e, alice.n);
System.out.println("Blinded Message: " + blindedMessage.toString());
BigInteger blindedMessageSignature = rsa.sign(blindedMessage, bank.d, bank.n);
System.out.println("Blinded Message Signature: " + blindedMessageSignature.toString());
BigInteger unblindedMessageSignature = rsa.unblindMessage(blindedMessage, blindingFactor, alice.n);
System.out.println("Unblinded Message Signature: " + unblindedMessageSignature.toString());
它会输出以下内容:
Message: 123
Cyphertext: 22707724
Plaintext: 123
Normal Signature: 13584112
Blinding factor: 14036619
Blinded Message: 689947713
Blinded Message Signature: 7031325
Unblinded Message Signature: 20354580078429051
我在这里做任何“错误”的事情,还是应该看起来像这样?