Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bn.js to 5.2.1 and fix test #304

Closed
wants to merge 1 commit into from
Closed

Update bn.js to 5.2.1 and fix test #304

wants to merge 1 commit into from

Conversation

agalatan
Copy link

@agalatan agalatan commented Mar 15, 2023

In bn.js@4.11.9, the string equals hello, and the function below executes with no error. Moreover, the test that i changed passes, due to pure luck.

// HELLO! string equals 'hello' when we test in "elliptic"
function parseHex4Bits (string, index) {
    var c = string.charCodeAt(index);
    // 'A' - 'F'
    if (c >= 65 && c <= 70) {
      return c - 55;
    // 'a' - 'f'
    } else if (c >= 97 && c <= 102) {
      return c - 87;
    // '0' - '9'
    } else {
      return (c - 48) & 0xf;
    }
  }

In bn.js@5.2.1, the string equals hello, and the assertion correctly throws

// HELLO! string equals 'hello' when we test in "elliptic"
function parseHex4Bits (string, index) {
    // string === 'hello'
    var c = string.charCodeAt(index);
    // '0' - '9'
    if (c >= 48 && c <= 57) {
      return c - 48;
    // 'A' - 'F'
    } else if (c >= 65 && c <= 70) {
      return c - 55;
    // 'a' - 'f'
    } else if (c >= 97 && c <= 102) {
      return c - 87;
    } else {
      assert(false, 'Invalid character in ' + string);
    }
  }
  • ALL the tests of elliptic provide a hex msg except one, that provides hello.

@agalatan agalatan changed the title Update bn to 5.2.0 and fix test Update bn.js to 5.2.0 and fix test Mar 15, 2023
@agalatan agalatan changed the title Update bn.js to 5.2.0 and fix test Update bn.js to 5.2.1 and fix test Mar 16, 2023
@agalatan agalatan closed this by deleting the head repository Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant