deps: upgrade to bcrypto 2.0. upgrade other deps.
This commit is contained in:
parent
8630a8ee51
commit
e0863d4a91
@ -537,7 +537,7 @@ class HDPrivateKey {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static generate() {
|
static generate() {
|
||||||
const key = secp256k1.generatePrivateKey();
|
const key = secp256k1.privateKeyGenerate();
|
||||||
const entropy = random.randomBytes(32);
|
const entropy = random.randomBytes(32);
|
||||||
return HDPrivateKey.fromKey(key, entropy);
|
return HDPrivateKey.fromKey(key, entropy);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ const {base58} = require('bstring');
|
|||||||
const {BloomFilter} = require('bfilter');
|
const {BloomFilter} = require('bfilter');
|
||||||
const sha256 = require('bcrypto/lib/sha256');
|
const sha256 = require('bcrypto/lib/sha256');
|
||||||
const random = require('bcrypto/lib/random');
|
const random = require('bcrypto/lib/random');
|
||||||
const ccmp = require('bcrypto/lib/ccmp');
|
const {safeEqual} = require('bcrypto/lib/safe');
|
||||||
const util = require('../utils/util');
|
const util = require('../utils/util');
|
||||||
const Address = require('../primitives/address');
|
const Address = require('../primitives/address');
|
||||||
const TX = require('../primitives/tx');
|
const TX = require('../primitives/tx');
|
||||||
@ -367,7 +367,7 @@ class HTTP extends Server {
|
|||||||
const data = Buffer.from(key, 'ascii');
|
const data = Buffer.from(key, 'ascii');
|
||||||
const hash = sha256.digest(data);
|
const hash = sha256.digest(data);
|
||||||
|
|
||||||
if (!ccmp(hash, this.options.apiHash))
|
if (!safeEqual(hash, this.options.apiHash))
|
||||||
throw new Error('Invalid API key.');
|
throw new Error('Invalid API key.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ const Validator = require('bval');
|
|||||||
const {BufferMap, BufferSet} = require('buffer-map');
|
const {BufferMap, BufferSet} = require('buffer-map');
|
||||||
const hash160 = require('bcrypto/lib/hash160');
|
const hash160 = require('bcrypto/lib/hash160');
|
||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
const ccmp = require('bcrypto/lib/ccmp');
|
const {safeEqual} = require('bcrypto/lib/safe');
|
||||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||||
const util = require('../utils/util');
|
const util = require('../utils/util');
|
||||||
const common = require('../blockchain/common');
|
const common = require('../blockchain/common');
|
||||||
@ -2111,7 +2111,7 @@ class RPC extends RPCBase {
|
|||||||
if (!key)
|
if (!key)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return ccmp(hash160.digest(key), addr.hash);
|
return safeEqual(hash160.digest(key), addr.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
async signMessageWithPrivkey(args, help) {
|
async signMessageWithPrivkey(args, help) {
|
||||||
|
|||||||
@ -171,7 +171,7 @@ class KeyRing {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
generate(compress) {
|
generate(compress) {
|
||||||
const key = secp256k1.generatePrivateKey();
|
const key = secp256k1.privateKeyGenerate();
|
||||||
return this.fromKey(key, compress);
|
return this.fromKey(key, compress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const Outpoint = require('../primitives/outpoint');
|
|||||||
const Script = require('../script/script');
|
const Script = require('../script/script');
|
||||||
const sha256 = require('bcrypto/lib/sha256');
|
const sha256 = require('bcrypto/lib/sha256');
|
||||||
const random = require('bcrypto/lib/random');
|
const random = require('bcrypto/lib/random');
|
||||||
const ccmp = require('bcrypto/lib/ccmp');
|
const {safeEqual} = require('bcrypto/lib/safe');
|
||||||
const Network = require('../protocol/network');
|
const Network = require('../protocol/network');
|
||||||
const Address = require('../primitives/address');
|
const Address = require('../primitives/address');
|
||||||
const KeyRing = require('../primitives/keyring');
|
const KeyRing = require('../primitives/keyring');
|
||||||
@ -102,7 +102,7 @@ class HTTP extends Server {
|
|||||||
const valid = Validator.fromRequest(req);
|
const valid = Validator.fromRequest(req);
|
||||||
const token = valid.buf('token');
|
const token = valid.buf('token');
|
||||||
|
|
||||||
if (token && ccmp(token, this.options.adminToken)) {
|
if (token && safeEqual(token, this.options.adminToken)) {
|
||||||
req.admin = true;
|
req.admin = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -949,7 +949,7 @@ class HTTP extends Server {
|
|||||||
const data = Buffer.from(key, 'utf8');
|
const data = Buffer.from(key, 'utf8');
|
||||||
const hash = sha256.digest(data);
|
const hash = sha256.digest(data);
|
||||||
|
|
||||||
if (!ccmp(hash, this.options.apiHash))
|
if (!safeEqual(hash, this.options.apiHash))
|
||||||
throw new Error('Invalid API key.');
|
throw new Error('Invalid API key.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,7 +981,7 @@ class HTTP extends Server {
|
|||||||
if (!this.options.walletAuth) {
|
if (!this.options.walletAuth) {
|
||||||
socket.join('admin');
|
socket.join('admin');
|
||||||
} else if (token) {
|
} else if (token) {
|
||||||
if (ccmp(token, this.options.adminToken))
|
if (safeEqual(token, this.options.adminToken))
|
||||||
socket.join('admin');
|
socket.join('admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ const {BloomFilter} = require('bfilter');
|
|||||||
const {Lock, MapLock} = require('bmutex');
|
const {Lock, MapLock} = require('bmutex');
|
||||||
const bdb = require('bdb');
|
const bdb = require('bdb');
|
||||||
const Logger = require('blgr');
|
const Logger = require('blgr');
|
||||||
const ccmp = require('bcrypto/lib/ccmp');
|
const {safeEqual} = require('bcrypto/lib/safe');
|
||||||
const aes = require('bcrypto/lib/aes');
|
const aes = require('bcrypto/lib/aes');
|
||||||
const Network = require('../protocol/network');
|
const Network = require('../protocol/network');
|
||||||
const Path = require('./path');
|
const Path = require('./path');
|
||||||
@ -1018,7 +1018,7 @@ class WalletDB extends EventEmitter {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Compare in constant time:
|
// Compare in constant time:
|
||||||
if (!ccmp(token, wallet.token))
|
if (!safeEqual(token, wallet.token))
|
||||||
throw new Error('WDB: Authentication error.');
|
throw new Error('WDB: Authentication error.');
|
||||||
|
|
||||||
return wallet;
|
return wallet;
|
||||||
|
|||||||
53
package.json
53
package.json
@ -23,36 +23,35 @@
|
|||||||
"node": ">=8.0.0"
|
"node": ">=8.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bcfg": "~0.1.2",
|
"bcfg": "~0.1.3",
|
||||||
"bclient": "~0.1.3",
|
"bclient": "~0.1.4",
|
||||||
"bcrypto": "~1.1.0",
|
"bcrypto": "~2.0.0",
|
||||||
"bdb": "~1.1.0",
|
"bdb": "~1.1.1",
|
||||||
"bdns": "~0.1.1",
|
"bdns": "~0.1.2",
|
||||||
"bevent": "~0.1.1",
|
"bevent": "~0.1.2",
|
||||||
"bfile": "~0.1.1",
|
"bfile": "~0.1.2",
|
||||||
"bfilter": "~1.0.0",
|
"bfilter": "~1.0.1",
|
||||||
"bheep": "~0.1.1",
|
"bheep": "~0.1.2",
|
||||||
"binet": "~0.3.1",
|
"binet": "~0.3.2",
|
||||||
"blgr": "~0.1.1",
|
"blgr": "~0.1.2",
|
||||||
"blru": "~0.1.2",
|
"blru": "~0.1.3",
|
||||||
"blst": "~0.1.1",
|
"blst": "~0.1.2",
|
||||||
"bmutex": "~0.1.2",
|
"bmutex": "~0.1.3",
|
||||||
"bsert": "~0.0.4",
|
"bsert": "~0.0.4",
|
||||||
"bsip": "~0.1.1",
|
"bsip": "~0.1.2",
|
||||||
"bsock": "~0.1.2",
|
"bsock": "~0.1.3",
|
||||||
"bsocks": "~0.2.1",
|
"bsocks": "~0.2.2",
|
||||||
"bstring": "~0.2.0",
|
"bstring": "~0.3.0",
|
||||||
"btcp": "~0.1.1",
|
"btcp": "~0.1.2",
|
||||||
"buffer-map": "~0.0.2",
|
"buffer-map": "~0.0.3",
|
||||||
"bufio": "~1.0.1",
|
"bufio": "~1.0.2",
|
||||||
"bupnp": "~0.2.2",
|
"bupnp": "~0.2.3",
|
||||||
"bval": "~0.1.2",
|
"bval": "~0.1.3",
|
||||||
"bweb": "~0.1.3",
|
"bweb": "~0.1.4",
|
||||||
"mrmr": "~0.1.1",
|
"mrmr": "~0.1.2",
|
||||||
"n64": "~0.2.1"
|
"n64": "~0.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^5.1.0",
|
|
||||||
"istanbul": "^1.1.0-alpha.1",
|
"istanbul": "^1.1.0-alpha.1",
|
||||||
"mocha": "^5.2.0"
|
"mocha": "^5.2.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -49,14 +49,14 @@ function assertConsensus(tx, output, flags, code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function randomSignature() {
|
function randomSignature() {
|
||||||
const r = secp256k1.generatePrivateKey();
|
const r = secp256k1.privateKeyGenerate();
|
||||||
const s = secp256k1.generatePrivateKey();
|
const s = secp256k1.privateKeyGenerate();
|
||||||
return secp256k1.toDER(Buffer.concat([r, s]));
|
return secp256k1.signatureExport(Buffer.concat([r, s]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomKey() {
|
function randomKey() {
|
||||||
const x = secp256k1.generatePrivateKey();
|
const x = secp256k1.privateKeyGenerate();
|
||||||
const y = secp256k1.generatePrivateKey();
|
const y = secp256k1.privateKeyGenerate();
|
||||||
|
|
||||||
if (rand(0, 2) === 0) {
|
if (rand(0, 2) === 0) {
|
||||||
const p = Buffer.from([2 | (y[y.length - 1] & 1)]);
|
const p = Buffer.from([2 | (y[y.length - 1] & 1)]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user