mirror of
https://github.com/hanzoai/elliptic.git
synced 2026-09-23 23:51:03 +00:00
6.6.1
This commit is contained in:
Vendored
+14
-1
@@ -2289,9 +2289,19 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
|
|||||||
if (!options)
|
if (!options)
|
||||||
options = {};
|
options = {};
|
||||||
|
|
||||||
|
if (typeof msg !== 'string' && typeof msg !== 'number' && !BN.isBN(msg)) {
|
||||||
|
assert(typeof msg === 'object' && msg && typeof msg.length === 'number',
|
||||||
|
'Expected message to be an array-like, a hex string, or a BN instance');
|
||||||
|
assert((msg.length >>> 0) === msg.length); // non-negative 32-bit integer
|
||||||
|
for (var i = 0; i < msg.length; i++) assert((msg[i] & 255) === msg[i]);
|
||||||
|
}
|
||||||
|
|
||||||
key = this.keyFromPrivate(key, enc);
|
key = this.keyFromPrivate(key, enc);
|
||||||
msg = this._truncateToN(msg, false, options.msgBitLength);
|
msg = this._truncateToN(msg, false, options.msgBitLength);
|
||||||
|
|
||||||
|
// Would fail further checks, but let's make the error message clear
|
||||||
|
assert(!msg.isNeg(), 'Can not sign a negative message');
|
||||||
|
|
||||||
// Zero-extend key to provide enough entropy
|
// Zero-extend key to provide enough entropy
|
||||||
var bytes = this.n.byteLength();
|
var bytes = this.n.byteLength();
|
||||||
var bkey = key.getPrivate().toArray('be', bytes);
|
var bkey = key.getPrivate().toArray('be', bytes);
|
||||||
@@ -2299,6 +2309,9 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
|
|||||||
// Zero-extend nonce to have the same byte size as N
|
// Zero-extend nonce to have the same byte size as N
|
||||||
var nonce = msg.toArray('be', bytes);
|
var nonce = msg.toArray('be', bytes);
|
||||||
|
|
||||||
|
// Recheck nonce to be bijective to msg
|
||||||
|
assert((new BN(nonce)).eq(msg), 'Can not sign message');
|
||||||
|
|
||||||
// Instantiate Hmac_DRBG
|
// Instantiate Hmac_DRBG
|
||||||
var drbg = new HmacDRBG({
|
var drbg = new HmacDRBG({
|
||||||
hash: this.hash,
|
hash: this.hash,
|
||||||
@@ -8889,7 +8902,7 @@ utils.encode = function encode(arr, enc) {
|
|||||||
},{}],35:[function(require,module,exports){
|
},{}],35:[function(require,module,exports){
|
||||||
module.exports={
|
module.exports={
|
||||||
"name": "elliptic",
|
"name": "elliptic",
|
||||||
"version": "6.6.0",
|
"version": "6.6.1",
|
||||||
"description": "EC cryptography",
|
"description": "EC cryptography",
|
||||||
"main": "lib/elliptic.js",
|
"main": "lib/elliptic.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "elliptic",
|
"name": "elliptic",
|
||||||
"version": "6.6.0",
|
"version": "6.6.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "6.6.0",
|
"version": "6.6.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bn.js": "^4.11.9",
|
"bn.js": "^4.11.9",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "elliptic",
|
"name": "elliptic",
|
||||||
"version": "6.6.0",
|
"version": "6.6.1",
|
||||||
"description": "EC cryptography",
|
"description": "EC cryptography",
|
||||||
"main": "lib/elliptic.js",
|
"main": "lib/elliptic.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
Reference in New Issue
Block a user