From my understanding, many questions in this chapter is more about the theory behind everything. There isn't way too many technical stuff about it. I will update this page with better information in the future, hopefully.
Note from the future: Hurray! I actually remembered to update it.
For now, there is a program below to help you with the discrete logarithm problems. Just give it a base number, the result you are looking for and a modulo value. It uses the collision, or meet-in-the-middle algorithm that was given in the textbook.
Even if we didn't have a good algorithm for this, we already have a really fast way of computing powers of a number in modulo p. We could theoretically try every possible value, and it would take us linear time. However, there is no need. Some brilliant mathematician out there already had a convenient way of doing it, isn't that nice ? You may try it below.
It is also possible to use this to find where an element starts to repeat itself, if you specify a result value of 1. Enjoy!
Solve gx = h mod(p)
Question 2.3
Question 2.4
With the help of the square_n_multiply program we defined in Chapter 1, it is easy to see that 2947 = 177 (mod 1373), which is denoted by A (aka. Alice's public key).
According to the given information, Alice then encrypt the plaintext m = 583 and she uses the random value k = 877. Then, according to Elgemal she needs to calculate c1 = gk = 2877 (mod 1373) and c2 = m.Bk = m.B877 (mod 1373). After calculation we see that c1 = 719 and c2 = m.644 (mod 1373), which at the end simplifies to c2 = 375462 = 623 (mod 1373). Hence, Alice sends bob the pair (719, 623).
For part (c), Alice decides to use a new secret key 299, and her public key becomes 34. She gets an encrypted message from Bob, the pair (661, 1325). Remember that 661 = 2k mod(1373) where k is a randomly chosen number. Using the calculator above we see that 2566 = 661 mod(1373). We also know that 1325 = m . 34661 mod(1373) = m . 201 mod(1373). Therefore, all we need to calculate is 1325 . 201-1 mod(1373). This is quite easy using our fast powering algorithm or even extended euclidean algorithm. 1325 . 201-1 = 1325 . 929 = 1230925 = 717 mod(1373).
Observe that we did not even use Alice's private key to decrypt this message, because finding the random number k was quite simple. This is a representation of what Eve(the third party) would do if she has the intention to decrypt our message.
The part (d) is also very similar to this. Using the meet-in-the-middle algorithm above you may find the necessary random value k, and help Eve out.
Question 2.10
The idea behind the system in this question is simple. The only number that is public is the modulo value 32611. Alice has a message that he wants to send to Bob, but Bob has no public key. Alice only has her own private key, the only thing she can do here is to encrypt it using her private key 3589 and send it to Bob. Right now Eve knows the fact that ma = 15950. Bob receives this message but he can not decrypt it, because he has no clue what Alice's secret key is, and the message he received is not encrypted with his private key in mind.
At this stage, Bob does the only logical thing, and encrypts the message he received with his private key. On the transfer Eve sees that v = m(4037 . 3589) = m(a.b) = 15422. Eve does not have the private key values 4037 and 3589, but using the two equations she has, if she can calculate for which value 15950x = 15422 is satisfied, then she basically finds the value b, which is Bob's private key. In the optimum circumstances this should not be easier than solving the DLP problem. However, if the order of 15950 is easily decomposable into small primes, then by Pohlig-Hellman's p-1 algorithm the value x can be found easily. Therefore, Bob needs to keep an eye out for the possibility that the value he calculated is not vulnerable to such an attack.
This makes the message exchange between Alice and Bob a little more complicated, not only they need to transfer multiple data just to send one message but also there are other variables they need to be aware of. The third party Eve, has more information to decrypt the message.
Now, the value 15422 has reached Alice. There is one big problem. She has no way of understanding whether this came from Bob. Bob has no public information available and the algorithm does not include a signing method. Therefore, Eve could act like the (wo)man-in-the-middle and intercept the messages on their way. This is also quite problematic.
Let us assume that everything went according to the plan. Alice has the plaintext value 11111 and she knows that 11111(3589 . 15619) = 1 mod(32611), this is because 3589 . 15619 = 1 mod(32610). Remember that a value to the power p-1 is actually 1, by Fermat's theorem. So, by taking powers of 11111 by 3589 and 15619 respectively, Alice basically made no changes to 11111, which is the plaintext message she wanted to send. She made it more obscure by first taking its 3589th power, and then se reverted those changes back, so that Bob can now actually read the message.
Bob knows that 4037 . 31883 = 1 mod(32610). He then makes the necessary operation to revert his changes back to the original. At the end both Alice's and Bob's effect on the plaintext is neutralized. What is left is the one and only m.
As you probably noticed know, the attack surface of this algorithm is quite big, considering Alice and Bob exchanges two pieces of data for one single message. Both Alice and Bob needs to be extra careful about the information they are sending. There is one more reverse effect of this. When Bob decrypts the message and finds 11111, he also knows from the previous steps that 11111a = 15950, where a is the private key of Alice, which is quite funny. Bob can become Eve if he wants to.
The same is also true for Alice, she knows from all these transactions that 11111b = 27257, which is what Bob send to Alice as a response. If she is able to solve this, she can obtain Bob's private key.
I feel like you get the point, this algorithm would work, but the attack surface is much larger, it is more costly and also requires extra attention to the value being transmitted. Depending on how often Alice and Bob can reach each other, sending one message will require multiple transactions of arbitrary data, which as a result makes this much inferior compared to Elgemal.