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