@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.js
CHANGED
|
@@ -5540,13 +5540,13 @@ function requireMinimal () {
|
|
|
5540
5540
|
|
|
5541
5541
|
var writer = Writer$1;
|
|
5542
5542
|
|
|
5543
|
-
var util$
|
|
5543
|
+
var util$7 = requireMinimal();
|
|
5544
5544
|
|
|
5545
5545
|
var BufferWriter$1; // cyclic
|
|
5546
5546
|
|
|
5547
|
-
var LongBits$1 = util$
|
|
5548
|
-
base64 = util$
|
|
5549
|
-
utf8$1 = util$
|
|
5547
|
+
var LongBits$1 = util$7.LongBits,
|
|
5548
|
+
base64 = util$7.base64,
|
|
5549
|
+
utf8$1 = util$7.utf8;
|
|
5550
5550
|
|
|
5551
5551
|
/**
|
|
5552
5552
|
* Constructs a new writer operation instance.
|
|
@@ -5661,7 +5661,7 @@ function Writer$1() {
|
|
|
5661
5661
|
}
|
|
5662
5662
|
|
|
5663
5663
|
var create$1 = function create() {
|
|
5664
|
-
return util$
|
|
5664
|
+
return util$7.Buffer
|
|
5665
5665
|
? function create_buffer_setup() {
|
|
5666
5666
|
return (Writer$1.create = function create_buffer() {
|
|
5667
5667
|
return new BufferWriter$1();
|
|
@@ -5686,13 +5686,13 @@ Writer$1.create = create$1();
|
|
|
5686
5686
|
* @returns {Uint8Array} Buffer
|
|
5687
5687
|
*/
|
|
5688
5688
|
Writer$1.alloc = function alloc(size) {
|
|
5689
|
-
return new util$
|
|
5689
|
+
return new util$7.Array(size);
|
|
5690
5690
|
};
|
|
5691
5691
|
|
|
5692
5692
|
// Use Uint8Array buffer pool in the browser, just like node does with buffers
|
|
5693
5693
|
/* istanbul ignore else */
|
|
5694
|
-
if (util$
|
|
5695
|
-
Writer$1.alloc = util$
|
|
5694
|
+
if (util$7.Array !== Array)
|
|
5695
|
+
Writer$1.alloc = util$7.pool(Writer$1.alloc, util$7.Array.prototype.subarray);
|
|
5696
5696
|
|
|
5697
5697
|
/**
|
|
5698
5698
|
* Pushes a new operation to the queue.
|
|
@@ -5882,7 +5882,7 @@ Writer$1.prototype.sfixed64 = Writer$1.prototype.fixed64;
|
|
|
5882
5882
|
* @returns {Writer} `this`
|
|
5883
5883
|
*/
|
|
5884
5884
|
Writer$1.prototype.float = function write_float(value) {
|
|
5885
|
-
return this._push(util$
|
|
5885
|
+
return this._push(util$7.float.writeFloatLE, 4, value);
|
|
5886
5886
|
};
|
|
5887
5887
|
|
|
5888
5888
|
/**
|
|
@@ -5892,10 +5892,10 @@ Writer$1.prototype.float = function write_float(value) {
|
|
|
5892
5892
|
* @returns {Writer} `this`
|
|
5893
5893
|
*/
|
|
5894
5894
|
Writer$1.prototype.double = function write_double(value) {
|
|
5895
|
-
return this._push(util$
|
|
5895
|
+
return this._push(util$7.float.writeDoubleLE, 8, value);
|
|
5896
5896
|
};
|
|
5897
5897
|
|
|
5898
|
-
var writeBytes = util$
|
|
5898
|
+
var writeBytes = util$7.Array.prototype.set
|
|
5899
5899
|
? function writeBytes_set(val, buf, pos) {
|
|
5900
5900
|
buf.set(val, pos); // also works for plain array values
|
|
5901
5901
|
}
|
|
@@ -5914,7 +5914,7 @@ Writer$1.prototype.bytes = function write_bytes(value) {
|
|
|
5914
5914
|
var len = value.length >>> 0;
|
|
5915
5915
|
if (!len)
|
|
5916
5916
|
return this._push(writeByte, 1, 0);
|
|
5917
|
-
if (util$
|
|
5917
|
+
if (util$7.isString(value)) {
|
|
5918
5918
|
var buf = Writer$1.alloc(len = base64.length(value));
|
|
5919
5919
|
base64.decode(value, buf, 0);
|
|
5920
5920
|
value = buf;
|
|
@@ -6009,7 +6009,7 @@ var writer_buffer = BufferWriter;
|
|
|
6009
6009
|
var Writer = writer;
|
|
6010
6010
|
(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
|
|
6011
6011
|
|
|
6012
|
-
var util$
|
|
6012
|
+
var util$6 = requireMinimal();
|
|
6013
6013
|
|
|
6014
6014
|
/**
|
|
6015
6015
|
* Constructs a new buffer writer instance.
|
|
@@ -6028,9 +6028,9 @@ BufferWriter._configure = function () {
|
|
|
6028
6028
|
* @param {number} size Buffer size
|
|
6029
6029
|
* @returns {Buffer} Buffer
|
|
6030
6030
|
*/
|
|
6031
|
-
BufferWriter.alloc = util$
|
|
6031
|
+
BufferWriter.alloc = util$6._Buffer_allocUnsafe;
|
|
6032
6032
|
|
|
6033
|
-
BufferWriter.writeBytesBuffer = util$
|
|
6033
|
+
BufferWriter.writeBytesBuffer = util$6.Buffer && util$6.Buffer.prototype instanceof Uint8Array && util$6.Buffer.prototype.set.name === "set"
|
|
6034
6034
|
? function writeBytesBuffer_set(val, buf, pos) {
|
|
6035
6035
|
buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)
|
|
6036
6036
|
// also works for plain array values
|
|
@@ -6049,8 +6049,8 @@ BufferWriter._configure = function () {
|
|
|
6049
6049
|
* @override
|
|
6050
6050
|
*/
|
|
6051
6051
|
BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
|
|
6052
|
-
if (util$
|
|
6053
|
-
value = util$
|
|
6052
|
+
if (util$6.isString(value))
|
|
6053
|
+
value = util$6._Buffer_from(value, "base64");
|
|
6054
6054
|
var len = value.length >>> 0;
|
|
6055
6055
|
this.uint32(len);
|
|
6056
6056
|
if (len)
|
|
@@ -6060,7 +6060,7 @@ BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
|
|
|
6060
6060
|
|
|
6061
6061
|
function writeStringBuffer(val, buf, pos) {
|
|
6062
6062
|
if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)
|
|
6063
|
-
util$
|
|
6063
|
+
util$6.utf8.write(val, buf, pos);
|
|
6064
6064
|
else if (buf.utf8Write)
|
|
6065
6065
|
buf.utf8Write(val, pos);
|
|
6066
6066
|
else
|
|
@@ -6071,7 +6071,7 @@ function writeStringBuffer(val, buf, pos) {
|
|
|
6071
6071
|
* @override
|
|
6072
6072
|
*/
|
|
6073
6073
|
BufferWriter.prototype.string = function write_string_buffer(value) {
|
|
6074
|
-
var len = util$
|
|
6074
|
+
var len = util$6.Buffer.byteLength(value);
|
|
6075
6075
|
this.uint32(len);
|
|
6076
6076
|
if (len)
|
|
6077
6077
|
this._push(writeStringBuffer, len, value);
|
|
@@ -6090,12 +6090,12 @@ BufferWriter._configure();
|
|
|
6090
6090
|
|
|
6091
6091
|
var reader = Reader$1;
|
|
6092
6092
|
|
|
6093
|
-
var util$
|
|
6093
|
+
var util$5 = requireMinimal();
|
|
6094
6094
|
|
|
6095
6095
|
var BufferReader$1; // cyclic
|
|
6096
6096
|
|
|
6097
|
-
var LongBits = util$
|
|
6098
|
-
utf8 = util$
|
|
6097
|
+
var LongBits = util$5.LongBits,
|
|
6098
|
+
utf8 = util$5.utf8;
|
|
6099
6099
|
|
|
6100
6100
|
/* istanbul ignore next */
|
|
6101
6101
|
function indexOutOfRange(reader, writeLength) {
|
|
@@ -6143,10 +6143,10 @@ var create_array = typeof Uint8Array !== "undefined"
|
|
|
6143
6143
|
};
|
|
6144
6144
|
|
|
6145
6145
|
var create = function create() {
|
|
6146
|
-
return util$
|
|
6146
|
+
return util$5.Buffer
|
|
6147
6147
|
? function create_buffer_setup(buffer) {
|
|
6148
6148
|
return (Reader$1.create = function create_buffer(buffer) {
|
|
6149
|
-
return util$
|
|
6149
|
+
return util$5.Buffer.isBuffer(buffer)
|
|
6150
6150
|
? new BufferReader$1(buffer)
|
|
6151
6151
|
/* istanbul ignore next */
|
|
6152
6152
|
: create_array(buffer);
|
|
@@ -6165,7 +6165,7 @@ var create = function create() {
|
|
|
6165
6165
|
*/
|
|
6166
6166
|
Reader$1.create = create();
|
|
6167
6167
|
|
|
6168
|
-
Reader$1.prototype._slice = util$
|
|
6168
|
+
Reader$1.prototype._slice = util$5.Array.prototype.subarray || /* istanbul ignore next */ util$5.Array.prototype.slice;
|
|
6169
6169
|
|
|
6170
6170
|
/**
|
|
6171
6171
|
* Reads a varint as an unsigned 32 bit value.
|
|
@@ -6364,7 +6364,7 @@ Reader$1.prototype.float = function read_float() {
|
|
|
6364
6364
|
if (this.pos + 4 > this.len)
|
|
6365
6365
|
throw indexOutOfRange(this, 4);
|
|
6366
6366
|
|
|
6367
|
-
var value = util$
|
|
6367
|
+
var value = util$5.float.readFloatLE(this.buf, this.pos);
|
|
6368
6368
|
this.pos += 4;
|
|
6369
6369
|
return value;
|
|
6370
6370
|
};
|
|
@@ -6380,7 +6380,7 @@ Reader$1.prototype.double = function read_double() {
|
|
|
6380
6380
|
if (this.pos + 8 > this.len)
|
|
6381
6381
|
throw indexOutOfRange(this, 4);
|
|
6382
6382
|
|
|
6383
|
-
var value = util$
|
|
6383
|
+
var value = util$5.float.readDoubleLE(this.buf, this.pos);
|
|
6384
6384
|
this.pos += 8;
|
|
6385
6385
|
return value;
|
|
6386
6386
|
};
|
|
@@ -6473,8 +6473,8 @@ Reader$1._configure = function(BufferReader_) {
|
|
|
6473
6473
|
Reader$1.create = create();
|
|
6474
6474
|
BufferReader$1._configure();
|
|
6475
6475
|
|
|
6476
|
-
var fn = util$
|
|
6477
|
-
util$
|
|
6476
|
+
var fn = util$5.Long ? "toLong" : /* istanbul ignore next */ "toNumber";
|
|
6477
|
+
util$5.merge(Reader$1.prototype, {
|
|
6478
6478
|
|
|
6479
6479
|
int64: function read_int64() {
|
|
6480
6480
|
return readLongVarint.call(this)[fn](false);
|
|
@@ -6505,7 +6505,7 @@ var reader_buffer = BufferReader;
|
|
|
6505
6505
|
var Reader = reader;
|
|
6506
6506
|
(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
|
|
6507
6507
|
|
|
6508
|
-
var util$
|
|
6508
|
+
var util$4 = requireMinimal();
|
|
6509
6509
|
|
|
6510
6510
|
/**
|
|
6511
6511
|
* Constructs a new buffer reader instance.
|
|
@@ -6526,8 +6526,8 @@ function BufferReader(buffer) {
|
|
|
6526
6526
|
|
|
6527
6527
|
BufferReader._configure = function () {
|
|
6528
6528
|
/* istanbul ignore else */
|
|
6529
|
-
if (util$
|
|
6530
|
-
BufferReader.prototype._slice = util$
|
|
6529
|
+
if (util$4.Buffer)
|
|
6530
|
+
BufferReader.prototype._slice = util$4.Buffer.prototype.slice;
|
|
6531
6531
|
};
|
|
6532
6532
|
|
|
6533
6533
|
|
|
@@ -6554,10 +6554,10 @@ var rpc = {};
|
|
|
6554
6554
|
|
|
6555
6555
|
var service$1 = Service;
|
|
6556
6556
|
|
|
6557
|
-
var util$
|
|
6557
|
+
var util$3 = requireMinimal();
|
|
6558
6558
|
|
|
6559
6559
|
// Extends EventEmitter
|
|
6560
|
-
(Service.prototype = Object.create(util$
|
|
6560
|
+
(Service.prototype = Object.create(util$3.EventEmitter.prototype)).constructor = Service;
|
|
6561
6561
|
|
|
6562
6562
|
/**
|
|
6563
6563
|
* A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
|
|
@@ -6597,7 +6597,7 @@ function Service(rpcImpl, requestDelimited, responseDelimited) {
|
|
|
6597
6597
|
if (typeof rpcImpl !== "function")
|
|
6598
6598
|
throw TypeError("rpcImpl must be a function");
|
|
6599
6599
|
|
|
6600
|
-
util$
|
|
6600
|
+
util$3.EventEmitter.call(this);
|
|
6601
6601
|
|
|
6602
6602
|
/**
|
|
6603
6603
|
* RPC implementation. Becomes `null` once the service is ended.
|
|
@@ -6636,7 +6636,7 @@ Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor,
|
|
|
6636
6636
|
|
|
6637
6637
|
var self = this;
|
|
6638
6638
|
if (!callback)
|
|
6639
|
-
return util$
|
|
6639
|
+
return util$3.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);
|
|
6640
6640
|
|
|
6641
6641
|
if (!self.rpcImpl) {
|
|
6642
6642
|
setTimeout(function() { callback(Error("already ended")); }, 0);
|
|
@@ -115209,25 +115209,20 @@ function requireBlowfish () {
|
|
|
115209
115209
|
|
|
115210
115210
|
cryptoJs.exports;
|
|
115211
115211
|
|
|
115212
|
-
|
|
115213
|
-
|
|
115214
|
-
function requireCryptoJs () {
|
|
115215
|
-
if (hasRequiredCryptoJs) return cryptoJs.exports;
|
|
115216
|
-
hasRequiredCryptoJs = 1;
|
|
115217
|
-
(function (module, exports) {
|
|
115212
|
+
(function (module, exports) {
|
|
115218
115213
|
(function (root, factory, undef) {
|
|
115219
|
-
|
|
115220
|
-
|
|
115221
|
-
|
|
115222
|
-
|
|
115223
|
-
|
|
115214
|
+
{
|
|
115215
|
+
// CommonJS
|
|
115216
|
+
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());
|
|
115217
|
+
}
|
|
115218
|
+
}(commonjsGlobal$1, function (CryptoJS) {
|
|
115224
115219
|
|
|
115225
|
-
|
|
115220
|
+
return CryptoJS;
|
|
115226
115221
|
|
|
115227
|
-
|
|
115228
|
-
|
|
115229
|
-
|
|
115230
|
-
|
|
115222
|
+
}));
|
|
115223
|
+
} (cryptoJs, cryptoJs.exports));
|
|
115224
|
+
|
|
115225
|
+
var cryptoJsExports = cryptoJs.exports;
|
|
115231
115226
|
|
|
115232
115227
|
var utility = {};
|
|
115233
115228
|
|
|
@@ -117732,858 +117727,826 @@ function requireUtility () {
|
|
|
117732
117727
|
return utility;
|
|
117733
117728
|
}
|
|
117734
117729
|
|
|
117735
|
-
|
|
117736
|
-
|
|
117737
|
-
|
|
117738
|
-
function
|
|
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
|
-
|
|
117791
|
-
|
|
117792
|
-
|
|
117793
|
-
|
|
117794
|
-
|
|
117795
|
-
|
|
117796
|
-
|
|
117797
|
-
|
|
117798
|
-
|
|
117799
|
-
|
|
117800
|
-
|
|
117801
|
-
|
|
117802
|
-
|
|
117803
|
-
|
|
117804
|
-
|
|
117805
|
-
|
|
117806
|
-
|
|
117807
|
-
|
|
117808
|
-
|
|
117809
|
-
|
|
117810
|
-
|
|
117811
|
-
|
|
117812
|
-
|
|
117813
|
-
|
|
117814
|
-
|
|
117815
|
-
|
|
117816
|
-
|
|
117817
|
-
|
|
117818
|
-
|
|
117819
|
-
util = {
|
|
117820
|
-
normalizeInput: normalizeInput,
|
|
117821
|
-
toHex: toHex,
|
|
117822
|
-
debugPrint: debugPrint,
|
|
117823
|
-
testSpeed: testSpeed
|
|
117824
|
-
};
|
|
117825
|
-
return util;
|
|
117826
|
-
}
|
|
117827
|
-
|
|
117828
|
-
var blake2b_1;
|
|
117829
|
-
var hasRequiredBlake2b;
|
|
117830
|
-
|
|
117831
|
-
function requireBlake2b () {
|
|
117832
|
-
if (hasRequiredBlake2b) return blake2b_1;
|
|
117833
|
-
hasRequiredBlake2b = 1;
|
|
117834
|
-
// Blake2B in pure Javascript
|
|
117835
|
-
// Adapted from the reference implementation in RFC7693
|
|
117836
|
-
// Ported to Javascript by DC - https://github.com/dcposch
|
|
117837
|
-
|
|
117838
|
-
const util = requireUtil();
|
|
117839
|
-
|
|
117840
|
-
// 64-bit unsigned addition
|
|
117841
|
-
// Sets v[a,a+1] += v[b,b+1]
|
|
117842
|
-
// v should be a Uint32Array
|
|
117843
|
-
function ADD64AA (v, a, b) {
|
|
117844
|
-
const o0 = v[a] + v[b];
|
|
117845
|
-
let o1 = v[a + 1] + v[b + 1];
|
|
117846
|
-
if (o0 >= 0x100000000) {
|
|
117847
|
-
o1++;
|
|
117848
|
-
}
|
|
117849
|
-
v[a] = o0;
|
|
117850
|
-
v[a + 1] = o1;
|
|
117851
|
-
}
|
|
117852
|
-
|
|
117853
|
-
// 64-bit unsigned addition
|
|
117854
|
-
// Sets v[a,a+1] += b
|
|
117855
|
-
// b0 is the low 32 bits of b, b1 represents the high 32 bits
|
|
117856
|
-
function ADD64AC (v, a, b0, b1) {
|
|
117857
|
-
let o0 = v[a] + b0;
|
|
117858
|
-
if (b0 < 0) {
|
|
117859
|
-
o0 += 0x100000000;
|
|
117860
|
-
}
|
|
117861
|
-
let o1 = v[a + 1] + b1;
|
|
117862
|
-
if (o0 >= 0x100000000) {
|
|
117863
|
-
o1++;
|
|
117864
|
-
}
|
|
117865
|
-
v[a] = o0;
|
|
117866
|
-
v[a + 1] = o1;
|
|
117867
|
-
}
|
|
117868
|
-
|
|
117869
|
-
// Little-endian byte access
|
|
117870
|
-
function B2B_GET32 (arr, i) {
|
|
117871
|
-
return arr[i] ^ (arr[i + 1] << 8) ^ (arr[i + 2] << 16) ^ (arr[i + 3] << 24)
|
|
117872
|
-
}
|
|
117873
|
-
|
|
117874
|
-
// G Mixing function
|
|
117875
|
-
// The ROTRs are inlined for speed
|
|
117876
|
-
function B2B_G (a, b, c, d, ix, iy) {
|
|
117877
|
-
const x0 = m[ix];
|
|
117878
|
-
const x1 = m[ix + 1];
|
|
117879
|
-
const y0 = m[iy];
|
|
117880
|
-
const y1 = m[iy + 1];
|
|
117881
|
-
|
|
117882
|
-
ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
|
|
117883
|
-
ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits
|
|
117884
|
-
|
|
117885
|
-
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
|
|
117886
|
-
let xor0 = v[d] ^ v[a];
|
|
117887
|
-
let xor1 = v[d + 1] ^ v[a + 1];
|
|
117888
|
-
v[d] = xor1;
|
|
117889
|
-
v[d + 1] = xor0;
|
|
117890
|
-
|
|
117891
|
-
ADD64AA(v, c, d);
|
|
117892
|
-
|
|
117893
|
-
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
|
|
117894
|
-
xor0 = v[b] ^ v[c];
|
|
117895
|
-
xor1 = v[b + 1] ^ v[c + 1];
|
|
117896
|
-
v[b] = (xor0 >>> 24) ^ (xor1 << 8);
|
|
117897
|
-
v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
|
|
117898
|
-
|
|
117899
|
-
ADD64AA(v, a, b);
|
|
117900
|
-
ADD64AC(v, a, y0, y1);
|
|
117901
|
-
|
|
117902
|
-
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
|
|
117903
|
-
xor0 = v[d] ^ v[a];
|
|
117904
|
-
xor1 = v[d + 1] ^ v[a + 1];
|
|
117905
|
-
v[d] = (xor0 >>> 16) ^ (xor1 << 16);
|
|
117906
|
-
v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
|
|
117907
|
-
|
|
117908
|
-
ADD64AA(v, c, d);
|
|
117909
|
-
|
|
117910
|
-
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
|
|
117911
|
-
xor0 = v[b] ^ v[c];
|
|
117912
|
-
xor1 = v[b + 1] ^ v[c + 1];
|
|
117913
|
-
v[b] = (xor1 >>> 31) ^ (xor0 << 1);
|
|
117914
|
-
v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
|
|
117915
|
-
}
|
|
117916
|
-
|
|
117917
|
-
// Initialization Vector
|
|
117918
|
-
const BLAKE2B_IV32 = new Uint32Array([
|
|
117919
|
-
0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372,
|
|
117920
|
-
0x5f1d36f1, 0xa54ff53a, 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c,
|
|
117921
|
-
0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19
|
|
117922
|
-
]);
|
|
117923
|
-
|
|
117924
|
-
const SIGMA8 = [
|
|
117925
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13,
|
|
117926
|
-
6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1,
|
|
117927
|
-
9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4,
|
|
117928
|
-
10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5,
|
|
117929
|
-
15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7,
|
|
117930
|
-
14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2,
|
|
117931
|
-
13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0,
|
|
117932
|
-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6,
|
|
117933
|
-
1, 12, 0, 2, 11, 7, 5, 3
|
|
117934
|
-
];
|
|
117935
|
-
|
|
117936
|
-
// These are offsets into a uint64 buffer.
|
|
117937
|
-
// Multiply them all by 2 to make them offsets into a uint32 buffer,
|
|
117938
|
-
// because this is Javascript and we don't have uint64s
|
|
117939
|
-
const SIGMA82 = new Uint8Array(
|
|
117940
|
-
SIGMA8.map(function (x) {
|
|
117941
|
-
return x * 2
|
|
117942
|
-
})
|
|
117943
|
-
);
|
|
117944
|
-
|
|
117945
|
-
// Compression function. 'last' flag indicates last block.
|
|
117946
|
-
// Note we're representing 16 uint64s as 32 uint32s
|
|
117947
|
-
const v = new Uint32Array(32);
|
|
117948
|
-
const m = new Uint32Array(32);
|
|
117949
|
-
function blake2bCompress (ctx, last) {
|
|
117950
|
-
let i = 0;
|
|
117951
|
-
|
|
117952
|
-
// init work variables
|
|
117953
|
-
for (i = 0; i < 16; i++) {
|
|
117954
|
-
v[i] = ctx.h[i];
|
|
117955
|
-
v[i + 16] = BLAKE2B_IV32[i];
|
|
117956
|
-
}
|
|
117957
|
-
|
|
117958
|
-
// low 64 bits of offset
|
|
117959
|
-
v[24] = v[24] ^ ctx.t;
|
|
117960
|
-
v[25] = v[25] ^ (ctx.t / 0x100000000);
|
|
117961
|
-
// high 64 bits not supported, offset may not be higher than 2**53-1
|
|
117962
|
-
|
|
117963
|
-
// last block flag set ?
|
|
117964
|
-
if (last) {
|
|
117965
|
-
v[28] = ~v[28];
|
|
117966
|
-
v[29] = ~v[29];
|
|
117967
|
-
}
|
|
117968
|
-
|
|
117969
|
-
// get little-endian words
|
|
117970
|
-
for (i = 0; i < 32; i++) {
|
|
117971
|
-
m[i] = B2B_GET32(ctx.b, 4 * i);
|
|
117972
|
-
}
|
|
117973
|
-
|
|
117974
|
-
// twelve rounds of mixing
|
|
117975
|
-
// uncomment the DebugPrint calls to log the computation
|
|
117976
|
-
// and match the RFC sample documentation
|
|
117977
|
-
// util.debugPrint(' m[16]', m, 64)
|
|
117978
|
-
for (i = 0; i < 12; i++) {
|
|
117979
|
-
// util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64)
|
|
117980
|
-
B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]);
|
|
117981
|
-
B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]);
|
|
117982
|
-
B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]);
|
|
117983
|
-
B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]);
|
|
117984
|
-
B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]);
|
|
117985
|
-
B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]);
|
|
117986
|
-
B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]);
|
|
117987
|
-
B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]);
|
|
117988
|
-
}
|
|
117989
|
-
// util.debugPrint(' (i=12) v[16]', v, 64)
|
|
117990
|
-
|
|
117991
|
-
for (i = 0; i < 16; i++) {
|
|
117992
|
-
ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16];
|
|
117993
|
-
}
|
|
117994
|
-
// util.debugPrint('h[8]', ctx.h, 64)
|
|
117995
|
-
}
|
|
117996
|
-
|
|
117997
|
-
// reusable parameterBlock
|
|
117998
|
-
const parameterBlock = new Uint8Array([
|
|
117999
|
-
0,
|
|
118000
|
-
0,
|
|
118001
|
-
0,
|
|
118002
|
-
0, // 0: outlen, keylen, fanout, depth
|
|
118003
|
-
0,
|
|
118004
|
-
0,
|
|
118005
|
-
0,
|
|
118006
|
-
0, // 4: leaf length, sequential mode
|
|
118007
|
-
0,
|
|
118008
|
-
0,
|
|
118009
|
-
0,
|
|
118010
|
-
0, // 8: node offset
|
|
118011
|
-
0,
|
|
118012
|
-
0,
|
|
118013
|
-
0,
|
|
118014
|
-
0, // 12: node offset
|
|
118015
|
-
0,
|
|
118016
|
-
0,
|
|
118017
|
-
0,
|
|
118018
|
-
0, // 16: node depth, inner length, rfu
|
|
118019
|
-
0,
|
|
118020
|
-
0,
|
|
118021
|
-
0,
|
|
118022
|
-
0, // 20: rfu
|
|
118023
|
-
0,
|
|
118024
|
-
0,
|
|
118025
|
-
0,
|
|
118026
|
-
0, // 24: rfu
|
|
118027
|
-
0,
|
|
118028
|
-
0,
|
|
118029
|
-
0,
|
|
118030
|
-
0, // 28: rfu
|
|
118031
|
-
0,
|
|
118032
|
-
0,
|
|
118033
|
-
0,
|
|
118034
|
-
0, // 32: salt
|
|
118035
|
-
0,
|
|
118036
|
-
0,
|
|
118037
|
-
0,
|
|
118038
|
-
0, // 36: salt
|
|
118039
|
-
0,
|
|
118040
|
-
0,
|
|
118041
|
-
0,
|
|
118042
|
-
0, // 40: salt
|
|
118043
|
-
0,
|
|
118044
|
-
0,
|
|
118045
|
-
0,
|
|
118046
|
-
0, // 44: salt
|
|
118047
|
-
0,
|
|
118048
|
-
0,
|
|
118049
|
-
0,
|
|
118050
|
-
0, // 48: personal
|
|
118051
|
-
0,
|
|
118052
|
-
0,
|
|
118053
|
-
0,
|
|
118054
|
-
0, // 52: personal
|
|
118055
|
-
0,
|
|
118056
|
-
0,
|
|
118057
|
-
0,
|
|
118058
|
-
0, // 56: personal
|
|
118059
|
-
0,
|
|
118060
|
-
0,
|
|
118061
|
-
0,
|
|
118062
|
-
0 // 60: personal
|
|
118063
|
-
]);
|
|
118064
|
-
|
|
118065
|
-
// Creates a BLAKE2b hashing context
|
|
118066
|
-
// Requires an output length between 1 and 64 bytes
|
|
118067
|
-
// Takes an optional Uint8Array key
|
|
118068
|
-
// Takes an optinal Uint8Array salt
|
|
118069
|
-
// Takes an optinal Uint8Array personal
|
|
118070
|
-
function blake2bInit (outlen, key, salt, personal) {
|
|
118071
|
-
if (outlen === 0 || outlen > 64) {
|
|
118072
|
-
throw new Error('Illegal output length, expected 0 < length <= 64')
|
|
118073
|
-
}
|
|
118074
|
-
if (key && key.length > 64) {
|
|
118075
|
-
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64')
|
|
118076
|
-
}
|
|
118077
|
-
if (salt && salt.length !== 16) {
|
|
118078
|
-
throw new Error('Illegal salt, expected Uint8Array with length is 16')
|
|
118079
|
-
}
|
|
118080
|
-
if (personal && personal.length !== 16) {
|
|
118081
|
-
throw new Error('Illegal personal, expected Uint8Array with length is 16')
|
|
118082
|
-
}
|
|
118083
|
-
|
|
118084
|
-
// state, 'param block'
|
|
118085
|
-
const ctx = {
|
|
118086
|
-
b: new Uint8Array(128),
|
|
118087
|
-
h: new Uint32Array(16),
|
|
118088
|
-
t: 0, // input count
|
|
118089
|
-
c: 0, // pointer within buffer
|
|
118090
|
-
outlen: outlen // output length in bytes
|
|
118091
|
-
};
|
|
118092
|
-
|
|
118093
|
-
// initialize parameterBlock before usage
|
|
118094
|
-
parameterBlock.fill(0);
|
|
118095
|
-
parameterBlock[0] = outlen;
|
|
118096
|
-
if (key) parameterBlock[1] = key.length;
|
|
118097
|
-
parameterBlock[2] = 1; // fanout
|
|
118098
|
-
parameterBlock[3] = 1; // depth
|
|
118099
|
-
if (salt) parameterBlock.set(salt, 32);
|
|
118100
|
-
if (personal) parameterBlock.set(personal, 48);
|
|
118101
|
-
|
|
118102
|
-
// initialize hash state
|
|
118103
|
-
for (let i = 0; i < 16; i++) {
|
|
118104
|
-
ctx.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameterBlock, i * 4);
|
|
118105
|
-
}
|
|
118106
|
-
|
|
118107
|
-
// key the hash, if applicable
|
|
118108
|
-
if (key) {
|
|
118109
|
-
blake2bUpdate(ctx, key);
|
|
118110
|
-
// at the end
|
|
118111
|
-
ctx.c = 128;
|
|
118112
|
-
}
|
|
118113
|
-
|
|
118114
|
-
return ctx
|
|
118115
|
-
}
|
|
118116
|
-
|
|
118117
|
-
// Updates a BLAKE2b streaming hash
|
|
118118
|
-
// Requires hash context and Uint8Array (byte array)
|
|
118119
|
-
function blake2bUpdate (ctx, input) {
|
|
118120
|
-
for (let i = 0; i < input.length; i++) {
|
|
118121
|
-
if (ctx.c === 128) {
|
|
118122
|
-
// buffer full ?
|
|
118123
|
-
ctx.t += ctx.c; // add counters
|
|
118124
|
-
blake2bCompress(ctx, false); // compress (not last)
|
|
118125
|
-
ctx.c = 0; // counter to zero
|
|
118126
|
-
}
|
|
118127
|
-
ctx.b[ctx.c++] = input[i];
|
|
118128
|
-
}
|
|
118129
|
-
}
|
|
118130
|
-
|
|
118131
|
-
// Completes a BLAKE2b streaming hash
|
|
118132
|
-
// Returns a Uint8Array containing the message digest
|
|
118133
|
-
function blake2bFinal (ctx) {
|
|
118134
|
-
ctx.t += ctx.c; // mark last block offset
|
|
118135
|
-
|
|
118136
|
-
while (ctx.c < 128) {
|
|
118137
|
-
// fill up with zeros
|
|
118138
|
-
ctx.b[ctx.c++] = 0;
|
|
118139
|
-
}
|
|
118140
|
-
blake2bCompress(ctx, true); // final block flag = 1
|
|
118141
|
-
|
|
118142
|
-
// little endian convert and store
|
|
118143
|
-
const out = new Uint8Array(ctx.outlen);
|
|
118144
|
-
for (let i = 0; i < ctx.outlen; i++) {
|
|
118145
|
-
out[i] = ctx.h[i >> 2] >> (8 * (i & 3));
|
|
118146
|
-
}
|
|
118147
|
-
return out
|
|
118148
|
-
}
|
|
118149
|
-
|
|
118150
|
-
// Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array
|
|
118151
|
-
//
|
|
118152
|
-
// Returns a n-byte Uint8Array
|
|
118153
|
-
//
|
|
118154
|
-
// Parameters:
|
|
118155
|
-
// - input - the input bytes, as a string, Buffer or Uint8Array
|
|
118156
|
-
// - key - optional key Uint8Array, up to 64 bytes
|
|
118157
|
-
// - outlen - optional output length in bytes, default 64
|
|
118158
|
-
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118159
|
-
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118160
|
-
function blake2b (input, key, outlen, salt, personal) {
|
|
118161
|
-
// preprocess inputs
|
|
118162
|
-
outlen = outlen || 64;
|
|
118163
|
-
input = util.normalizeInput(input);
|
|
118164
|
-
if (salt) {
|
|
118165
|
-
salt = util.normalizeInput(salt);
|
|
118166
|
-
}
|
|
118167
|
-
if (personal) {
|
|
118168
|
-
personal = util.normalizeInput(personal);
|
|
118169
|
-
}
|
|
118170
|
-
|
|
118171
|
-
// do the math
|
|
118172
|
-
const ctx = blake2bInit(outlen, key, salt, personal);
|
|
118173
|
-
blake2bUpdate(ctx, input);
|
|
118174
|
-
return blake2bFinal(ctx)
|
|
118175
|
-
}
|
|
118176
|
-
|
|
118177
|
-
// Computes the BLAKE2B hash of a string or byte array
|
|
118178
|
-
//
|
|
118179
|
-
// Returns an n-byte hash in hex, all lowercase
|
|
118180
|
-
//
|
|
118181
|
-
// Parameters:
|
|
118182
|
-
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118183
|
-
// - key - optional key Uint8Array, up to 64 bytes
|
|
118184
|
-
// - outlen - optional output length in bytes, default 64
|
|
118185
|
-
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118186
|
-
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118187
|
-
function blake2bHex (input, key, outlen, salt, personal) {
|
|
118188
|
-
const output = blake2b(input, key, outlen, salt, personal);
|
|
118189
|
-
return util.toHex(output)
|
|
118190
|
-
}
|
|
118191
|
-
|
|
118192
|
-
blake2b_1 = {
|
|
118193
|
-
blake2b: blake2b,
|
|
118194
|
-
blake2bHex: blake2bHex,
|
|
118195
|
-
blake2bInit: blake2bInit,
|
|
118196
|
-
blake2bUpdate: blake2bUpdate,
|
|
118197
|
-
blake2bFinal: blake2bFinal
|
|
118198
|
-
};
|
|
118199
|
-
return blake2b_1;
|
|
118200
|
-
}
|
|
118201
|
-
|
|
118202
|
-
var blake2s_1;
|
|
118203
|
-
var hasRequiredBlake2s;
|
|
118204
|
-
|
|
118205
|
-
function requireBlake2s () {
|
|
118206
|
-
if (hasRequiredBlake2s) return blake2s_1;
|
|
118207
|
-
hasRequiredBlake2s = 1;
|
|
118208
|
-
// BLAKE2s hash function in pure Javascript
|
|
118209
|
-
// Adapted from the reference implementation in RFC7693
|
|
118210
|
-
// Ported to Javascript by DC - https://github.com/dcposch
|
|
118211
|
-
|
|
118212
|
-
const util = requireUtil();
|
|
118213
|
-
|
|
118214
|
-
// Little-endian byte access.
|
|
118215
|
-
// Expects a Uint8Array and an index
|
|
118216
|
-
// Returns the little-endian uint32 at v[i..i+3]
|
|
118217
|
-
function B2S_GET32 (v, i) {
|
|
118218
|
-
return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24)
|
|
118219
|
-
}
|
|
118220
|
-
|
|
118221
|
-
// Mixing function G.
|
|
118222
|
-
function B2S_G (a, b, c, d, x, y) {
|
|
118223
|
-
v[a] = v[a] + v[b] + x;
|
|
118224
|
-
v[d] = ROTR32(v[d] ^ v[a], 16);
|
|
118225
|
-
v[c] = v[c] + v[d];
|
|
118226
|
-
v[b] = ROTR32(v[b] ^ v[c], 12);
|
|
118227
|
-
v[a] = v[a] + v[b] + y;
|
|
118228
|
-
v[d] = ROTR32(v[d] ^ v[a], 8);
|
|
118229
|
-
v[c] = v[c] + v[d];
|
|
118230
|
-
v[b] = ROTR32(v[b] ^ v[c], 7);
|
|
118231
|
-
}
|
|
118232
|
-
|
|
118233
|
-
// 32-bit right rotation
|
|
118234
|
-
// x should be a uint32
|
|
118235
|
-
// y must be between 1 and 31, inclusive
|
|
118236
|
-
function ROTR32 (x, y) {
|
|
118237
|
-
return (x >>> y) ^ (x << (32 - y))
|
|
118238
|
-
}
|
|
118239
|
-
|
|
118240
|
-
// Initialization Vector.
|
|
118241
|
-
const BLAKE2S_IV = new Uint32Array([
|
|
118242
|
-
0x6a09e667,
|
|
118243
|
-
0xbb67ae85,
|
|
118244
|
-
0x3c6ef372,
|
|
118245
|
-
0xa54ff53a,
|
|
118246
|
-
0x510e527f,
|
|
118247
|
-
0x9b05688c,
|
|
118248
|
-
0x1f83d9ab,
|
|
118249
|
-
0x5be0cd19
|
|
118250
|
-
]);
|
|
118251
|
-
|
|
118252
|
-
const SIGMA = new Uint8Array([
|
|
118253
|
-
0,
|
|
118254
|
-
1,
|
|
118255
|
-
2,
|
|
118256
|
-
3,
|
|
118257
|
-
4,
|
|
118258
|
-
5,
|
|
118259
|
-
6,
|
|
118260
|
-
7,
|
|
118261
|
-
8,
|
|
118262
|
-
9,
|
|
118263
|
-
10,
|
|
118264
|
-
11,
|
|
118265
|
-
12,
|
|
118266
|
-
13,
|
|
118267
|
-
14,
|
|
118268
|
-
15,
|
|
118269
|
-
14,
|
|
118270
|
-
10,
|
|
118271
|
-
4,
|
|
118272
|
-
8,
|
|
118273
|
-
9,
|
|
118274
|
-
15,
|
|
118275
|
-
13,
|
|
118276
|
-
6,
|
|
118277
|
-
1,
|
|
118278
|
-
12,
|
|
118279
|
-
0,
|
|
118280
|
-
2,
|
|
118281
|
-
11,
|
|
118282
|
-
7,
|
|
118283
|
-
5,
|
|
118284
|
-
3,
|
|
118285
|
-
11,
|
|
118286
|
-
8,
|
|
118287
|
-
12,
|
|
118288
|
-
0,
|
|
118289
|
-
5,
|
|
118290
|
-
2,
|
|
118291
|
-
15,
|
|
118292
|
-
13,
|
|
118293
|
-
10,
|
|
118294
|
-
14,
|
|
118295
|
-
3,
|
|
118296
|
-
6,
|
|
118297
|
-
7,
|
|
118298
|
-
1,
|
|
118299
|
-
9,
|
|
118300
|
-
4,
|
|
118301
|
-
7,
|
|
118302
|
-
9,
|
|
118303
|
-
3,
|
|
118304
|
-
1,
|
|
118305
|
-
13,
|
|
118306
|
-
12,
|
|
118307
|
-
11,
|
|
118308
|
-
14,
|
|
118309
|
-
2,
|
|
118310
|
-
6,
|
|
118311
|
-
5,
|
|
118312
|
-
10,
|
|
118313
|
-
4,
|
|
118314
|
-
0,
|
|
118315
|
-
15,
|
|
118316
|
-
8,
|
|
118317
|
-
9,
|
|
118318
|
-
0,
|
|
118319
|
-
5,
|
|
118320
|
-
7,
|
|
118321
|
-
2,
|
|
118322
|
-
4,
|
|
118323
|
-
10,
|
|
118324
|
-
15,
|
|
118325
|
-
14,
|
|
118326
|
-
1,
|
|
118327
|
-
11,
|
|
118328
|
-
12,
|
|
118329
|
-
6,
|
|
118330
|
-
8,
|
|
118331
|
-
3,
|
|
118332
|
-
13,
|
|
118333
|
-
2,
|
|
118334
|
-
12,
|
|
118335
|
-
6,
|
|
118336
|
-
10,
|
|
118337
|
-
0,
|
|
118338
|
-
11,
|
|
118339
|
-
8,
|
|
118340
|
-
3,
|
|
118341
|
-
4,
|
|
118342
|
-
13,
|
|
118343
|
-
7,
|
|
118344
|
-
5,
|
|
118345
|
-
15,
|
|
118346
|
-
14,
|
|
118347
|
-
1,
|
|
118348
|
-
9,
|
|
118349
|
-
12,
|
|
118350
|
-
5,
|
|
118351
|
-
1,
|
|
118352
|
-
15,
|
|
118353
|
-
14,
|
|
118354
|
-
13,
|
|
118355
|
-
4,
|
|
118356
|
-
10,
|
|
118357
|
-
0,
|
|
118358
|
-
7,
|
|
118359
|
-
6,
|
|
118360
|
-
3,
|
|
118361
|
-
9,
|
|
118362
|
-
2,
|
|
118363
|
-
8,
|
|
118364
|
-
11,
|
|
118365
|
-
13,
|
|
118366
|
-
11,
|
|
118367
|
-
7,
|
|
118368
|
-
14,
|
|
118369
|
-
12,
|
|
118370
|
-
1,
|
|
118371
|
-
3,
|
|
118372
|
-
9,
|
|
118373
|
-
5,
|
|
118374
|
-
0,
|
|
118375
|
-
15,
|
|
118376
|
-
4,
|
|
118377
|
-
8,
|
|
118378
|
-
6,
|
|
118379
|
-
2,
|
|
118380
|
-
10,
|
|
118381
|
-
6,
|
|
118382
|
-
15,
|
|
118383
|
-
14,
|
|
118384
|
-
9,
|
|
118385
|
-
11,
|
|
118386
|
-
3,
|
|
118387
|
-
0,
|
|
118388
|
-
8,
|
|
118389
|
-
12,
|
|
118390
|
-
2,
|
|
118391
|
-
13,
|
|
118392
|
-
7,
|
|
118393
|
-
1,
|
|
118394
|
-
4,
|
|
118395
|
-
10,
|
|
118396
|
-
5,
|
|
118397
|
-
10,
|
|
118398
|
-
2,
|
|
118399
|
-
8,
|
|
118400
|
-
4,
|
|
118401
|
-
7,
|
|
118402
|
-
6,
|
|
118403
|
-
1,
|
|
118404
|
-
5,
|
|
118405
|
-
15,
|
|
118406
|
-
11,
|
|
118407
|
-
9,
|
|
118408
|
-
14,
|
|
118409
|
-
3,
|
|
118410
|
-
12,
|
|
118411
|
-
13,
|
|
118412
|
-
0
|
|
118413
|
-
]);
|
|
118414
|
-
|
|
118415
|
-
// Compression function. "last" flag indicates last block
|
|
118416
|
-
const v = new Uint32Array(16);
|
|
118417
|
-
const m = new Uint32Array(16);
|
|
118418
|
-
function blake2sCompress (ctx, last) {
|
|
118419
|
-
let i = 0;
|
|
118420
|
-
for (i = 0; i < 8; i++) {
|
|
118421
|
-
// init work variables
|
|
118422
|
-
v[i] = ctx.h[i];
|
|
118423
|
-
v[i + 8] = BLAKE2S_IV[i];
|
|
118424
|
-
}
|
|
118425
|
-
|
|
118426
|
-
v[12] ^= ctx.t; // low 32 bits of offset
|
|
118427
|
-
v[13] ^= ctx.t / 0x100000000; // high 32 bits
|
|
118428
|
-
if (last) {
|
|
118429
|
-
// last block flag set ?
|
|
118430
|
-
v[14] = ~v[14];
|
|
118431
|
-
}
|
|
118432
|
-
|
|
118433
|
-
for (i = 0; i < 16; i++) {
|
|
118434
|
-
// get little-endian words
|
|
118435
|
-
m[i] = B2S_GET32(ctx.b, 4 * i);
|
|
118436
|
-
}
|
|
118437
|
-
|
|
118438
|
-
// ten rounds of mixing
|
|
118439
|
-
// uncomment the DebugPrint calls to log the computation
|
|
118440
|
-
// and match the RFC sample documentation
|
|
118441
|
-
// util.debugPrint(' m[16]', m, 32)
|
|
118442
|
-
for (i = 0; i < 10; i++) {
|
|
118443
|
-
// util.debugPrint(' (i=' + i + ') v[16]', v, 32)
|
|
118444
|
-
B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]);
|
|
118445
|
-
B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]);
|
|
118446
|
-
B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]);
|
|
118447
|
-
B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]);
|
|
118448
|
-
B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]);
|
|
118449
|
-
B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]);
|
|
118450
|
-
B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]);
|
|
118451
|
-
B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]);
|
|
118452
|
-
}
|
|
118453
|
-
// util.debugPrint(' (i=10) v[16]', v, 32)
|
|
118454
|
-
|
|
118455
|
-
for (i = 0; i < 8; i++) {
|
|
118456
|
-
ctx.h[i] ^= v[i] ^ v[i + 8];
|
|
118457
|
-
}
|
|
118458
|
-
// util.debugPrint('h[8]', ctx.h, 32)
|
|
118459
|
-
}
|
|
118460
|
-
|
|
118461
|
-
// Creates a BLAKE2s hashing context
|
|
118462
|
-
// Requires an output length between 1 and 32 bytes
|
|
118463
|
-
// Takes an optional Uint8Array key
|
|
118464
|
-
function blake2sInit (outlen, key) {
|
|
118465
|
-
if (!(outlen > 0 && outlen <= 32)) {
|
|
118466
|
-
throw new Error('Incorrect output length, should be in [1, 32]')
|
|
118467
|
-
}
|
|
118468
|
-
const keylen = key ? key.length : 0;
|
|
118469
|
-
if (key && !(keylen > 0 && keylen <= 32)) {
|
|
118470
|
-
throw new Error('Incorrect key length, should be in [1, 32]')
|
|
118471
|
-
}
|
|
118472
|
-
|
|
118473
|
-
const ctx = {
|
|
118474
|
-
h: new Uint32Array(BLAKE2S_IV), // hash state
|
|
118475
|
-
b: new Uint8Array(64), // input block
|
|
118476
|
-
c: 0, // pointer within block
|
|
118477
|
-
t: 0, // input count
|
|
118478
|
-
outlen: outlen // output length in bytes
|
|
118479
|
-
};
|
|
118480
|
-
ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen;
|
|
118481
|
-
|
|
118482
|
-
if (keylen > 0) {
|
|
118483
|
-
blake2sUpdate(ctx, key);
|
|
118484
|
-
ctx.c = 64; // at the end
|
|
118485
|
-
}
|
|
117730
|
+
const ERROR_MSG_INPUT = 'Input must be an string, Buffer or Uint8Array';
|
|
117731
|
+
|
|
117732
|
+
// For convenience, let people hash a string, not just a Uint8Array
|
|
117733
|
+
function normalizeInput (input) {
|
|
117734
|
+
let ret;
|
|
117735
|
+
if (input instanceof Uint8Array) {
|
|
117736
|
+
ret = input;
|
|
117737
|
+
} else if (typeof input === 'string') {
|
|
117738
|
+
const encoder = new TextEncoder();
|
|
117739
|
+
ret = encoder.encode(input);
|
|
117740
|
+
} else {
|
|
117741
|
+
throw new Error(ERROR_MSG_INPUT)
|
|
117742
|
+
}
|
|
117743
|
+
return ret
|
|
117744
|
+
}
|
|
117745
|
+
|
|
117746
|
+
// Converts a Uint8Array to a hexadecimal string
|
|
117747
|
+
// For example, toHex([255, 0, 255]) returns "ff00ff"
|
|
117748
|
+
function toHex (bytes) {
|
|
117749
|
+
return Array.prototype.map
|
|
117750
|
+
.call(bytes, function (n) {
|
|
117751
|
+
return (n < 16 ? '0' : '') + n.toString(16)
|
|
117752
|
+
})
|
|
117753
|
+
.join('')
|
|
117754
|
+
}
|
|
117755
|
+
|
|
117756
|
+
// Converts any value in [0...2^32-1] to an 8-character hex string
|
|
117757
|
+
function uint32ToHex (val) {
|
|
117758
|
+
return (0x100000000 + val).toString(16).substring(1)
|
|
117759
|
+
}
|
|
117760
|
+
|
|
117761
|
+
// For debugging: prints out hash state in the same format as the RFC
|
|
117762
|
+
// sample computation exactly, so that you can diff
|
|
117763
|
+
function debugPrint (label, arr, size) {
|
|
117764
|
+
let msg = '\n' + label + ' = ';
|
|
117765
|
+
for (let i = 0; i < arr.length; i += 2) {
|
|
117766
|
+
if (size === 32) {
|
|
117767
|
+
msg += uint32ToHex(arr[i]).toUpperCase();
|
|
117768
|
+
msg += ' ';
|
|
117769
|
+
msg += uint32ToHex(arr[i + 1]).toUpperCase();
|
|
117770
|
+
} else if (size === 64) {
|
|
117771
|
+
msg += uint32ToHex(arr[i + 1]).toUpperCase();
|
|
117772
|
+
msg += uint32ToHex(arr[i]).toUpperCase();
|
|
117773
|
+
} else throw new Error('Invalid size ' + size)
|
|
117774
|
+
if (i % 6 === 4) {
|
|
117775
|
+
msg += '\n' + new Array(label.length + 4).join(' ');
|
|
117776
|
+
} else if (i < arr.length - 2) {
|
|
117777
|
+
msg += ' ';
|
|
117778
|
+
}
|
|
117779
|
+
}
|
|
117780
|
+
console.log(msg);
|
|
117781
|
+
}
|
|
117782
|
+
|
|
117783
|
+
// For performance testing: generates N bytes of input, hashes M times
|
|
117784
|
+
// Measures and prints MB/second hash performance each time
|
|
117785
|
+
function testSpeed (hashFn, N, M) {
|
|
117786
|
+
let startMs = new Date().getTime();
|
|
117787
|
+
|
|
117788
|
+
const input = new Uint8Array(N);
|
|
117789
|
+
for (let i = 0; i < N; i++) {
|
|
117790
|
+
input[i] = i % 256;
|
|
117791
|
+
}
|
|
117792
|
+
const genMs = new Date().getTime();
|
|
117793
|
+
console.log('Generated random input in ' + (genMs - startMs) + 'ms');
|
|
117794
|
+
startMs = genMs;
|
|
117795
|
+
|
|
117796
|
+
for (let i = 0; i < M; i++) {
|
|
117797
|
+
const hashHex = hashFn(input);
|
|
117798
|
+
const hashMs = new Date().getTime();
|
|
117799
|
+
const ms = hashMs - startMs;
|
|
117800
|
+
startMs = hashMs;
|
|
117801
|
+
console.log('Hashed in ' + ms + 'ms: ' + hashHex.substring(0, 20) + '...');
|
|
117802
|
+
console.log(
|
|
117803
|
+
Math.round((N / (1 << 20) / (ms / 1000)) * 100) / 100 + ' MB PER SECOND'
|
|
117804
|
+
);
|
|
117805
|
+
}
|
|
117806
|
+
}
|
|
117807
|
+
|
|
117808
|
+
var util$2 = {
|
|
117809
|
+
normalizeInput: normalizeInput,
|
|
117810
|
+
toHex: toHex,
|
|
117811
|
+
debugPrint: debugPrint,
|
|
117812
|
+
testSpeed: testSpeed
|
|
117813
|
+
};
|
|
118486
117814
|
|
|
118487
|
-
|
|
118488
|
-
|
|
117815
|
+
// Blake2B in pure Javascript
|
|
117816
|
+
// Adapted from the reference implementation in RFC7693
|
|
117817
|
+
// Ported to Javascript by DC - https://github.com/dcposch
|
|
117818
|
+
|
|
117819
|
+
const util$1 = util$2;
|
|
117820
|
+
|
|
117821
|
+
// 64-bit unsigned addition
|
|
117822
|
+
// Sets v[a,a+1] += v[b,b+1]
|
|
117823
|
+
// v should be a Uint32Array
|
|
117824
|
+
function ADD64AA (v, a, b) {
|
|
117825
|
+
const o0 = v[a] + v[b];
|
|
117826
|
+
let o1 = v[a + 1] + v[b + 1];
|
|
117827
|
+
if (o0 >= 0x100000000) {
|
|
117828
|
+
o1++;
|
|
117829
|
+
}
|
|
117830
|
+
v[a] = o0;
|
|
117831
|
+
v[a + 1] = o1;
|
|
117832
|
+
}
|
|
117833
|
+
|
|
117834
|
+
// 64-bit unsigned addition
|
|
117835
|
+
// Sets v[a,a+1] += b
|
|
117836
|
+
// b0 is the low 32 bits of b, b1 represents the high 32 bits
|
|
117837
|
+
function ADD64AC (v, a, b0, b1) {
|
|
117838
|
+
let o0 = v[a] + b0;
|
|
117839
|
+
if (b0 < 0) {
|
|
117840
|
+
o0 += 0x100000000;
|
|
117841
|
+
}
|
|
117842
|
+
let o1 = v[a + 1] + b1;
|
|
117843
|
+
if (o0 >= 0x100000000) {
|
|
117844
|
+
o1++;
|
|
117845
|
+
}
|
|
117846
|
+
v[a] = o0;
|
|
117847
|
+
v[a + 1] = o1;
|
|
117848
|
+
}
|
|
117849
|
+
|
|
117850
|
+
// Little-endian byte access
|
|
117851
|
+
function B2B_GET32 (arr, i) {
|
|
117852
|
+
return arr[i] ^ (arr[i + 1] << 8) ^ (arr[i + 2] << 16) ^ (arr[i + 3] << 24)
|
|
117853
|
+
}
|
|
117854
|
+
|
|
117855
|
+
// G Mixing function
|
|
117856
|
+
// The ROTRs are inlined for speed
|
|
117857
|
+
function B2B_G (a, b, c, d, ix, iy) {
|
|
117858
|
+
const x0 = m$1[ix];
|
|
117859
|
+
const x1 = m$1[ix + 1];
|
|
117860
|
+
const y0 = m$1[iy];
|
|
117861
|
+
const y1 = m$1[iy + 1];
|
|
117862
|
+
|
|
117863
|
+
ADD64AA(v$1, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
|
|
117864
|
+
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
|
|
117865
|
+
|
|
117866
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
|
|
117867
|
+
let xor0 = v$1[d] ^ v$1[a];
|
|
117868
|
+
let xor1 = v$1[d + 1] ^ v$1[a + 1];
|
|
117869
|
+
v$1[d] = xor1;
|
|
117870
|
+
v$1[d + 1] = xor0;
|
|
117871
|
+
|
|
117872
|
+
ADD64AA(v$1, c, d);
|
|
117873
|
+
|
|
117874
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
|
|
117875
|
+
xor0 = v$1[b] ^ v$1[c];
|
|
117876
|
+
xor1 = v$1[b + 1] ^ v$1[c + 1];
|
|
117877
|
+
v$1[b] = (xor0 >>> 24) ^ (xor1 << 8);
|
|
117878
|
+
v$1[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
|
|
117879
|
+
|
|
117880
|
+
ADD64AA(v$1, a, b);
|
|
117881
|
+
ADD64AC(v$1, a, y0, y1);
|
|
117882
|
+
|
|
117883
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
|
|
117884
|
+
xor0 = v$1[d] ^ v$1[a];
|
|
117885
|
+
xor1 = v$1[d + 1] ^ v$1[a + 1];
|
|
117886
|
+
v$1[d] = (xor0 >>> 16) ^ (xor1 << 16);
|
|
117887
|
+
v$1[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
|
|
117888
|
+
|
|
117889
|
+
ADD64AA(v$1, c, d);
|
|
117890
|
+
|
|
117891
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
|
|
117892
|
+
xor0 = v$1[b] ^ v$1[c];
|
|
117893
|
+
xor1 = v$1[b + 1] ^ v$1[c + 1];
|
|
117894
|
+
v$1[b] = (xor1 >>> 31) ^ (xor0 << 1);
|
|
117895
|
+
v$1[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
|
|
117896
|
+
}
|
|
117897
|
+
|
|
117898
|
+
// Initialization Vector
|
|
117899
|
+
const BLAKE2B_IV32 = new Uint32Array([
|
|
117900
|
+
0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372,
|
|
117901
|
+
0x5f1d36f1, 0xa54ff53a, 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c,
|
|
117902
|
+
0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19
|
|
117903
|
+
]);
|
|
118489
117904
|
|
|
118490
|
-
|
|
118491
|
-
|
|
118492
|
-
|
|
118493
|
-
|
|
118494
|
-
|
|
118495
|
-
|
|
118496
|
-
|
|
118497
|
-
|
|
118498
|
-
|
|
118499
|
-
|
|
118500
|
-
|
|
118501
|
-
}
|
|
118502
|
-
}
|
|
117905
|
+
const SIGMA8 = [
|
|
117906
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13,
|
|
117907
|
+
6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1,
|
|
117908
|
+
9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4,
|
|
117909
|
+
10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5,
|
|
117910
|
+
15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7,
|
|
117911
|
+
14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2,
|
|
117912
|
+
13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0,
|
|
117913
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6,
|
|
117914
|
+
1, 12, 0, 2, 11, 7, 5, 3
|
|
117915
|
+
];
|
|
118503
117916
|
|
|
118504
|
-
|
|
118505
|
-
|
|
118506
|
-
|
|
118507
|
-
|
|
118508
|
-
|
|
118509
|
-
|
|
118510
|
-
|
|
118511
|
-
|
|
118512
|
-
blake2sCompress(ctx, true); // final block flag = 1
|
|
117917
|
+
// These are offsets into a uint64 buffer.
|
|
117918
|
+
// Multiply them all by 2 to make them offsets into a uint32 buffer,
|
|
117919
|
+
// because this is Javascript and we don't have uint64s
|
|
117920
|
+
const SIGMA82 = new Uint8Array(
|
|
117921
|
+
SIGMA8.map(function (x) {
|
|
117922
|
+
return x * 2
|
|
117923
|
+
})
|
|
117924
|
+
);
|
|
118513
117925
|
|
|
118514
|
-
|
|
118515
|
-
|
|
118516
|
-
|
|
118517
|
-
|
|
118518
|
-
|
|
118519
|
-
|
|
118520
|
-
|
|
117926
|
+
// Compression function. 'last' flag indicates last block.
|
|
117927
|
+
// Note we're representing 16 uint64s as 32 uint32s
|
|
117928
|
+
const v$1 = new Uint32Array(32);
|
|
117929
|
+
const m$1 = new Uint32Array(32);
|
|
117930
|
+
function blake2bCompress (ctx, last) {
|
|
117931
|
+
let i = 0;
|
|
117932
|
+
|
|
117933
|
+
// init work variables
|
|
117934
|
+
for (i = 0; i < 16; i++) {
|
|
117935
|
+
v$1[i] = ctx.h[i];
|
|
117936
|
+
v$1[i + 16] = BLAKE2B_IV32[i];
|
|
117937
|
+
}
|
|
117938
|
+
|
|
117939
|
+
// low 64 bits of offset
|
|
117940
|
+
v$1[24] = v$1[24] ^ ctx.t;
|
|
117941
|
+
v$1[25] = v$1[25] ^ (ctx.t / 0x100000000);
|
|
117942
|
+
// high 64 bits not supported, offset may not be higher than 2**53-1
|
|
117943
|
+
|
|
117944
|
+
// last block flag set ?
|
|
117945
|
+
if (last) {
|
|
117946
|
+
v$1[28] = ~v$1[28];
|
|
117947
|
+
v$1[29] = ~v$1[29];
|
|
117948
|
+
}
|
|
117949
|
+
|
|
117950
|
+
// get little-endian words
|
|
117951
|
+
for (i = 0; i < 32; i++) {
|
|
117952
|
+
m$1[i] = B2B_GET32(ctx.b, 4 * i);
|
|
117953
|
+
}
|
|
117954
|
+
|
|
117955
|
+
// twelve rounds of mixing
|
|
117956
|
+
// uncomment the DebugPrint calls to log the computation
|
|
117957
|
+
// and match the RFC sample documentation
|
|
117958
|
+
// util.debugPrint(' m[16]', m, 64)
|
|
117959
|
+
for (i = 0; i < 12; i++) {
|
|
117960
|
+
// util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64)
|
|
117961
|
+
B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]);
|
|
117962
|
+
B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]);
|
|
117963
|
+
B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]);
|
|
117964
|
+
B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]);
|
|
117965
|
+
B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]);
|
|
117966
|
+
B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]);
|
|
117967
|
+
B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]);
|
|
117968
|
+
B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]);
|
|
117969
|
+
}
|
|
117970
|
+
// util.debugPrint(' (i=12) v[16]', v, 64)
|
|
117971
|
+
|
|
117972
|
+
for (i = 0; i < 16; i++) {
|
|
117973
|
+
ctx.h[i] = ctx.h[i] ^ v$1[i] ^ v$1[i + 16];
|
|
117974
|
+
}
|
|
117975
|
+
// util.debugPrint('h[8]', ctx.h, 64)
|
|
117976
|
+
}
|
|
117977
|
+
|
|
117978
|
+
// reusable parameterBlock
|
|
117979
|
+
const parameterBlock = new Uint8Array([
|
|
117980
|
+
0,
|
|
117981
|
+
0,
|
|
117982
|
+
0,
|
|
117983
|
+
0, // 0: outlen, keylen, fanout, depth
|
|
117984
|
+
0,
|
|
117985
|
+
0,
|
|
117986
|
+
0,
|
|
117987
|
+
0, // 4: leaf length, sequential mode
|
|
117988
|
+
0,
|
|
117989
|
+
0,
|
|
117990
|
+
0,
|
|
117991
|
+
0, // 8: node offset
|
|
117992
|
+
0,
|
|
117993
|
+
0,
|
|
117994
|
+
0,
|
|
117995
|
+
0, // 12: node offset
|
|
117996
|
+
0,
|
|
117997
|
+
0,
|
|
117998
|
+
0,
|
|
117999
|
+
0, // 16: node depth, inner length, rfu
|
|
118000
|
+
0,
|
|
118001
|
+
0,
|
|
118002
|
+
0,
|
|
118003
|
+
0, // 20: rfu
|
|
118004
|
+
0,
|
|
118005
|
+
0,
|
|
118006
|
+
0,
|
|
118007
|
+
0, // 24: rfu
|
|
118008
|
+
0,
|
|
118009
|
+
0,
|
|
118010
|
+
0,
|
|
118011
|
+
0, // 28: rfu
|
|
118012
|
+
0,
|
|
118013
|
+
0,
|
|
118014
|
+
0,
|
|
118015
|
+
0, // 32: salt
|
|
118016
|
+
0,
|
|
118017
|
+
0,
|
|
118018
|
+
0,
|
|
118019
|
+
0, // 36: salt
|
|
118020
|
+
0,
|
|
118021
|
+
0,
|
|
118022
|
+
0,
|
|
118023
|
+
0, // 40: salt
|
|
118024
|
+
0,
|
|
118025
|
+
0,
|
|
118026
|
+
0,
|
|
118027
|
+
0, // 44: salt
|
|
118028
|
+
0,
|
|
118029
|
+
0,
|
|
118030
|
+
0,
|
|
118031
|
+
0, // 48: personal
|
|
118032
|
+
0,
|
|
118033
|
+
0,
|
|
118034
|
+
0,
|
|
118035
|
+
0, // 52: personal
|
|
118036
|
+
0,
|
|
118037
|
+
0,
|
|
118038
|
+
0,
|
|
118039
|
+
0, // 56: personal
|
|
118040
|
+
0,
|
|
118041
|
+
0,
|
|
118042
|
+
0,
|
|
118043
|
+
0 // 60: personal
|
|
118044
|
+
]);
|
|
118521
118045
|
|
|
118522
|
-
|
|
118523
|
-
|
|
118524
|
-
|
|
118525
|
-
|
|
118526
|
-
|
|
118527
|
-
|
|
118528
|
-
|
|
118529
|
-
|
|
118530
|
-
|
|
118531
|
-
|
|
118532
|
-
|
|
118533
|
-
|
|
118534
|
-
|
|
118535
|
-
|
|
118536
|
-
|
|
118537
|
-
|
|
118538
|
-
|
|
118539
|
-
|
|
118540
|
-
|
|
118541
|
-
|
|
118542
|
-
|
|
118543
|
-
|
|
118544
|
-
|
|
118545
|
-
|
|
118546
|
-
|
|
118547
|
-
|
|
118548
|
-
|
|
118549
|
-
|
|
118550
|
-
|
|
118551
|
-
|
|
118552
|
-
|
|
118046
|
+
// Creates a BLAKE2b hashing context
|
|
118047
|
+
// Requires an output length between 1 and 64 bytes
|
|
118048
|
+
// Takes an optional Uint8Array key
|
|
118049
|
+
// Takes an optinal Uint8Array salt
|
|
118050
|
+
// Takes an optinal Uint8Array personal
|
|
118051
|
+
function blake2bInit (outlen, key, salt, personal) {
|
|
118052
|
+
if (outlen === 0 || outlen > 64) {
|
|
118053
|
+
throw new Error('Illegal output length, expected 0 < length <= 64')
|
|
118054
|
+
}
|
|
118055
|
+
if (key && key.length > 64) {
|
|
118056
|
+
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64')
|
|
118057
|
+
}
|
|
118058
|
+
if (salt && salt.length !== 16) {
|
|
118059
|
+
throw new Error('Illegal salt, expected Uint8Array with length is 16')
|
|
118060
|
+
}
|
|
118061
|
+
if (personal && personal.length !== 16) {
|
|
118062
|
+
throw new Error('Illegal personal, expected Uint8Array with length is 16')
|
|
118063
|
+
}
|
|
118064
|
+
|
|
118065
|
+
// state, 'param block'
|
|
118066
|
+
const ctx = {
|
|
118067
|
+
b: new Uint8Array(128),
|
|
118068
|
+
h: new Uint32Array(16),
|
|
118069
|
+
t: 0, // input count
|
|
118070
|
+
c: 0, // pointer within buffer
|
|
118071
|
+
outlen: outlen // output length in bytes
|
|
118072
|
+
};
|
|
118073
|
+
|
|
118074
|
+
// initialize parameterBlock before usage
|
|
118075
|
+
parameterBlock.fill(0);
|
|
118076
|
+
parameterBlock[0] = outlen;
|
|
118077
|
+
if (key) parameterBlock[1] = key.length;
|
|
118078
|
+
parameterBlock[2] = 1; // fanout
|
|
118079
|
+
parameterBlock[3] = 1; // depth
|
|
118080
|
+
if (salt) parameterBlock.set(salt, 32);
|
|
118081
|
+
if (personal) parameterBlock.set(personal, 48);
|
|
118082
|
+
|
|
118083
|
+
// initialize hash state
|
|
118084
|
+
for (let i = 0; i < 16; i++) {
|
|
118085
|
+
ctx.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameterBlock, i * 4);
|
|
118086
|
+
}
|
|
118087
|
+
|
|
118088
|
+
// key the hash, if applicable
|
|
118089
|
+
if (key) {
|
|
118090
|
+
blake2bUpdate(ctx, key);
|
|
118091
|
+
// at the end
|
|
118092
|
+
ctx.c = 128;
|
|
118093
|
+
}
|
|
118094
|
+
|
|
118095
|
+
return ctx
|
|
118096
|
+
}
|
|
118097
|
+
|
|
118098
|
+
// Updates a BLAKE2b streaming hash
|
|
118099
|
+
// Requires hash context and Uint8Array (byte array)
|
|
118100
|
+
function blake2bUpdate (ctx, input) {
|
|
118101
|
+
for (let i = 0; i < input.length; i++) {
|
|
118102
|
+
if (ctx.c === 128) {
|
|
118103
|
+
// buffer full ?
|
|
118104
|
+
ctx.t += ctx.c; // add counters
|
|
118105
|
+
blake2bCompress(ctx, false); // compress (not last)
|
|
118106
|
+
ctx.c = 0; // counter to zero
|
|
118107
|
+
}
|
|
118108
|
+
ctx.b[ctx.c++] = input[i];
|
|
118109
|
+
}
|
|
118110
|
+
}
|
|
118111
|
+
|
|
118112
|
+
// Completes a BLAKE2b streaming hash
|
|
118113
|
+
// Returns a Uint8Array containing the message digest
|
|
118114
|
+
function blake2bFinal (ctx) {
|
|
118115
|
+
ctx.t += ctx.c; // mark last block offset
|
|
118116
|
+
|
|
118117
|
+
while (ctx.c < 128) {
|
|
118118
|
+
// fill up with zeros
|
|
118119
|
+
ctx.b[ctx.c++] = 0;
|
|
118120
|
+
}
|
|
118121
|
+
blake2bCompress(ctx, true); // final block flag = 1
|
|
118122
|
+
|
|
118123
|
+
// little endian convert and store
|
|
118124
|
+
const out = new Uint8Array(ctx.outlen);
|
|
118125
|
+
for (let i = 0; i < ctx.outlen; i++) {
|
|
118126
|
+
out[i] = ctx.h[i >> 2] >> (8 * (i & 3));
|
|
118127
|
+
}
|
|
118128
|
+
return out
|
|
118129
|
+
}
|
|
118130
|
+
|
|
118131
|
+
// Computes the BLAKE2B hash of a string or byte array, and returns a Uint8Array
|
|
118132
|
+
//
|
|
118133
|
+
// Returns a n-byte Uint8Array
|
|
118134
|
+
//
|
|
118135
|
+
// Parameters:
|
|
118136
|
+
// - input - the input bytes, as a string, Buffer or Uint8Array
|
|
118137
|
+
// - key - optional key Uint8Array, up to 64 bytes
|
|
118138
|
+
// - outlen - optional output length in bytes, default 64
|
|
118139
|
+
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118140
|
+
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118141
|
+
function blake2b (input, key, outlen, salt, personal) {
|
|
118142
|
+
// preprocess inputs
|
|
118143
|
+
outlen = outlen || 64;
|
|
118144
|
+
input = util$1.normalizeInput(input);
|
|
118145
|
+
if (salt) {
|
|
118146
|
+
salt = util$1.normalizeInput(salt);
|
|
118147
|
+
}
|
|
118148
|
+
if (personal) {
|
|
118149
|
+
personal = util$1.normalizeInput(personal);
|
|
118150
|
+
}
|
|
118151
|
+
|
|
118152
|
+
// do the math
|
|
118153
|
+
const ctx = blake2bInit(outlen, key, salt, personal);
|
|
118154
|
+
blake2bUpdate(ctx, input);
|
|
118155
|
+
return blake2bFinal(ctx)
|
|
118156
|
+
}
|
|
118157
|
+
|
|
118158
|
+
// Computes the BLAKE2B hash of a string or byte array
|
|
118159
|
+
//
|
|
118160
|
+
// Returns an n-byte hash in hex, all lowercase
|
|
118161
|
+
//
|
|
118162
|
+
// Parameters:
|
|
118163
|
+
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118164
|
+
// - key - optional key Uint8Array, up to 64 bytes
|
|
118165
|
+
// - outlen - optional output length in bytes, default 64
|
|
118166
|
+
// - salt - optional salt bytes, string, Buffer or Uint8Array
|
|
118167
|
+
// - personal - optional personal bytes, string, Buffer or Uint8Array
|
|
118168
|
+
function blake2bHex (input, key, outlen, salt, personal) {
|
|
118169
|
+
const output = blake2b(input, key, outlen, salt, personal);
|
|
118170
|
+
return util$1.toHex(output)
|
|
118171
|
+
}
|
|
118172
|
+
|
|
118173
|
+
var blake2b_1 = {
|
|
118174
|
+
blake2b: blake2b,
|
|
118175
|
+
blake2bHex: blake2bHex,
|
|
118176
|
+
blake2bInit: blake2bInit,
|
|
118177
|
+
blake2bUpdate: blake2bUpdate,
|
|
118178
|
+
blake2bFinal: blake2bFinal
|
|
118179
|
+
};
|
|
118553
118180
|
|
|
118554
|
-
|
|
118555
|
-
|
|
118556
|
-
|
|
118557
|
-
|
|
118558
|
-
|
|
118559
|
-
|
|
118560
|
-
|
|
118561
|
-
|
|
118562
|
-
|
|
118181
|
+
// BLAKE2s hash function in pure Javascript
|
|
118182
|
+
// Adapted from the reference implementation in RFC7693
|
|
118183
|
+
// Ported to Javascript by DC - https://github.com/dcposch
|
|
118184
|
+
|
|
118185
|
+
const util = util$2;
|
|
118186
|
+
|
|
118187
|
+
// Little-endian byte access.
|
|
118188
|
+
// Expects a Uint8Array and an index
|
|
118189
|
+
// Returns the little-endian uint32 at v[i..i+3]
|
|
118190
|
+
function B2S_GET32 (v, i) {
|
|
118191
|
+
return v[i] ^ (v[i + 1] << 8) ^ (v[i + 2] << 16) ^ (v[i + 3] << 24)
|
|
118192
|
+
}
|
|
118193
|
+
|
|
118194
|
+
// Mixing function G.
|
|
118195
|
+
function B2S_G (a, b, c, d, x, y) {
|
|
118196
|
+
v[a] = v[a] + v[b] + x;
|
|
118197
|
+
v[d] = ROTR32(v[d] ^ v[a], 16);
|
|
118198
|
+
v[c] = v[c] + v[d];
|
|
118199
|
+
v[b] = ROTR32(v[b] ^ v[c], 12);
|
|
118200
|
+
v[a] = v[a] + v[b] + y;
|
|
118201
|
+
v[d] = ROTR32(v[d] ^ v[a], 8);
|
|
118202
|
+
v[c] = v[c] + v[d];
|
|
118203
|
+
v[b] = ROTR32(v[b] ^ v[c], 7);
|
|
118204
|
+
}
|
|
118205
|
+
|
|
118206
|
+
// 32-bit right rotation
|
|
118207
|
+
// x should be a uint32
|
|
118208
|
+
// y must be between 1 and 31, inclusive
|
|
118209
|
+
function ROTR32 (x, y) {
|
|
118210
|
+
return (x >>> y) ^ (x << (32 - y))
|
|
118211
|
+
}
|
|
118212
|
+
|
|
118213
|
+
// Initialization Vector.
|
|
118214
|
+
const BLAKE2S_IV = new Uint32Array([
|
|
118215
|
+
0x6a09e667,
|
|
118216
|
+
0xbb67ae85,
|
|
118217
|
+
0x3c6ef372,
|
|
118218
|
+
0xa54ff53a,
|
|
118219
|
+
0x510e527f,
|
|
118220
|
+
0x9b05688c,
|
|
118221
|
+
0x1f83d9ab,
|
|
118222
|
+
0x5be0cd19
|
|
118223
|
+
]);
|
|
118563
118224
|
|
|
118564
|
-
|
|
118565
|
-
|
|
118225
|
+
const SIGMA = new Uint8Array([
|
|
118226
|
+
0,
|
|
118227
|
+
1,
|
|
118228
|
+
2,
|
|
118229
|
+
3,
|
|
118230
|
+
4,
|
|
118231
|
+
5,
|
|
118232
|
+
6,
|
|
118233
|
+
7,
|
|
118234
|
+
8,
|
|
118235
|
+
9,
|
|
118236
|
+
10,
|
|
118237
|
+
11,
|
|
118238
|
+
12,
|
|
118239
|
+
13,
|
|
118240
|
+
14,
|
|
118241
|
+
15,
|
|
118242
|
+
14,
|
|
118243
|
+
10,
|
|
118244
|
+
4,
|
|
118245
|
+
8,
|
|
118246
|
+
9,
|
|
118247
|
+
15,
|
|
118248
|
+
13,
|
|
118249
|
+
6,
|
|
118250
|
+
1,
|
|
118251
|
+
12,
|
|
118252
|
+
0,
|
|
118253
|
+
2,
|
|
118254
|
+
11,
|
|
118255
|
+
7,
|
|
118256
|
+
5,
|
|
118257
|
+
3,
|
|
118258
|
+
11,
|
|
118259
|
+
8,
|
|
118260
|
+
12,
|
|
118261
|
+
0,
|
|
118262
|
+
5,
|
|
118263
|
+
2,
|
|
118264
|
+
15,
|
|
118265
|
+
13,
|
|
118266
|
+
10,
|
|
118267
|
+
14,
|
|
118268
|
+
3,
|
|
118269
|
+
6,
|
|
118270
|
+
7,
|
|
118271
|
+
1,
|
|
118272
|
+
9,
|
|
118273
|
+
4,
|
|
118274
|
+
7,
|
|
118275
|
+
9,
|
|
118276
|
+
3,
|
|
118277
|
+
1,
|
|
118278
|
+
13,
|
|
118279
|
+
12,
|
|
118280
|
+
11,
|
|
118281
|
+
14,
|
|
118282
|
+
2,
|
|
118283
|
+
6,
|
|
118284
|
+
5,
|
|
118285
|
+
10,
|
|
118286
|
+
4,
|
|
118287
|
+
0,
|
|
118288
|
+
15,
|
|
118289
|
+
8,
|
|
118290
|
+
9,
|
|
118291
|
+
0,
|
|
118292
|
+
5,
|
|
118293
|
+
7,
|
|
118294
|
+
2,
|
|
118295
|
+
4,
|
|
118296
|
+
10,
|
|
118297
|
+
15,
|
|
118298
|
+
14,
|
|
118299
|
+
1,
|
|
118300
|
+
11,
|
|
118301
|
+
12,
|
|
118302
|
+
6,
|
|
118303
|
+
8,
|
|
118304
|
+
3,
|
|
118305
|
+
13,
|
|
118306
|
+
2,
|
|
118307
|
+
12,
|
|
118308
|
+
6,
|
|
118309
|
+
10,
|
|
118310
|
+
0,
|
|
118311
|
+
11,
|
|
118312
|
+
8,
|
|
118313
|
+
3,
|
|
118314
|
+
4,
|
|
118315
|
+
13,
|
|
118316
|
+
7,
|
|
118317
|
+
5,
|
|
118318
|
+
15,
|
|
118319
|
+
14,
|
|
118320
|
+
1,
|
|
118321
|
+
9,
|
|
118322
|
+
12,
|
|
118323
|
+
5,
|
|
118324
|
+
1,
|
|
118325
|
+
15,
|
|
118326
|
+
14,
|
|
118327
|
+
13,
|
|
118328
|
+
4,
|
|
118329
|
+
10,
|
|
118330
|
+
0,
|
|
118331
|
+
7,
|
|
118332
|
+
6,
|
|
118333
|
+
3,
|
|
118334
|
+
9,
|
|
118335
|
+
2,
|
|
118336
|
+
8,
|
|
118337
|
+
11,
|
|
118338
|
+
13,
|
|
118339
|
+
11,
|
|
118340
|
+
7,
|
|
118341
|
+
14,
|
|
118342
|
+
12,
|
|
118343
|
+
1,
|
|
118344
|
+
3,
|
|
118345
|
+
9,
|
|
118346
|
+
5,
|
|
118347
|
+
0,
|
|
118348
|
+
15,
|
|
118349
|
+
4,
|
|
118350
|
+
8,
|
|
118351
|
+
6,
|
|
118352
|
+
2,
|
|
118353
|
+
10,
|
|
118354
|
+
6,
|
|
118355
|
+
15,
|
|
118356
|
+
14,
|
|
118357
|
+
9,
|
|
118358
|
+
11,
|
|
118359
|
+
3,
|
|
118360
|
+
0,
|
|
118361
|
+
8,
|
|
118362
|
+
12,
|
|
118363
|
+
2,
|
|
118364
|
+
13,
|
|
118365
|
+
7,
|
|
118366
|
+
1,
|
|
118367
|
+
4,
|
|
118368
|
+
10,
|
|
118369
|
+
5,
|
|
118370
|
+
10,
|
|
118371
|
+
2,
|
|
118372
|
+
8,
|
|
118373
|
+
4,
|
|
118374
|
+
7,
|
|
118375
|
+
6,
|
|
118376
|
+
1,
|
|
118377
|
+
5,
|
|
118378
|
+
15,
|
|
118379
|
+
11,
|
|
118380
|
+
9,
|
|
118381
|
+
14,
|
|
118382
|
+
3,
|
|
118383
|
+
12,
|
|
118384
|
+
13,
|
|
118385
|
+
0
|
|
118386
|
+
]);
|
|
118566
118387
|
|
|
118567
|
-
function
|
|
118568
|
-
|
|
118569
|
-
|
|
118570
|
-
|
|
118571
|
-
|
|
118388
|
+
// Compression function. "last" flag indicates last block
|
|
118389
|
+
const v = new Uint32Array(16);
|
|
118390
|
+
const m = new Uint32Array(16);
|
|
118391
|
+
function blake2sCompress (ctx, last) {
|
|
118392
|
+
let i = 0;
|
|
118393
|
+
for (i = 0; i < 8; i++) {
|
|
118394
|
+
// init work variables
|
|
118395
|
+
v[i] = ctx.h[i];
|
|
118396
|
+
v[i + 8] = BLAKE2S_IV[i];
|
|
118397
|
+
}
|
|
118398
|
+
|
|
118399
|
+
v[12] ^= ctx.t; // low 32 bits of offset
|
|
118400
|
+
v[13] ^= ctx.t / 0x100000000; // high 32 bits
|
|
118401
|
+
if (last) {
|
|
118402
|
+
// last block flag set ?
|
|
118403
|
+
v[14] = ~v[14];
|
|
118404
|
+
}
|
|
118405
|
+
|
|
118406
|
+
for (i = 0; i < 16; i++) {
|
|
118407
|
+
// get little-endian words
|
|
118408
|
+
m[i] = B2S_GET32(ctx.b, 4 * i);
|
|
118409
|
+
}
|
|
118410
|
+
|
|
118411
|
+
// ten rounds of mixing
|
|
118412
|
+
// uncomment the DebugPrint calls to log the computation
|
|
118413
|
+
// and match the RFC sample documentation
|
|
118414
|
+
// util.debugPrint(' m[16]', m, 32)
|
|
118415
|
+
for (i = 0; i < 10; i++) {
|
|
118416
|
+
// util.debugPrint(' (i=' + i + ') v[16]', v, 32)
|
|
118417
|
+
B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]);
|
|
118418
|
+
B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]);
|
|
118419
|
+
B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]);
|
|
118420
|
+
B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]);
|
|
118421
|
+
B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]);
|
|
118422
|
+
B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]);
|
|
118423
|
+
B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]);
|
|
118424
|
+
B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]);
|
|
118425
|
+
}
|
|
118426
|
+
// util.debugPrint(' (i=10) v[16]', v, 32)
|
|
118427
|
+
|
|
118428
|
+
for (i = 0; i < 8; i++) {
|
|
118429
|
+
ctx.h[i] ^= v[i] ^ v[i + 8];
|
|
118430
|
+
}
|
|
118431
|
+
// util.debugPrint('h[8]', ctx.h, 32)
|
|
118432
|
+
}
|
|
118433
|
+
|
|
118434
|
+
// Creates a BLAKE2s hashing context
|
|
118435
|
+
// Requires an output length between 1 and 32 bytes
|
|
118436
|
+
// Takes an optional Uint8Array key
|
|
118437
|
+
function blake2sInit (outlen, key) {
|
|
118438
|
+
if (!(outlen > 0 && outlen <= 32)) {
|
|
118439
|
+
throw new Error('Incorrect output length, should be in [1, 32]')
|
|
118440
|
+
}
|
|
118441
|
+
const keylen = key ? key.length : 0;
|
|
118442
|
+
if (key && !(keylen > 0 && keylen <= 32)) {
|
|
118443
|
+
throw new Error('Incorrect key length, should be in [1, 32]')
|
|
118444
|
+
}
|
|
118445
|
+
|
|
118446
|
+
const ctx = {
|
|
118447
|
+
h: new Uint32Array(BLAKE2S_IV), // hash state
|
|
118448
|
+
b: new Uint8Array(64), // input block
|
|
118449
|
+
c: 0, // pointer within block
|
|
118450
|
+
t: 0, // input count
|
|
118451
|
+
outlen: outlen // output length in bytes
|
|
118452
|
+
};
|
|
118453
|
+
ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen;
|
|
118454
|
+
|
|
118455
|
+
if (keylen > 0) {
|
|
118456
|
+
blake2sUpdate(ctx, key);
|
|
118457
|
+
ctx.c = 64; // at the end
|
|
118458
|
+
}
|
|
118459
|
+
|
|
118460
|
+
return ctx
|
|
118461
|
+
}
|
|
118462
|
+
|
|
118463
|
+
// Updates a BLAKE2s streaming hash
|
|
118464
|
+
// Requires hash context and Uint8Array (byte array)
|
|
118465
|
+
function blake2sUpdate (ctx, input) {
|
|
118466
|
+
for (let i = 0; i < input.length; i++) {
|
|
118467
|
+
if (ctx.c === 64) {
|
|
118468
|
+
// buffer full ?
|
|
118469
|
+
ctx.t += ctx.c; // add counters
|
|
118470
|
+
blake2sCompress(ctx, false); // compress (not last)
|
|
118471
|
+
ctx.c = 0; // counter to zero
|
|
118472
|
+
}
|
|
118473
|
+
ctx.b[ctx.c++] = input[i];
|
|
118474
|
+
}
|
|
118475
|
+
}
|
|
118476
|
+
|
|
118477
|
+
// Completes a BLAKE2s streaming hash
|
|
118478
|
+
// Returns a Uint8Array containing the message digest
|
|
118479
|
+
function blake2sFinal (ctx) {
|
|
118480
|
+
ctx.t += ctx.c; // mark last block offset
|
|
118481
|
+
while (ctx.c < 64) {
|
|
118482
|
+
// fill up with zeros
|
|
118483
|
+
ctx.b[ctx.c++] = 0;
|
|
118484
|
+
}
|
|
118485
|
+
blake2sCompress(ctx, true); // final block flag = 1
|
|
118486
|
+
|
|
118487
|
+
// little endian convert and store
|
|
118488
|
+
const out = new Uint8Array(ctx.outlen);
|
|
118489
|
+
for (let i = 0; i < ctx.outlen; i++) {
|
|
118490
|
+
out[i] = (ctx.h[i >> 2] >> (8 * (i & 3))) & 0xff;
|
|
118491
|
+
}
|
|
118492
|
+
return out
|
|
118493
|
+
}
|
|
118494
|
+
|
|
118495
|
+
// Computes the BLAKE2S hash of a string or byte array, and returns a Uint8Array
|
|
118496
|
+
//
|
|
118497
|
+
// Returns a n-byte Uint8Array
|
|
118498
|
+
//
|
|
118499
|
+
// Parameters:
|
|
118500
|
+
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118501
|
+
// - key - optional key Uint8Array, up to 32 bytes
|
|
118502
|
+
// - outlen - optional output length in bytes, default 64
|
|
118503
|
+
function blake2s (input, key, outlen) {
|
|
118504
|
+
// preprocess inputs
|
|
118505
|
+
outlen = outlen || 32;
|
|
118506
|
+
input = util.normalizeInput(input);
|
|
118507
|
+
|
|
118508
|
+
// do the math
|
|
118509
|
+
const ctx = blake2sInit(outlen, key);
|
|
118510
|
+
blake2sUpdate(ctx, input);
|
|
118511
|
+
return blake2sFinal(ctx)
|
|
118512
|
+
}
|
|
118513
|
+
|
|
118514
|
+
// Computes the BLAKE2S hash of a string or byte array
|
|
118515
|
+
//
|
|
118516
|
+
// Returns an n-byte hash in hex, all lowercase
|
|
118517
|
+
//
|
|
118518
|
+
// Parameters:
|
|
118519
|
+
// - input - the input bytes, as a string, Buffer, or Uint8Array
|
|
118520
|
+
// - key - optional key Uint8Array, up to 32 bytes
|
|
118521
|
+
// - outlen - optional output length in bytes, default 64
|
|
118522
|
+
function blake2sHex (input, key, outlen) {
|
|
118523
|
+
const output = blake2s(input, key, outlen);
|
|
118524
|
+
return util.toHex(output)
|
|
118525
|
+
}
|
|
118526
|
+
|
|
118527
|
+
var blake2s_1 = {
|
|
118528
|
+
blake2s: blake2s,
|
|
118529
|
+
blake2sHex: blake2sHex,
|
|
118530
|
+
blake2sInit: blake2sInit,
|
|
118531
|
+
blake2sUpdate: blake2sUpdate,
|
|
118532
|
+
blake2sFinal: blake2sFinal
|
|
118533
|
+
};
|
|
118572
118534
|
|
|
118573
|
-
|
|
118574
|
-
|
|
118575
|
-
|
|
118576
|
-
|
|
118577
|
-
|
|
118578
|
-
|
|
118579
|
-
|
|
118580
|
-
|
|
118581
|
-
|
|
118582
|
-
|
|
118583
|
-
|
|
118584
|
-
|
|
118585
|
-
|
|
118586
|
-
|
|
118535
|
+
const b2b = blake2b_1;
|
|
118536
|
+
const b2s = blake2s_1;
|
|
118537
|
+
|
|
118538
|
+
var blakejs = {
|
|
118539
|
+
blake2b: b2b.blake2b,
|
|
118540
|
+
blake2bHex: b2b.blake2bHex,
|
|
118541
|
+
blake2bInit: b2b.blake2bInit,
|
|
118542
|
+
blake2bUpdate: b2b.blake2bUpdate,
|
|
118543
|
+
blake2bFinal: b2b.blake2bFinal,
|
|
118544
|
+
blake2s: b2s.blake2s,
|
|
118545
|
+
blake2sHex: b2s.blake2sHex,
|
|
118546
|
+
blake2sInit: b2s.blake2sInit,
|
|
118547
|
+
blake2sUpdate: b2s.blake2sUpdate,
|
|
118548
|
+
blake2sFinal: b2s.blake2sFinal
|
|
118549
|
+
};
|
|
118587
118550
|
|
|
118588
118551
|
var hasRequiredHash;
|
|
118589
118552
|
|
|
@@ -118592,12 +118555,12 @@ function requireHash () {
|
|
|
118592
118555
|
hasRequiredHash = 1;
|
|
118593
118556
|
Object.defineProperty(hash, "__esModule", { value: true });
|
|
118594
118557
|
hash.ripemd160 = hash.blake128WithKey = hash.blake128 = hash.blake160WithKey = hash.blake160 = hash.blake256WithKey = hash.blake256 = void 0;
|
|
118595
|
-
const crypto_js_1 =
|
|
118558
|
+
const crypto_js_1 = cryptoJsExports;
|
|
118596
118559
|
const utility_1 = requireUtility();
|
|
118597
118560
|
/**
|
|
118598
118561
|
* @hidden
|
|
118599
118562
|
*/
|
|
118600
|
-
const blake =
|
|
118563
|
+
const blake = blakejs;
|
|
118601
118564
|
/**
|
|
118602
118565
|
* Gets data's 256 bit blake hash.
|
|
118603
118566
|
* @param data buffer or hexadecimal string
|
|
@@ -124922,6 +124885,7 @@ $root.common = (function() {
|
|
|
124922
124885
|
* @property {string|null} [symbol] Asset symbol
|
|
124923
124886
|
* @property {string|null} [ticker] Asset ticker
|
|
124924
124887
|
* @property {boolean|null} [synth] Asset synth
|
|
124888
|
+
* @property {boolean|null} [trade] Asset trade
|
|
124925
124889
|
*/
|
|
124926
124890
|
|
|
124927
124891
|
/**
|
|
@@ -124971,6 +124935,14 @@ $root.common = (function() {
|
|
|
124971
124935
|
*/
|
|
124972
124936
|
Asset.prototype.synth = false;
|
|
124973
124937
|
|
|
124938
|
+
/**
|
|
124939
|
+
* Asset trade.
|
|
124940
|
+
* @member {boolean} trade
|
|
124941
|
+
* @memberof common.Asset
|
|
124942
|
+
* @instance
|
|
124943
|
+
*/
|
|
124944
|
+
Asset.prototype.trade = false;
|
|
124945
|
+
|
|
124974
124946
|
/**
|
|
124975
124947
|
* Creates a new Asset instance using the specified properties.
|
|
124976
124948
|
* @function create
|
|
@@ -125003,6 +124975,8 @@ $root.common = (function() {
|
|
|
125003
124975
|
writer.uint32(/* id 3, wireType 2 =*/26).string(message.ticker);
|
|
125004
124976
|
if (message.synth != null && Object.hasOwnProperty.call(message, "synth"))
|
|
125005
124977
|
writer.uint32(/* id 4, wireType 0 =*/32).bool(message.synth);
|
|
124978
|
+
if (message.trade != null && Object.hasOwnProperty.call(message, "trade"))
|
|
124979
|
+
writer.uint32(/* id 5, wireType 0 =*/40).bool(message.trade);
|
|
125006
124980
|
return writer;
|
|
125007
124981
|
};
|
|
125008
124982
|
|
|
@@ -125049,6 +125023,9 @@ $root.common = (function() {
|
|
|
125049
125023
|
case 4:
|
|
125050
125024
|
message.synth = reader.bool();
|
|
125051
125025
|
break;
|
|
125026
|
+
case 5:
|
|
125027
|
+
message.trade = reader.bool();
|
|
125028
|
+
break;
|
|
125052
125029
|
default:
|
|
125053
125030
|
reader.skipType(tag & 7);
|
|
125054
125031
|
break;
|
|
@@ -125096,6 +125073,9 @@ $root.common = (function() {
|
|
|
125096
125073
|
if (message.synth != null && message.hasOwnProperty("synth"))
|
|
125097
125074
|
if (typeof message.synth !== "boolean")
|
|
125098
125075
|
return "synth: boolean expected";
|
|
125076
|
+
if (message.trade != null && message.hasOwnProperty("trade"))
|
|
125077
|
+
if (typeof message.trade !== "boolean")
|
|
125078
|
+
return "trade: boolean expected";
|
|
125099
125079
|
return null;
|
|
125100
125080
|
};
|
|
125101
125081
|
|
|
@@ -125119,6 +125099,8 @@ $root.common = (function() {
|
|
|
125119
125099
|
message.ticker = String(object.ticker);
|
|
125120
125100
|
if (object.synth != null)
|
|
125121
125101
|
message.synth = Boolean(object.synth);
|
|
125102
|
+
if (object.trade != null)
|
|
125103
|
+
message.trade = Boolean(object.trade);
|
|
125122
125104
|
return message;
|
|
125123
125105
|
};
|
|
125124
125106
|
|
|
@@ -125140,6 +125122,7 @@ $root.common = (function() {
|
|
|
125140
125122
|
object.symbol = "";
|
|
125141
125123
|
object.ticker = "";
|
|
125142
125124
|
object.synth = false;
|
|
125125
|
+
object.trade = false;
|
|
125143
125126
|
}
|
|
125144
125127
|
if (message.chain != null && message.hasOwnProperty("chain"))
|
|
125145
125128
|
object.chain = message.chain;
|
|
@@ -125149,6 +125132,8 @@ $root.common = (function() {
|
|
|
125149
125132
|
object.ticker = message.ticker;
|
|
125150
125133
|
if (message.synth != null && message.hasOwnProperty("synth"))
|
|
125151
125134
|
object.synth = message.synth;
|
|
125135
|
+
if (message.trade != null && message.hasOwnProperty("trade"))
|
|
125136
|
+
object.trade = message.trade;
|
|
125152
125137
|
return object;
|
|
125153
125138
|
};
|
|
125154
125139
|
|
|
@@ -126222,6 +126207,193 @@ $root.common = (function() {
|
|
|
126222
126207
|
return Fee;
|
|
126223
126208
|
})();
|
|
126224
126209
|
|
|
126210
|
+
common.ProtoUint = (function() {
|
|
126211
|
+
|
|
126212
|
+
/**
|
|
126213
|
+
* Properties of a ProtoUint.
|
|
126214
|
+
* @memberof common
|
|
126215
|
+
* @interface IProtoUint
|
|
126216
|
+
* @property {string|null} [value] ProtoUint value
|
|
126217
|
+
*/
|
|
126218
|
+
|
|
126219
|
+
/**
|
|
126220
|
+
* Constructs a new ProtoUint.
|
|
126221
|
+
* @memberof common
|
|
126222
|
+
* @classdesc Represents a ProtoUint.
|
|
126223
|
+
* @implements IProtoUint
|
|
126224
|
+
* @constructor
|
|
126225
|
+
* @param {common.IProtoUint=} [properties] Properties to set
|
|
126226
|
+
*/
|
|
126227
|
+
function ProtoUint(properties) {
|
|
126228
|
+
if (properties)
|
|
126229
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
126230
|
+
if (properties[keys[i]] != null)
|
|
126231
|
+
this[keys[i]] = properties[keys[i]];
|
|
126232
|
+
}
|
|
126233
|
+
|
|
126234
|
+
/**
|
|
126235
|
+
* ProtoUint value.
|
|
126236
|
+
* @member {string} value
|
|
126237
|
+
* @memberof common.ProtoUint
|
|
126238
|
+
* @instance
|
|
126239
|
+
*/
|
|
126240
|
+
ProtoUint.prototype.value = "";
|
|
126241
|
+
|
|
126242
|
+
/**
|
|
126243
|
+
* Creates a new ProtoUint instance using the specified properties.
|
|
126244
|
+
* @function create
|
|
126245
|
+
* @memberof common.ProtoUint
|
|
126246
|
+
* @static
|
|
126247
|
+
* @param {common.IProtoUint=} [properties] Properties to set
|
|
126248
|
+
* @returns {common.ProtoUint} ProtoUint instance
|
|
126249
|
+
*/
|
|
126250
|
+
ProtoUint.create = function create(properties) {
|
|
126251
|
+
return new ProtoUint(properties);
|
|
126252
|
+
};
|
|
126253
|
+
|
|
126254
|
+
/**
|
|
126255
|
+
* Encodes the specified ProtoUint message. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
|
|
126256
|
+
* @function encode
|
|
126257
|
+
* @memberof common.ProtoUint
|
|
126258
|
+
* @static
|
|
126259
|
+
* @param {common.IProtoUint} message ProtoUint message or plain object to encode
|
|
126260
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
126261
|
+
* @returns {$protobuf.Writer} Writer
|
|
126262
|
+
*/
|
|
126263
|
+
ProtoUint.encode = function encode(message, writer) {
|
|
126264
|
+
if (!writer)
|
|
126265
|
+
writer = $Writer.create();
|
|
126266
|
+
if (message.value != null && Object.hasOwnProperty.call(message, "value"))
|
|
126267
|
+
writer.uint32(/* id 1, wireType 2 =*/10).string(message.value);
|
|
126268
|
+
return writer;
|
|
126269
|
+
};
|
|
126270
|
+
|
|
126271
|
+
/**
|
|
126272
|
+
* Encodes the specified ProtoUint message, length delimited. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
|
|
126273
|
+
* @function encodeDelimited
|
|
126274
|
+
* @memberof common.ProtoUint
|
|
126275
|
+
* @static
|
|
126276
|
+
* @param {common.IProtoUint} message ProtoUint message or plain object to encode
|
|
126277
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
126278
|
+
* @returns {$protobuf.Writer} Writer
|
|
126279
|
+
*/
|
|
126280
|
+
ProtoUint.encodeDelimited = function encodeDelimited(message, writer) {
|
|
126281
|
+
return this.encode(message, writer).ldelim();
|
|
126282
|
+
};
|
|
126283
|
+
|
|
126284
|
+
/**
|
|
126285
|
+
* Decodes a ProtoUint message from the specified reader or buffer.
|
|
126286
|
+
* @function decode
|
|
126287
|
+
* @memberof common.ProtoUint
|
|
126288
|
+
* @static
|
|
126289
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
126290
|
+
* @param {number} [length] Message length if known beforehand
|
|
126291
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126292
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
126293
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
126294
|
+
*/
|
|
126295
|
+
ProtoUint.decode = function decode(reader, length) {
|
|
126296
|
+
if (!(reader instanceof $Reader))
|
|
126297
|
+
reader = $Reader.create(reader);
|
|
126298
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.common.ProtoUint();
|
|
126299
|
+
while (reader.pos < end) {
|
|
126300
|
+
var tag = reader.uint32();
|
|
126301
|
+
switch (tag >>> 3) {
|
|
126302
|
+
case 1:
|
|
126303
|
+
message.value = reader.string();
|
|
126304
|
+
break;
|
|
126305
|
+
default:
|
|
126306
|
+
reader.skipType(tag & 7);
|
|
126307
|
+
break;
|
|
126308
|
+
}
|
|
126309
|
+
}
|
|
126310
|
+
return message;
|
|
126311
|
+
};
|
|
126312
|
+
|
|
126313
|
+
/**
|
|
126314
|
+
* Decodes a ProtoUint message from the specified reader or buffer, length delimited.
|
|
126315
|
+
* @function decodeDelimited
|
|
126316
|
+
* @memberof common.ProtoUint
|
|
126317
|
+
* @static
|
|
126318
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
126319
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126320
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
126321
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
126322
|
+
*/
|
|
126323
|
+
ProtoUint.decodeDelimited = function decodeDelimited(reader) {
|
|
126324
|
+
if (!(reader instanceof $Reader))
|
|
126325
|
+
reader = new $Reader(reader);
|
|
126326
|
+
return this.decode(reader, reader.uint32());
|
|
126327
|
+
};
|
|
126328
|
+
|
|
126329
|
+
/**
|
|
126330
|
+
* Verifies a ProtoUint message.
|
|
126331
|
+
* @function verify
|
|
126332
|
+
* @memberof common.ProtoUint
|
|
126333
|
+
* @static
|
|
126334
|
+
* @param {Object.<string,*>} message Plain object to verify
|
|
126335
|
+
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
|
126336
|
+
*/
|
|
126337
|
+
ProtoUint.verify = function verify(message) {
|
|
126338
|
+
if (typeof message !== "object" || message === null)
|
|
126339
|
+
return "object expected";
|
|
126340
|
+
if (message.value != null && message.hasOwnProperty("value"))
|
|
126341
|
+
if (!$util.isString(message.value))
|
|
126342
|
+
return "value: string expected";
|
|
126343
|
+
return null;
|
|
126344
|
+
};
|
|
126345
|
+
|
|
126346
|
+
/**
|
|
126347
|
+
* Creates a ProtoUint message from a plain object. Also converts values to their respective internal types.
|
|
126348
|
+
* @function fromObject
|
|
126349
|
+
* @memberof common.ProtoUint
|
|
126350
|
+
* @static
|
|
126351
|
+
* @param {Object.<string,*>} object Plain object
|
|
126352
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126353
|
+
*/
|
|
126354
|
+
ProtoUint.fromObject = function fromObject(object) {
|
|
126355
|
+
if (object instanceof $root.common.ProtoUint)
|
|
126356
|
+
return object;
|
|
126357
|
+
var message = new $root.common.ProtoUint();
|
|
126358
|
+
if (object.value != null)
|
|
126359
|
+
message.value = String(object.value);
|
|
126360
|
+
return message;
|
|
126361
|
+
};
|
|
126362
|
+
|
|
126363
|
+
/**
|
|
126364
|
+
* Creates a plain object from a ProtoUint message. Also converts values to other types if specified.
|
|
126365
|
+
* @function toObject
|
|
126366
|
+
* @memberof common.ProtoUint
|
|
126367
|
+
* @static
|
|
126368
|
+
* @param {common.ProtoUint} message ProtoUint
|
|
126369
|
+
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
|
126370
|
+
* @returns {Object.<string,*>} Plain object
|
|
126371
|
+
*/
|
|
126372
|
+
ProtoUint.toObject = function toObject(message, options) {
|
|
126373
|
+
if (!options)
|
|
126374
|
+
options = {};
|
|
126375
|
+
var object = {};
|
|
126376
|
+
if (options.defaults)
|
|
126377
|
+
object.value = "";
|
|
126378
|
+
if (message.value != null && message.hasOwnProperty("value"))
|
|
126379
|
+
object.value = message.value;
|
|
126380
|
+
return object;
|
|
126381
|
+
};
|
|
126382
|
+
|
|
126383
|
+
/**
|
|
126384
|
+
* Converts this ProtoUint to JSON.
|
|
126385
|
+
* @function toJSON
|
|
126386
|
+
* @memberof common.ProtoUint
|
|
126387
|
+
* @instance
|
|
126388
|
+
* @returns {Object.<string,*>} JSON object
|
|
126389
|
+
*/
|
|
126390
|
+
ProtoUint.prototype.toJSON = function toJSON() {
|
|
126391
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
126392
|
+
};
|
|
126393
|
+
|
|
126394
|
+
return ProtoUint;
|
|
126395
|
+
})();
|
|
126396
|
+
|
|
126225
126397
|
return common;
|
|
126226
126398
|
})();
|
|
126227
126399
|
|
|
@@ -127651,14 +127823,14 @@ const getExplorerTxUrl = (tx) => ({
|
|
|
127651
127823
|
/**
|
|
127652
127824
|
* Checks whether an asset is the native RUNE asset
|
|
127653
127825
|
*
|
|
127654
|
-
* @param {
|
|
127826
|
+
* @param {CompatibleAsset} asset
|
|
127655
127827
|
* @returns {boolean} `true` or `false`
|
|
127656
127828
|
*/
|
|
127657
127829
|
const isAssetRuneNative = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(AssetRuneNative);
|
|
127658
127830
|
/**
|
|
127659
127831
|
* Get denomination from Asset
|
|
127660
127832
|
*
|
|
127661
|
-
* @param {
|
|
127833
|
+
* @param {CompatibleAsset} asset
|
|
127662
127834
|
* @returns {string} The denomination of the given asset
|
|
127663
127835
|
*/
|
|
127664
127836
|
const getDenom = (asset) => {
|
|
@@ -127749,6 +127921,18 @@ function sortedObject(obj) {
|
|
|
127749
127921
|
function sortAndStringifyJson(obj) {
|
|
127750
127922
|
return JSON.stringify(sortedObject(obj));
|
|
127751
127923
|
}
|
|
127924
|
+
/**
|
|
127925
|
+
* Parse XChainJS asset to Thornode asset
|
|
127926
|
+
*/
|
|
127927
|
+
const parseAssetToTHORNodeAsset = (asset) => {
|
|
127928
|
+
return {
|
|
127929
|
+
chain: asset.chain,
|
|
127930
|
+
symbol: asset.symbol,
|
|
127931
|
+
ticker: asset.ticker,
|
|
127932
|
+
synth: asset.type === xchainUtil.AssetType.SYNTH,
|
|
127933
|
+
trade: asset.type === xchainUtil.AssetType.TRADE,
|
|
127934
|
+
};
|
|
127935
|
+
};
|
|
127752
127936
|
|
|
127753
127937
|
/**
|
|
127754
127938
|
* Import necessary modules and types for the Thorchain client configuration.
|
|
@@ -127788,7 +127972,12 @@ const THORChain = 'THOR';
|
|
|
127788
127972
|
/**
|
|
127789
127973
|
* Native asset representation for RUNE in Thorchain
|
|
127790
127974
|
*/
|
|
127791
|
-
const AssetRuneNative = {
|
|
127975
|
+
const AssetRuneNative = {
|
|
127976
|
+
chain: THORChain,
|
|
127977
|
+
symbol: RUNE_TICKER,
|
|
127978
|
+
ticker: RUNE_TICKER,
|
|
127979
|
+
type: xchainUtil.AssetType.NATIVE,
|
|
127980
|
+
};
|
|
127792
127981
|
/**
|
|
127793
127982
|
* Message type URL used to make send transactions
|
|
127794
127983
|
*/
|
|
@@ -127851,7 +128040,7 @@ class Client extends xchainCosmosSdk.Client {
|
|
|
127851
128040
|
/**
|
|
127852
128041
|
* Returns the number of the decimals of known assets
|
|
127853
128042
|
*
|
|
127854
|
-
* @param {
|
|
128043
|
+
* @param {CompatibleAsset} asset - Asset of which return the number of decimals
|
|
127855
128044
|
* @returns {number} the number of decimals of the assets
|
|
127856
128045
|
*/
|
|
127857
128046
|
getAssetDecimals(asset) {
|
|
@@ -127889,7 +128078,7 @@ class Client extends xchainCosmosSdk.Client {
|
|
|
127889
128078
|
* Get Asset from denomination
|
|
127890
128079
|
*
|
|
127891
128080
|
* @param {string} denom The denomination for which to get the asset.
|
|
127892
|
-
* @returns {
|
|
128081
|
+
* @returns {CompatibleAsset|null} The asset of the given denomination.
|
|
127893
128082
|
*/
|
|
127894
128083
|
assetFromDenom(denom) {
|
|
127895
128084
|
if (denom === RUNE_DENOM)
|
|
@@ -127899,7 +128088,7 @@ class Client extends xchainCosmosSdk.Client {
|
|
|
127899
128088
|
/**
|
|
127900
128089
|
* Get denomination from Asset
|
|
127901
128090
|
*
|
|
127902
|
-
* @param {
|
|
128091
|
+
* @param {CompatibleAsset} asset The asset for which to get the denomination.
|
|
127903
128092
|
* @returns {string} The denomination of the given asset.
|
|
127904
128093
|
*/
|
|
127905
128094
|
getDenom(asset) {
|
|
@@ -128070,7 +128259,7 @@ class ClientKeystore extends Client {
|
|
|
128070
128259
|
*
|
|
128071
128260
|
* @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
|
|
128072
128261
|
* If it is not set, address associated with index 0 will be used
|
|
128073
|
-
* @param {
|
|
128262
|
+
* @param {CompatibleAsset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
|
|
128074
128263
|
* used
|
|
128075
128264
|
* @param {BaseAmount} param.amount The amount that will be deposit
|
|
128076
128265
|
* @param {string} param.memo Optional - The memo associated with the deposit
|
|
@@ -128196,7 +128385,7 @@ class ClientKeystore extends Client {
|
|
|
128196
128385
|
* @param {BigNumber} gasLimit Gas limit for the transaction
|
|
128197
128386
|
* @param {BaseAmount} amount Amount to deposit
|
|
128198
128387
|
* @param {string} memo Deposit memo
|
|
128199
|
-
* @param {
|
|
128388
|
+
* @param {CompatibleAsset} asset Asset to deposit
|
|
128200
128389
|
* @returns {DeliverTxResponse} The transaction broadcasted
|
|
128201
128390
|
*/
|
|
128202
128391
|
roundRobinSignAndBroadcastDeposit(sender, signer, gasLimit, amount, memo, asset) {
|
|
@@ -128216,7 +128405,7 @@ class ClientKeystore extends Client {
|
|
|
128216
128405
|
coins: [
|
|
128217
128406
|
{
|
|
128218
128407
|
amount: amount.amount().toString(),
|
|
128219
|
-
asset,
|
|
128408
|
+
asset: parseAssetToTHORNodeAsset(asset),
|
|
128220
128409
|
},
|
|
128221
128410
|
],
|
|
128222
128411
|
},
|
|
@@ -128445,7 +128634,7 @@ class ClientLedger extends Client {
|
|
|
128445
128634
|
signer: xchainCosmosSdk.bech32ToBase64(params.signer),
|
|
128446
128635
|
memo: params.memo,
|
|
128447
128636
|
coins: params.coins.map((coin) => {
|
|
128448
|
-
return Object.assign(Object.assign({}, coin), { asset: xchainUtil.assetFromStringEx(coin.asset) });
|
|
128637
|
+
return Object.assign(Object.assign({}, coin), { asset: parseAssetToTHORNodeAsset(xchainUtil.assetFromStringEx(coin.asset)) });
|
|
128449
128638
|
}),
|
|
128450
128639
|
}),
|
|
128451
128640
|
},
|
|
@@ -128477,6 +128666,7 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
|
128477
128666
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
128478
128667
|
exports.getPrefix = getPrefix;
|
|
128479
128668
|
exports.isAssetRuneNative = isAssetRuneNative;
|
|
128669
|
+
exports.parseAssetToTHORNodeAsset = parseAssetToTHORNodeAsset;
|
|
128480
128670
|
exports.parseDerivationPath = parseDerivationPath;
|
|
128481
128671
|
exports.sortAndStringifyJson = sortAndStringifyJson;
|
|
128482
128672
|
exports.sortedObject = sortedObject;
|