Houjie
2025-07-24 52a3ff1bce1417b39f6872d8e8cb378e9c2ccc6f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var IllegalArgumentException_1 = require("../../../IllegalArgumentException");
var ArithmeticException_1 = require("../../../ArithmeticException");
var ModulusBase = /** @class */ (function () {
    function ModulusBase() {
    }
    ModulusBase.prototype.add = function (a, b) {
        return (a + b) % this.modulus;
    };
    ModulusBase.prototype.subtract = function (a, b) {
        return (this.modulus + a - b) % this.modulus;
    };
    ModulusBase.prototype.exp = function (a) {
        return this.expTable[a];
    };
    ModulusBase.prototype.log = function (a) {
        if (a === 0) {
            throw new IllegalArgumentException_1.default();
        }
        return this.logTable[a];
    };
    ModulusBase.prototype.inverse = function (a) {
        if (a === 0) {
            throw new ArithmeticException_1.default();
        }
        return this.expTable[this.modulus - this.logTable[a] - 1];
    };
    ModulusBase.prototype.multiply = function (a, b) {
        if (a === 0 || b === 0) {
            return 0;
        }
        return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.modulus - 1)];
    };
    ModulusBase.prototype.getSize = function () {
        return this.modulus;
    };
    ModulusBase.prototype.equals = function (o) {
        return o === this;
    };
    return ModulusBase;
}());
exports.default = ModulusBase;