indutny/elliptic

View on GitHub

Showing 136 of 136 total issues

File secp256k1.js has 780 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module.exports = {
  doubles: {
    step: 4,
    points: [
      [
Severity: Major
Found in lib/elliptic/precomputed/secp256k1.js - About 1 day to fix

    File short.js has 698 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    var utils = require('../utils');
    var BN = require('bn.js');
    var inherits = require('inherits');
    Severity: Major
    Found in lib/elliptic/curve/short.js - About 1 day to fix

      Function exports has 185 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(grunt) {
        grunt.initConfig({
          browserify: {
            unittests: {
              files: {
      Severity: Major
      Found in Gruntfile.js - About 7 hrs to fix

        Function _wnafMulAdd has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

        BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
          points,
          coeffs,
          len,
          jacobianResult) {
        Severity: Minor
        Found in lib/elliptic/curve/base.js - About 6 hrs 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

        Function getJSF has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

        function getJSF(k1, k2) {
          var jsf = [
            [],
            [],
          ];
        Severity: Minor
        Found in lib/elliptic/utils.js - About 3 hrs 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

        Function _wnafMulAdd has 91 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
          points,
          coeffs,
          len,
          jacobianResult) {
        Severity: Major
        Found in lib/elliptic/curve/base.js - About 3 hrs to fix

          File edwards.js has 299 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict';
          
          var utils = require('../utils');
          var BN = require('bn.js');
          var inherits = require('inherits');
          Severity: Minor
          Found in lib/elliptic/curve/edwards.js - About 3 hrs to fix

            File base.js has 293 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            'use strict';
            
            var BN = require('bn.js');
            var utils = require('../utils');
            var getNAF = utils.getNAF;
            Severity: Minor
            Found in lib/elliptic/curve/base.js - About 3 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              Point.prototype.inspect = function inspect() {
                if (this.isInfinity())
                  return '<EC Point Infinity>';
                return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
                    ' z: ' + this.z.fromRed().toString(16, 2) + '>';
              Severity: Major
              Found in lib/elliptic/curve/mont.js and 1 other location - About 3 hrs to fix
              lib/elliptic/curve/short.js on lines 354..359

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 95.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              Point.prototype.inspect = function inspect() {
                if (this.isInfinity())
                  return '<EC Point Infinity>';
                return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
                    ' y: ' + this.y.fromRed().toString(16, 2) + '>';
              Severity: Major
              Found in lib/elliptic/curve/short.js and 1 other location - About 3 hrs to fix
              lib/elliptic/curve/mont.js on lines 70..75

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 95.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function sign has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

              EC.prototype.sign = function sign(msg, key, enc, options) {
                if (typeof enc === 'object') {
                  options = enc;
                  enc = null;
                }
              Severity: Minor
              Found in lib/elliptic/ec/index.js - About 2 hrs 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  if ((m24 & 1) === 0) {
                    u2 = 0;
                  } else {
                    m8 = (k2.andln(7) + d2) & 7;
                    if ((m8 === 3 || m8 === 5) && m14 === 2)
              Severity: Major
              Found in lib/elliptic/utils.js and 1 other location - About 2 hrs to fix
              lib/elliptic/utils.js on lines 67..75

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 90.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  if ((m14 & 1) === 0) {
                    u1 = 0;
                  } else {
                    m8 = (k1.andln(7) + d1) & 7;
                    if ((m8 === 3 || m8 === 5) && m24 === 2)
              Severity: Major
              Found in lib/elliptic/utils.js and 1 other location - About 2 hrs to fix
              lib/elliptic/utils.js on lines 79..87

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 90.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                for (;;) {
                  xc.iadd(this.curve.n);
                  if (xc.cmp(this.curve.p) >= 0)
                    return false;
              
              
              Severity: Major
              Found in lib/elliptic/curve/edwards.js and 1 other location - About 2 hrs to fix
              lib/elliptic/curve/short.js on lines 916..924

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 85.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                for (;;) {
                  xc.iadd(this.curve.n);
                  if (xc.cmp(this.curve.p) >= 0)
                    return false;
              
              
              Severity: Major
              Found in lib/elliptic/curve/short.js and 1 other location - About 2 hrs to fix
              lib/elliptic/curve/edwards.js on lines 422..430

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 85.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function _importDER has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              Signature.prototype._importDER = function _importDER(data, enc) {
                data = utils.toArray(data, enc);
                var p = new Position();
                if (data[p.place++] !== 0x30) {
                  return false;
              Severity: Minor
              Found in lib/elliptic/ec/signature.js - About 2 hrs 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

              Function _wnafMul has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
                var w = 4;
              
                // Precompute window
                var nafPoints = p._getNAFPoints(w);
              Severity: Minor
              Found in lib/elliptic/curve/base.js - About 2 hrs 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

              Function _getEndoBasis has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
                // aprxSqrt >= sqrt(this.n)
                var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
              
                // 3.74
              Severity: Major
              Found in lib/elliptic/curve/short.js - About 2 hrs to fix

                Function Point has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                function Point(curve, x, y, z, t) {
                  Base.BasePoint.call(this, curve, 'projective');
                  if (x === null && y === null && z === null) {
                    this.x = this.curve.zero;
                    this.y = this.curve.one;
                Severity: Minor
                Found in lib/elliptic/curve/edwards.js - About 2 hrs 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

                Function _importDER has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Signature.prototype._importDER = function _importDER(data, enc) {
                  data = utils.toArray(data, enc);
                  var p = new Position();
                  if (data[p.place++] !== 0x30) {
                    return false;
                Severity: Major
                Found in lib/elliptic/ec/signature.js - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language