0

I essentially have the same exact question as this one: Diffie Hellman Problem, which unfortunately doesn't have any good answers that clear up my confusion. There is one answer that is highly technical and that I don't understand. The comments seem to be on the right track, but I don't follow.

What I do understand is the following:

  1. Alice and Bob agree on two public numbers, $g$ and $n$.
  2. Alice chooses a private number, $a$, such that $1 <= a <= n$.
  3. Bob chooses a private number, $b$, such that $1 <= b <= n$.
  4. Alice computes $g^a (\text{mod n})$ and sends the result to Bob.
  5. Bob computes $g^b (\text{mod n})$ and sends the result to Alice.
  6. Upon receiving $g^a(\text{mod n})$ from Alice, Bob performs: $(g^a)^b (\text{mod n})$.
  7. Upon receiving $g^b(\text{mod n})$ from Bob, Alice performs: $(g^b)^a (\text{mod n})$.
  8. These are identical, and the result is used as the key for their communication.

Everything makes sense for me up until step 6. Bob received $g^a (\text{mod n})$ from Alice, so how can he perform $(g^a)^b$ if he does not know the value of $a$? Similarly, Alice received $g^b (\text{mod n})$ from Bob, so how can she perform $(g^b)^a$ if she doesn't know the value of $b$?

Said differently, Bob needs to calculate this:

$$ (g^a \text{mod n})^b (\text{mod n}) $$

What property of modular arithmetic allows him to simplify it to the following?

$$ g^{ab} (\text{mod n}) $$

Aleksandr Hovhannisyan
  • 2,983
  • 4
  • 34
  • 59
  • So you’re essentially asking: why is $(x\text{ mod }n)^k\text{ mod }n =x^k\text{ mod }n$? Just write $x=a+bn$ and see what happens. – FShrike Aug 07 '22 at 16:26
  • @FShrike Yep, that's my question. – Aleksandr Hovhannisyan Aug 07 '22 at 16:29
  • @FShrike So if $x = a + bn$, where the $a$ and $b$ here are not related to the original problem and we're just representing $x$ as its divisor times the quotient plus the remainder, then rearranging for $a$ gives: $a = x - bn$, which is precisely the remainder, or $x \mod n$. So Substituting gives $(x-bn)^k \mod n$. But I'm not sure how to proceed from there. – Aleksandr Hovhannisyan Aug 07 '22 at 16:32
  • @Bill Dubuque Sure thing, I should have checked for the dupe first – FShrike Aug 07 '22 at 16:52

0 Answers0