RSA私钥和公钥

时间:2014-03-16 06:08:42

标签: math rsa

很少关注如何处理这个问题:

Xavier and Yvonne are in love. They both set up their own RSA keys: 
Xavier’s public key     is (eX , nX ) = (887, 15833), and Yvonne’s public key 
is (eY , nY ) = (977, 13019). For each of the following, do not factor nX nor 
nY , show the set up of the calculations and the results. You should use a 
computer to perform the calculations.

(a) Yvonne wants to send Xavier a private message of love, which is
    M = 3141. What is the ciphertext that Yvonne needs to send to Xavier?

(b) In return, Yvonne received three mysterious messages: C1 = 10889, 
    C2 = 2622, C3 = 4061. All three senders claim to be Xavier, and all 
    claim to have sent the message Ci ≡ MdX (mod nX) where M = 3141 and dX 
    is Xavier’s private key. However, only Xavier himself knows the actual 
    value of dX , and the other two are imposters trying to steal Yvonne away 
    from him. Help Yvonne determine which message is actually from Xavier, 
    and explain why your method works.

任何提示都会非常感谢!

1 个答案:

答案 0 :(得分:2)

a)为了发送RSA加密的消息,只有私钥持有者可以对其进行解密,必须使用接收者的公钥对其进行加密。在这种情况下,收件人是Xavier,因此邮件使用他的公钥加密:(e X ,n X )=(887,15833):

Message: M = 3141
Ciphertext: C = MeX mod nX
C = 3141887 mod 15833
C = 2054

b)这实际上是使用Xavier私钥签名的消息的签名验证,该私钥需要使用签名者的公钥。当使用Xavier的公钥解密时,有必要找到三条消息中的哪一条导致发送的消息(3141):

Ciphertext 1: C1 = 10889
Message 1: M1 = C1eX mod nX
M1 = 10889887 mod 15833
M1 = 6555 (mismatch)
Ciphertext 2: C2 = 2622
Message 2: M2 = C2eX mod nX
M2 = 2622887 mod 15833
M2 = 1466 (mismatch)
Ciphertext 3: C3 = 2622
Message 3: M3 = C3eX mod nX
M3 = 4061887 mod 15833
M3 = 3141 (match!)

当使用Xavier的公钥解密时,只有C 3 匹配该消息,因此唯一的真实消息也是如此。


注意:我使用WolframAlpha执行上面的模幂运算,但是手动使用重复乘法然后减少模数n很容易(虽然相当费时)。< / p>