MCPcopy Create free account
hub / github.com/cryptii/cryptii / validateInitialBiasValue

Method validateInitialBiasValue

src/Encoder/Bootstring.js:541–560  ·  view source on GitHub ↗

* Validates initial bias setting value according to section 4 of RFC 3492 * such that `initial_bias mod base <= base - tmin`. * @param {number} value Initial bias to be validated * @param {Field} setting Sender field * @return {boolean|object}

(value, setting)

Source from the content-addressed store, hash-verified

539 * @return {boolean|object}
540 */
541 validateInitialBiasValue (value, setting) {
542 // Can't validate initial bias without valid base and tmin values
543 if (!this.isSettingValid('digitMapping', 'tmin')) {
544 return false
545 }
546
547 const base = this.getSettingValue('digitMapping').getLength()
548 const tmin = this.getSettingValue('tmin')
549
550 if (MathUtil.mod(value, base) > base - tmin) {
551 return {
552 key: 'bootstringInitialBiasInvalid',
553 message:
554 'The value must be chosen such that ' +
555 'initial_bias mod base <= base - tmin'
556 }
557 }
558
559 return true
560 }
561}

Callers

nothing calls this directly

Calls 4

isSettingValidMethod · 0.80
getSettingValueMethod · 0.80
modMethod · 0.80
getLengthMethod · 0.45

Tested by

no test coverage detected