import { extendedEuclideanGCD } from './ExtendedEuclideanGCD' /** * https://brilliant.org/wiki/modular-arithmetic/ * @param {Number} arg1 first argument * @param {Number} arg2 second argument * @returns {Number} */ export class ModRing { constructor (MOD) { this.MOD = MOD } isInputValid = (arg1, arg2) => { if (!this.MOD) { throw new Error('Modulus must be initialized in the object constructor') } if (typeof arg1 !== 'number' || typeof arg2 !== 'number') { throw new TypeError('Input must be Numbers') } } /** * Modulus is Distributive property, * As a result, we separate it into numbers in order to keep it within MOD's range */ add = (arg1, arg2) => { this.isIn