r/compsci•
mrcollet

Digital signature and asymmetric encryption question

My textbook has the following information about how digital signatures work:

"The sender of the message uses their own private key to encrypt the hash total. The signature is attached to the message to be sent and the whole message is encrypted using the recipient's public key. The recipient decrypts using their private key, then decrypts the hash total using the sender's public key."

I follow up until the last sentence which mentions how the recipient uses the sender's public key to decrypt something encrypted by the sender's private key. I thought that messages that were encrypted by a public key can only be decrypted by the corresponding private key and not vice versa.

Posted Jun 2, 2017, 10:58 AM UTC

12
SwordInALake•

So taking rsa for example and just looking at hash of the message so using the senders keys. The sender has an encryption key e, decryption key d and a modulus N=pq. However the encrypting/decrypting function in rsa just raises the input to the power of the respective key. You can see how these functions commute with each other and so (decrypt then encrypt) is the same as (encrypt then decrypt) which is the identity giving you back the hash, which the receiver can compute after decrypting the message with his key. Breaking this would be as hard as finding d from e and N. If you take a look at the encrypting method your using you should try doing some algebra and seeing how things cancel back to give you the message even in the wrong order. In rsa it's easy to see as we pick d as e inverse mod phi(N) but we could swap and have chosen e as d inverse.

2
arbitrarycivilian•

In RSA, the public key A and private key B are actually inverses, so we have A(B(m))=m=B(A(m)). The first form is used for digital signing, the second for encryption. This is not necessarily a property of all public-key cryptosystems.

2