arithmetic-operations-for/integers-modulo-n-big-endian

View on GitHub

Showing 5 of 7 total issues

Function _redc has 11 arguments (exceeds 4 allowed). Consider refactoring.
Open

export default function _redc(b, k, N, Ni, Nj, M, Mi, Mj, T, Ti, Tj) {
Severity: Major
Found in src/_redc.js - About 1 hr to fix

    Function inv has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        inv(aRmodN) {
            // The modular inverse
            // Compute (aR mod N)^-1 using Euclidean algo
            const ai = n_trim_positive(aRmodN, 0, this.k);
    
    
    Severity: Minor
    Found in src/Montgomery.js - About 1 hr to fix

      Function _montgomery has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function _montgomery(b, N) {
          assert(N.length > 0);
          assert(N[0] !== 0);
      
          const k = N.length;
      Severity: Minor
      Found in src/_montgomery.js - About 1 hr to fix

        Function _mul has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export default function _mul(r, N, M, a, b, c) {
        Severity: Minor
        Found in src/_mul.js - About 45 mins to fix

          Function pown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              pown(aRmodN, x) {
                  // Modular
                  // exponentiation can be done using exponentiation by squaring by initializing the
                  // initial product to the Montgomery representation of 1, that is, to R mod N, and
                  // by replacing the multiply and square steps by Montgomery multiplies.
          Severity: Minor
          Found in src/Montgomery.js - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Severity
          Category
          Status
          Source
          Language