Skip to content

Commit

Permalink
update node to v16, and upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangxn committed Jan 7, 2022
1 parent dd7e411 commit 94ae9df
Show file tree
Hide file tree
Showing 16 changed files with 4,458 additions and 7,337 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ npm-debug.log
node_modules
dist
es
build
2 changes: 1 addition & 1 deletion examples/redeemHtlc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Apis.instance("wss://node.testnet.bitshares.eu", true).init_promise.then(
// in the backend

let operationJSON = {
preimage: new Buffer(preimageValue).toString("hex"),
preimage: Buffer.from(preimageValue).toString("hex"),
fee: {
amount: 0,
asset_id: "1.3.0"
Expand Down
4 changes: 2 additions & 2 deletions lib/chain/src/TransactionBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class TransactionBuilder {
) {
this.ref_block_num =
r[0].head_block_number & 0xffff;
this.ref_block_prefix = new Buffer(
this.ref_block_prefix = Buffer.from(
r[0].head_block_id,
"hex"
).readUInt32LE(4);
Expand Down Expand Up @@ -753,7 +753,7 @@ class TransactionBuilder {
for (var i = 0; 0 < end ? i < end : i > end; 0 < end ? i++ : i++) {
var [private_key, public_key] = this.signer_private_keys[i];
var sig = Signature.signBuffer(
Buffer.concat([new Buffer(chain_id, "hex"), this.tr_buffer]),
Buffer.concat([Buffer.from(chain_id, "hex"), this.tr_buffer]),
private_key,
public_key
);
Expand Down
2 changes: 1 addition & 1 deletion lib/ecc/src/PrivateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class PrivateKey {
}

static fromHex(hex) {
return PrivateKey.fromBuffer(new Buffer(hex, "hex"));
return PrivateKey.fromBuffer(Buffer.from(hex, "hex"));
}

toHex() {
Expand Down
2 changes: 1 addition & 1 deletion lib/ecc/src/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Address {
`Expecting key to begin with ${address_prefix}, instead got ${prefix}`
);
var addy = string.slice(address_prefix.length);
addy = new Buffer(decode(addy), "binary");
addy = Buffer.from(decode(addy), "binary");
var checksum = addy.slice(-4);
addy = addy.slice(0, -4);
var new_checksum = ripemd160(addy);
Expand Down
16 changes: 8 additions & 8 deletions lib/ecc/src/aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Aes {
nonce = "";

if (!Buffer.isBuffer(message)) {
message = new Buffer(message, "hex");
message = Buffer.from(message, "hex");
}

var S = private_key.get_shared_secret(public_key, legacy);
Expand Down Expand Up @@ -130,7 +130,7 @@ class Aes {
nonce = "";

if (!Buffer.isBuffer(message)) {
message = new Buffer(message, "binary");
message = Buffer.from(message, "binary");
}

var S = private_key.get_shared_secret(public_key);
Expand Down Expand Up @@ -180,15 +180,15 @@ class Aes {
*/
decrypt(ciphertext) {
if (typeof ciphertext === "string") {
ciphertext = new Buffer(ciphertext, "binary");
ciphertext = Buffer.from(ciphertext, "binary");
}
if (!Buffer.isBuffer(ciphertext)) {
throw new Error("buffer required");
}
assert(ciphertext, "Missing cipher text");
// hex is the only common format
var hex = this.decryptHex(ciphertext.toString("hex"));
return new Buffer(hex, "hex");
return Buffer.from(hex, "hex");
}

/** This method does not use a checksum, the returned data must be validated some other way.
Expand All @@ -197,15 +197,15 @@ class Aes {
*/
encrypt(plaintext) {
if (typeof plaintext === "string") {
plaintext = new Buffer(plaintext, "binary");
plaintext = Buffer.from(plaintext, "binary");
}
if (!Buffer.isBuffer(plaintext)) {
throw new Error("buffer required");
}
//assert plaintext, "Missing plain text"
// hex is the only common format
var hex = this.encryptHex(plaintext.toString("hex"));
return new Buffer(hex, "hex");
return Buffer.from(hex, "hex");
}

/** This method does not use a checksum, the returned data must be validated some other way.
Expand All @@ -214,7 +214,7 @@ class Aes {
*/
encryptToHex(plaintext) {
if (typeof plaintext === "string") {
plaintext = new Buffer(plaintext, "binary");
plaintext = Buffer.from(plaintext, "binary");
}
if (!Buffer.isBuffer(plaintext)) {
throw new Error("buffer required");
Expand Down Expand Up @@ -246,7 +246,7 @@ class Aes {
var cipher_array = encHex.parse(cipher);
var plainwords = this._decrypt_word_array(cipher_array);
var plainhex = encHex.stringify(plainwords);
return new Buffer(plainhex, "hex");
return Buffer.from(plainhex, "hex");
}

/** This method does not use a checksum, the returned data must be validated some other way.
Expand Down
6 changes: 3 additions & 3 deletions lib/ecc/src/ecdsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ function deterministicGenerateK(curve, hash, d, checkSig, nonce) {
k.fill(0);

// Step D
k = HmacSHA256(Buffer.concat([v, new Buffer([0]), x, hash]), k);
k = HmacSHA256(Buffer.concat([v, Buffer.from([0]), x, hash]), k);

// Step E
v = HmacSHA256(v, k);

// Step F
k = HmacSHA256(Buffer.concat([v, new Buffer([1]), x, hash]), k);
k = HmacSHA256(Buffer.concat([v, Buffer.from([1]), x, hash]), k);

// Step G
v = HmacSHA256(v, k);
Expand All @@ -48,7 +48,7 @@ function deterministicGenerateK(curve, hash, d, checkSig, nonce) {

// Step H3, repeat until T is within the interval [1, n - 1]
while (T.signum() <= 0 || T.compareTo(curve.n) >= 0 || !checkSig(T)) {
k = HmacSHA256(Buffer.concat([v, new Buffer([0])]), k);
k = HmacSHA256(Buffer.concat([v, Buffer.from([0])]), k);
v = HmacSHA256(v, k);

// Step H1/H2a, again, ignored as tlen === qlen (256 bit)
Expand Down
Loading

0 comments on commit 94ae9df

Please sign in to comment.