* Validates slope (a) setting value. * @param {number} a * @return {boolean|object}
(a)
| 174 | * @return {boolean|object} |
| 175 | */ |
| 176 | validateSlopeValue (a) { |
| 177 | const alphabetSetting = this.getSetting('alphabet') |
| 178 | if (!alphabetSetting.isValid()) { |
| 179 | // Can't validate slope without valid alphabet setting |
| 180 | return false |
| 181 | } |
| 182 | |
| 183 | // The value a must be chosen such that a and m are coprime |
| 184 | const m = alphabetSetting.getValue().getLength() |
| 185 | if (!MathUtil.isCoprime(a, m)) { |
| 186 | return { |
| 187 | key: 'affineCipherFunctionInvalid', |
| 188 | message: |
| 189 | 'The value must be chosen such that it is coprime to the size ' + |
| 190 | `of the alphabet (${m})` |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | return true |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Generates a random slope setting value. |
nothing calls this directly
no test coverage detected