@xchainjs/xchain-thorchain 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.d.ts +8 -8
- package/lib/clientKeystore.d.ts +3 -4
- package/lib/clientLedger.d.ts +1 -2
- package/lib/index.esm.js +1098 -909
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1097 -907
- package/lib/index.js.map +1 -1
- package/lib/types/client-types.d.ts +7 -3
- package/lib/utils.d.ts +16 -5
- package/package.json +4 -4
package/lib/index.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ import { BigNumber } from 'bignumber.js';
|
|
|
15
15
|
import { toWords as toWords$1, encode as encode$2 } from 'bech32';
|
|
16
16
|
import { fromSeed } from 'bip32';
|
|
17
17
|
import { publicKeyCreate } from 'secp256k1';
|
|
18
|
-
import { assetToString, isSynthAsset, assetToBase, assetAmount, eqAsset, assetFromString, assetFromStringEx } from '@xchainjs/xchain-util';
|
|
18
|
+
import { assetToString, isSynthAsset, AssetType, assetToBase, assetAmount, eqAsset, assetFromString, assetFromStringEx } from '@xchainjs/xchain-util';
|
|
19
19
|
import { Network } from '@xchainjs/xchain-client';
|
|
20
20
|
import THORChainApp, { extractSignatureFromTLV } from '@xchainjs/ledger-thorchain';
|
|
21
21
|
|
|
@@ -5511,13 +5511,13 @@ function requireMinimal () {
|
|
|
5511
5511
|
|
|
5512
5512
|
var writer = Writer$1;
|
|
5513
5513
|
|
|
5514
|
-
var util$
|
|
5514
|
+
var util$7 = requireMinimal();
|
|
5515
5515
|
|
|
5516
5516
|
var BufferWriter$1; // cyclic
|
|
5517
5517
|
|
|
5518
|
-
var LongBits$1 = util$
|
|
5519
|
-
base64 = util$
|
|
5520
|
-
utf8$1 = util$
|
|
5518
|
+
var LongBits$1 = util$7.LongBits,
|
|
5519
|
+
base64 = util$7.base64,
|
|
5520
|
+
utf8$1 = util$7.utf8;
|
|
5521
5521
|
|
|
5522
5522
|
/**
|
|
5523
5523
|
* Constructs a new writer operation instance.
|
|
@@ -5632,7 +5632,7 @@ function Writer$1() {
|
|
|
5632
5632
|
}
|
|
5633
5633
|
|
|
5634
5634
|
var create$1 = function create() {
|
|
5635
|
-
return util$
|
|
5635
|
+
return util$7.Buffer
|
|
5636
5636
|
? function create_buffer_setup() {
|
|
5637
5637
|
return (Writer$1.create = function create_buffer() {
|
|
5638
5638
|
return new BufferWriter$1();
|
|
@@ -5657,13 +5657,13 @@ Writer$1.create = create$1();
|
|
|
5657
5657
|
* @returns {Uint8Array} Buffer
|
|
5658
5658
|
*/
|
|
5659
5659
|
Writer$1.alloc = function alloc(size) {
|
|
5660
|
-
return new util$
|
|
5660
|
+
return new util$7.Array(size);
|
|
5661
5661
|
};
|
|
5662
5662
|
|
|
5663
5663
|
// Use Uint8Array buffer pool in the browser, just like node does with buffers
|
|
5664
5664
|
/* istanbul ignore else */
|
|
5665
|
-
if (util$
|
|
5666
|
-
Writer$1.alloc = util$
|
|
5665
|
+
if (util$7.Array !== Array)
|
|
5666
|
+
Writer$1.alloc = util$7.pool(Writer$1.alloc, util$7.Array.prototype.subarray);
|
|
5667
5667
|
|
|
5668
5668
|
/**
|
|
5669
5669
|
* Pushes a new operation to the queue.
|
|
@@ -5853,7 +5853,7 @@ Writer$1.prototype.sfixed64 = Writer$1.prototype.fixed64;
|
|
|
5853
5853
|
* @returns {Writer} `this`
|
|
5854
5854
|
*/
|
|
5855
5855
|
Writer$1.prototype.float = function write_float(value) {
|
|
5856
|
-
return this._push(util$
|
|
5856
|
+
return this._push(util$7.float.writeFloatLE, 4, value);
|
|
5857
5857
|
};
|
|
5858
5858
|
|
|
5859
5859
|
/**
|
|
@@ -5863,10 +5863,10 @@ Writer$1.prototype.float = function write_float(value) {
|
|
|
5863
5863
|
* @returns {Writer} `this`
|
|
5864
5864
|
*/
|
|
5865
5865
|
Writer$1.prototype.double = function write_double(value) {
|
|
5866
|
-
return this._push(util$
|
|
5866
|
+
return this._push(util$7.float.writeDoubleLE, 8, value);
|
|
5867
5867
|
};
|
|
5868
5868
|
|
|
5869
|
-
var writeBytes = util$
|
|
5869
|
+
var writeBytes = util$7.Array.prototype.set
|
|
5870
5870
|
? function writeBytes_set(val, buf, pos) {
|
|
5871
5871
|
buf.set(val, pos); // also works for plain array values
|
|
5872
5872
|
}
|
|
@@ -5885,7 +5885,7 @@ Writer$1.prototype.bytes = function write_bytes(value) {
|
|
|
5885
5885
|
var len = value.length >>> 0;
|
|
5886
5886
|
if (!len)
|
|
5887
5887
|
return this._push(writeByte, 1, 0);
|
|
5888
|
-
if (util$
|
|
5888
|
+
if (util$7.isString(value)) {
|
|
5889
5889
|
var buf = Writer$1.alloc(len = base64.length(value));
|
|
5890
5890
|
base64.decode(value, buf, 0);
|
|
5891
5891
|
value = buf;
|
|
@@ -5980,7 +5980,7 @@ var writer_buffer = BufferWriter;
|
|
|
5980
5980
|
var Writer = writer;
|
|
5981
5981
|
(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
|
|
5982
5982
|
|
|
5983
|
-
var util$
|
|
5983
|
+
var util$6 = requireMinimal();
|
|
5984
5984
|
|
|
5985
5985
|
/**
|
|
5986
5986
|
* Constructs a new buffer writer instance.
|
|
@@ -5999,9 +5999,9 @@ BufferWriter._configure = function () {
|
|
|
5999
5999
|
* @param {number} size Buffer size
|
|
6000
6000
|
* @returns {Buffer} Buffer
|
|
6001
6001
|
*/
|
|
6002
|
-
BufferWriter.alloc = util$
|
|
6002
|
+
BufferWriter.alloc = util$6._Buffer_allocUnsafe;
|
|
6003
6003
|
|
|
6004
|
-
BufferWriter.writeBytesBuffer = util$
|
|
6004
|
+
BufferWriter.writeBytesBuffer = util$6.Buffer && util$6.Buffer.prototype instanceof Uint8Array && util$6.Buffer.prototype.set.name === "set"
|
|
6005
6005
|
? function writeBytesBuffer_set(val, buf, pos) {
|
|
6006
6006
|
buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)
|
|
6007
6007
|
// also works for plain array values
|
|
@@ -6020,8 +6020,8 @@ BufferWriter._configure = function () {
|
|
|
6020
6020
|
* @override
|
|
6021
6021
|
*/
|
|
6022
6022
|
BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
|
|
6023
|
-
if (util$
|
|
6024
|
-
value = util$
|
|
6023
|
+
if (util$6.isString(value))
|
|
6024
|
+
value = util$6._Buffer_from(value, "base64");
|
|
6025
6025
|
var len = value.length >>> 0;
|
|
6026
6026
|
this.uint32(len);
|
|
6027
6027
|
if (len)
|
|
@@ -6031,7 +6031,7 @@ BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
|
|
|
6031
6031
|
|
|
6032
6032
|
function writeStringBuffer(val, buf, pos) {
|
|
6033
6033
|
if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)
|
|
6034
|
-
util$
|
|
6034
|
+
util$6.utf8.write(val, buf, pos);
|
|
6035
6035
|
else if (buf.utf8Write)
|
|
6036
6036
|
buf.utf8Write(val, pos);
|
|
6037
6037
|
else
|
|
@@ -6042,7 +6042,7 @@ function writeStringBuffer(val, buf, pos) {
|
|
|
6042
6042
|
* @override
|
|
6043
6043
|
*/
|
|
6044
6044
|
BufferWriter.prototype.string = function write_string_buffer(value) {
|
|
6045
|
-
var len = util$
|
|
6045
|
+
var len = util$6.Buffer.byteLength(value);
|
|
6046
6046
|
this.uint32(len);
|
|
6047
6047
|
if (len)
|
|
6048
6048
|
this._push(writeStringBuffer, len, value);
|
|
@@ -6061,12 +6061,12 @@ BufferWriter._configure();
|
|
|
6061
6061
|
|
|
6062
6062
|
var reader = Reader$1;
|
|
6063
6063
|
|
|
6064
|
-
var util$
|
|
6064
|
+
var util$5 = requireMinimal();
|
|
6065
6065
|
|
|
6066
6066
|
var BufferReader$1; // cyclic
|
|
6067
6067
|
|
|
6068
|
-
var LongBits = util$
|
|
6069
|
-
utf8 = util$
|
|
6068
|
+
var LongBits = util$5.LongBits,
|
|
6069
|
+
utf8 = util$5.utf8;
|
|
6070
6070
|
|
|
6071
6071
|
/* istanbul ignore next */
|
|
6072
6072
|
function indexOutOfRange(reader, writeLength) {
|
|
@@ -6114,10 +6114,10 @@ var create_array = typeof Uint8Array !== "undefined"
|
|
|
6114
6114
|
};
|
|
6115
6115
|
|
|
6116
6116
|
var create = function create() {
|
|
6117
|
-
return util$
|
|
6117
|
+
return util$5.Buffer
|
|
6118
6118
|
? function create_buffer_setup(buffer) {
|
|
6119
6119
|
return (Reader$1.create = function create_buffer(buffer) {
|
|
6120
|
-
return util$
|
|
6120
|
+
return util$5.Buffer.isBuffer(buffer)
|
|
6121
6121
|
? new BufferReader$1(buffer)
|
|
6122
6122
|
/* istanbul ignore next */
|
|
6123
6123
|
: create_array(buffer);
|
|
@@ -6136,7 +6136,7 @@ var create = function create() {
|
|
|
6136
6136
|
*/
|
|
6137
6137
|
Reader$1.create = create();
|
|
6138
6138
|
|
|
6139
|
-
Reader$1.prototype._slice = util$
|
|
6139
|
+
Reader$1.prototype._slice = util$5.Array.prototype.subarray || /* istanbul ignore next */ util$5.Array.prototype.slice;
|
|
6140
6140
|
|
|
6141
6141
|
/**
|
|
6142
6142
|
* Reads a varint as an unsigned 32 bit value.
|
|
@@ -6335,7 +6335,7 @@ Reader$1.prototype.float = function read_float() {
|
|
|
6335
6335
|
if (this.pos + 4 > this.len)
|
|
6336
6336
|
throw indexOutOfRange(this, 4);
|
|
6337
6337
|
|
|
6338
|
-
var value = util$
|
|
6338
|
+
var value = util$5.float.readFloatLE(this.buf, this.pos);
|
|
6339
6339
|
this.pos += 4;
|
|
6340
6340
|
return value;
|
|
6341
6341
|
};
|
|
@@ -6351,7 +6351,7 @@ Reader$1.prototype.double = function read_double() {
|
|
|
6351
6351
|
if (this.pos + 8 > this.len)
|
|
6352
6352
|
throw indexOutOfRange(this, 4);
|
|
6353
6353
|
|
|
6354
|
-
var value = util$
|
|
6354
|
+
var value = util$5.float.readDoubleLE(this.buf, this.pos);
|
|
6355
6355
|
this.pos += 8;
|
|
6356
6356
|
return value;
|
|
6357
6357
|
};
|
|
@@ -6444,8 +6444,8 @@ Reader$1._configure = function(BufferReader_) {
|
|
|
6444
6444
|
Reader$1.create = create();
|
|
6445
6445
|
BufferReader$1._configure();
|
|
6446
6446
|
|
|
6447
|
-
var fn = util$
|
|
6448
|
-
util$
|
|
6447
|
+
var fn = util$5.Long ? "toLong" : /* istanbul ignore next */ "toNumber";
|
|
6448
|
+
util$5.merge(Reader$1.prototype, {
|
|
6449
6449
|
|
|
6450
6450
|
int64: function read_int64() {
|
|
6451
6451
|
return readLongVarint.call(this)[fn](false);
|
|
@@ -6476,7 +6476,7 @@ var reader_buffer = BufferReader;
|
|
|
6476
6476
|
var Reader = reader;
|
|
6477
6477
|
(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
|
|
6478
6478
|
|
|
6479
|
-
var util$
|
|
6479
|
+
var util$4 = requireMinimal();
|
|
6480
6480
|
|
|
6481
6481
|
/**
|
|
6482
6482
|
* Constructs a new buffer reader instance.
|
|
@@ -6497,8 +6497,8 @@ function BufferReader(buffer) {
|
|
|
6497
6497
|
|
|
6498
6498
|
BufferReader._configure = function () {
|
|
6499
6499
|
/* istanbul ignore else */
|
|
6500
|
-
if (util$
|
|
6501
|
-
BufferReader.prototype._slice = util$
|
|
6500
|
+
if (util$4.Buffer)
|
|
6501
|
+
BufferReader.prototype._slice = util$4.Buffer.prototype.slice;
|
|
6502
6502
|
};
|
|
6503
6503
|
|
|
6504
6504
|
|
|
@@ -6525,10 +6525,10 @@ var rpc = {};
|
|
|
6525
6525
|
|
|
6526
6526
|
var service$1 = Service;
|
|
6527
6527
|
|
|
6528
|
-
var util$
|
|
6528
|
+
var util$3 = requireMinimal();
|
|
6529
6529
|
|
|
6530
6530
|
// Extends EventEmitter
|
|
6531
|
-
(Service.prototype = Object.create(util$
|
|
6531
|
+
(Service.prototype = Object.create(util$3.EventEmitter.prototype)).constructor = Service;
|
|
6532
6532
|
|
|
6533
6533
|
/**
|
|
6534
6534
|
* A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
|
|
@@ -6568,7 +6568,7 @@ function Service(rpcImpl, requestDelimited, responseDelimited) {
|
|
|
6568
6568
|
if (typeof rpcImpl !== "function")
|
|
6569
6569
|
throw TypeError("rpcImpl must be a function");
|
|
6570
6570
|
|
|
6571
|
-
util$
|
|
6571
|
+
util$3.EventEmitter.call(this);
|
|
6572
6572
|
|
|
6573
6573
|
/**
|
|
6574
6574
|
* RPC implementation. Becomes `null` once the service is ended.
|
|
@@ -6607,7 +6607,7 @@ Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor,
|
|
|
6607
6607
|
|
|
6608
6608
|
var self = this;
|
|
6609
6609
|
if (!callback)
|
|
6610
|
-
return util$
|
|
6610
|
+
return util$3.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);
|
|
6611
6611
|
|
|
6612
6612
|
if (!self.rpcImpl) {
|
|
6613
6613
|
setTimeout(function() { callback(Error("already ended")); }, 0);
|
|
@@ -115180,25 +115180,20 @@ function requireBlowfish () {
|
|
|
115180
115180
|
|
|
115181
115181
|
cryptoJs.exports;
|
|
115182
115182
|
|
|
115183
|
-
|
|
115184
|
-
|
|
115185
|
-
function requireCryptoJs () {
|
|
115186
|
-
if (hasRequiredCryptoJs) return cryptoJs.exports;
|
|
115187
|
-
hasRequiredCryptoJs = 1;
|
|
115188
|
-
(function (module, exports) {
|
|
115183
|
+
(function (module, exports) {
|
|
115189
115184
|
(function (root, factory, undef) {
|
|
115190
|
-
|
|
115191
|
-
|
|
115192
|
-
|
|
115193
|
-
|
|
115194
|
-
|
|
115185
|
+
{
|
|
115186
|
+
// CommonJS
|
|
115187
|
+
module.exports = factory(requireCore$1(), requireX64Core(), requireLibTypedarrays(), requireEncUtf16(), requireEncBase64(), requireEncBase64url(), requireMd5(), requireSha1(), requireSha256(), requireSha224(), requireSha512(), requireSha384(), requireSha3(), requireRipemd160(), requireHmac(), requirePbkdf2(), requireEvpkdf(), requireCipherCore(), requireModeCfb(), requireModeCtr(), requireModeCtrGladman(), requireModeOfb(), requireModeEcb(), requirePadAnsix923(), requirePadIso10126(), requirePadIso97971(), requirePadZeropadding(), requirePadNopadding(), requireFormatHex(), requireAes(), requireTripledes(), requireRc4(), requireRabbit(), requireRabbitLegacy(), requireBlowfish());
|
|
115188
|
+
}
|
|
115189
|
+
}(commonjsGlobal$1, function (CryptoJS) {
|
|
115195
115190
|
|
|
115196
|
-
|
|
115191
|
+
return CryptoJS;
|
|
115197
115192
|
|
|
115198
|
-
|
|
115199
|
-
|
|
115200
|
-
|
|
115201
|
-
|
|
115193
|
+
}));
|
|
115194
|
+
} (cryptoJs, cryptoJs.exports));
|
|
115195
|
+
|
|
115196
|
+
var cryptoJsExports = cryptoJs.exports;
|
|
115202
115197
|
|
|
115203
115198
|
var utility = {};
|
|
115204
115199
|
|
|
@@ -117703,858 +117698,826 @@ function requireUtility () {
|
|
|
117703
117698
|
return utility;
|
|
117704
117699
|
}
|
|
117705
117700
|
|
|
117706
|
-
|
|
117707
|
-
|
|
117708
|
-
|
|
117709
|
-
function
|
|
117710
|
-
|
|
117711
|
-
|
|
117712
|
-
|
|
117713
|
-
|
|
117714
|
-
|
|
117715
|
-
|
|
117716
|
-
|
|
117717
|
-
|
|
117718
|
-
|
|
117719
|
-
|
|
117720
|
-
|
|
117721
|
-
|
|
117722
|
-
|
|
117723
|
-
|
|
117724
|
-
|
|
117725
|
-
|
|
117726
|
-
|
|
117727
|
-
|
|
117728
|
-
|
|
117729
|
-
|
|
117730
|
-
|
|
117731
|
-
|
|
117732
|
-
|
|
117733
|
-
|
|
117734
|
-
|
|
117735
|
-
|
|
117736
|
-
|
|
117737
|
-
|
|
117738
|
-
|
|
117739
|
-
|
|
117740
|
-
|
|
117741
|
-
|
|
117742
|
-
|
|
117743
|
-
|
|
117744
|
-
|
|
117745
|
-
|
|
117746
|
-
|
|
117747
|
-
|
|
117748
|
-
|
|
117749
|
-
|
|
117750
|
-
|
|
117751
|
-
|
|
117752
|
-
|
|
117753
|
-
|
|
117754
|
-
|
|
117755
|
-
|
|
117756
|
-
|
|
117757
|
-
|
|
117758
|
-
|
|
117759
|
-
|
|
117760
|
-
|
|
117761
|
-
|
|
117762
|
-
|
|
117763
|
-
|
|
117764
|
-
|
|
117765
|
-
|
|
117766
|
-
|
|
117767
|
-
|
|
117768
|
-
|
|
117769
|
-
|
|
117770
|
-
|
|
117771
|
-
|
|
117772
|
-
|
|
117773
|
-
|
|
117774
|
-
|
|
117775
|
-
|
|
117776
|
-
|
|
117777
|
-
|
|
117778
|
-
|
|
117779
|
-
|
|
117780
|
-
|
|
117781
|
-
|
|
117782
|
-
|
|
117783
|
-
|
|
117784
|
-
|
|
117785
|
-
|
|
117786
|
-
|
|
117787
|
-
|
|
117788
|
-
|
|
117789
|
-
|
|
117790
|
-
util = {
|
|
117791
|
-
normalizeInput: normalizeInput,
|
|
117792
|
-
toHex: toHex,
|
|
117793
|
-
debugPrint: debugPrint,
|
|
117794
|
-
testSpeed: testSpeed
|
|
117795
|
-
};
|
|
117796
|
-
return util;
|
|
117797
|
-
}
|
|
117798
|
-
|
|
117799
|
-
var blake2b_1;
|
|
117800
|
-
var hasRequiredBlake2b;
|
|
117801
|
-
|
|
117802
|
-
function requireBlake2b () {
|
|
117803
|
-
if (hasRequiredBlake2b) return blake2b_1;
|
|
117804
|
-
hasRequiredBlake2b = 1;
|
|
117805
|
-
// Blake2B in pure Javascript
|
|
117806
|
-
// Adapted from the reference implementation in RFC7693
|
|
117807
|
-
// Ported to Javascript by DC - https://github.com/dcposch
|
|
117808
|
-
|
|
117809
|
-
const util = requireUtil();
|
|
117810
|
-
|
|
117811
|
-
// 64-bit unsigned addition
|
|
117812
|
-
// Sets v[a,a+1] += v[b,b+1]
|
|
117813
|
-
// v should be a Uint32Array
|
|
117814
|
-
function ADD64AA (v, a, b) {
|
|
117815
|
-
const o0 = v[a] + v[b];
|
|
117816
|
-
let o1 = v[a + 1] + v[b + 1];
|
|
117817
|
-
if (o0 >= 0x100000000) {
|
|
117818
|
-
o1++;
|
|
117819
|
-
}
|
|
117820
|
-
v[a] = o0;
|
|
117821
|
-
v[a + 1] = o1;
|
|
117822
|
-
}
|
|
117823
|
-
|
|
117824
|
-
// 64-bit unsigned addition
|
|
117825
|
-
// Sets v[a,a+1] += b
|
|
117826
|
-
// b0 is the low 32 bits of b, b1 represents the high 32 bits
|
|
117827
|
-
function ADD64AC (v, a, b0, b1) {
|
|
117828
|
-
let o0 = v[a] + b0;
|
|
117829
|
-
if (b0 < 0) {
|
|
117830
|
-
o0 += 0x100000000;
|
|
117831
|
-
}
|
|
117832
|
-
let o1 = v[a + 1] + b1;
|
|
117833
|
-
if (o0 >= 0x100000000) {
|
|
117834
|
-
o1++;
|
|
117835
|
-
}
|
|
117836
|
-
v[a] = o0;
|
|
117837
|
-
v[a + 1] = o1;
|
|
117838
|
-
}
|
|
117839
|
-
|
|
117840
|
-
// Little-endian byte access
|
|
117841
|
-
function B2B_GET32 (arr, i) {
|
|
117842
|
-
return arr[i] ^ (arr[i + 1] << 8) ^ (arr[i + 2] << 16) ^ (arr[i + 3] << 24)
|
|
117843
|
-
}
|
|
117844
|
-
|
|
117845
|
-
// G Mixing function
|
|
117846
|
-
// The ROTRs are inlined for speed
|
|
117847
|
-
function B2B_G (a, b, c, d, ix, iy) {
|
|
117848
|
-
const x0 = m[ix];
|
|
117849
|
-
const x1 = m[ix + 1];
|
|
117850
|
-
const y0 = m[iy];
|
|
117851
|
-
const y1 = m[iy + 1];
|
|
117852
|
-
|
|
117853
|
-
ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
|
|
117854
|
-
ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits
|
|
117855
|
-
|
|
117856
|
-
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
|
|
117857
|
-
let xor0 = v[d] ^ v[a];
|
|
117858
|
-
let xor1 = v[d + 1] ^ v[a + 1];
|
|
117859
|
-
v[d] = xor1;
|
|
117860
|
-
v[d + 1] = xor0;
|
|
117861
|
-
|
|
117862
|
-
ADD64AA(v, c, d);
|
|
117863
|
-
|
|
117864
|
-
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
|
|
117865
|
-
xor0 = v[b] ^ v[c];
|
|
117866
|
-
xor1 = v[b + 1] ^ v[c + 1];
|
|
117867
|
-
v[b] = (xor0 >>> 24) ^ (xor1 << 8);
|
|
117868
|
-
v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
|
|
117869
|
-
|
|
117870
|
-
ADD64AA(v, a, b);
|
|
117871
|
-
ADD64AC(v, a, y0, y1);
|
|
117872
|
-
|
|
117873
|
-
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
|
|
117874
|
-
xor0 = v[d] ^ v[a];
|
|
117875
|
-
xor1 = v[d + 1] ^ v[a + 1];
|
|
117876
|
-
v[d] = (xor0 >>> 16) ^ (xor1 << 16);
|
|
117877
|
-
v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
|
|
117878
|
-
|
|
117879
|
-
ADD64AA(v, c, d);
|
|
117880
|
-
|
|
117881
|
-
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
|
|
117882
|
-
xor0 = v[b] ^ v[c];
|
|
117883
|
-
xor1 = v[b + 1] ^ v[c + 1];
|
|
117884
|
-
v[b] = (xor1 >>> 31) ^ (xor0 << 1);
|
|
117885
|
-
v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
|
|
117886
|
-
}
|
|
117887
|
-
|
|
117888
|
-
// Initialization Vector
|
|
117889
|
-
const BLAKE2B_IV32 = new Uint32Array([
|
|
117890
|
-
0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372,
|
|
117891
|
-
0x5f1d36f1, 0xa54ff53a, 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c,
|
|
117892
|
-
0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19
|
|
117893
|
-
]);
|
|
117894
|
-
|
|
117895
|
-
const SIGMA8 = [
|
|
117896
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13,
|
|
117897
|
-
6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1,
|
|
117898
|
-
9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4,
|
|
117899
|
-
10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5,
|
|
117900
|
-
15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7,
|
|
117901
|
-
14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2,
|
|
117902
|
-
13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0,
|
|
117903
|
-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6,
|
|
117904
|
-
1, 12, 0, 2, 11, 7, 5, 3
|
|
117905
|
-
];
|
|
117906
|
-
|
|
117907
|
-
// These are offsets into a uint64 buffer.
|
|
117908
|
-
// Multiply them all by 2 to make them offsets into a uint32 buffer,
|
|
117909
|
-
// because this is Javascript and we don't have uint64s
|
|
117910
|
-
const SIGMA82 = new Uint8Array(
|
|
117911
|
-
SIGMA8.map(function (x) {
|
|
117912
|
-
return x * 2
|
|
117913
|
-
})
|
|
117914
|
-
);
|
|
117915
|
-
|
|
117916
|
-
// Compression function. 'last' flag indicates last block.
|
|
117917
|
-
// Note we're representing 16 uint64s as 32 uint32s
|
|
117918
|
-
const v = new Uint32Array(32);
|
|
117919
|
-
const m = new Uint32Array(32);
|
|
117920
|
-
function blake2bCompress (ctx, last) {
|
|
117921
|
-
let i = 0;
|
|
117922
|
-
|
|
117923
|
-
// init work variables
|
|
117924
|
-
for (i = 0; i < 16; i++) {
|
|
117925
|
-
v[i] = ctx.h[i];
|
|
117926
|
-
v[i + 16] = BLAKE2B_IV32[i];
|
|
117927
|
-
}
|
|
117928
|
-
|
|
117929
|
-
// low 64 bits of offset
|
|
117930
|
-
v[24] = v[24] ^ ctx.t;
|
|
117931
|
-
v[25] = v[25] ^ (ctx.t / 0x100000000);
|
|
117932
|
-
// high 64 bits not supported, offset may not be higher than 2**53-1
|
|
117933
|
-
|
|
117934
|
-
// last block flag set ?
|
|
117935
|
-
if (last) {
|
|
117936
|
-
v[28] = ~v[28];
|
|
117937
|
-
v[29] = ~v[29];
|
|
117938
|
-
}
|
|
117939
|
-
|
|
117940
|
-
// get little-endian words
|
|
117941
|
-
for (i = 0; i < 32; i++) {
|
|
117942
|
-
m[i] = B2B_GET32(ctx.b, 4 * i);
|
|
117943
|
-
}
|
|
117944
|
-
|
|
117945
|
-
// twelve rounds of mixing
|
|
117946
|
-
// uncomment the DebugPrint calls to log the computation
|
|
117947
|
-
// and match the RFC sample documentation
|
|
117948
|
-
// util.debugPrint(' m[16]', m, 64)
|
|
117949
|
-
for (i = 0; i < 12; i++) {
|
|
117950
|
-
// util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64)
|
|
117951
|
-
B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]);
|
|
117952
|
-
B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]);
|
|
117953
|
-
B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]);
|
|
117954
|
-
B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]);
|
|
117955
|
-
B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]);
|
|
117956
|
-
B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]);
|
|
117957
|
-
B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]);
|
|
117958
|
-
B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]);
|
|
117959
|
-
}
|
|
117960
|
-
// util.debugPrint(' (i=12) v[16]', v, 64)
|
|
117961
|
-
|
|
117962
|
-
for (i = 0; i < 16; i++) {
|
|
117963
|
-
ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16];
|
|
117964
|
-
}
|
|
117965
|
-
// util.debugPrint('h[8]', ctx.h, 64)
|
|
117966
|
-
}
|
|
117967
|
-
|
|
117968
|
-
// reusable parameterBlock
|
|
117969
|
-
const parameterBlock = new Uint8Array([
|
|
117970
|
-
0,
|
|
117971
|
-
0,
|
|
117972
|
-
0,
|
|
117973
|
-
0, // 0: outlen, keylen, fanout, depth
|
|
117974
|
-
0,
|
|
117975
|
-
0,
|
|
117976
|
-
0,
|
|
117977
|
-
0, // 4: leaf length, sequential mode
|
|
117978
|
-
0,
|
|
117979
|
-
0,
|
|
117980
|
-
0,
|
|
117981
|
-
0, // 8: node offset
|
|
117982
|
-
0,
|
|
117983
|
-
0,
|
|
117984
|
-
0,
|
|
117985
|
-
0, // 12: node offset
|
|
117986
|
-
0,
|
|
117987
|
-
0,
|
|
117988
|
-
0,
|
|
117989
|
-
0, // 16: node depth, inner length, rfu
|
|
117990
|
-
0,
|
|
117991
|
-
0,
|
|
117992
|
-
0,
|
|
117993
|
-
0, // 20: rfu
|
|
117994
|
-
0,
|
|
117995
|
-
0,
|
|
117996
|
-
0,
|
|
117997
|
-
0, // 24: rfu
|
|
117998
|
-
0,
|
|
117999
|
-
0,
|
|
118000
|
-
0,
|
|
118001
|
-
0, // 28: rfu
|
|
118002
|
-
0,
|
|
118003
|
-
0,
|
|
118004
|
-
0,
|
|
118005
|
-
0, // 32: salt
|
|
118006
|
-
0,
|
|
118007
|
-
0,
|
|
118008
|
-
0,
|
|
118009
|
-
0, // 36: salt
|
|
118010
|
-
0,
|
|
118011
|
-
0,
|
|
118012
|
-
0,
|
|
118013
|
-
0, // 40: salt
|
|
118014
|
-
0,
|
|
118015
|
-
0,
|
|
118016
|
-
0,
|
|
118017
|
-
0, // 44: salt
|
|
118018
|
-
0,
|
|
118019
|
-
0,
|
|
118020
|
-
0,
|
|
118021
|
-
0, // 48: personal
|
|
118022
|
-
0,
|
|
118023
|
-
0,
|
|
118024
|
-
0,
|
|
118025
|
-
0, // 52: personal
|
|
118026
|
-
0,
|
|
118027
|
-
0,
|
|
118028
|
-
0,
|
|
118029
|
-
0, // 56: personal
|
|
118030
|
-
0,
|
|
118031
|
-
0,
|
|
118032
|
-
0,
|
|
118033
|
-
0 // 60: personal
|
|
118034
|
-
]);
|
|
118035
|
-
|
|
118036
|
-
// Creates a BLAKE2b hashing context
|
|
118037
|
-
// Requires an output length between 1 and 64 bytes
|
|
118038
|
-
// Takes an optional Uint8Array key
|
|
118039
|
-
// Takes an optinal Uint8Array salt
|
|
118040
|
-
// Takes an optinal Uint8Array personal
|
|
118041
|
-
function blake2bInit (outlen, key, salt, personal) {
|
|
118042
|
-
if (outlen === 0 || outlen > 64) {
|
|
118043
|
-
throw new Error('Illegal output length, expected 0 < length <= 64')
|
|
118044
|
-
}
|
|
118045
|
-
if (key && key.length > 64) {
|
|
118046
|
-
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64')
|
|
118047
|
-
}
|
|
118048
|
-
if (salt && salt.length !== 16) {
|
|
118049
|
-
throw new Error('Illegal salt, expected Uint8Array with length is 16')
|
|
118050
|
-
}
|
|
118051
|
-
if (personal && personal.length !== 16) {
|
|
118052
|
-
throw new Error('Illegal personal, expected Uint8Array with length is 16')
|
|
118053
|
-
}
|
|
118054
|
-
|
|
118055
|
-
// state, 'param block'
|
|
118056
|
-
const ctx = {
|
|
118057
|
-
b: new Uint8Array(128),
|
|
118058
|
-
h: new Uint32Array(16),
|
|
118059
|
-
t: 0, // input count
|
|
118060
|
-
c: 0, // pointer within buffer
|
|
118061
|
-
outlen: outlen // output length in bytes
|
|
118062
|
-
};
|
|
118063
|
-
|
|
118064
|
-
// initialize parameterBlock before usage
|
|
118065
|
-
parameterBlock.fill(0);
|
|
118066
|
-
parameterBlock[0] = outlen;
|
|
118067
|
-
if (key) parameterBlock[1] = key.length;
|
|
118068
|
-
parameterBlock[2] = 1; // fanout
|
|
118069
|
-
parameterBlock[3] = 1; // depth
|
|
118070
|
-
if (salt) parameterBlock.set(salt, 32);
|
|
118071
|
-
if (personal) parameterBlock.set(personal, 48);
|
|
118072
|
-
|
|
118073
|
-
// initialize hash state
|
|
118074
|
-
for (let i = 0; i < 16; i++) {
|
|
118075
|
-
ctx.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameterBlock, i * 4);
|
|
118076
|
-
}
|
|
118077
|
-
|
|
118078
|
-
// key the hash, if applicable
|
|
118079
|
-
if (key) {
|
|
118080
|
-
blake2bUpdate(ctx, key);
|
|
118081
|
-
// at the end
|
|
118082
|
-
ctx.c = 128;
|
|
118083
|
-
}
|
|
118084
|
-
|
|
118085
|
-
return ctx
|
|
118086
|
-
}
|
|
118087
|
-
|
|
118088
|
-
// Updates a BLAKE2b streaming hash
|
|
118089
|
-
// Requires hash context and Uint8Array (byte array)
|
|
118090
|
-
function blake2bUpdate (ctx, input) {
|
|
118091
|
-
for (let i = 0; i < input.length; i++) {
|
|
118092
|
-
if (ctx.c === 128) {
|
|
118093
|
-
// buffer full ?
|
|
118094
|
-
ctx.t += ctx.c; // add counters
|
|
118095
|
-
blake2bCompress(ctx, false); // compress (not last)
|
|
118096
|
-
ctx.c = 0; // counter to zero
|
|
118097
|
-
}
|
|
118098
|
-
ctx.b[ctx.c++] = input[i];
|
|
118099
|
-
}
|
|
118100
|
-
}
|
|
118101
|
-
|
|
118102
|
-
// Completes a BLAKE2b streaming hash
|
|
118103
|
-
// Returns a Uint8Array containing the message digest
|
|
118104
|
-
function blake2bFinal (ctx) {
|
|
118105
|
-
ctx.t += ctx.c; // mark last block offset
|
|
118106
|
-
|
|
118107
|
-
while (ctx.c < 128) {
|
|
118108
|
-
// fill up with zeros
|
|
118109
|
-
ctx.b[ctx.c++] = 0;
|
|
118110
|
-
}
|
|
118111
|
-
blake2bCompress(ctx, true); // final block flag = 1
|
|
118112
|
-
|
|
118113
|
-
// little endian convert and store
|
|
118114
|
-
const out = new Uint8Array(ctx.outlen);
|
|
118115
|
-
for (let i = 0; i < ctx.outlen; i++) {
|
|
118116
|
-
out[i] = ctx.h[i >> 2] >> (8 * (i & 3));
|
|
118117
|
-
}
|
|
118118
|
-
return out
|
|
118119
|
-
}
|
|
118120
|
-
|
|
118121
|
-
// Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array
|
|
118122
|
-
//
|
|
118123
|
-
// Returns a n-byte Uint8Array
|
|
118124
|
-
//
|
|
118125
|
-
// Parameters:
|
|
118126
|
-
// - input - the input bytes, as a string, Buffer or Uint8Array
|
|
118127
|
-
// - key - optional key Uint8Array, up to 64 bytes
|
|
118128
|
-
// - outlen - optional output length in bytes, default 64
|
|
118129
|
-
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118130
|
-
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118131
|
-
function blake2b (input, key, outlen, salt, personal) {
|
|
118132
|
-
// preprocess inputs
|
|
118133
|
-
outlen = outlen || 64;
|
|
118134
|
-
input = util.normalizeInput(input);
|
|
118135
|
-
if (salt) {
|
|
118136
|
-
salt = util.normalizeInput(salt);
|
|
118137
|
-
}
|
|
118138
|
-
if (personal) {
|
|
118139
|
-
personal = util.normalizeInput(personal);
|
|
118140
|
-
}
|
|
118141
|
-
|
|
118142
|
-
// do the math
|
|
118143
|
-
const ctx = blake2bInit(outlen, key, salt, personal);
|
|
118144
|
-
blake2bUpdate(ctx, input);
|
|
118145
|
-
return blake2bFinal(ctx)
|
|
118146
|
-
}
|
|
118147
|
-
|
|
118148
|
-
// Computes the BLAKE2B hash of a string or byte array
|
|
118149
|
-
//
|
|
118150
|
-
// Returns an n-byte hash in hex, all lowercase
|
|
118151
|
-
//
|
|
118152
|
-
// Parameters:
|
|
118153
|
-
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118154
|
-
// - key - optional key Uint8Array, up to 64 bytes
|
|
118155
|
-
// - outlen - optional output length in bytes, default 64
|
|
118156
|
-
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118157
|
-
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118158
|
-
function blake2bHex (input, key, outlen, salt, personal) {
|
|
118159
|
-
const output = blake2b(input, key, outlen, salt, personal);
|
|
118160
|
-
return util.toHex(output)
|
|
118161
|
-
}
|
|
118162
|
-
|
|
118163
|
-
blake2b_1 = {
|
|
118164
|
-
blake2b: blake2b,
|
|
118165
|
-
blake2bHex: blake2bHex,
|
|
118166
|
-
blake2bInit: blake2bInit,
|
|
118167
|
-
blake2bUpdate: blake2bUpdate,
|
|
118168
|
-
blake2bFinal: blake2bFinal
|
|
118169
|
-
};
|
|
118170
|
-
return blake2b_1;
|
|
118171
|
-
}
|
|
118172
|
-
|
|
118173
|
-
var blake2s_1;
|
|
118174
|
-
var hasRequiredBlake2s;
|
|
118175
|
-
|
|
118176
|
-
function requireBlake2s () {
|
|
118177
|
-
if (hasRequiredBlake2s) return blake2s_1;
|
|
118178
|
-
hasRequiredBlake2s = 1;
|
|
118179
|
-
// BLAKE2s hash function in pure Javascript
|
|
118180
|
-
// Adapted from the reference implementation in RFC7693
|
|
118181
|
-
// Ported to Javascript by DC - https://github.com/dcposch
|
|
118182
|
-
|
|
118183
|
-
const util = requireUtil();
|
|
118184
|
-
|
|
118185
|
-
// Little-endian byte access.
|
|
118186
|
-
// Expects a Uint8Array and an index
|
|
118187
|
-
// Returns the little-endian uint32 at v[i..i+3]
|
|
118188
|
-
function B2S_GET32 (v, i) {
|
|
118189
|
-
return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24)
|
|
118190
|
-
}
|
|
118191
|
-
|
|
118192
|
-
// Mixing function G.
|
|
118193
|
-
function B2S_G (a, b, c, d, x, y) {
|
|
118194
|
-
v[a] = v[a] + v[b] + x;
|
|
118195
|
-
v[d] = ROTR32(v[d] ^ v[a], 16);
|
|
118196
|
-
v[c] = v[c] + v[d];
|
|
118197
|
-
v[b] = ROTR32(v[b] ^ v[c], 12);
|
|
118198
|
-
v[a] = v[a] + v[b] + y;
|
|
118199
|
-
v[d] = ROTR32(v[d] ^ v[a], 8);
|
|
118200
|
-
v[c] = v[c] + v[d];
|
|
118201
|
-
v[b] = ROTR32(v[b] ^ v[c], 7);
|
|
118202
|
-
}
|
|
118203
|
-
|
|
118204
|
-
// 32-bit right rotation
|
|
118205
|
-
// x should be a uint32
|
|
118206
|
-
// y must be between 1 and 31, inclusive
|
|
118207
|
-
function ROTR32 (x, y) {
|
|
118208
|
-
return (x >>> y) ^ (x << (32 - y))
|
|
118209
|
-
}
|
|
118210
|
-
|
|
118211
|
-
// Initialization Vector.
|
|
118212
|
-
const BLAKE2S_IV = new Uint32Array([
|
|
118213
|
-
0x6a09e667,
|
|
118214
|
-
0xbb67ae85,
|
|
118215
|
-
0x3c6ef372,
|
|
118216
|
-
0xa54ff53a,
|
|
118217
|
-
0x510e527f,
|
|
118218
|
-
0x9b05688c,
|
|
118219
|
-
0x1f83d9ab,
|
|
118220
|
-
0x5be0cd19
|
|
118221
|
-
]);
|
|
118222
|
-
|
|
118223
|
-
const SIGMA = new Uint8Array([
|
|
118224
|
-
0,
|
|
118225
|
-
1,
|
|
118226
|
-
2,
|
|
118227
|
-
3,
|
|
118228
|
-
4,
|
|
118229
|
-
5,
|
|
118230
|
-
6,
|
|
118231
|
-
7,
|
|
118232
|
-
8,
|
|
118233
|
-
9,
|
|
118234
|
-
10,
|
|
118235
|
-
11,
|
|
118236
|
-
12,
|
|
118237
|
-
13,
|
|
118238
|
-
14,
|
|
118239
|
-
15,
|
|
118240
|
-
14,
|
|
118241
|
-
10,
|
|
118242
|
-
4,
|
|
118243
|
-
8,
|
|
118244
|
-
9,
|
|
118245
|
-
15,
|
|
118246
|
-
13,
|
|
118247
|
-
6,
|
|
118248
|
-
1,
|
|
118249
|
-
12,
|
|
118250
|
-
0,
|
|
118251
|
-
2,
|
|
118252
|
-
11,
|
|
118253
|
-
7,
|
|
118254
|
-
5,
|
|
118255
|
-
3,
|
|
118256
|
-
11,
|
|
118257
|
-
8,
|
|
118258
|
-
12,
|
|
118259
|
-
0,
|
|
118260
|
-
5,
|
|
118261
|
-
2,
|
|
118262
|
-
15,
|
|
118263
|
-
13,
|
|
118264
|
-
10,
|
|
118265
|
-
14,
|
|
118266
|
-
3,
|
|
118267
|
-
6,
|
|
118268
|
-
7,
|
|
118269
|
-
1,
|
|
118270
|
-
9,
|
|
118271
|
-
4,
|
|
118272
|
-
7,
|
|
118273
|
-
9,
|
|
118274
|
-
3,
|
|
118275
|
-
1,
|
|
118276
|
-
13,
|
|
118277
|
-
12,
|
|
118278
|
-
11,
|
|
118279
|
-
14,
|
|
118280
|
-
2,
|
|
118281
|
-
6,
|
|
118282
|
-
5,
|
|
118283
|
-
10,
|
|
118284
|
-
4,
|
|
118285
|
-
0,
|
|
118286
|
-
15,
|
|
118287
|
-
8,
|
|
118288
|
-
9,
|
|
118289
|
-
0,
|
|
118290
|
-
5,
|
|
118291
|
-
7,
|
|
118292
|
-
2,
|
|
118293
|
-
4,
|
|
118294
|
-
10,
|
|
118295
|
-
15,
|
|
118296
|
-
14,
|
|
118297
|
-
1,
|
|
118298
|
-
11,
|
|
118299
|
-
12,
|
|
118300
|
-
6,
|
|
118301
|
-
8,
|
|
118302
|
-
3,
|
|
118303
|
-
13,
|
|
118304
|
-
2,
|
|
118305
|
-
12,
|
|
118306
|
-
6,
|
|
118307
|
-
10,
|
|
118308
|
-
0,
|
|
118309
|
-
11,
|
|
118310
|
-
8,
|
|
118311
|
-
3,
|
|
118312
|
-
4,
|
|
118313
|
-
13,
|
|
118314
|
-
7,
|
|
118315
|
-
5,
|
|
118316
|
-
15,
|
|
118317
|
-
14,
|
|
118318
|
-
1,
|
|
118319
|
-
9,
|
|
118320
|
-
12,
|
|
118321
|
-
5,
|
|
118322
|
-
1,
|
|
118323
|
-
15,
|
|
118324
|
-
14,
|
|
118325
|
-
13,
|
|
118326
|
-
4,
|
|
118327
|
-
10,
|
|
118328
|
-
0,
|
|
118329
|
-
7,
|
|
118330
|
-
6,
|
|
118331
|
-
3,
|
|
118332
|
-
9,
|
|
118333
|
-
2,
|
|
118334
|
-
8,
|
|
118335
|
-
11,
|
|
118336
|
-
13,
|
|
118337
|
-
11,
|
|
118338
|
-
7,
|
|
118339
|
-
14,
|
|
118340
|
-
12,
|
|
118341
|
-
1,
|
|
118342
|
-
3,
|
|
118343
|
-
9,
|
|
118344
|
-
5,
|
|
118345
|
-
0,
|
|
118346
|
-
15,
|
|
118347
|
-
4,
|
|
118348
|
-
8,
|
|
118349
|
-
6,
|
|
118350
|
-
2,
|
|
118351
|
-
10,
|
|
118352
|
-
6,
|
|
118353
|
-
15,
|
|
118354
|
-
14,
|
|
118355
|
-
9,
|
|
118356
|
-
11,
|
|
118357
|
-
3,
|
|
118358
|
-
0,
|
|
118359
|
-
8,
|
|
118360
|
-
12,
|
|
118361
|
-
2,
|
|
118362
|
-
13,
|
|
118363
|
-
7,
|
|
118364
|
-
1,
|
|
118365
|
-
4,
|
|
118366
|
-
10,
|
|
118367
|
-
5,
|
|
118368
|
-
10,
|
|
118369
|
-
2,
|
|
118370
|
-
8,
|
|
118371
|
-
4,
|
|
118372
|
-
7,
|
|
118373
|
-
6,
|
|
118374
|
-
1,
|
|
118375
|
-
5,
|
|
118376
|
-
15,
|
|
118377
|
-
11,
|
|
118378
|
-
9,
|
|
118379
|
-
14,
|
|
118380
|
-
3,
|
|
118381
|
-
12,
|
|
118382
|
-
13,
|
|
118383
|
-
0
|
|
118384
|
-
]);
|
|
118385
|
-
|
|
118386
|
-
// Compression function. "last" flag indicates last block
|
|
118387
|
-
const v = new Uint32Array(16);
|
|
118388
|
-
const m = new Uint32Array(16);
|
|
118389
|
-
function blake2sCompress (ctx, last) {
|
|
118390
|
-
let i = 0;
|
|
118391
|
-
for (i = 0; i < 8; i++) {
|
|
118392
|
-
// init work variables
|
|
118393
|
-
v[i] = ctx.h[i];
|
|
118394
|
-
v[i + 8] = BLAKE2S_IV[i];
|
|
118395
|
-
}
|
|
118396
|
-
|
|
118397
|
-
v[12] ^= ctx.t; // low 32 bits of offset
|
|
118398
|
-
v[13] ^= ctx.t / 0x100000000; // high 32 bits
|
|
118399
|
-
if (last) {
|
|
118400
|
-
// last block flag set ?
|
|
118401
|
-
v[14] = ~v[14];
|
|
118402
|
-
}
|
|
118403
|
-
|
|
118404
|
-
for (i = 0; i < 16; i++) {
|
|
118405
|
-
// get little-endian words
|
|
118406
|
-
m[i] = B2S_GET32(ctx.b, 4 * i);
|
|
118407
|
-
}
|
|
118408
|
-
|
|
118409
|
-
// ten rounds of mixing
|
|
118410
|
-
// uncomment the DebugPrint calls to log the computation
|
|
118411
|
-
// and match the RFC sample documentation
|
|
118412
|
-
// util.debugPrint(' m[16]', m, 32)
|
|
118413
|
-
for (i = 0; i < 10; i++) {
|
|
118414
|
-
// util.debugPrint(' (i=' + i + ') v[16]', v, 32)
|
|
118415
|
-
B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]);
|
|
118416
|
-
B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]);
|
|
118417
|
-
B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]);
|
|
118418
|
-
B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]);
|
|
118419
|
-
B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]);
|
|
118420
|
-
B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]);
|
|
118421
|
-
B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]);
|
|
118422
|
-
B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]);
|
|
118423
|
-
}
|
|
118424
|
-
// util.debugPrint(' (i=10) v[16]', v, 32)
|
|
118425
|
-
|
|
118426
|
-
for (i = 0; i < 8; i++) {
|
|
118427
|
-
ctx.h[i] ^= v[i] ^ v[i + 8];
|
|
118428
|
-
}
|
|
118429
|
-
// util.debugPrint('h[8]', ctx.h, 32)
|
|
118430
|
-
}
|
|
118431
|
-
|
|
118432
|
-
// Creates a BLAKE2s hashing context
|
|
118433
|
-
// Requires an output length between 1 and 32 bytes
|
|
118434
|
-
// Takes an optional Uint8Array key
|
|
118435
|
-
function blake2sInit (outlen, key) {
|
|
118436
|
-
if (!(outlen > 0 && outlen <= 32)) {
|
|
118437
|
-
throw new Error('Incorrect output length, should be in [1, 32]')
|
|
118438
|
-
}
|
|
118439
|
-
const keylen = key ? key.length : 0;
|
|
118440
|
-
if (key && !(keylen > 0 && keylen <= 32)) {
|
|
118441
|
-
throw new Error('Incorrect key length, should be in [1, 32]')
|
|
118442
|
-
}
|
|
118443
|
-
|
|
118444
|
-
const ctx = {
|
|
118445
|
-
h: new Uint32Array(BLAKE2S_IV), // hash state
|
|
118446
|
-
b: new Uint8Array(64), // input block
|
|
118447
|
-
c: 0, // pointer within block
|
|
118448
|
-
t: 0, // input count
|
|
118449
|
-
outlen: outlen // output length in bytes
|
|
118450
|
-
};
|
|
118451
|
-
ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen;
|
|
118452
|
-
|
|
118453
|
-
if (keylen > 0) {
|
|
118454
|
-
blake2sUpdate(ctx, key);
|
|
118455
|
-
ctx.c = 64; // at the end
|
|
118456
|
-
}
|
|
117701
|
+
const ERROR_MSG_INPUT = 'Input must be an string, Buffer or Uint8Array';
|
|
117702
|
+
|
|
117703
|
+
// For convenience, let people hash a string, not just a Uint8Array
|
|
117704
|
+
function normalizeInput (input) {
|
|
117705
|
+
let ret;
|
|
117706
|
+
if (input instanceof Uint8Array) {
|
|
117707
|
+
ret = input;
|
|
117708
|
+
} else if (typeof input === 'string') {
|
|
117709
|
+
const encoder = new TextEncoder();
|
|
117710
|
+
ret = encoder.encode(input);
|
|
117711
|
+
} else {
|
|
117712
|
+
throw new Error(ERROR_MSG_INPUT)
|
|
117713
|
+
}
|
|
117714
|
+
return ret
|
|
117715
|
+
}
|
|
117716
|
+
|
|
117717
|
+
// Converts a Uint8Array to a hexadecimal string
|
|
117718
|
+
// For example, toHex([255, 0, 255]) returns "ff00ff"
|
|
117719
|
+
function toHex (bytes) {
|
|
117720
|
+
return Array.prototype.map
|
|
117721
|
+
.call(bytes, function (n) {
|
|
117722
|
+
return (n < 16 ? '0' : '') + n.toString(16)
|
|
117723
|
+
})
|
|
117724
|
+
.join('')
|
|
117725
|
+
}
|
|
117726
|
+
|
|
117727
|
+
// Converts any value in [0...2^32-1] to an 8-character hex string
|
|
117728
|
+
function uint32ToHex (val) {
|
|
117729
|
+
return (0x100000000 + val).toString(16).substring(1)
|
|
117730
|
+
}
|
|
117731
|
+
|
|
117732
|
+
// For debugging: prints out hash state in the same format as the RFC
|
|
117733
|
+
// sample computation exactly, so that you can diff
|
|
117734
|
+
function debugPrint (label, arr, size) {
|
|
117735
|
+
let msg = '\n' + label + ' = ';
|
|
117736
|
+
for (let i = 0; i < arr.length; i += 2) {
|
|
117737
|
+
if (size === 32) {
|
|
117738
|
+
msg += uint32ToHex(arr[i]).toUpperCase();
|
|
117739
|
+
msg += ' ';
|
|
117740
|
+
msg += uint32ToHex(arr[i + 1]).toUpperCase();
|
|
117741
|
+
} else if (size === 64) {
|
|
117742
|
+
msg += uint32ToHex(arr[i + 1]).toUpperCase();
|
|
117743
|
+
msg += uint32ToHex(arr[i]).toUpperCase();
|
|
117744
|
+
} else throw new Error('Invalid size ' + size)
|
|
117745
|
+
if (i % 6 === 4) {
|
|
117746
|
+
msg += '\n' + new Array(label.length + 4).join(' ');
|
|
117747
|
+
} else if (i < arr.length - 2) {
|
|
117748
|
+
msg += ' ';
|
|
117749
|
+
}
|
|
117750
|
+
}
|
|
117751
|
+
console.log(msg);
|
|
117752
|
+
}
|
|
117753
|
+
|
|
117754
|
+
// For performance testing: generates N bytes of input, hashes M times
|
|
117755
|
+
// Measures and prints MB/second hash performance each time
|
|
117756
|
+
function testSpeed (hashFn, N, M) {
|
|
117757
|
+
let startMs = new Date().getTime();
|
|
117758
|
+
|
|
117759
|
+
const input = new Uint8Array(N);
|
|
117760
|
+
for (let i = 0; i < N; i++) {
|
|
117761
|
+
input[i] = i % 256;
|
|
117762
|
+
}
|
|
117763
|
+
const genMs = new Date().getTime();
|
|
117764
|
+
console.log('Generated random input in ' + (genMs - startMs) + 'ms');
|
|
117765
|
+
startMs = genMs;
|
|
117766
|
+
|
|
117767
|
+
for (let i = 0; i < M; i++) {
|
|
117768
|
+
const hashHex = hashFn(input);
|
|
117769
|
+
const hashMs = new Date().getTime();
|
|
117770
|
+
const ms = hashMs - startMs;
|
|
117771
|
+
startMs = hashMs;
|
|
117772
|
+
console.log('Hashed in ' + ms + 'ms: ' + hashHex.substring(0, 20) + '...');
|
|
117773
|
+
console.log(
|
|
117774
|
+
Math.round((N / (1 << 20) / (ms / 1000)) * 100) / 100 + ' MB PER SECOND'
|
|
117775
|
+
);
|
|
117776
|
+
}
|
|
117777
|
+
}
|
|
117778
|
+
|
|
117779
|
+
var util$2 = {
|
|
117780
|
+
normalizeInput: normalizeInput,
|
|
117781
|
+
toHex: toHex,
|
|
117782
|
+
debugPrint: debugPrint,
|
|
117783
|
+
testSpeed: testSpeed
|
|
117784
|
+
};
|
|
118457
117785
|
|
|
118458
|
-
|
|
118459
|
-
|
|
117786
|
+
// Blake2B in pure Javascript
|
|
117787
|
+
// Adapted from the reference implementation in RFC7693
|
|
117788
|
+
// Ported to Javascript by DC - https://github.com/dcposch
|
|
117789
|
+
|
|
117790
|
+
const util$1 = util$2;
|
|
117791
|
+
|
|
117792
|
+
// 64-bit unsigned addition
|
|
117793
|
+
// Sets v[a,a+1] += v[b,b+1]
|
|
117794
|
+
// v should be a Uint32Array
|
|
117795
|
+
function ADD64AA (v, a, b) {
|
|
117796
|
+
const o0 = v[a] + v[b];
|
|
117797
|
+
let o1 = v[a + 1] + v[b + 1];
|
|
117798
|
+
if (o0 >= 0x100000000) {
|
|
117799
|
+
o1++;
|
|
117800
|
+
}
|
|
117801
|
+
v[a] = o0;
|
|
117802
|
+
v[a + 1] = o1;
|
|
117803
|
+
}
|
|
117804
|
+
|
|
117805
|
+
// 64-bit unsigned addition
|
|
117806
|
+
// Sets v[a,a+1] += b
|
|
117807
|
+
// b0 is the low 32 bits of b, b1 represents the high 32 bits
|
|
117808
|
+
function ADD64AC (v, a, b0, b1) {
|
|
117809
|
+
let o0 = v[a] + b0;
|
|
117810
|
+
if (b0 < 0) {
|
|
117811
|
+
o0 += 0x100000000;
|
|
117812
|
+
}
|
|
117813
|
+
let o1 = v[a + 1] + b1;
|
|
117814
|
+
if (o0 >= 0x100000000) {
|
|
117815
|
+
o1++;
|
|
117816
|
+
}
|
|
117817
|
+
v[a] = o0;
|
|
117818
|
+
v[a + 1] = o1;
|
|
117819
|
+
}
|
|
117820
|
+
|
|
117821
|
+
// Little-endian byte access
|
|
117822
|
+
function B2B_GET32 (arr, i) {
|
|
117823
|
+
return arr[i] ^ (arr[i + 1] << 8) ^ (arr[i + 2] << 16) ^ (arr[i + 3] << 24)
|
|
117824
|
+
}
|
|
117825
|
+
|
|
117826
|
+
// G Mixing function
|
|
117827
|
+
// The ROTRs are inlined for speed
|
|
117828
|
+
function B2B_G (a, b, c, d, ix, iy) {
|
|
117829
|
+
const x0 = m$1[ix];
|
|
117830
|
+
const x1 = m$1[ix + 1];
|
|
117831
|
+
const y0 = m$1[iy];
|
|
117832
|
+
const y1 = m$1[iy + 1];
|
|
117833
|
+
|
|
117834
|
+
ADD64AA(v$1, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
|
|
117835
|
+
ADD64AC(v$1, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits
|
|
117836
|
+
|
|
117837
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
|
|
117838
|
+
let xor0 = v$1[d] ^ v$1[a];
|
|
117839
|
+
let xor1 = v$1[d + 1] ^ v$1[a + 1];
|
|
117840
|
+
v$1[d] = xor1;
|
|
117841
|
+
v$1[d + 1] = xor0;
|
|
117842
|
+
|
|
117843
|
+
ADD64AA(v$1, c, d);
|
|
117844
|
+
|
|
117845
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
|
|
117846
|
+
xor0 = v$1[b] ^ v$1[c];
|
|
117847
|
+
xor1 = v$1[b + 1] ^ v$1[c + 1];
|
|
117848
|
+
v$1[b] = (xor0 >>> 24) ^ (xor1 << 8);
|
|
117849
|
+
v$1[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
|
|
117850
|
+
|
|
117851
|
+
ADD64AA(v$1, a, b);
|
|
117852
|
+
ADD64AC(v$1, a, y0, y1);
|
|
117853
|
+
|
|
117854
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
|
|
117855
|
+
xor0 = v$1[d] ^ v$1[a];
|
|
117856
|
+
xor1 = v$1[d + 1] ^ v$1[a + 1];
|
|
117857
|
+
v$1[d] = (xor0 >>> 16) ^ (xor1 << 16);
|
|
117858
|
+
v$1[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
|
|
117859
|
+
|
|
117860
|
+
ADD64AA(v$1, c, d);
|
|
117861
|
+
|
|
117862
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
|
|
117863
|
+
xor0 = v$1[b] ^ v$1[c];
|
|
117864
|
+
xor1 = v$1[b + 1] ^ v$1[c + 1];
|
|
117865
|
+
v$1[b] = (xor1 >>> 31) ^ (xor0 << 1);
|
|
117866
|
+
v$1[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
|
|
117867
|
+
}
|
|
117868
|
+
|
|
117869
|
+
// Initialization Vector
|
|
117870
|
+
const BLAKE2B_IV32 = new Uint32Array([
|
|
117871
|
+
0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372,
|
|
117872
|
+
0x5f1d36f1, 0xa54ff53a, 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c,
|
|
117873
|
+
0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19
|
|
117874
|
+
]);
|
|
118460
117875
|
|
|
118461
|
-
|
|
118462
|
-
|
|
118463
|
-
|
|
118464
|
-
|
|
118465
|
-
|
|
118466
|
-
|
|
118467
|
-
|
|
118468
|
-
|
|
118469
|
-
|
|
118470
|
-
|
|
118471
|
-
|
|
118472
|
-
}
|
|
118473
|
-
}
|
|
117876
|
+
const SIGMA8 = [
|
|
117877
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13,
|
|
117878
|
+
6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1,
|
|
117879
|
+
9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4,
|
|
117880
|
+
10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5,
|
|
117881
|
+
15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7,
|
|
117882
|
+
14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2,
|
|
117883
|
+
13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0,
|
|
117884
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6,
|
|
117885
|
+
1, 12, 0, 2, 11, 7, 5, 3
|
|
117886
|
+
];
|
|
118474
117887
|
|
|
118475
|
-
|
|
118476
|
-
|
|
118477
|
-
|
|
118478
|
-
|
|
118479
|
-
|
|
118480
|
-
|
|
118481
|
-
|
|
118482
|
-
|
|
118483
|
-
blake2sCompress(ctx, true); // final block flag = 1
|
|
117888
|
+
// These are offsets into a uint64 buffer.
|
|
117889
|
+
// Multiply them all by 2 to make them offsets into a uint32 buffer,
|
|
117890
|
+
// because this is Javascript and we don't have uint64s
|
|
117891
|
+
const SIGMA82 = new Uint8Array(
|
|
117892
|
+
SIGMA8.map(function (x) {
|
|
117893
|
+
return x * 2
|
|
117894
|
+
})
|
|
117895
|
+
);
|
|
118484
117896
|
|
|
118485
|
-
|
|
118486
|
-
|
|
118487
|
-
|
|
118488
|
-
|
|
118489
|
-
|
|
118490
|
-
|
|
118491
|
-
|
|
117897
|
+
// Compression function. 'last' flag indicates last block.
|
|
117898
|
+
// Note we're representing 16 uint64s as 32 uint32s
|
|
117899
|
+
const v$1 = new Uint32Array(32);
|
|
117900
|
+
const m$1 = new Uint32Array(32);
|
|
117901
|
+
function blake2bCompress (ctx, last) {
|
|
117902
|
+
let i = 0;
|
|
117903
|
+
|
|
117904
|
+
// init work variables
|
|
117905
|
+
for (i = 0; i < 16; i++) {
|
|
117906
|
+
v$1[i] = ctx.h[i];
|
|
117907
|
+
v$1[i + 16] = BLAKE2B_IV32[i];
|
|
117908
|
+
}
|
|
117909
|
+
|
|
117910
|
+
// low 64 bits of offset
|
|
117911
|
+
v$1[24] = v$1[24] ^ ctx.t;
|
|
117912
|
+
v$1[25] = v$1[25] ^ (ctx.t / 0x100000000);
|
|
117913
|
+
// high 64 bits not supported, offset may not be higher than 2**53-1
|
|
117914
|
+
|
|
117915
|
+
// last block flag set ?
|
|
117916
|
+
if (last) {
|
|
117917
|
+
v$1[28] = ~v$1[28];
|
|
117918
|
+
v$1[29] = ~v$1[29];
|
|
117919
|
+
}
|
|
117920
|
+
|
|
117921
|
+
// get little-endian words
|
|
117922
|
+
for (i = 0; i < 32; i++) {
|
|
117923
|
+
m$1[i] = B2B_GET32(ctx.b, 4 * i);
|
|
117924
|
+
}
|
|
117925
|
+
|
|
117926
|
+
// twelve rounds of mixing
|
|
117927
|
+
// uncomment the DebugPrint calls to log the computation
|
|
117928
|
+
// and match the RFC sample documentation
|
|
117929
|
+
// util.debugPrint(' m[16]', m, 64)
|
|
117930
|
+
for (i = 0; i < 12; i++) {
|
|
117931
|
+
// util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64)
|
|
117932
|
+
B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]);
|
|
117933
|
+
B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]);
|
|
117934
|
+
B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]);
|
|
117935
|
+
B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]);
|
|
117936
|
+
B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]);
|
|
117937
|
+
B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]);
|
|
117938
|
+
B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]);
|
|
117939
|
+
B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]);
|
|
117940
|
+
}
|
|
117941
|
+
// util.debugPrint(' (i=12) v[16]', v, 64)
|
|
117942
|
+
|
|
117943
|
+
for (i = 0; i < 16; i++) {
|
|
117944
|
+
ctx.h[i] = ctx.h[i] ^ v$1[i] ^ v$1[i + 16];
|
|
117945
|
+
}
|
|
117946
|
+
// util.debugPrint('h[8]', ctx.h, 64)
|
|
117947
|
+
}
|
|
117948
|
+
|
|
117949
|
+
// reusable parameterBlock
|
|
117950
|
+
const parameterBlock = new Uint8Array([
|
|
117951
|
+
0,
|
|
117952
|
+
0,
|
|
117953
|
+
0,
|
|
117954
|
+
0, // 0: outlen, keylen, fanout, depth
|
|
117955
|
+
0,
|
|
117956
|
+
0,
|
|
117957
|
+
0,
|
|
117958
|
+
0, // 4: leaf length, sequential mode
|
|
117959
|
+
0,
|
|
117960
|
+
0,
|
|
117961
|
+
0,
|
|
117962
|
+
0, // 8: node offset
|
|
117963
|
+
0,
|
|
117964
|
+
0,
|
|
117965
|
+
0,
|
|
117966
|
+
0, // 12: node offset
|
|
117967
|
+
0,
|
|
117968
|
+
0,
|
|
117969
|
+
0,
|
|
117970
|
+
0, // 16: node depth, inner length, rfu
|
|
117971
|
+
0,
|
|
117972
|
+
0,
|
|
117973
|
+
0,
|
|
117974
|
+
0, // 20: rfu
|
|
117975
|
+
0,
|
|
117976
|
+
0,
|
|
117977
|
+
0,
|
|
117978
|
+
0, // 24: rfu
|
|
117979
|
+
0,
|
|
117980
|
+
0,
|
|
117981
|
+
0,
|
|
117982
|
+
0, // 28: rfu
|
|
117983
|
+
0,
|
|
117984
|
+
0,
|
|
117985
|
+
0,
|
|
117986
|
+
0, // 32: salt
|
|
117987
|
+
0,
|
|
117988
|
+
0,
|
|
117989
|
+
0,
|
|
117990
|
+
0, // 36: salt
|
|
117991
|
+
0,
|
|
117992
|
+
0,
|
|
117993
|
+
0,
|
|
117994
|
+
0, // 40: salt
|
|
117995
|
+
0,
|
|
117996
|
+
0,
|
|
117997
|
+
0,
|
|
117998
|
+
0, // 44: salt
|
|
117999
|
+
0,
|
|
118000
|
+
0,
|
|
118001
|
+
0,
|
|
118002
|
+
0, // 48: personal
|
|
118003
|
+
0,
|
|
118004
|
+
0,
|
|
118005
|
+
0,
|
|
118006
|
+
0, // 52: personal
|
|
118007
|
+
0,
|
|
118008
|
+
0,
|
|
118009
|
+
0,
|
|
118010
|
+
0, // 56: personal
|
|
118011
|
+
0,
|
|
118012
|
+
0,
|
|
118013
|
+
0,
|
|
118014
|
+
0 // 60: personal
|
|
118015
|
+
]);
|
|
118492
118016
|
|
|
118493
|
-
|
|
118494
|
-
|
|
118495
|
-
|
|
118496
|
-
|
|
118497
|
-
|
|
118498
|
-
|
|
118499
|
-
|
|
118500
|
-
|
|
118501
|
-
|
|
118502
|
-
|
|
118503
|
-
|
|
118504
|
-
|
|
118505
|
-
|
|
118506
|
-
|
|
118507
|
-
|
|
118508
|
-
|
|
118509
|
-
|
|
118510
|
-
|
|
118511
|
-
|
|
118512
|
-
|
|
118513
|
-
|
|
118514
|
-
|
|
118515
|
-
|
|
118516
|
-
|
|
118517
|
-
|
|
118518
|
-
|
|
118519
|
-
|
|
118520
|
-
|
|
118521
|
-
|
|
118522
|
-
|
|
118523
|
-
|
|
118017
|
+
// Creates a BLAKE2b hashing context
|
|
118018
|
+
// Requires an output length between 1 and 64 bytes
|
|
118019
|
+
// Takes an optional Uint8Array key
|
|
118020
|
+
// Takes an optinal Uint8Array salt
|
|
118021
|
+
// Takes an optinal Uint8Array personal
|
|
118022
|
+
function blake2bInit (outlen, key, salt, personal) {
|
|
118023
|
+
if (outlen === 0 || outlen > 64) {
|
|
118024
|
+
throw new Error('Illegal output length, expected 0 < length <= 64')
|
|
118025
|
+
}
|
|
118026
|
+
if (key && key.length > 64) {
|
|
118027
|
+
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64')
|
|
118028
|
+
}
|
|
118029
|
+
if (salt && salt.length !== 16) {
|
|
118030
|
+
throw new Error('Illegal salt, expected Uint8Array with length is 16')
|
|
118031
|
+
}
|
|
118032
|
+
if (personal && personal.length !== 16) {
|
|
118033
|
+
throw new Error('Illegal personal, expected Uint8Array with length is 16')
|
|
118034
|
+
}
|
|
118035
|
+
|
|
118036
|
+
// state, 'param block'
|
|
118037
|
+
const ctx = {
|
|
118038
|
+
b: new Uint8Array(128),
|
|
118039
|
+
h: new Uint32Array(16),
|
|
118040
|
+
t: 0, // input count
|
|
118041
|
+
c: 0, // pointer within buffer
|
|
118042
|
+
outlen: outlen // output length in bytes
|
|
118043
|
+
};
|
|
118044
|
+
|
|
118045
|
+
// initialize parameterBlock before usage
|
|
118046
|
+
parameterBlock.fill(0);
|
|
118047
|
+
parameterBlock[0] = outlen;
|
|
118048
|
+
if (key) parameterBlock[1] = key.length;
|
|
118049
|
+
parameterBlock[2] = 1; // fanout
|
|
118050
|
+
parameterBlock[3] = 1; // depth
|
|
118051
|
+
if (salt) parameterBlock.set(salt, 32);
|
|
118052
|
+
if (personal) parameterBlock.set(personal, 48);
|
|
118053
|
+
|
|
118054
|
+
// initialize hash state
|
|
118055
|
+
for (let i = 0; i < 16; i++) {
|
|
118056
|
+
ctx.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameterBlock, i * 4);
|
|
118057
|
+
}
|
|
118058
|
+
|
|
118059
|
+
// key the hash, if applicable
|
|
118060
|
+
if (key) {
|
|
118061
|
+
blake2bUpdate(ctx, key);
|
|
118062
|
+
// at the end
|
|
118063
|
+
ctx.c = 128;
|
|
118064
|
+
}
|
|
118065
|
+
|
|
118066
|
+
return ctx
|
|
118067
|
+
}
|
|
118068
|
+
|
|
118069
|
+
// Updates a BLAKE2b streaming hash
|
|
118070
|
+
// Requires hash context and Uint8Array (byte array)
|
|
118071
|
+
function blake2bUpdate (ctx, input) {
|
|
118072
|
+
for (let i = 0; i < input.length; i++) {
|
|
118073
|
+
if (ctx.c === 128) {
|
|
118074
|
+
// buffer full ?
|
|
118075
|
+
ctx.t += ctx.c; // add counters
|
|
118076
|
+
blake2bCompress(ctx, false); // compress (not last)
|
|
118077
|
+
ctx.c = 0; // counter to zero
|
|
118078
|
+
}
|
|
118079
|
+
ctx.b[ctx.c++] = input[i];
|
|
118080
|
+
}
|
|
118081
|
+
}
|
|
118082
|
+
|
|
118083
|
+
// Completes a BLAKE2b streaming hash
|
|
118084
|
+
// Returns a Uint8Array containing the message digest
|
|
118085
|
+
function blake2bFinal (ctx) {
|
|
118086
|
+
ctx.t += ctx.c; // mark last block offset
|
|
118087
|
+
|
|
118088
|
+
while (ctx.c < 128) {
|
|
118089
|
+
// fill up with zeros
|
|
118090
|
+
ctx.b[ctx.c++] = 0;
|
|
118091
|
+
}
|
|
118092
|
+
blake2bCompress(ctx, true); // final block flag = 1
|
|
118093
|
+
|
|
118094
|
+
// little endian convert and store
|
|
118095
|
+
const out = new Uint8Array(ctx.outlen);
|
|
118096
|
+
for (let i = 0; i < ctx.outlen; i++) {
|
|
118097
|
+
out[i] = ctx.h[i >> 2] >> (8 * (i & 3));
|
|
118098
|
+
}
|
|
118099
|
+
return out
|
|
118100
|
+
}
|
|
118101
|
+
|
|
118102
|
+
// Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array
|
|
118103
|
+
//
|
|
118104
|
+
// Returns a n-byte Uint8Array
|
|
118105
|
+
//
|
|
118106
|
+
// Parameters:
|
|
118107
|
+
// - input - the input bytes, as a string, Buffer or Uint8Array
|
|
118108
|
+
// - key - optional key Uint8Array, up to 64 bytes
|
|
118109
|
+
// - outlen - optional output length in bytes, default 64
|
|
118110
|
+
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118111
|
+
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118112
|
+
function blake2b (input, key, outlen, salt, personal) {
|
|
118113
|
+
// preprocess inputs
|
|
118114
|
+
outlen = outlen || 64;
|
|
118115
|
+
input = util$1.normalizeInput(input);
|
|
118116
|
+
if (salt) {
|
|
118117
|
+
salt = util$1.normalizeInput(salt);
|
|
118118
|
+
}
|
|
118119
|
+
if (personal) {
|
|
118120
|
+
personal = util$1.normalizeInput(personal);
|
|
118121
|
+
}
|
|
118122
|
+
|
|
118123
|
+
// do the math
|
|
118124
|
+
const ctx = blake2bInit(outlen, key, salt, personal);
|
|
118125
|
+
blake2bUpdate(ctx, input);
|
|
118126
|
+
return blake2bFinal(ctx)
|
|
118127
|
+
}
|
|
118128
|
+
|
|
118129
|
+
// Computes the BLAKE2B hash of a string or byte array
|
|
118130
|
+
//
|
|
118131
|
+
// Returns an n-byte hash in hex, all lowercase
|
|
118132
|
+
//
|
|
118133
|
+
// Parameters:
|
|
118134
|
+
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118135
|
+
// - key - optional key Uint8Array, up to 64 bytes
|
|
118136
|
+
// - outlen - optional output length in bytes, default 64
|
|
118137
|
+
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118138
|
+
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118139
|
+
function blake2bHex (input, key, outlen, salt, personal) {
|
|
118140
|
+
const output = blake2b(input, key, outlen, salt, personal);
|
|
118141
|
+
return util$1.toHex(output)
|
|
118142
|
+
}
|
|
118143
|
+
|
|
118144
|
+
var blake2b_1 = {
|
|
118145
|
+
blake2b: blake2b,
|
|
118146
|
+
blake2bHex: blake2bHex,
|
|
118147
|
+
blake2bInit: blake2bInit,
|
|
118148
|
+
blake2bUpdate: blake2bUpdate,
|
|
118149
|
+
blake2bFinal: blake2bFinal
|
|
118150
|
+
};
|
|
118524
118151
|
|
|
118525
|
-
|
|
118526
|
-
|
|
118527
|
-
|
|
118528
|
-
|
|
118529
|
-
|
|
118530
|
-
|
|
118531
|
-
|
|
118532
|
-
|
|
118533
|
-
|
|
118152
|
+
// BLAKE2s hash function in pure Javascript
|
|
118153
|
+
// Adapted from the reference implementation in RFC7693
|
|
118154
|
+
// Ported to Javascript by DC - https://github.com/dcposch
|
|
118155
|
+
|
|
118156
|
+
const util = util$2;
|
|
118157
|
+
|
|
118158
|
+
// Little-endian byte access.
|
|
118159
|
+
// Expects a Uint8Array and an index
|
|
118160
|
+
// Returns the little-endian uint32 at v[i..i+3]
|
|
118161
|
+
function B2S_GET32 (v, i) {
|
|
118162
|
+
return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24)
|
|
118163
|
+
}
|
|
118164
|
+
|
|
118165
|
+
// Mixing function G.
|
|
118166
|
+
function B2S_G (a, b, c, d, x, y) {
|
|
118167
|
+
v[a] = v[a] + v[b] + x;
|
|
118168
|
+
v[d] = ROTR32(v[d] ^ v[a], 16);
|
|
118169
|
+
v[c] = v[c] + v[d];
|
|
118170
|
+
v[b] = ROTR32(v[b] ^ v[c], 12);
|
|
118171
|
+
v[a] = v[a] + v[b] + y;
|
|
118172
|
+
v[d] = ROTR32(v[d] ^ v[a], 8);
|
|
118173
|
+
v[c] = v[c] + v[d];
|
|
118174
|
+
v[b] = ROTR32(v[b] ^ v[c], 7);
|
|
118175
|
+
}
|
|
118176
|
+
|
|
118177
|
+
// 32-bit right rotation
|
|
118178
|
+
// x should be a uint32
|
|
118179
|
+
// y must be between 1 and 31, inclusive
|
|
118180
|
+
function ROTR32 (x, y) {
|
|
118181
|
+
return (x >>> y) ^ (x << (32 - y))
|
|
118182
|
+
}
|
|
118183
|
+
|
|
118184
|
+
// Initialization Vector.
|
|
118185
|
+
const BLAKE2S_IV = new Uint32Array([
|
|
118186
|
+
0x6a09e667,
|
|
118187
|
+
0xbb67ae85,
|
|
118188
|
+
0x3c6ef372,
|
|
118189
|
+
0xa54ff53a,
|
|
118190
|
+
0x510e527f,
|
|
118191
|
+
0x9b05688c,
|
|
118192
|
+
0x1f83d9ab,
|
|
118193
|
+
0x5be0cd19
|
|
118194
|
+
]);
|
|
118534
118195
|
|
|
118535
|
-
|
|
118536
|
-
|
|
118196
|
+
const SIGMA = new Uint8Array([
|
|
118197
|
+
0,
|
|
118198
|
+
1,
|
|
118199
|
+
2,
|
|
118200
|
+
3,
|
|
118201
|
+
4,
|
|
118202
|
+
5,
|
|
118203
|
+
6,
|
|
118204
|
+
7,
|
|
118205
|
+
8,
|
|
118206
|
+
9,
|
|
118207
|
+
10,
|
|
118208
|
+
11,
|
|
118209
|
+
12,
|
|
118210
|
+
13,
|
|
118211
|
+
14,
|
|
118212
|
+
15,
|
|
118213
|
+
14,
|
|
118214
|
+
10,
|
|
118215
|
+
4,
|
|
118216
|
+
8,
|
|
118217
|
+
9,
|
|
118218
|
+
15,
|
|
118219
|
+
13,
|
|
118220
|
+
6,
|
|
118221
|
+
1,
|
|
118222
|
+
12,
|
|
118223
|
+
0,
|
|
118224
|
+
2,
|
|
118225
|
+
11,
|
|
118226
|
+
7,
|
|
118227
|
+
5,
|
|
118228
|
+
3,
|
|
118229
|
+
11,
|
|
118230
|
+
8,
|
|
118231
|
+
12,
|
|
118232
|
+
0,
|
|
118233
|
+
5,
|
|
118234
|
+
2,
|
|
118235
|
+
15,
|
|
118236
|
+
13,
|
|
118237
|
+
10,
|
|
118238
|
+
14,
|
|
118239
|
+
3,
|
|
118240
|
+
6,
|
|
118241
|
+
7,
|
|
118242
|
+
1,
|
|
118243
|
+
9,
|
|
118244
|
+
4,
|
|
118245
|
+
7,
|
|
118246
|
+
9,
|
|
118247
|
+
3,
|
|
118248
|
+
1,
|
|
118249
|
+
13,
|
|
118250
|
+
12,
|
|
118251
|
+
11,
|
|
118252
|
+
14,
|
|
118253
|
+
2,
|
|
118254
|
+
6,
|
|
118255
|
+
5,
|
|
118256
|
+
10,
|
|
118257
|
+
4,
|
|
118258
|
+
0,
|
|
118259
|
+
15,
|
|
118260
|
+
8,
|
|
118261
|
+
9,
|
|
118262
|
+
0,
|
|
118263
|
+
5,
|
|
118264
|
+
7,
|
|
118265
|
+
2,
|
|
118266
|
+
4,
|
|
118267
|
+
10,
|
|
118268
|
+
15,
|
|
118269
|
+
14,
|
|
118270
|
+
1,
|
|
118271
|
+
11,
|
|
118272
|
+
12,
|
|
118273
|
+
6,
|
|
118274
|
+
8,
|
|
118275
|
+
3,
|
|
118276
|
+
13,
|
|
118277
|
+
2,
|
|
118278
|
+
12,
|
|
118279
|
+
6,
|
|
118280
|
+
10,
|
|
118281
|
+
0,
|
|
118282
|
+
11,
|
|
118283
|
+
8,
|
|
118284
|
+
3,
|
|
118285
|
+
4,
|
|
118286
|
+
13,
|
|
118287
|
+
7,
|
|
118288
|
+
5,
|
|
118289
|
+
15,
|
|
118290
|
+
14,
|
|
118291
|
+
1,
|
|
118292
|
+
9,
|
|
118293
|
+
12,
|
|
118294
|
+
5,
|
|
118295
|
+
1,
|
|
118296
|
+
15,
|
|
118297
|
+
14,
|
|
118298
|
+
13,
|
|
118299
|
+
4,
|
|
118300
|
+
10,
|
|
118301
|
+
0,
|
|
118302
|
+
7,
|
|
118303
|
+
6,
|
|
118304
|
+
3,
|
|
118305
|
+
9,
|
|
118306
|
+
2,
|
|
118307
|
+
8,
|
|
118308
|
+
11,
|
|
118309
|
+
13,
|
|
118310
|
+
11,
|
|
118311
|
+
7,
|
|
118312
|
+
14,
|
|
118313
|
+
12,
|
|
118314
|
+
1,
|
|
118315
|
+
3,
|
|
118316
|
+
9,
|
|
118317
|
+
5,
|
|
118318
|
+
0,
|
|
118319
|
+
15,
|
|
118320
|
+
4,
|
|
118321
|
+
8,
|
|
118322
|
+
6,
|
|
118323
|
+
2,
|
|
118324
|
+
10,
|
|
118325
|
+
6,
|
|
118326
|
+
15,
|
|
118327
|
+
14,
|
|
118328
|
+
9,
|
|
118329
|
+
11,
|
|
118330
|
+
3,
|
|
118331
|
+
0,
|
|
118332
|
+
8,
|
|
118333
|
+
12,
|
|
118334
|
+
2,
|
|
118335
|
+
13,
|
|
118336
|
+
7,
|
|
118337
|
+
1,
|
|
118338
|
+
4,
|
|
118339
|
+
10,
|
|
118340
|
+
5,
|
|
118341
|
+
10,
|
|
118342
|
+
2,
|
|
118343
|
+
8,
|
|
118344
|
+
4,
|
|
118345
|
+
7,
|
|
118346
|
+
6,
|
|
118347
|
+
1,
|
|
118348
|
+
5,
|
|
118349
|
+
15,
|
|
118350
|
+
11,
|
|
118351
|
+
9,
|
|
118352
|
+
14,
|
|
118353
|
+
3,
|
|
118354
|
+
12,
|
|
118355
|
+
13,
|
|
118356
|
+
0
|
|
118357
|
+
]);
|
|
118537
118358
|
|
|
118538
|
-
function
|
|
118539
|
-
|
|
118540
|
-
|
|
118541
|
-
|
|
118542
|
-
|
|
118359
|
+
// Compression function. "last" flag indicates last block
|
|
118360
|
+
const v = new Uint32Array(16);
|
|
118361
|
+
const m = new Uint32Array(16);
|
|
118362
|
+
function blake2sCompress (ctx, last) {
|
|
118363
|
+
let i = 0;
|
|
118364
|
+
for (i = 0; i < 8; i++) {
|
|
118365
|
+
// init work variables
|
|
118366
|
+
v[i] = ctx.h[i];
|
|
118367
|
+
v[i + 8] = BLAKE2S_IV[i];
|
|
118368
|
+
}
|
|
118369
|
+
|
|
118370
|
+
v[12] ^= ctx.t; // low 32 bits of offset
|
|
118371
|
+
v[13] ^= ctx.t / 0x100000000; // high 32 bits
|
|
118372
|
+
if (last) {
|
|
118373
|
+
// last block flag set ?
|
|
118374
|
+
v[14] = ~v[14];
|
|
118375
|
+
}
|
|
118376
|
+
|
|
118377
|
+
for (i = 0; i < 16; i++) {
|
|
118378
|
+
// get little-endian words
|
|
118379
|
+
m[i] = B2S_GET32(ctx.b, 4 * i);
|
|
118380
|
+
}
|
|
118381
|
+
|
|
118382
|
+
// ten rounds of mixing
|
|
118383
|
+
// uncomment the DebugPrint calls to log the computation
|
|
118384
|
+
// and match the RFC sample documentation
|
|
118385
|
+
// util.debugPrint(' m[16]', m, 32)
|
|
118386
|
+
for (i = 0; i < 10; i++) {
|
|
118387
|
+
// util.debugPrint(' (i=' + i + ') v[16]', v, 32)
|
|
118388
|
+
B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]);
|
|
118389
|
+
B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]);
|
|
118390
|
+
B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]);
|
|
118391
|
+
B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]);
|
|
118392
|
+
B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]);
|
|
118393
|
+
B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]);
|
|
118394
|
+
B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]);
|
|
118395
|
+
B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]);
|
|
118396
|
+
}
|
|
118397
|
+
// util.debugPrint(' (i=10) v[16]', v, 32)
|
|
118398
|
+
|
|
118399
|
+
for (i = 0; i < 8; i++) {
|
|
118400
|
+
ctx.h[i] ^= v[i] ^ v[i + 8];
|
|
118401
|
+
}
|
|
118402
|
+
// util.debugPrint('h[8]', ctx.h, 32)
|
|
118403
|
+
}
|
|
118404
|
+
|
|
118405
|
+
// Creates a BLAKE2s hashing context
|
|
118406
|
+
// Requires an output length between 1 and 32 bytes
|
|
118407
|
+
// Takes an optional Uint8Array key
|
|
118408
|
+
function blake2sInit (outlen, key) {
|
|
118409
|
+
if (!(outlen > 0 && outlen <= 32)) {
|
|
118410
|
+
throw new Error('Incorrect output length, should be in [1, 32]')
|
|
118411
|
+
}
|
|
118412
|
+
const keylen = key ? key.length : 0;
|
|
118413
|
+
if (key && !(keylen > 0 && keylen <= 32)) {
|
|
118414
|
+
throw new Error('Incorrect key length, should be in [1, 32]')
|
|
118415
|
+
}
|
|
118416
|
+
|
|
118417
|
+
const ctx = {
|
|
118418
|
+
h: new Uint32Array(BLAKE2S_IV), // hash state
|
|
118419
|
+
b: new Uint8Array(64), // input block
|
|
118420
|
+
c: 0, // pointer within block
|
|
118421
|
+
t: 0, // input count
|
|
118422
|
+
outlen: outlen // output length in bytes
|
|
118423
|
+
};
|
|
118424
|
+
ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen;
|
|
118425
|
+
|
|
118426
|
+
if (keylen > 0) {
|
|
118427
|
+
blake2sUpdate(ctx, key);
|
|
118428
|
+
ctx.c = 64; // at the end
|
|
118429
|
+
}
|
|
118430
|
+
|
|
118431
|
+
return ctx
|
|
118432
|
+
}
|
|
118433
|
+
|
|
118434
|
+
// Updates a BLAKE2s streaming hash
|
|
118435
|
+
// Requires hash context and Uint8Array (byte array)
|
|
118436
|
+
function blake2sUpdate (ctx, input) {
|
|
118437
|
+
for (let i = 0; i < input.length; i++) {
|
|
118438
|
+
if (ctx.c === 64) {
|
|
118439
|
+
// buffer full ?
|
|
118440
|
+
ctx.t += ctx.c; // add counters
|
|
118441
|
+
blake2sCompress(ctx, false); // compress (not last)
|
|
118442
|
+
ctx.c = 0; // counter to zero
|
|
118443
|
+
}
|
|
118444
|
+
ctx.b[ctx.c++] = input[i];
|
|
118445
|
+
}
|
|
118446
|
+
}
|
|
118447
|
+
|
|
118448
|
+
// Completes a BLAKE2s streaming hash
|
|
118449
|
+
// Returns a Uint8Array containing the message digest
|
|
118450
|
+
function blake2sFinal (ctx) {
|
|
118451
|
+
ctx.t += ctx.c; // mark last block offset
|
|
118452
|
+
while (ctx.c < 64) {
|
|
118453
|
+
// fill up with zeros
|
|
118454
|
+
ctx.b[ctx.c++] = 0;
|
|
118455
|
+
}
|
|
118456
|
+
blake2sCompress(ctx, true); // final block flag = 1
|
|
118457
|
+
|
|
118458
|
+
// little endian convert and store
|
|
118459
|
+
const out = new Uint8Array(ctx.outlen);
|
|
118460
|
+
for (let i = 0; i < ctx.outlen; i++) {
|
|
118461
|
+
out[i] = (ctx.h[i >> 2] >> (8 * (i & 3))) & 0xff;
|
|
118462
|
+
}
|
|
118463
|
+
return out
|
|
118464
|
+
}
|
|
118465
|
+
|
|
118466
|
+
// Computes the BLAKE2S hash of a string or byte array, and returns a Uint8Array
|
|
118467
|
+
//
|
|
118468
|
+
// Returns a n-byte Uint8Array
|
|
118469
|
+
//
|
|
118470
|
+
// Parameters:
|
|
118471
|
+
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118472
|
+
// - key - optional key Uint8Array, up to 32 bytes
|
|
118473
|
+
// - outlen - optional output length in bytes, default 64
|
|
118474
|
+
function blake2s (input, key, outlen) {
|
|
118475
|
+
// preprocess inputs
|
|
118476
|
+
outlen = outlen || 32;
|
|
118477
|
+
input = util.normalizeInput(input);
|
|
118478
|
+
|
|
118479
|
+
// do the math
|
|
118480
|
+
const ctx = blake2sInit(outlen, key);
|
|
118481
|
+
blake2sUpdate(ctx, input);
|
|
118482
|
+
return blake2sFinal(ctx)
|
|
118483
|
+
}
|
|
118484
|
+
|
|
118485
|
+
// Computes the BLAKE2S hash of a string or byte array
|
|
118486
|
+
//
|
|
118487
|
+
// Returns an n-byte hash in hex, all lowercase
|
|
118488
|
+
//
|
|
118489
|
+
// Parameters:
|
|
118490
|
+
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118491
|
+
// - key - optional key Uint8Array, up to 32 bytes
|
|
118492
|
+
// - outlen - optional output length in bytes, default 64
|
|
118493
|
+
function blake2sHex (input, key, outlen) {
|
|
118494
|
+
const output = blake2s(input, key, outlen);
|
|
118495
|
+
return util.toHex(output)
|
|
118496
|
+
}
|
|
118497
|
+
|
|
118498
|
+
var blake2s_1 = {
|
|
118499
|
+
blake2s: blake2s,
|
|
118500
|
+
blake2sHex: blake2sHex,
|
|
118501
|
+
blake2sInit: blake2sInit,
|
|
118502
|
+
blake2sUpdate: blake2sUpdate,
|
|
118503
|
+
blake2sFinal: blake2sFinal
|
|
118504
|
+
};
|
|
118543
118505
|
|
|
118544
|
-
|
|
118545
|
-
|
|
118546
|
-
|
|
118547
|
-
|
|
118548
|
-
|
|
118549
|
-
|
|
118550
|
-
|
|
118551
|
-
|
|
118552
|
-
|
|
118553
|
-
|
|
118554
|
-
|
|
118555
|
-
|
|
118556
|
-
|
|
118557
|
-
|
|
118506
|
+
const b2b = blake2b_1;
|
|
118507
|
+
const b2s = blake2s_1;
|
|
118508
|
+
|
|
118509
|
+
var blakejs = {
|
|
118510
|
+
blake2b: b2b.blake2b,
|
|
118511
|
+
blake2bHex: b2b.blake2bHex,
|
|
118512
|
+
blake2bInit: b2b.blake2bInit,
|
|
118513
|
+
blake2bUpdate: b2b.blake2bUpdate,
|
|
118514
|
+
blake2bFinal: b2b.blake2bFinal,
|
|
118515
|
+
blake2s: b2s.blake2s,
|
|
118516
|
+
blake2sHex: b2s.blake2sHex,
|
|
118517
|
+
blake2sInit: b2s.blake2sInit,
|
|
118518
|
+
blake2sUpdate: b2s.blake2sUpdate,
|
|
118519
|
+
blake2sFinal: b2s.blake2sFinal
|
|
118520
|
+
};
|
|
118558
118521
|
|
|
118559
118522
|
var hasRequiredHash;
|
|
118560
118523
|
|
|
@@ -118563,12 +118526,12 @@ function requireHash () {
|
|
|
118563
118526
|
hasRequiredHash = 1;
|
|
118564
118527
|
Object.defineProperty(hash, "__esModule", { value: true });
|
|
118565
118528
|
hash.ripemd160 = hash.blake128WithKey = hash.blake128 = hash.blake160WithKey = hash.blake160 = hash.blake256WithKey = hash.blake256 = void 0;
|
|
118566
|
-
const crypto_js_1 =
|
|
118529
|
+
const crypto_js_1 = cryptoJsExports;
|
|
118567
118530
|
const utility_1 = requireUtility();
|
|
118568
118531
|
/**
|
|
118569
118532
|
* @hidden
|
|
118570
118533
|
*/
|
|
118571
|
-
const blake =
|
|
118534
|
+
const blake = blakejs;
|
|
118572
118535
|
/**
|
|
118573
118536
|
* Gets data's 256 bit blake hash.
|
|
118574
118537
|
* @param data buffer or hexadecimal string
|
|
@@ -124893,6 +124856,7 @@ $root.common = (function() {
|
|
|
124893
124856
|
* @property {string|null} [symbol] Asset symbol
|
|
124894
124857
|
* @property {string|null} [ticker] Asset ticker
|
|
124895
124858
|
* @property {boolean|null} [synth] Asset synth
|
|
124859
|
+
* @property {boolean|null} [trade] Asset trade
|
|
124896
124860
|
*/
|
|
124897
124861
|
|
|
124898
124862
|
/**
|
|
@@ -124942,6 +124906,14 @@ $root.common = (function() {
|
|
|
124942
124906
|
*/
|
|
124943
124907
|
Asset.prototype.synth = false;
|
|
124944
124908
|
|
|
124909
|
+
/**
|
|
124910
|
+
* Asset trade.
|
|
124911
|
+
* @member {boolean} trade
|
|
124912
|
+
* @memberof common.Asset
|
|
124913
|
+
* @instance
|
|
124914
|
+
*/
|
|
124915
|
+
Asset.prototype.trade = false;
|
|
124916
|
+
|
|
124945
124917
|
/**
|
|
124946
124918
|
* Creates a new Asset instance using the specified properties.
|
|
124947
124919
|
* @function create
|
|
@@ -124974,6 +124946,8 @@ $root.common = (function() {
|
|
|
124974
124946
|
writer.uint32(/* id 3, wireType 2 =*/26).string(message.ticker);
|
|
124975
124947
|
if (message.synth != null && Object.hasOwnProperty.call(message, "synth"))
|
|
124976
124948
|
writer.uint32(/* id 4, wireType 0 =*/32).bool(message.synth);
|
|
124949
|
+
if (message.trade != null && Object.hasOwnProperty.call(message, "trade"))
|
|
124950
|
+
writer.uint32(/* id 5, wireType 0 =*/40).bool(message.trade);
|
|
124977
124951
|
return writer;
|
|
124978
124952
|
};
|
|
124979
124953
|
|
|
@@ -125020,6 +124994,9 @@ $root.common = (function() {
|
|
|
125020
124994
|
case 4:
|
|
125021
124995
|
message.synth = reader.bool();
|
|
125022
124996
|
break;
|
|
124997
|
+
case 5:
|
|
124998
|
+
message.trade = reader.bool();
|
|
124999
|
+
break;
|
|
125023
125000
|
default:
|
|
125024
125001
|
reader.skipType(tag & 7);
|
|
125025
125002
|
break;
|
|
@@ -125067,6 +125044,9 @@ $root.common = (function() {
|
|
|
125067
125044
|
if (message.synth != null && message.hasOwnProperty("synth"))
|
|
125068
125045
|
if (typeof message.synth !== "boolean")
|
|
125069
125046
|
return "synth: boolean expected";
|
|
125047
|
+
if (message.trade != null && message.hasOwnProperty("trade"))
|
|
125048
|
+
if (typeof message.trade !== "boolean")
|
|
125049
|
+
return "trade: boolean expected";
|
|
125070
125050
|
return null;
|
|
125071
125051
|
};
|
|
125072
125052
|
|
|
@@ -125090,6 +125070,8 @@ $root.common = (function() {
|
|
|
125090
125070
|
message.ticker = String(object.ticker);
|
|
125091
125071
|
if (object.synth != null)
|
|
125092
125072
|
message.synth = Boolean(object.synth);
|
|
125073
|
+
if (object.trade != null)
|
|
125074
|
+
message.trade = Boolean(object.trade);
|
|
125093
125075
|
return message;
|
|
125094
125076
|
};
|
|
125095
125077
|
|
|
@@ -125111,6 +125093,7 @@ $root.common = (function() {
|
|
|
125111
125093
|
object.symbol = "";
|
|
125112
125094
|
object.ticker = "";
|
|
125113
125095
|
object.synth = false;
|
|
125096
|
+
object.trade = false;
|
|
125114
125097
|
}
|
|
125115
125098
|
if (message.chain != null && message.hasOwnProperty("chain"))
|
|
125116
125099
|
object.chain = message.chain;
|
|
@@ -125120,6 +125103,8 @@ $root.common = (function() {
|
|
|
125120
125103
|
object.ticker = message.ticker;
|
|
125121
125104
|
if (message.synth != null && message.hasOwnProperty("synth"))
|
|
125122
125105
|
object.synth = message.synth;
|
|
125106
|
+
if (message.trade != null && message.hasOwnProperty("trade"))
|
|
125107
|
+
object.trade = message.trade;
|
|
125123
125108
|
return object;
|
|
125124
125109
|
};
|
|
125125
125110
|
|
|
@@ -126193,6 +126178,193 @@ $root.common = (function() {
|
|
|
126193
126178
|
return Fee;
|
|
126194
126179
|
})();
|
|
126195
126180
|
|
|
126181
|
+
common.ProtoUint = (function() {
|
|
126182
|
+
|
|
126183
|
+
/**
|
|
126184
|
+
* Properties of a ProtoUint.
|
|
126185
|
+
* @memberof common
|
|
126186
|
+
* @interface IProtoUint
|
|
126187
|
+
* @property {string|null} [value] ProtoUint value
|
|
126188
|
+
*/
|
|
126189
|
+
|
|
126190
|
+
/**
|
|
126191
|
+
* Constructs a new ProtoUint.
|
|
126192
|
+
* @memberof common
|
|
126193
|
+
* @classdesc Represents a ProtoUint.
|
|
126194
|
+
* @implements IProtoUint
|
|
126195
|
+
* @constructor
|
|
126196
|
+
* @param {common.IProtoUint=} [properties] Properties to set
|
|
126197
|
+
*/
|
|
126198
|
+
function ProtoUint(properties) {
|
|
126199
|
+
if (properties)
|
|
126200
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
126201
|
+
if (properties[keys[i]] != null)
|
|
126202
|
+
this[keys[i]] = properties[keys[i]];
|
|
126203
|
+
}
|
|
126204
|
+
|
|
126205
|
+
/**
|
|
126206
|
+
* ProtoUint value.
|
|
126207
|
+
* @member {string} value
|
|
126208
|
+
* @memberof common.ProtoUint
|
|
126209
|
+
* @instance
|
|
126210
|
+
*/
|
|
126211
|
+
ProtoUint.prototype.value = "";
|
|
126212
|
+
|
|
126213
|
+
/**
|
|
126214
|
+
* Creates a new ProtoUint instance using the specified properties.
|
|
126215
|
+
* @function create
|
|
126216
|
+
* @memberof common.ProtoUint
|
|
126217
|
+
* @static
|
|
126218
|
+
* @param {common.IProtoUint=} [properties] Properties to set
|
|
126219
|
+
* @returns {common.ProtoUint} ProtoUint instance
|
|
126220
|
+
*/
|
|
126221
|
+
ProtoUint.create = function create(properties) {
|
|
126222
|
+
return new ProtoUint(properties);
|
|
126223
|
+
};
|
|
126224
|
+
|
|
126225
|
+
/**
|
|
126226
|
+
* Encodes the specified ProtoUint message. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
|
|
126227
|
+
* @function encode
|
|
126228
|
+
* @memberof common.ProtoUint
|
|
126229
|
+
* @static
|
|
126230
|
+
* @param {common.IProtoUint} message ProtoUint message or plain object to encode
|
|
126231
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
126232
|
+
* @returns {$protobuf.Writer} Writer
|
|
126233
|
+
*/
|
|
126234
|
+
ProtoUint.encode = function encode(message, writer) {
|
|
126235
|
+
if (!writer)
|
|
126236
|
+
writer = $Writer.create();
|
|
126237
|
+
if (message.value != null && Object.hasOwnProperty.call(message, "value"))
|
|
126238
|
+
writer.uint32(/* id 1, wireType 2 =*/10).string(message.value);
|
|
126239
|
+
return writer;
|
|
126240
|
+
};
|
|
126241
|
+
|
|
126242
|
+
/**
|
|
126243
|
+
* Encodes the specified ProtoUint message, length delimited. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
|
|
126244
|
+
* @function encodeDelimited
|
|
126245
|
+
* @memberof common.ProtoUint
|
|
126246
|
+
* @static
|
|
126247
|
+
* @param {common.IProtoUint} message ProtoUint message or plain object to encode
|
|
126248
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
126249
|
+
* @returns {$protobuf.Writer} Writer
|
|
126250
|
+
*/
|
|
126251
|
+
ProtoUint.encodeDelimited = function encodeDelimited(message, writer) {
|
|
126252
|
+
return this.encode(message, writer).ldelim();
|
|
126253
|
+
};
|
|
126254
|
+
|
|
126255
|
+
/**
|
|
126256
|
+
* Decodes a ProtoUint message from the specified reader or buffer.
|
|
126257
|
+
* @function decode
|
|
126258
|
+
* @memberof common.ProtoUint
|
|
126259
|
+
* @static
|
|
126260
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
126261
|
+
* @param {number} [length] Message length if known beforehand
|
|
126262
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126263
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
126264
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
126265
|
+
*/
|
|
126266
|
+
ProtoUint.decode = function decode(reader, length) {
|
|
126267
|
+
if (!(reader instanceof $Reader))
|
|
126268
|
+
reader = $Reader.create(reader);
|
|
126269
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.common.ProtoUint();
|
|
126270
|
+
while (reader.pos < end) {
|
|
126271
|
+
var tag = reader.uint32();
|
|
126272
|
+
switch (tag >>> 3) {
|
|
126273
|
+
case 1:
|
|
126274
|
+
message.value = reader.string();
|
|
126275
|
+
break;
|
|
126276
|
+
default:
|
|
126277
|
+
reader.skipType(tag & 7);
|
|
126278
|
+
break;
|
|
126279
|
+
}
|
|
126280
|
+
}
|
|
126281
|
+
return message;
|
|
126282
|
+
};
|
|
126283
|
+
|
|
126284
|
+
/**
|
|
126285
|
+
* Decodes a ProtoUint message from the specified reader or buffer, length delimited.
|
|
126286
|
+
* @function decodeDelimited
|
|
126287
|
+
* @memberof common.ProtoUint
|
|
126288
|
+
* @static
|
|
126289
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
126290
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126291
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
126292
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
126293
|
+
*/
|
|
126294
|
+
ProtoUint.decodeDelimited = function decodeDelimited(reader) {
|
|
126295
|
+
if (!(reader instanceof $Reader))
|
|
126296
|
+
reader = new $Reader(reader);
|
|
126297
|
+
return this.decode(reader, reader.uint32());
|
|
126298
|
+
};
|
|
126299
|
+
|
|
126300
|
+
/**
|
|
126301
|
+
* Verifies a ProtoUint message.
|
|
126302
|
+
* @function verify
|
|
126303
|
+
* @memberof common.ProtoUint
|
|
126304
|
+
* @static
|
|
126305
|
+
* @param {Object.<string,*>} message Plain object to verify
|
|
126306
|
+
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
|
126307
|
+
*/
|
|
126308
|
+
ProtoUint.verify = function verify(message) {
|
|
126309
|
+
if (typeof message !== "object" || message === null)
|
|
126310
|
+
return "object expected";
|
|
126311
|
+
if (message.value != null && message.hasOwnProperty("value"))
|
|
126312
|
+
if (!$util.isString(message.value))
|
|
126313
|
+
return "value: string expected";
|
|
126314
|
+
return null;
|
|
126315
|
+
};
|
|
126316
|
+
|
|
126317
|
+
/**
|
|
126318
|
+
* Creates a ProtoUint message from a plain object. Also converts values to their respective internal types.
|
|
126319
|
+
* @function fromObject
|
|
126320
|
+
* @memberof common.ProtoUint
|
|
126321
|
+
* @static
|
|
126322
|
+
* @param {Object.<string,*>} object Plain object
|
|
126323
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126324
|
+
*/
|
|
126325
|
+
ProtoUint.fromObject = function fromObject(object) {
|
|
126326
|
+
if (object instanceof $root.common.ProtoUint)
|
|
126327
|
+
return object;
|
|
126328
|
+
var message = new $root.common.ProtoUint();
|
|
126329
|
+
if (object.value != null)
|
|
126330
|
+
message.value = String(object.value);
|
|
126331
|
+
return message;
|
|
126332
|
+
};
|
|
126333
|
+
|
|
126334
|
+
/**
|
|
126335
|
+
* Creates a plain object from a ProtoUint message. Also converts values to other types if specified.
|
|
126336
|
+
* @function toObject
|
|
126337
|
+
* @memberof common.ProtoUint
|
|
126338
|
+
* @static
|
|
126339
|
+
* @param {common.ProtoUint} message ProtoUint
|
|
126340
|
+
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
|
126341
|
+
* @returns {Object.<string,*>} Plain object
|
|
126342
|
+
*/
|
|
126343
|
+
ProtoUint.toObject = function toObject(message, options) {
|
|
126344
|
+
if (!options)
|
|
126345
|
+
options = {};
|
|
126346
|
+
var object = {};
|
|
126347
|
+
if (options.defaults)
|
|
126348
|
+
object.value = "";
|
|
126349
|
+
if (message.value != null && message.hasOwnProperty("value"))
|
|
126350
|
+
object.value = message.value;
|
|
126351
|
+
return object;
|
|
126352
|
+
};
|
|
126353
|
+
|
|
126354
|
+
/**
|
|
126355
|
+
* Converts this ProtoUint to JSON.
|
|
126356
|
+
* @function toJSON
|
|
126357
|
+
* @memberof common.ProtoUint
|
|
126358
|
+
* @instance
|
|
126359
|
+
* @returns {Object.<string,*>} JSON object
|
|
126360
|
+
*/
|
|
126361
|
+
ProtoUint.prototype.toJSON = function toJSON() {
|
|
126362
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
126363
|
+
};
|
|
126364
|
+
|
|
126365
|
+
return ProtoUint;
|
|
126366
|
+
})();
|
|
126367
|
+
|
|
126196
126368
|
return common;
|
|
126197
126369
|
})();
|
|
126198
126370
|
|
|
@@ -127622,14 +127794,14 @@ const getExplorerTxUrl = (tx) => ({
|
|
|
127622
127794
|
/**
|
|
127623
127795
|
* Checks whether an asset is the native RUNE asset
|
|
127624
127796
|
*
|
|
127625
|
-
* @param {
|
|
127797
|
+
* @param {CompatibleAsset} asset
|
|
127626
127798
|
* @returns {boolean} `true` or `false`
|
|
127627
127799
|
*/
|
|
127628
127800
|
const isAssetRuneNative = (asset) => assetToString(asset) === assetToString(AssetRuneNative);
|
|
127629
127801
|
/**
|
|
127630
127802
|
* Get denomination from Asset
|
|
127631
127803
|
*
|
|
127632
|
-
* @param {
|
|
127804
|
+
* @param {CompatibleAsset} asset
|
|
127633
127805
|
* @returns {string} The denomination of the given asset
|
|
127634
127806
|
*/
|
|
127635
127807
|
const getDenom = (asset) => {
|
|
@@ -127720,6 +127892,18 @@ function sortedObject(obj) {
|
|
|
127720
127892
|
function sortAndStringifyJson(obj) {
|
|
127721
127893
|
return JSON.stringify(sortedObject(obj));
|
|
127722
127894
|
}
|
|
127895
|
+
/**
|
|
127896
|
+
* Parse XChainJS asset to Thornode asset
|
|
127897
|
+
*/
|
|
127898
|
+
const parseAssetToTHORNodeAsset = (asset) => {
|
|
127899
|
+
return {
|
|
127900
|
+
chain: asset.chain,
|
|
127901
|
+
symbol: asset.symbol,
|
|
127902
|
+
ticker: asset.ticker,
|
|
127903
|
+
synth: asset.type === AssetType.SYNTH,
|
|
127904
|
+
trade: asset.type === AssetType.TRADE,
|
|
127905
|
+
};
|
|
127906
|
+
};
|
|
127723
127907
|
|
|
127724
127908
|
/**
|
|
127725
127909
|
* Import necessary modules and types for the Thorchain client configuration.
|
|
@@ -127759,7 +127943,12 @@ const THORChain = 'THOR';
|
|
|
127759
127943
|
/**
|
|
127760
127944
|
* Native asset representation for RUNE in Thorchain
|
|
127761
127945
|
*/
|
|
127762
|
-
const AssetRuneNative = {
|
|
127946
|
+
const AssetRuneNative = {
|
|
127947
|
+
chain: THORChain,
|
|
127948
|
+
symbol: RUNE_TICKER,
|
|
127949
|
+
ticker: RUNE_TICKER,
|
|
127950
|
+
type: AssetType.NATIVE,
|
|
127951
|
+
};
|
|
127763
127952
|
/**
|
|
127764
127953
|
* Message type URL used to make send transactions
|
|
127765
127954
|
*/
|
|
@@ -127822,7 +128011,7 @@ class Client extends Client$1 {
|
|
|
127822
128011
|
/**
|
|
127823
128012
|
* Returns the number of the decimals of known assets
|
|
127824
128013
|
*
|
|
127825
|
-
* @param {
|
|
128014
|
+
* @param {CompatibleAsset} asset - Asset of which return the number of decimals
|
|
127826
128015
|
* @returns {number} the number of decimals of the assets
|
|
127827
128016
|
*/
|
|
127828
128017
|
getAssetDecimals(asset) {
|
|
@@ -127860,7 +128049,7 @@ class Client extends Client$1 {
|
|
|
127860
128049
|
* Get Asset from denomination
|
|
127861
128050
|
*
|
|
127862
128051
|
* @param {string} denom The denomination for which to get the asset.
|
|
127863
|
-
* @returns {
|
|
128052
|
+
* @returns {CompatibleAsset|null} The asset of the given denomination.
|
|
127864
128053
|
*/
|
|
127865
128054
|
assetFromDenom(denom) {
|
|
127866
128055
|
if (denom === RUNE_DENOM)
|
|
@@ -127870,7 +128059,7 @@ class Client extends Client$1 {
|
|
|
127870
128059
|
/**
|
|
127871
128060
|
* Get denomination from Asset
|
|
127872
128061
|
*
|
|
127873
|
-
* @param {
|
|
128062
|
+
* @param {CompatibleAsset} asset The asset for which to get the denomination.
|
|
127874
128063
|
* @returns {string} The denomination of the given asset.
|
|
127875
128064
|
*/
|
|
127876
128065
|
getDenom(asset) {
|
|
@@ -128041,7 +128230,7 @@ class ClientKeystore extends Client {
|
|
|
128041
128230
|
*
|
|
128042
128231
|
* @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
|
|
128043
128232
|
* If it is not set, address associated with index 0 will be used
|
|
128044
|
-
* @param {
|
|
128233
|
+
* @param {CompatibleAsset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
|
|
128045
128234
|
* used
|
|
128046
128235
|
* @param {BaseAmount} param.amount The amount that will be deposit
|
|
128047
128236
|
* @param {string} param.memo Optional - The memo associated with the deposit
|
|
@@ -128167,7 +128356,7 @@ class ClientKeystore extends Client {
|
|
|
128167
128356
|
* @param {BigNumber} gasLimit Gas limit for the transaction
|
|
128168
128357
|
* @param {BaseAmount} amount Amount to deposit
|
|
128169
128358
|
* @param {string} memo Deposit memo
|
|
128170
|
-
* @param {
|
|
128359
|
+
* @param {CompatibleAsset} asset Asset to deposit
|
|
128171
128360
|
* @returns {DeliverTxResponse} The transaction broadcasted
|
|
128172
128361
|
*/
|
|
128173
128362
|
roundRobinSignAndBroadcastDeposit(sender, signer, gasLimit, amount, memo, asset) {
|
|
@@ -128187,7 +128376,7 @@ class ClientKeystore extends Client {
|
|
|
128187
128376
|
coins: [
|
|
128188
128377
|
{
|
|
128189
128378
|
amount: amount.amount().toString(),
|
|
128190
|
-
asset,
|
|
128379
|
+
asset: parseAssetToTHORNodeAsset(asset),
|
|
128191
128380
|
},
|
|
128192
128381
|
],
|
|
128193
128382
|
},
|
|
@@ -128416,7 +128605,7 @@ class ClientLedger extends Client {
|
|
|
128416
128605
|
signer: bech32ToBase64(params.signer),
|
|
128417
128606
|
memo: params.memo,
|
|
128418
128607
|
coins: params.coins.map((coin) => {
|
|
128419
|
-
return Object.assign(Object.assign({}, coin), { asset: assetFromStringEx(coin.asset) });
|
|
128608
|
+
return Object.assign(Object.assign({}, coin), { asset: parseAssetToTHORNodeAsset(assetFromStringEx(coin.asset)) });
|
|
128420
128609
|
}),
|
|
128421
128610
|
}),
|
|
128422
128611
|
},
|
|
@@ -128424,5 +128613,5 @@ class ClientLedger extends Client {
|
|
|
128424
128613
|
}
|
|
128425
128614
|
}
|
|
128426
128615
|
|
|
128427
|
-
export { AssetRuneNative, ClientKeystore as Client, ClientKeystore, ClientLedger, DEFAULT_EXPLORER_URL, DEFAULT_FEE, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MSG_DEPOSIT_TYPE_URL, MSG_SEND_TYPE_URL, RUNE_DECIMAL, RUNE_DENOM, RUNE_TICKER, THORChain, defaultClientConfig, getChainId, getDefaultClientUrls, getDefaultExplorers, getDefaultRootDerivationPaths, getDenom, getExplorerAddressUrl, getExplorerTxUrl, getPrefix, isAssetRuneNative, parseDerivationPath, sortAndStringifyJson, sortedObject };
|
|
128616
|
+
export { AssetRuneNative, ClientKeystore as Client, ClientKeystore, ClientLedger, DEFAULT_EXPLORER_URL, DEFAULT_FEE, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MSG_DEPOSIT_TYPE_URL, MSG_SEND_TYPE_URL, RUNE_DECIMAL, RUNE_DENOM, RUNE_TICKER, THORChain, defaultClientConfig, getChainId, getDefaultClientUrls, getDefaultExplorers, getDefaultRootDerivationPaths, getDenom, getExplorerAddressUrl, getExplorerTxUrl, getPrefix, isAssetRuneNative, parseAssetToTHORNodeAsset, parseDerivationPath, sortAndStringifyJson, sortedObject };
|
|
128428
128617
|
//# sourceMappingURL=index.esm.js.map
|