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.
bn.js
must be upgraded to 5.2.0In
bn.js@4.11.9
, the string equalshello
, and the function below executes with no error. Moreover, the test that i changed passes, due to pure luck.In
bn.js@5.2.1
, the string equalshello
, and the assertion correctly throwselliptic
provide a hexmsg
except one, that provideshello
.