1

我正在通过 wiki 研究 RSA 盲签名。这是我理解的方法,其中 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

我在这里做任何“错误”,还是他们应该看起来的样子?

4

0 回答 0