2079 12

CSC327 · 2079 · 5 marks

What is the condition of for two integers, x and y, to be relatively prime? Find whether 61 is prime or not using Miller-Rabin algorithm.

What is the condition of for two integers, x and y, to be relatively prime? Find whether 61 is prime or not using Miller-Rabin algorithm. [5]

CryptographyChapter 3: Asymmetric CiphersNumber TheoryNumerical: Miller-Rabin primality test

Relatively Prime Condition and Miller-Rabin Test for 61

Given

  • Number to test: $n = 61$
  • Question asks: (a) condition for two integers $x, y$ to be relatively prime; (b) test primality of 61 using Miller-Rabin.
  • No specific witness $a$ is given, so we choose valid witnesses.

Solution

Part 1: Condition for Relatively Prime

Two integers $x$ and $y$ are relatively prime (coprime) if and only if their greatest common divisor is 1:

$$\gcd(x, y) = 1$$

They share no common positive divisor other than 1.

Example: $\gcd(8, 15) = 1$, so 8 and 15 are relatively prime.


Part 2: Miller-Rabin Test for n = 61

Step 1: Write $n - 1 = 2^k \cdot m$, m odd

$$n - 1 = 60 = 2^2 \times 15$$

So $k = 2$, $m = 15$ (odd, confirmed).

Step 2: Choose witness $a = 2$ (valid: $1 < 2 < 60$).

Step 3: Compute $b = a^m \bmod n = 2^{15} \bmod 61$

$$2^{15} = 32768$$ $$32768 \bmod 61: \quad 61 \times 537 = 32757, \quad 32768 - 32757 = 11$$

Cross-check via the alternative decomposition: $b = 11$.

Step 4: Is $b = 1$? No, $11 \neq 1$. Proceed to loop.

Step 5: Loop $i = 0$ to $k-1 = 1$

Check $b = n - 1 = 60$ at start of each iteration:

  • $i = 0$: $b = 11 \neq 60$. Square: $b = 11^2 = 121 \equiv 121 - 61 = 60 \pmod{61}$.

    Now $b = 60 = -1 \pmod{61}$ at the moment it is produced.

Note on algorithm form: In the correct Miller-Rabin loop, after squaring we check whether we hit $-1$. The sequence of squarings starting from $2^{15}$ is:

$$2^{15} \equiv 11, \quad 2^{30} \equiv 11^2 = 60 \equiv -1 \pmod{61}$$

Since one of the values $a^{2^i m}$ equals $-1$ (here $2^{30} \equiv -1$), the test declares probably prime. Witness $a = 2$ is a strong liar-free result: 61 passes.

$$11^2 = 121, \quad 121 - 61 = 60 \quad (\text{not } 59)$$

Therefore, with $a = 2$ itself, the test returns Prime (no second witness needed).

Double-check with $a = 7$:

$$7^2 = 49,\ 7^4 = 49^2 = 2401 \equiv 2401 - 39(61)=2401-2379=22$$ $$7^8 = 22^2 = 484 \equiv 484 - 7(61) = 484 - 427 = 57$$ $$7^{15} = 7^8 \cdot 7^4 \cdot 7^2 \cdot 7 = 57 \cdot 22 \cdot 49 \cdot 7 \pmod{61}$$ $$57 \cdot 22 = 1254 \equiv 1254 - 20(61)=1254-1220=34$$ $$34 \cdot 49 = 1666 \equiv 1666 - 27(61)=1666-1647=19$$ $$19 \cdot 7 = 133 \equiv 133 - 2(61) = 11 \pmod{61}$$

So $7^{15} \equiv 11 \neq 1, \neq 60$. Square: $11^2 = 121 \equiv 60 \equiv -1$. Returns Prime.

(Note that $7^{15} \equiv 11$, not $60$; the squaring still gives $-1$, so the conclusion "Prime" holds.)


Conclusion

$$\boxed{61 \text{ is Prime (probably prime by Miller-Rabin)}}$$

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.