* @function isValidP * @description Checks if A, B, and p fulfill A^p = mB + 1. * @param {BigInt} A * @param {BigInt} B * @param {BigInt} p * @returns Whether A, B, and p fulfill A^p = mB + 1.
(A, B, p)
| 76 | * @returns Whether A, B, and p fulfill A^p = mB + 1. |
| 77 | */ |
| 78 | function isValidP(A, B, p) { |
| 79 | // A^p = mB + 1 => A^p - 1 = 0 (mod B) |
| 80 | return (A ** p - 1n) % B === 0n |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @function gcd |