@solana/web3.js 1.29.2 → 1.29.4
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/index.browser.esm.js +1767 -69
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +1772 -64
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +1771 -63
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +16296 -16689
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +10 -10
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +1 -1
- package/package.json +31 -31
- package/src/message.ts +9 -12
- package/src/publickey.ts +5 -3
- package/src/transaction.ts +2 -2
- package/src/util/guarded-array-utils.ts +37 -0
- package/src/validator-info.ts +5 -4
package/lib/index.cjs.js
CHANGED
|
@@ -7,7 +7,6 @@ var nacl = require('tweetnacl');
|
|
|
7
7
|
var buffer = require('buffer');
|
|
8
8
|
var BN = require('bn.js');
|
|
9
9
|
var bs58 = require('bs58');
|
|
10
|
-
var cryptoHash = require('crypto-hash');
|
|
11
10
|
var borsh = require('borsh');
|
|
12
11
|
var BufferLayout = require('@solana/buffer-layout');
|
|
13
12
|
var fetch = require('cross-fetch');
|
|
@@ -17,7 +16,7 @@ var RpcClient = require('jayson/lib/client/browser');
|
|
|
17
16
|
var http = require('http');
|
|
18
17
|
var https = require('https');
|
|
19
18
|
var secp256k1 = require('secp256k1');
|
|
20
|
-
var
|
|
19
|
+
var sha3 = require('js-sha3');
|
|
21
20
|
|
|
22
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
22
|
|
|
@@ -61,6 +60,1683 @@ const toBuffer = arr => {
|
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
62
|
|
|
63
|
+
const version$2 = "logger/5.5.0";
|
|
64
|
+
|
|
65
|
+
let _permanentCensorErrors = false;
|
|
66
|
+
let _censorErrors = false;
|
|
67
|
+
const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
|
|
68
|
+
let _logLevel = LogLevels["default"];
|
|
69
|
+
let _globalLogger = null;
|
|
70
|
+
function _checkNormalize() {
|
|
71
|
+
try {
|
|
72
|
+
const missing = [];
|
|
73
|
+
// Make sure all forms of normalization are supported
|
|
74
|
+
["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
|
|
75
|
+
try {
|
|
76
|
+
if ("test".normalize(form) !== "test") {
|
|
77
|
+
throw new Error("bad normalize");
|
|
78
|
+
}
|
|
79
|
+
;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
missing.push(form);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (missing.length) {
|
|
86
|
+
throw new Error("missing " + missing.join(", "));
|
|
87
|
+
}
|
|
88
|
+
if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
|
|
89
|
+
throw new Error("broken implementation");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return error.message;
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const _normalizeError = _checkNormalize();
|
|
98
|
+
var LogLevel;
|
|
99
|
+
(function (LogLevel) {
|
|
100
|
+
LogLevel["DEBUG"] = "DEBUG";
|
|
101
|
+
LogLevel["INFO"] = "INFO";
|
|
102
|
+
LogLevel["WARNING"] = "WARNING";
|
|
103
|
+
LogLevel["ERROR"] = "ERROR";
|
|
104
|
+
LogLevel["OFF"] = "OFF";
|
|
105
|
+
})(LogLevel || (LogLevel = {}));
|
|
106
|
+
var ErrorCode;
|
|
107
|
+
(function (ErrorCode) {
|
|
108
|
+
///////////////////
|
|
109
|
+
// Generic Errors
|
|
110
|
+
// Unknown Error
|
|
111
|
+
ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
112
|
+
// Not Implemented
|
|
113
|
+
ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
|
114
|
+
// Unsupported Operation
|
|
115
|
+
// - operation
|
|
116
|
+
ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
|
|
117
|
+
// Network Error (i.e. Ethereum Network, such as an invalid chain ID)
|
|
118
|
+
// - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
|
|
119
|
+
ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
120
|
+
// Some sort of bad response from the server
|
|
121
|
+
ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
122
|
+
// Timeout
|
|
123
|
+
ErrorCode["TIMEOUT"] = "TIMEOUT";
|
|
124
|
+
///////////////////
|
|
125
|
+
// Operational Errors
|
|
126
|
+
// Buffer Overrun
|
|
127
|
+
ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
|
|
128
|
+
// Numeric Fault
|
|
129
|
+
// - operation: the operation being executed
|
|
130
|
+
// - fault: the reason this faulted
|
|
131
|
+
ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
|
|
132
|
+
///////////////////
|
|
133
|
+
// Argument Errors
|
|
134
|
+
// Missing new operator to an object
|
|
135
|
+
// - name: The name of the class
|
|
136
|
+
ErrorCode["MISSING_NEW"] = "MISSING_NEW";
|
|
137
|
+
// Invalid argument (e.g. value is incompatible with type) to a function:
|
|
138
|
+
// - argument: The argument name that was invalid
|
|
139
|
+
// - value: The value of the argument
|
|
140
|
+
ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
|
|
141
|
+
// Missing argument to a function:
|
|
142
|
+
// - count: The number of arguments received
|
|
143
|
+
// - expectedCount: The number of arguments expected
|
|
144
|
+
ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
|
|
145
|
+
// Too many arguments
|
|
146
|
+
// - count: The number of arguments received
|
|
147
|
+
// - expectedCount: The number of arguments expected
|
|
148
|
+
ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
|
|
149
|
+
///////////////////
|
|
150
|
+
// Blockchain Errors
|
|
151
|
+
// Call exception
|
|
152
|
+
// - transaction: the transaction
|
|
153
|
+
// - address?: the contract address
|
|
154
|
+
// - args?: The arguments passed into the function
|
|
155
|
+
// - method?: The Solidity method signature
|
|
156
|
+
// - errorSignature?: The EIP848 error signature
|
|
157
|
+
// - errorArgs?: The EIP848 error parameters
|
|
158
|
+
// - reason: The reason (only for EIP848 "Error(string)")
|
|
159
|
+
ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
|
|
160
|
+
// Insufficient funds (< value + gasLimit * gasPrice)
|
|
161
|
+
// - transaction: the transaction attempted
|
|
162
|
+
ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
163
|
+
// Nonce has already been used
|
|
164
|
+
// - transaction: the transaction attempted
|
|
165
|
+
ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
|
|
166
|
+
// The replacement fee for the transaction is too low
|
|
167
|
+
// - transaction: the transaction attempted
|
|
168
|
+
ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
|
|
169
|
+
// The gas limit could not be estimated
|
|
170
|
+
// - transaction: the transaction passed to estimateGas
|
|
171
|
+
ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
|
172
|
+
// The transaction was replaced by one with a higher gas price
|
|
173
|
+
// - reason: "cancelled", "replaced" or "repriced"
|
|
174
|
+
// - cancelled: true if reason == "cancelled" or reason == "replaced")
|
|
175
|
+
// - hash: original transaction hash
|
|
176
|
+
// - replacement: the full TransactionsResponse for the replacement
|
|
177
|
+
// - receipt: the receipt of the replacement
|
|
178
|
+
ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
|
|
179
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
180
|
+
const HEX = "0123456789abcdef";
|
|
181
|
+
class Logger {
|
|
182
|
+
constructor(version) {
|
|
183
|
+
Object.defineProperty(this, "version", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
value: version,
|
|
186
|
+
writable: false
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
_log(logLevel, args) {
|
|
190
|
+
const level = logLevel.toLowerCase();
|
|
191
|
+
if (LogLevels[level] == null) {
|
|
192
|
+
this.throwArgumentError("invalid log level name", "logLevel", logLevel);
|
|
193
|
+
}
|
|
194
|
+
if (_logLevel > LogLevels[level]) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
console.log.apply(console, args);
|
|
198
|
+
}
|
|
199
|
+
debug(...args) {
|
|
200
|
+
this._log(Logger.levels.DEBUG, args);
|
|
201
|
+
}
|
|
202
|
+
info(...args) {
|
|
203
|
+
this._log(Logger.levels.INFO, args);
|
|
204
|
+
}
|
|
205
|
+
warn(...args) {
|
|
206
|
+
this._log(Logger.levels.WARNING, args);
|
|
207
|
+
}
|
|
208
|
+
makeError(message, code, params) {
|
|
209
|
+
// Errors are being censored
|
|
210
|
+
if (_censorErrors) {
|
|
211
|
+
return this.makeError("censored error", code, {});
|
|
212
|
+
}
|
|
213
|
+
if (!code) {
|
|
214
|
+
code = Logger.errors.UNKNOWN_ERROR;
|
|
215
|
+
}
|
|
216
|
+
if (!params) {
|
|
217
|
+
params = {};
|
|
218
|
+
}
|
|
219
|
+
const messageDetails = [];
|
|
220
|
+
Object.keys(params).forEach((key) => {
|
|
221
|
+
const value = params[key];
|
|
222
|
+
try {
|
|
223
|
+
if (value instanceof Uint8Array) {
|
|
224
|
+
let hex = "";
|
|
225
|
+
for (let i = 0; i < value.length; i++) {
|
|
226
|
+
hex += HEX[value[i] >> 4];
|
|
227
|
+
hex += HEX[value[i] & 0x0f];
|
|
228
|
+
}
|
|
229
|
+
messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
messageDetails.push(key + "=" + JSON.stringify(value));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
messageDetails.push(`code=${code}`);
|
|
240
|
+
messageDetails.push(`version=${this.version}`);
|
|
241
|
+
const reason = message;
|
|
242
|
+
if (messageDetails.length) {
|
|
243
|
+
message += " (" + messageDetails.join(", ") + ")";
|
|
244
|
+
}
|
|
245
|
+
// @TODO: Any??
|
|
246
|
+
const error = new Error(message);
|
|
247
|
+
error.reason = reason;
|
|
248
|
+
error.code = code;
|
|
249
|
+
Object.keys(params).forEach(function (key) {
|
|
250
|
+
error[key] = params[key];
|
|
251
|
+
});
|
|
252
|
+
return error;
|
|
253
|
+
}
|
|
254
|
+
throwError(message, code, params) {
|
|
255
|
+
throw this.makeError(message, code, params);
|
|
256
|
+
}
|
|
257
|
+
throwArgumentError(message, name, value) {
|
|
258
|
+
return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
|
|
259
|
+
argument: name,
|
|
260
|
+
value: value
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
assert(condition, message, code, params) {
|
|
264
|
+
if (!!condition) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
this.throwError(message, code, params);
|
|
268
|
+
}
|
|
269
|
+
assertArgument(condition, message, name, value) {
|
|
270
|
+
if (!!condition) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this.throwArgumentError(message, name, value);
|
|
274
|
+
}
|
|
275
|
+
checkNormalize(message) {
|
|
276
|
+
if (_normalizeError) {
|
|
277
|
+
this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
278
|
+
operation: "String.prototype.normalize", form: _normalizeError
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
checkSafeUint53(value, message) {
|
|
283
|
+
if (typeof (value) !== "number") {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (message == null) {
|
|
287
|
+
message = "value not safe";
|
|
288
|
+
}
|
|
289
|
+
if (value < 0 || value >= 0x1fffffffffffff) {
|
|
290
|
+
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
|
291
|
+
operation: "checkSafeInteger",
|
|
292
|
+
fault: "out-of-safe-range",
|
|
293
|
+
value: value
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (value % 1) {
|
|
297
|
+
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
|
298
|
+
operation: "checkSafeInteger",
|
|
299
|
+
fault: "non-integer",
|
|
300
|
+
value: value
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
checkArgumentCount(count, expectedCount, message) {
|
|
305
|
+
if (message) {
|
|
306
|
+
message = ": " + message;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
message = "";
|
|
310
|
+
}
|
|
311
|
+
if (count < expectedCount) {
|
|
312
|
+
this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
|
|
313
|
+
count: count,
|
|
314
|
+
expectedCount: expectedCount
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
if (count > expectedCount) {
|
|
318
|
+
this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
|
|
319
|
+
count: count,
|
|
320
|
+
expectedCount: expectedCount
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
checkNew(target, kind) {
|
|
325
|
+
if (target === Object || target == null) {
|
|
326
|
+
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
checkAbstract(target, kind) {
|
|
330
|
+
if (target === kind) {
|
|
331
|
+
this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
|
|
332
|
+
}
|
|
333
|
+
else if (target === Object || target == null) {
|
|
334
|
+
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
static globalLogger() {
|
|
338
|
+
if (!_globalLogger) {
|
|
339
|
+
_globalLogger = new Logger(version$2);
|
|
340
|
+
}
|
|
341
|
+
return _globalLogger;
|
|
342
|
+
}
|
|
343
|
+
static setCensorship(censorship, permanent) {
|
|
344
|
+
if (!censorship && permanent) {
|
|
345
|
+
this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
346
|
+
operation: "setCensorship"
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
if (_permanentCensorErrors) {
|
|
350
|
+
if (!censorship) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
354
|
+
operation: "setCensorship"
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
_censorErrors = !!censorship;
|
|
358
|
+
_permanentCensorErrors = !!permanent;
|
|
359
|
+
}
|
|
360
|
+
static setLogLevel(logLevel) {
|
|
361
|
+
const level = LogLevels[logLevel.toLowerCase()];
|
|
362
|
+
if (level == null) {
|
|
363
|
+
Logger.globalLogger().warn("invalid log level - " + logLevel);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
_logLevel = level;
|
|
367
|
+
}
|
|
368
|
+
static from(version) {
|
|
369
|
+
return new Logger(version);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
Logger.errors = ErrorCode;
|
|
373
|
+
Logger.levels = LogLevel;
|
|
374
|
+
|
|
375
|
+
const version$1 = "bytes/5.5.0";
|
|
376
|
+
|
|
377
|
+
const logger = new Logger(version$1);
|
|
378
|
+
///////////////////////////////
|
|
379
|
+
function isHexable(value) {
|
|
380
|
+
return !!(value.toHexString);
|
|
381
|
+
}
|
|
382
|
+
function addSlice(array) {
|
|
383
|
+
if (array.slice) {
|
|
384
|
+
return array;
|
|
385
|
+
}
|
|
386
|
+
array.slice = function () {
|
|
387
|
+
const args = Array.prototype.slice.call(arguments);
|
|
388
|
+
return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
|
|
389
|
+
};
|
|
390
|
+
return array;
|
|
391
|
+
}
|
|
392
|
+
function isInteger(value) {
|
|
393
|
+
return (typeof (value) === "number" && value == value && (value % 1) === 0);
|
|
394
|
+
}
|
|
395
|
+
function isBytes(value) {
|
|
396
|
+
if (value == null) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
if (value.constructor === Uint8Array) {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
if (typeof (value) === "string") {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
if (!isInteger(value.length) || value.length < 0) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
for (let i = 0; i < value.length; i++) {
|
|
409
|
+
const v = value[i];
|
|
410
|
+
if (!isInteger(v) || v < 0 || v >= 256) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
function arrayify(value, options) {
|
|
417
|
+
if (!options) {
|
|
418
|
+
options = {};
|
|
419
|
+
}
|
|
420
|
+
if (typeof (value) === "number") {
|
|
421
|
+
logger.checkSafeUint53(value, "invalid arrayify value");
|
|
422
|
+
const result = [];
|
|
423
|
+
while (value) {
|
|
424
|
+
result.unshift(value & 0xff);
|
|
425
|
+
value = parseInt(String(value / 256));
|
|
426
|
+
}
|
|
427
|
+
if (result.length === 0) {
|
|
428
|
+
result.push(0);
|
|
429
|
+
}
|
|
430
|
+
return addSlice(new Uint8Array(result));
|
|
431
|
+
}
|
|
432
|
+
if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
|
|
433
|
+
value = "0x" + value;
|
|
434
|
+
}
|
|
435
|
+
if (isHexable(value)) {
|
|
436
|
+
value = value.toHexString();
|
|
437
|
+
}
|
|
438
|
+
if (isHexString(value)) {
|
|
439
|
+
let hex = value.substring(2);
|
|
440
|
+
if (hex.length % 2) {
|
|
441
|
+
if (options.hexPad === "left") {
|
|
442
|
+
hex = "0x0" + hex.substring(2);
|
|
443
|
+
}
|
|
444
|
+
else if (options.hexPad === "right") {
|
|
445
|
+
hex += "0";
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
logger.throwArgumentError("hex data is odd-length", "value", value);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const result = [];
|
|
452
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
453
|
+
result.push(parseInt(hex.substring(i, i + 2), 16));
|
|
454
|
+
}
|
|
455
|
+
return addSlice(new Uint8Array(result));
|
|
456
|
+
}
|
|
457
|
+
if (isBytes(value)) {
|
|
458
|
+
return addSlice(new Uint8Array(value));
|
|
459
|
+
}
|
|
460
|
+
return logger.throwArgumentError("invalid arrayify value", "value", value);
|
|
461
|
+
}
|
|
462
|
+
function isHexString(value, length) {
|
|
463
|
+
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
if (length && value.length !== 2 + 2 * length) {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
return true;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
var hash$1 = {};
|
|
473
|
+
|
|
474
|
+
var utils$9 = {};
|
|
475
|
+
|
|
476
|
+
var minimalisticAssert = assert$6;
|
|
477
|
+
|
|
478
|
+
function assert$6(val, msg) {
|
|
479
|
+
if (!val)
|
|
480
|
+
throw new Error(msg || 'Assertion failed');
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
assert$6.equal = function assertEqual(l, r, msg) {
|
|
484
|
+
if (l != r)
|
|
485
|
+
throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
var inherits$1 = {exports: {}};
|
|
489
|
+
|
|
490
|
+
var inherits_browser = {exports: {}};
|
|
491
|
+
|
|
492
|
+
if (typeof Object.create === 'function') {
|
|
493
|
+
// implementation from standard node.js 'util' module
|
|
494
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
495
|
+
ctor.super_ = superCtor;
|
|
496
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
497
|
+
constructor: {
|
|
498
|
+
value: ctor,
|
|
499
|
+
enumerable: false,
|
|
500
|
+
writable: true,
|
|
501
|
+
configurable: true
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
} else {
|
|
506
|
+
// old school shim for old browsers
|
|
507
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
508
|
+
ctor.super_ = superCtor;
|
|
509
|
+
var TempCtor = function () {};
|
|
510
|
+
TempCtor.prototype = superCtor.prototype;
|
|
511
|
+
ctor.prototype = new TempCtor();
|
|
512
|
+
ctor.prototype.constructor = ctor;
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
try {
|
|
517
|
+
var util = require('util');
|
|
518
|
+
if (typeof util.inherits !== 'function') throw '';
|
|
519
|
+
inherits$1.exports = util.inherits;
|
|
520
|
+
} catch (e) {
|
|
521
|
+
inherits$1.exports = inherits_browser.exports;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
var assert$5 = minimalisticAssert;
|
|
525
|
+
var inherits = inherits$1.exports;
|
|
526
|
+
|
|
527
|
+
utils$9.inherits = inherits;
|
|
528
|
+
|
|
529
|
+
function isSurrogatePair(msg, i) {
|
|
530
|
+
if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
if (i < 0 || i + 1 >= msg.length) {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function toArray(msg, enc) {
|
|
540
|
+
if (Array.isArray(msg))
|
|
541
|
+
return msg.slice();
|
|
542
|
+
if (!msg)
|
|
543
|
+
return [];
|
|
544
|
+
var res = [];
|
|
545
|
+
if (typeof msg === 'string') {
|
|
546
|
+
if (!enc) {
|
|
547
|
+
// Inspired by stringToUtf8ByteArray() in closure-library by Google
|
|
548
|
+
// https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
|
|
549
|
+
// Apache License 2.0
|
|
550
|
+
// https://github.com/google/closure-library/blob/master/LICENSE
|
|
551
|
+
var p = 0;
|
|
552
|
+
for (var i = 0; i < msg.length; i++) {
|
|
553
|
+
var c = msg.charCodeAt(i);
|
|
554
|
+
if (c < 128) {
|
|
555
|
+
res[p++] = c;
|
|
556
|
+
} else if (c < 2048) {
|
|
557
|
+
res[p++] = (c >> 6) | 192;
|
|
558
|
+
res[p++] = (c & 63) | 128;
|
|
559
|
+
} else if (isSurrogatePair(msg, i)) {
|
|
560
|
+
c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
|
|
561
|
+
res[p++] = (c >> 18) | 240;
|
|
562
|
+
res[p++] = ((c >> 12) & 63) | 128;
|
|
563
|
+
res[p++] = ((c >> 6) & 63) | 128;
|
|
564
|
+
res[p++] = (c & 63) | 128;
|
|
565
|
+
} else {
|
|
566
|
+
res[p++] = (c >> 12) | 224;
|
|
567
|
+
res[p++] = ((c >> 6) & 63) | 128;
|
|
568
|
+
res[p++] = (c & 63) | 128;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
} else if (enc === 'hex') {
|
|
572
|
+
msg = msg.replace(/[^a-z0-9]+/ig, '');
|
|
573
|
+
if (msg.length % 2 !== 0)
|
|
574
|
+
msg = '0' + msg;
|
|
575
|
+
for (i = 0; i < msg.length; i += 2)
|
|
576
|
+
res.push(parseInt(msg[i] + msg[i + 1], 16));
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
for (i = 0; i < msg.length; i++)
|
|
580
|
+
res[i] = msg[i] | 0;
|
|
581
|
+
}
|
|
582
|
+
return res;
|
|
583
|
+
}
|
|
584
|
+
utils$9.toArray = toArray;
|
|
585
|
+
|
|
586
|
+
function toHex(msg) {
|
|
587
|
+
var res = '';
|
|
588
|
+
for (var i = 0; i < msg.length; i++)
|
|
589
|
+
res += zero2(msg[i].toString(16));
|
|
590
|
+
return res;
|
|
591
|
+
}
|
|
592
|
+
utils$9.toHex = toHex;
|
|
593
|
+
|
|
594
|
+
function htonl(w) {
|
|
595
|
+
var res = (w >>> 24) |
|
|
596
|
+
((w >>> 8) & 0xff00) |
|
|
597
|
+
((w << 8) & 0xff0000) |
|
|
598
|
+
((w & 0xff) << 24);
|
|
599
|
+
return res >>> 0;
|
|
600
|
+
}
|
|
601
|
+
utils$9.htonl = htonl;
|
|
602
|
+
|
|
603
|
+
function toHex32(msg, endian) {
|
|
604
|
+
var res = '';
|
|
605
|
+
for (var i = 0; i < msg.length; i++) {
|
|
606
|
+
var w = msg[i];
|
|
607
|
+
if (endian === 'little')
|
|
608
|
+
w = htonl(w);
|
|
609
|
+
res += zero8(w.toString(16));
|
|
610
|
+
}
|
|
611
|
+
return res;
|
|
612
|
+
}
|
|
613
|
+
utils$9.toHex32 = toHex32;
|
|
614
|
+
|
|
615
|
+
function zero2(word) {
|
|
616
|
+
if (word.length === 1)
|
|
617
|
+
return '0' + word;
|
|
618
|
+
else
|
|
619
|
+
return word;
|
|
620
|
+
}
|
|
621
|
+
utils$9.zero2 = zero2;
|
|
622
|
+
|
|
623
|
+
function zero8(word) {
|
|
624
|
+
if (word.length === 7)
|
|
625
|
+
return '0' + word;
|
|
626
|
+
else if (word.length === 6)
|
|
627
|
+
return '00' + word;
|
|
628
|
+
else if (word.length === 5)
|
|
629
|
+
return '000' + word;
|
|
630
|
+
else if (word.length === 4)
|
|
631
|
+
return '0000' + word;
|
|
632
|
+
else if (word.length === 3)
|
|
633
|
+
return '00000' + word;
|
|
634
|
+
else if (word.length === 2)
|
|
635
|
+
return '000000' + word;
|
|
636
|
+
else if (word.length === 1)
|
|
637
|
+
return '0000000' + word;
|
|
638
|
+
else
|
|
639
|
+
return word;
|
|
640
|
+
}
|
|
641
|
+
utils$9.zero8 = zero8;
|
|
642
|
+
|
|
643
|
+
function join32(msg, start, end, endian) {
|
|
644
|
+
var len = end - start;
|
|
645
|
+
assert$5(len % 4 === 0);
|
|
646
|
+
var res = new Array(len / 4);
|
|
647
|
+
for (var i = 0, k = start; i < res.length; i++, k += 4) {
|
|
648
|
+
var w;
|
|
649
|
+
if (endian === 'big')
|
|
650
|
+
w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
|
|
651
|
+
else
|
|
652
|
+
w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
|
|
653
|
+
res[i] = w >>> 0;
|
|
654
|
+
}
|
|
655
|
+
return res;
|
|
656
|
+
}
|
|
657
|
+
utils$9.join32 = join32;
|
|
658
|
+
|
|
659
|
+
function split32(msg, endian) {
|
|
660
|
+
var res = new Array(msg.length * 4);
|
|
661
|
+
for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
|
|
662
|
+
var m = msg[i];
|
|
663
|
+
if (endian === 'big') {
|
|
664
|
+
res[k] = m >>> 24;
|
|
665
|
+
res[k + 1] = (m >>> 16) & 0xff;
|
|
666
|
+
res[k + 2] = (m >>> 8) & 0xff;
|
|
667
|
+
res[k + 3] = m & 0xff;
|
|
668
|
+
} else {
|
|
669
|
+
res[k + 3] = m >>> 24;
|
|
670
|
+
res[k + 2] = (m >>> 16) & 0xff;
|
|
671
|
+
res[k + 1] = (m >>> 8) & 0xff;
|
|
672
|
+
res[k] = m & 0xff;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return res;
|
|
676
|
+
}
|
|
677
|
+
utils$9.split32 = split32;
|
|
678
|
+
|
|
679
|
+
function rotr32$1(w, b) {
|
|
680
|
+
return (w >>> b) | (w << (32 - b));
|
|
681
|
+
}
|
|
682
|
+
utils$9.rotr32 = rotr32$1;
|
|
683
|
+
|
|
684
|
+
function rotl32$2(w, b) {
|
|
685
|
+
return (w << b) | (w >>> (32 - b));
|
|
686
|
+
}
|
|
687
|
+
utils$9.rotl32 = rotl32$2;
|
|
688
|
+
|
|
689
|
+
function sum32$3(a, b) {
|
|
690
|
+
return (a + b) >>> 0;
|
|
691
|
+
}
|
|
692
|
+
utils$9.sum32 = sum32$3;
|
|
693
|
+
|
|
694
|
+
function sum32_3$1(a, b, c) {
|
|
695
|
+
return (a + b + c) >>> 0;
|
|
696
|
+
}
|
|
697
|
+
utils$9.sum32_3 = sum32_3$1;
|
|
698
|
+
|
|
699
|
+
function sum32_4$2(a, b, c, d) {
|
|
700
|
+
return (a + b + c + d) >>> 0;
|
|
701
|
+
}
|
|
702
|
+
utils$9.sum32_4 = sum32_4$2;
|
|
703
|
+
|
|
704
|
+
function sum32_5$2(a, b, c, d, e) {
|
|
705
|
+
return (a + b + c + d + e) >>> 0;
|
|
706
|
+
}
|
|
707
|
+
utils$9.sum32_5 = sum32_5$2;
|
|
708
|
+
|
|
709
|
+
function sum64$1(buf, pos, ah, al) {
|
|
710
|
+
var bh = buf[pos];
|
|
711
|
+
var bl = buf[pos + 1];
|
|
712
|
+
|
|
713
|
+
var lo = (al + bl) >>> 0;
|
|
714
|
+
var hi = (lo < al ? 1 : 0) + ah + bh;
|
|
715
|
+
buf[pos] = hi >>> 0;
|
|
716
|
+
buf[pos + 1] = lo;
|
|
717
|
+
}
|
|
718
|
+
utils$9.sum64 = sum64$1;
|
|
719
|
+
|
|
720
|
+
function sum64_hi$1(ah, al, bh, bl) {
|
|
721
|
+
var lo = (al + bl) >>> 0;
|
|
722
|
+
var hi = (lo < al ? 1 : 0) + ah + bh;
|
|
723
|
+
return hi >>> 0;
|
|
724
|
+
}
|
|
725
|
+
utils$9.sum64_hi = sum64_hi$1;
|
|
726
|
+
|
|
727
|
+
function sum64_lo$1(ah, al, bh, bl) {
|
|
728
|
+
var lo = al + bl;
|
|
729
|
+
return lo >>> 0;
|
|
730
|
+
}
|
|
731
|
+
utils$9.sum64_lo = sum64_lo$1;
|
|
732
|
+
|
|
733
|
+
function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
|
|
734
|
+
var carry = 0;
|
|
735
|
+
var lo = al;
|
|
736
|
+
lo = (lo + bl) >>> 0;
|
|
737
|
+
carry += lo < al ? 1 : 0;
|
|
738
|
+
lo = (lo + cl) >>> 0;
|
|
739
|
+
carry += lo < cl ? 1 : 0;
|
|
740
|
+
lo = (lo + dl) >>> 0;
|
|
741
|
+
carry += lo < dl ? 1 : 0;
|
|
742
|
+
|
|
743
|
+
var hi = ah + bh + ch + dh + carry;
|
|
744
|
+
return hi >>> 0;
|
|
745
|
+
}
|
|
746
|
+
utils$9.sum64_4_hi = sum64_4_hi$1;
|
|
747
|
+
|
|
748
|
+
function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
|
|
749
|
+
var lo = al + bl + cl + dl;
|
|
750
|
+
return lo >>> 0;
|
|
751
|
+
}
|
|
752
|
+
utils$9.sum64_4_lo = sum64_4_lo$1;
|
|
753
|
+
|
|
754
|
+
function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
|
|
755
|
+
var carry = 0;
|
|
756
|
+
var lo = al;
|
|
757
|
+
lo = (lo + bl) >>> 0;
|
|
758
|
+
carry += lo < al ? 1 : 0;
|
|
759
|
+
lo = (lo + cl) >>> 0;
|
|
760
|
+
carry += lo < cl ? 1 : 0;
|
|
761
|
+
lo = (lo + dl) >>> 0;
|
|
762
|
+
carry += lo < dl ? 1 : 0;
|
|
763
|
+
lo = (lo + el) >>> 0;
|
|
764
|
+
carry += lo < el ? 1 : 0;
|
|
765
|
+
|
|
766
|
+
var hi = ah + bh + ch + dh + eh + carry;
|
|
767
|
+
return hi >>> 0;
|
|
768
|
+
}
|
|
769
|
+
utils$9.sum64_5_hi = sum64_5_hi$1;
|
|
770
|
+
|
|
771
|
+
function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
|
|
772
|
+
var lo = al + bl + cl + dl + el;
|
|
773
|
+
|
|
774
|
+
return lo >>> 0;
|
|
775
|
+
}
|
|
776
|
+
utils$9.sum64_5_lo = sum64_5_lo$1;
|
|
777
|
+
|
|
778
|
+
function rotr64_hi$1(ah, al, num) {
|
|
779
|
+
var r = (al << (32 - num)) | (ah >>> num);
|
|
780
|
+
return r >>> 0;
|
|
781
|
+
}
|
|
782
|
+
utils$9.rotr64_hi = rotr64_hi$1;
|
|
783
|
+
|
|
784
|
+
function rotr64_lo$1(ah, al, num) {
|
|
785
|
+
var r = (ah << (32 - num)) | (al >>> num);
|
|
786
|
+
return r >>> 0;
|
|
787
|
+
}
|
|
788
|
+
utils$9.rotr64_lo = rotr64_lo$1;
|
|
789
|
+
|
|
790
|
+
function shr64_hi$1(ah, al, num) {
|
|
791
|
+
return ah >>> num;
|
|
792
|
+
}
|
|
793
|
+
utils$9.shr64_hi = shr64_hi$1;
|
|
794
|
+
|
|
795
|
+
function shr64_lo$1(ah, al, num) {
|
|
796
|
+
var r = (ah << (32 - num)) | (al >>> num);
|
|
797
|
+
return r >>> 0;
|
|
798
|
+
}
|
|
799
|
+
utils$9.shr64_lo = shr64_lo$1;
|
|
800
|
+
|
|
801
|
+
var common$5 = {};
|
|
802
|
+
|
|
803
|
+
var utils$8 = utils$9;
|
|
804
|
+
var assert$4 = minimalisticAssert;
|
|
805
|
+
|
|
806
|
+
function BlockHash$4() {
|
|
807
|
+
this.pending = null;
|
|
808
|
+
this.pendingTotal = 0;
|
|
809
|
+
this.blockSize = this.constructor.blockSize;
|
|
810
|
+
this.outSize = this.constructor.outSize;
|
|
811
|
+
this.hmacStrength = this.constructor.hmacStrength;
|
|
812
|
+
this.padLength = this.constructor.padLength / 8;
|
|
813
|
+
this.endian = 'big';
|
|
814
|
+
|
|
815
|
+
this._delta8 = this.blockSize / 8;
|
|
816
|
+
this._delta32 = this.blockSize / 32;
|
|
817
|
+
}
|
|
818
|
+
common$5.BlockHash = BlockHash$4;
|
|
819
|
+
|
|
820
|
+
BlockHash$4.prototype.update = function update(msg, enc) {
|
|
821
|
+
// Convert message to array, pad it, and join into 32bit blocks
|
|
822
|
+
msg = utils$8.toArray(msg, enc);
|
|
823
|
+
if (!this.pending)
|
|
824
|
+
this.pending = msg;
|
|
825
|
+
else
|
|
826
|
+
this.pending = this.pending.concat(msg);
|
|
827
|
+
this.pendingTotal += msg.length;
|
|
828
|
+
|
|
829
|
+
// Enough data, try updating
|
|
830
|
+
if (this.pending.length >= this._delta8) {
|
|
831
|
+
msg = this.pending;
|
|
832
|
+
|
|
833
|
+
// Process pending data in blocks
|
|
834
|
+
var r = msg.length % this._delta8;
|
|
835
|
+
this.pending = msg.slice(msg.length - r, msg.length);
|
|
836
|
+
if (this.pending.length === 0)
|
|
837
|
+
this.pending = null;
|
|
838
|
+
|
|
839
|
+
msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
|
|
840
|
+
for (var i = 0; i < msg.length; i += this._delta32)
|
|
841
|
+
this._update(msg, i, i + this._delta32);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
return this;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
BlockHash$4.prototype.digest = function digest(enc) {
|
|
848
|
+
this.update(this._pad());
|
|
849
|
+
assert$4(this.pending === null);
|
|
850
|
+
|
|
851
|
+
return this._digest(enc);
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
BlockHash$4.prototype._pad = function pad() {
|
|
855
|
+
var len = this.pendingTotal;
|
|
856
|
+
var bytes = this._delta8;
|
|
857
|
+
var k = bytes - ((len + this.padLength) % bytes);
|
|
858
|
+
var res = new Array(k + this.padLength);
|
|
859
|
+
res[0] = 0x80;
|
|
860
|
+
for (var i = 1; i < k; i++)
|
|
861
|
+
res[i] = 0;
|
|
862
|
+
|
|
863
|
+
// Append length
|
|
864
|
+
len <<= 3;
|
|
865
|
+
if (this.endian === 'big') {
|
|
866
|
+
for (var t = 8; t < this.padLength; t++)
|
|
867
|
+
res[i++] = 0;
|
|
868
|
+
|
|
869
|
+
res[i++] = 0;
|
|
870
|
+
res[i++] = 0;
|
|
871
|
+
res[i++] = 0;
|
|
872
|
+
res[i++] = 0;
|
|
873
|
+
res[i++] = (len >>> 24) & 0xff;
|
|
874
|
+
res[i++] = (len >>> 16) & 0xff;
|
|
875
|
+
res[i++] = (len >>> 8) & 0xff;
|
|
876
|
+
res[i++] = len & 0xff;
|
|
877
|
+
} else {
|
|
878
|
+
res[i++] = len & 0xff;
|
|
879
|
+
res[i++] = (len >>> 8) & 0xff;
|
|
880
|
+
res[i++] = (len >>> 16) & 0xff;
|
|
881
|
+
res[i++] = (len >>> 24) & 0xff;
|
|
882
|
+
res[i++] = 0;
|
|
883
|
+
res[i++] = 0;
|
|
884
|
+
res[i++] = 0;
|
|
885
|
+
res[i++] = 0;
|
|
886
|
+
|
|
887
|
+
for (t = 8; t < this.padLength; t++)
|
|
888
|
+
res[i++] = 0;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
return res;
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
var sha = {};
|
|
895
|
+
|
|
896
|
+
var common$4 = {};
|
|
897
|
+
|
|
898
|
+
var utils$7 = utils$9;
|
|
899
|
+
var rotr32 = utils$7.rotr32;
|
|
900
|
+
|
|
901
|
+
function ft_1$1(s, x, y, z) {
|
|
902
|
+
if (s === 0)
|
|
903
|
+
return ch32$1(x, y, z);
|
|
904
|
+
if (s === 1 || s === 3)
|
|
905
|
+
return p32(x, y, z);
|
|
906
|
+
if (s === 2)
|
|
907
|
+
return maj32$1(x, y, z);
|
|
908
|
+
}
|
|
909
|
+
common$4.ft_1 = ft_1$1;
|
|
910
|
+
|
|
911
|
+
function ch32$1(x, y, z) {
|
|
912
|
+
return (x & y) ^ ((~x) & z);
|
|
913
|
+
}
|
|
914
|
+
common$4.ch32 = ch32$1;
|
|
915
|
+
|
|
916
|
+
function maj32$1(x, y, z) {
|
|
917
|
+
return (x & y) ^ (x & z) ^ (y & z);
|
|
918
|
+
}
|
|
919
|
+
common$4.maj32 = maj32$1;
|
|
920
|
+
|
|
921
|
+
function p32(x, y, z) {
|
|
922
|
+
return x ^ y ^ z;
|
|
923
|
+
}
|
|
924
|
+
common$4.p32 = p32;
|
|
925
|
+
|
|
926
|
+
function s0_256$1(x) {
|
|
927
|
+
return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
|
|
928
|
+
}
|
|
929
|
+
common$4.s0_256 = s0_256$1;
|
|
930
|
+
|
|
931
|
+
function s1_256$1(x) {
|
|
932
|
+
return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
|
|
933
|
+
}
|
|
934
|
+
common$4.s1_256 = s1_256$1;
|
|
935
|
+
|
|
936
|
+
function g0_256$1(x) {
|
|
937
|
+
return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
|
|
938
|
+
}
|
|
939
|
+
common$4.g0_256 = g0_256$1;
|
|
940
|
+
|
|
941
|
+
function g1_256$1(x) {
|
|
942
|
+
return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
|
|
943
|
+
}
|
|
944
|
+
common$4.g1_256 = g1_256$1;
|
|
945
|
+
|
|
946
|
+
var utils$6 = utils$9;
|
|
947
|
+
var common$3 = common$5;
|
|
948
|
+
var shaCommon$1 = common$4;
|
|
949
|
+
|
|
950
|
+
var rotl32$1 = utils$6.rotl32;
|
|
951
|
+
var sum32$2 = utils$6.sum32;
|
|
952
|
+
var sum32_5$1 = utils$6.sum32_5;
|
|
953
|
+
var ft_1 = shaCommon$1.ft_1;
|
|
954
|
+
var BlockHash$3 = common$3.BlockHash;
|
|
955
|
+
|
|
956
|
+
var sha1_K = [
|
|
957
|
+
0x5A827999, 0x6ED9EBA1,
|
|
958
|
+
0x8F1BBCDC, 0xCA62C1D6
|
|
959
|
+
];
|
|
960
|
+
|
|
961
|
+
function SHA1() {
|
|
962
|
+
if (!(this instanceof SHA1))
|
|
963
|
+
return new SHA1();
|
|
964
|
+
|
|
965
|
+
BlockHash$3.call(this);
|
|
966
|
+
this.h = [
|
|
967
|
+
0x67452301, 0xefcdab89, 0x98badcfe,
|
|
968
|
+
0x10325476, 0xc3d2e1f0 ];
|
|
969
|
+
this.W = new Array(80);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
utils$6.inherits(SHA1, BlockHash$3);
|
|
973
|
+
var _1 = SHA1;
|
|
974
|
+
|
|
975
|
+
SHA1.blockSize = 512;
|
|
976
|
+
SHA1.outSize = 160;
|
|
977
|
+
SHA1.hmacStrength = 80;
|
|
978
|
+
SHA1.padLength = 64;
|
|
979
|
+
|
|
980
|
+
SHA1.prototype._update = function _update(msg, start) {
|
|
981
|
+
var W = this.W;
|
|
982
|
+
|
|
983
|
+
for (var i = 0; i < 16; i++)
|
|
984
|
+
W[i] = msg[start + i];
|
|
985
|
+
|
|
986
|
+
for(; i < W.length; i++)
|
|
987
|
+
W[i] = rotl32$1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
|
|
988
|
+
|
|
989
|
+
var a = this.h[0];
|
|
990
|
+
var b = this.h[1];
|
|
991
|
+
var c = this.h[2];
|
|
992
|
+
var d = this.h[3];
|
|
993
|
+
var e = this.h[4];
|
|
994
|
+
|
|
995
|
+
for (i = 0; i < W.length; i++) {
|
|
996
|
+
var s = ~~(i / 20);
|
|
997
|
+
var t = sum32_5$1(rotl32$1(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
|
|
998
|
+
e = d;
|
|
999
|
+
d = c;
|
|
1000
|
+
c = rotl32$1(b, 30);
|
|
1001
|
+
b = a;
|
|
1002
|
+
a = t;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
this.h[0] = sum32$2(this.h[0], a);
|
|
1006
|
+
this.h[1] = sum32$2(this.h[1], b);
|
|
1007
|
+
this.h[2] = sum32$2(this.h[2], c);
|
|
1008
|
+
this.h[3] = sum32$2(this.h[3], d);
|
|
1009
|
+
this.h[4] = sum32$2(this.h[4], e);
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
SHA1.prototype._digest = function digest(enc) {
|
|
1013
|
+
if (enc === 'hex')
|
|
1014
|
+
return utils$6.toHex32(this.h, 'big');
|
|
1015
|
+
else
|
|
1016
|
+
return utils$6.split32(this.h, 'big');
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
var utils$5 = utils$9;
|
|
1020
|
+
var common$2 = common$5;
|
|
1021
|
+
var shaCommon = common$4;
|
|
1022
|
+
var assert$3 = minimalisticAssert;
|
|
1023
|
+
|
|
1024
|
+
var sum32$1 = utils$5.sum32;
|
|
1025
|
+
var sum32_4$1 = utils$5.sum32_4;
|
|
1026
|
+
var sum32_5 = utils$5.sum32_5;
|
|
1027
|
+
var ch32 = shaCommon.ch32;
|
|
1028
|
+
var maj32 = shaCommon.maj32;
|
|
1029
|
+
var s0_256 = shaCommon.s0_256;
|
|
1030
|
+
var s1_256 = shaCommon.s1_256;
|
|
1031
|
+
var g0_256 = shaCommon.g0_256;
|
|
1032
|
+
var g1_256 = shaCommon.g1_256;
|
|
1033
|
+
|
|
1034
|
+
var BlockHash$2 = common$2.BlockHash;
|
|
1035
|
+
|
|
1036
|
+
var sha256_K = [
|
|
1037
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
|
1038
|
+
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
1039
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
1040
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
1041
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
|
1042
|
+
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
1043
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
|
1044
|
+
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
1045
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
1046
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
1047
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
|
1048
|
+
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
1049
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
|
1050
|
+
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
1051
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
1052
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
1053
|
+
];
|
|
1054
|
+
|
|
1055
|
+
function SHA256$1() {
|
|
1056
|
+
if (!(this instanceof SHA256$1))
|
|
1057
|
+
return new SHA256$1();
|
|
1058
|
+
|
|
1059
|
+
BlockHash$2.call(this);
|
|
1060
|
+
this.h = [
|
|
1061
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
|
1062
|
+
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
1063
|
+
];
|
|
1064
|
+
this.k = sha256_K;
|
|
1065
|
+
this.W = new Array(64);
|
|
1066
|
+
}
|
|
1067
|
+
utils$5.inherits(SHA256$1, BlockHash$2);
|
|
1068
|
+
var _256 = SHA256$1;
|
|
1069
|
+
|
|
1070
|
+
SHA256$1.blockSize = 512;
|
|
1071
|
+
SHA256$1.outSize = 256;
|
|
1072
|
+
SHA256$1.hmacStrength = 192;
|
|
1073
|
+
SHA256$1.padLength = 64;
|
|
1074
|
+
|
|
1075
|
+
SHA256$1.prototype._update = function _update(msg, start) {
|
|
1076
|
+
var W = this.W;
|
|
1077
|
+
|
|
1078
|
+
for (var i = 0; i < 16; i++)
|
|
1079
|
+
W[i] = msg[start + i];
|
|
1080
|
+
for (; i < W.length; i++)
|
|
1081
|
+
W[i] = sum32_4$1(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
|
|
1082
|
+
|
|
1083
|
+
var a = this.h[0];
|
|
1084
|
+
var b = this.h[1];
|
|
1085
|
+
var c = this.h[2];
|
|
1086
|
+
var d = this.h[3];
|
|
1087
|
+
var e = this.h[4];
|
|
1088
|
+
var f = this.h[5];
|
|
1089
|
+
var g = this.h[6];
|
|
1090
|
+
var h = this.h[7];
|
|
1091
|
+
|
|
1092
|
+
assert$3(this.k.length === W.length);
|
|
1093
|
+
for (i = 0; i < W.length; i++) {
|
|
1094
|
+
var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
|
|
1095
|
+
var T2 = sum32$1(s0_256(a), maj32(a, b, c));
|
|
1096
|
+
h = g;
|
|
1097
|
+
g = f;
|
|
1098
|
+
f = e;
|
|
1099
|
+
e = sum32$1(d, T1);
|
|
1100
|
+
d = c;
|
|
1101
|
+
c = b;
|
|
1102
|
+
b = a;
|
|
1103
|
+
a = sum32$1(T1, T2);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
this.h[0] = sum32$1(this.h[0], a);
|
|
1107
|
+
this.h[1] = sum32$1(this.h[1], b);
|
|
1108
|
+
this.h[2] = sum32$1(this.h[2], c);
|
|
1109
|
+
this.h[3] = sum32$1(this.h[3], d);
|
|
1110
|
+
this.h[4] = sum32$1(this.h[4], e);
|
|
1111
|
+
this.h[5] = sum32$1(this.h[5], f);
|
|
1112
|
+
this.h[6] = sum32$1(this.h[6], g);
|
|
1113
|
+
this.h[7] = sum32$1(this.h[7], h);
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
SHA256$1.prototype._digest = function digest(enc) {
|
|
1117
|
+
if (enc === 'hex')
|
|
1118
|
+
return utils$5.toHex32(this.h, 'big');
|
|
1119
|
+
else
|
|
1120
|
+
return utils$5.split32(this.h, 'big');
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
var utils$4 = utils$9;
|
|
1124
|
+
var SHA256 = _256;
|
|
1125
|
+
|
|
1126
|
+
function SHA224() {
|
|
1127
|
+
if (!(this instanceof SHA224))
|
|
1128
|
+
return new SHA224();
|
|
1129
|
+
|
|
1130
|
+
SHA256.call(this);
|
|
1131
|
+
this.h = [
|
|
1132
|
+
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
|
|
1133
|
+
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
|
|
1134
|
+
}
|
|
1135
|
+
utils$4.inherits(SHA224, SHA256);
|
|
1136
|
+
var _224 = SHA224;
|
|
1137
|
+
|
|
1138
|
+
SHA224.blockSize = 512;
|
|
1139
|
+
SHA224.outSize = 224;
|
|
1140
|
+
SHA224.hmacStrength = 192;
|
|
1141
|
+
SHA224.padLength = 64;
|
|
1142
|
+
|
|
1143
|
+
SHA224.prototype._digest = function digest(enc) {
|
|
1144
|
+
// Just truncate output
|
|
1145
|
+
if (enc === 'hex')
|
|
1146
|
+
return utils$4.toHex32(this.h.slice(0, 7), 'big');
|
|
1147
|
+
else
|
|
1148
|
+
return utils$4.split32(this.h.slice(0, 7), 'big');
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
var utils$3 = utils$9;
|
|
1152
|
+
var common$1 = common$5;
|
|
1153
|
+
var assert$2 = minimalisticAssert;
|
|
1154
|
+
|
|
1155
|
+
var rotr64_hi = utils$3.rotr64_hi;
|
|
1156
|
+
var rotr64_lo = utils$3.rotr64_lo;
|
|
1157
|
+
var shr64_hi = utils$3.shr64_hi;
|
|
1158
|
+
var shr64_lo = utils$3.shr64_lo;
|
|
1159
|
+
var sum64 = utils$3.sum64;
|
|
1160
|
+
var sum64_hi = utils$3.sum64_hi;
|
|
1161
|
+
var sum64_lo = utils$3.sum64_lo;
|
|
1162
|
+
var sum64_4_hi = utils$3.sum64_4_hi;
|
|
1163
|
+
var sum64_4_lo = utils$3.sum64_4_lo;
|
|
1164
|
+
var sum64_5_hi = utils$3.sum64_5_hi;
|
|
1165
|
+
var sum64_5_lo = utils$3.sum64_5_lo;
|
|
1166
|
+
|
|
1167
|
+
var BlockHash$1 = common$1.BlockHash;
|
|
1168
|
+
|
|
1169
|
+
var sha512_K = [
|
|
1170
|
+
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
|
|
1171
|
+
0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
|
|
1172
|
+
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
|
|
1173
|
+
0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
|
|
1174
|
+
0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
|
|
1175
|
+
0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
|
|
1176
|
+
0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
|
|
1177
|
+
0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
|
|
1178
|
+
0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
|
|
1179
|
+
0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
|
|
1180
|
+
0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
|
|
1181
|
+
0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
|
|
1182
|
+
0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
|
|
1183
|
+
0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
|
|
1184
|
+
0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
|
|
1185
|
+
0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
|
|
1186
|
+
0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
|
|
1187
|
+
0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
|
|
1188
|
+
0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
|
|
1189
|
+
0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
|
|
1190
|
+
0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
|
|
1191
|
+
0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
|
|
1192
|
+
0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
|
|
1193
|
+
0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
|
|
1194
|
+
0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
|
|
1195
|
+
0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
|
|
1196
|
+
0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
|
|
1197
|
+
0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
|
|
1198
|
+
0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
|
|
1199
|
+
0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
|
|
1200
|
+
0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
|
|
1201
|
+
0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
|
|
1202
|
+
0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
|
|
1203
|
+
0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
|
|
1204
|
+
0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
|
|
1205
|
+
0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
|
|
1206
|
+
0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
|
|
1207
|
+
0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
|
|
1208
|
+
0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
|
|
1209
|
+
0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
|
|
1210
|
+
];
|
|
1211
|
+
|
|
1212
|
+
function SHA512$1() {
|
|
1213
|
+
if (!(this instanceof SHA512$1))
|
|
1214
|
+
return new SHA512$1();
|
|
1215
|
+
|
|
1216
|
+
BlockHash$1.call(this);
|
|
1217
|
+
this.h = [
|
|
1218
|
+
0x6a09e667, 0xf3bcc908,
|
|
1219
|
+
0xbb67ae85, 0x84caa73b,
|
|
1220
|
+
0x3c6ef372, 0xfe94f82b,
|
|
1221
|
+
0xa54ff53a, 0x5f1d36f1,
|
|
1222
|
+
0x510e527f, 0xade682d1,
|
|
1223
|
+
0x9b05688c, 0x2b3e6c1f,
|
|
1224
|
+
0x1f83d9ab, 0xfb41bd6b,
|
|
1225
|
+
0x5be0cd19, 0x137e2179 ];
|
|
1226
|
+
this.k = sha512_K;
|
|
1227
|
+
this.W = new Array(160);
|
|
1228
|
+
}
|
|
1229
|
+
utils$3.inherits(SHA512$1, BlockHash$1);
|
|
1230
|
+
var _512 = SHA512$1;
|
|
1231
|
+
|
|
1232
|
+
SHA512$1.blockSize = 1024;
|
|
1233
|
+
SHA512$1.outSize = 512;
|
|
1234
|
+
SHA512$1.hmacStrength = 192;
|
|
1235
|
+
SHA512$1.padLength = 128;
|
|
1236
|
+
|
|
1237
|
+
SHA512$1.prototype._prepareBlock = function _prepareBlock(msg, start) {
|
|
1238
|
+
var W = this.W;
|
|
1239
|
+
|
|
1240
|
+
// 32 x 32bit words
|
|
1241
|
+
for (var i = 0; i < 32; i++)
|
|
1242
|
+
W[i] = msg[start + i];
|
|
1243
|
+
for (; i < W.length; i += 2) {
|
|
1244
|
+
var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
|
|
1245
|
+
var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
|
|
1246
|
+
var c1_hi = W[i - 14]; // i - 7
|
|
1247
|
+
var c1_lo = W[i - 13];
|
|
1248
|
+
var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
|
|
1249
|
+
var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
|
|
1250
|
+
var c3_hi = W[i - 32]; // i - 16
|
|
1251
|
+
var c3_lo = W[i - 31];
|
|
1252
|
+
|
|
1253
|
+
W[i] = sum64_4_hi(
|
|
1254
|
+
c0_hi, c0_lo,
|
|
1255
|
+
c1_hi, c1_lo,
|
|
1256
|
+
c2_hi, c2_lo,
|
|
1257
|
+
c3_hi, c3_lo);
|
|
1258
|
+
W[i + 1] = sum64_4_lo(
|
|
1259
|
+
c0_hi, c0_lo,
|
|
1260
|
+
c1_hi, c1_lo,
|
|
1261
|
+
c2_hi, c2_lo,
|
|
1262
|
+
c3_hi, c3_lo);
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
SHA512$1.prototype._update = function _update(msg, start) {
|
|
1267
|
+
this._prepareBlock(msg, start);
|
|
1268
|
+
|
|
1269
|
+
var W = this.W;
|
|
1270
|
+
|
|
1271
|
+
var ah = this.h[0];
|
|
1272
|
+
var al = this.h[1];
|
|
1273
|
+
var bh = this.h[2];
|
|
1274
|
+
var bl = this.h[3];
|
|
1275
|
+
var ch = this.h[4];
|
|
1276
|
+
var cl = this.h[5];
|
|
1277
|
+
var dh = this.h[6];
|
|
1278
|
+
var dl = this.h[7];
|
|
1279
|
+
var eh = this.h[8];
|
|
1280
|
+
var el = this.h[9];
|
|
1281
|
+
var fh = this.h[10];
|
|
1282
|
+
var fl = this.h[11];
|
|
1283
|
+
var gh = this.h[12];
|
|
1284
|
+
var gl = this.h[13];
|
|
1285
|
+
var hh = this.h[14];
|
|
1286
|
+
var hl = this.h[15];
|
|
1287
|
+
|
|
1288
|
+
assert$2(this.k.length === W.length);
|
|
1289
|
+
for (var i = 0; i < W.length; i += 2) {
|
|
1290
|
+
var c0_hi = hh;
|
|
1291
|
+
var c0_lo = hl;
|
|
1292
|
+
var c1_hi = s1_512_hi(eh, el);
|
|
1293
|
+
var c1_lo = s1_512_lo(eh, el);
|
|
1294
|
+
var c2_hi = ch64_hi(eh, el, fh, fl, gh);
|
|
1295
|
+
var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
|
|
1296
|
+
var c3_hi = this.k[i];
|
|
1297
|
+
var c3_lo = this.k[i + 1];
|
|
1298
|
+
var c4_hi = W[i];
|
|
1299
|
+
var c4_lo = W[i + 1];
|
|
1300
|
+
|
|
1301
|
+
var T1_hi = sum64_5_hi(
|
|
1302
|
+
c0_hi, c0_lo,
|
|
1303
|
+
c1_hi, c1_lo,
|
|
1304
|
+
c2_hi, c2_lo,
|
|
1305
|
+
c3_hi, c3_lo,
|
|
1306
|
+
c4_hi, c4_lo);
|
|
1307
|
+
var T1_lo = sum64_5_lo(
|
|
1308
|
+
c0_hi, c0_lo,
|
|
1309
|
+
c1_hi, c1_lo,
|
|
1310
|
+
c2_hi, c2_lo,
|
|
1311
|
+
c3_hi, c3_lo,
|
|
1312
|
+
c4_hi, c4_lo);
|
|
1313
|
+
|
|
1314
|
+
c0_hi = s0_512_hi(ah, al);
|
|
1315
|
+
c0_lo = s0_512_lo(ah, al);
|
|
1316
|
+
c1_hi = maj64_hi(ah, al, bh, bl, ch);
|
|
1317
|
+
c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
|
|
1318
|
+
|
|
1319
|
+
var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
|
|
1320
|
+
var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
|
|
1321
|
+
|
|
1322
|
+
hh = gh;
|
|
1323
|
+
hl = gl;
|
|
1324
|
+
|
|
1325
|
+
gh = fh;
|
|
1326
|
+
gl = fl;
|
|
1327
|
+
|
|
1328
|
+
fh = eh;
|
|
1329
|
+
fl = el;
|
|
1330
|
+
|
|
1331
|
+
eh = sum64_hi(dh, dl, T1_hi, T1_lo);
|
|
1332
|
+
el = sum64_lo(dl, dl, T1_hi, T1_lo);
|
|
1333
|
+
|
|
1334
|
+
dh = ch;
|
|
1335
|
+
dl = cl;
|
|
1336
|
+
|
|
1337
|
+
ch = bh;
|
|
1338
|
+
cl = bl;
|
|
1339
|
+
|
|
1340
|
+
bh = ah;
|
|
1341
|
+
bl = al;
|
|
1342
|
+
|
|
1343
|
+
ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
|
|
1344
|
+
al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
sum64(this.h, 0, ah, al);
|
|
1348
|
+
sum64(this.h, 2, bh, bl);
|
|
1349
|
+
sum64(this.h, 4, ch, cl);
|
|
1350
|
+
sum64(this.h, 6, dh, dl);
|
|
1351
|
+
sum64(this.h, 8, eh, el);
|
|
1352
|
+
sum64(this.h, 10, fh, fl);
|
|
1353
|
+
sum64(this.h, 12, gh, gl);
|
|
1354
|
+
sum64(this.h, 14, hh, hl);
|
|
1355
|
+
};
|
|
1356
|
+
|
|
1357
|
+
SHA512$1.prototype._digest = function digest(enc) {
|
|
1358
|
+
if (enc === 'hex')
|
|
1359
|
+
return utils$3.toHex32(this.h, 'big');
|
|
1360
|
+
else
|
|
1361
|
+
return utils$3.split32(this.h, 'big');
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
function ch64_hi(xh, xl, yh, yl, zh) {
|
|
1365
|
+
var r = (xh & yh) ^ ((~xh) & zh);
|
|
1366
|
+
if (r < 0)
|
|
1367
|
+
r += 0x100000000;
|
|
1368
|
+
return r;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
function ch64_lo(xh, xl, yh, yl, zh, zl) {
|
|
1372
|
+
var r = (xl & yl) ^ ((~xl) & zl);
|
|
1373
|
+
if (r < 0)
|
|
1374
|
+
r += 0x100000000;
|
|
1375
|
+
return r;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
function maj64_hi(xh, xl, yh, yl, zh) {
|
|
1379
|
+
var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
|
|
1380
|
+
if (r < 0)
|
|
1381
|
+
r += 0x100000000;
|
|
1382
|
+
return r;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
function maj64_lo(xh, xl, yh, yl, zh, zl) {
|
|
1386
|
+
var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
|
|
1387
|
+
if (r < 0)
|
|
1388
|
+
r += 0x100000000;
|
|
1389
|
+
return r;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
function s0_512_hi(xh, xl) {
|
|
1393
|
+
var c0_hi = rotr64_hi(xh, xl, 28);
|
|
1394
|
+
var c1_hi = rotr64_hi(xl, xh, 2); // 34
|
|
1395
|
+
var c2_hi = rotr64_hi(xl, xh, 7); // 39
|
|
1396
|
+
|
|
1397
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1398
|
+
if (r < 0)
|
|
1399
|
+
r += 0x100000000;
|
|
1400
|
+
return r;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function s0_512_lo(xh, xl) {
|
|
1404
|
+
var c0_lo = rotr64_lo(xh, xl, 28);
|
|
1405
|
+
var c1_lo = rotr64_lo(xl, xh, 2); // 34
|
|
1406
|
+
var c2_lo = rotr64_lo(xl, xh, 7); // 39
|
|
1407
|
+
|
|
1408
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1409
|
+
if (r < 0)
|
|
1410
|
+
r += 0x100000000;
|
|
1411
|
+
return r;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
function s1_512_hi(xh, xl) {
|
|
1415
|
+
var c0_hi = rotr64_hi(xh, xl, 14);
|
|
1416
|
+
var c1_hi = rotr64_hi(xh, xl, 18);
|
|
1417
|
+
var c2_hi = rotr64_hi(xl, xh, 9); // 41
|
|
1418
|
+
|
|
1419
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1420
|
+
if (r < 0)
|
|
1421
|
+
r += 0x100000000;
|
|
1422
|
+
return r;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function s1_512_lo(xh, xl) {
|
|
1426
|
+
var c0_lo = rotr64_lo(xh, xl, 14);
|
|
1427
|
+
var c1_lo = rotr64_lo(xh, xl, 18);
|
|
1428
|
+
var c2_lo = rotr64_lo(xl, xh, 9); // 41
|
|
1429
|
+
|
|
1430
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1431
|
+
if (r < 0)
|
|
1432
|
+
r += 0x100000000;
|
|
1433
|
+
return r;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
function g0_512_hi(xh, xl) {
|
|
1437
|
+
var c0_hi = rotr64_hi(xh, xl, 1);
|
|
1438
|
+
var c1_hi = rotr64_hi(xh, xl, 8);
|
|
1439
|
+
var c2_hi = shr64_hi(xh, xl, 7);
|
|
1440
|
+
|
|
1441
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1442
|
+
if (r < 0)
|
|
1443
|
+
r += 0x100000000;
|
|
1444
|
+
return r;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
function g0_512_lo(xh, xl) {
|
|
1448
|
+
var c0_lo = rotr64_lo(xh, xl, 1);
|
|
1449
|
+
var c1_lo = rotr64_lo(xh, xl, 8);
|
|
1450
|
+
var c2_lo = shr64_lo(xh, xl, 7);
|
|
1451
|
+
|
|
1452
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1453
|
+
if (r < 0)
|
|
1454
|
+
r += 0x100000000;
|
|
1455
|
+
return r;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
function g1_512_hi(xh, xl) {
|
|
1459
|
+
var c0_hi = rotr64_hi(xh, xl, 19);
|
|
1460
|
+
var c1_hi = rotr64_hi(xl, xh, 29); // 61
|
|
1461
|
+
var c2_hi = shr64_hi(xh, xl, 6);
|
|
1462
|
+
|
|
1463
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1464
|
+
if (r < 0)
|
|
1465
|
+
r += 0x100000000;
|
|
1466
|
+
return r;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
function g1_512_lo(xh, xl) {
|
|
1470
|
+
var c0_lo = rotr64_lo(xh, xl, 19);
|
|
1471
|
+
var c1_lo = rotr64_lo(xl, xh, 29); // 61
|
|
1472
|
+
var c2_lo = shr64_lo(xh, xl, 6);
|
|
1473
|
+
|
|
1474
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1475
|
+
if (r < 0)
|
|
1476
|
+
r += 0x100000000;
|
|
1477
|
+
return r;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
var utils$2 = utils$9;
|
|
1481
|
+
|
|
1482
|
+
var SHA512 = _512;
|
|
1483
|
+
|
|
1484
|
+
function SHA384() {
|
|
1485
|
+
if (!(this instanceof SHA384))
|
|
1486
|
+
return new SHA384();
|
|
1487
|
+
|
|
1488
|
+
SHA512.call(this);
|
|
1489
|
+
this.h = [
|
|
1490
|
+
0xcbbb9d5d, 0xc1059ed8,
|
|
1491
|
+
0x629a292a, 0x367cd507,
|
|
1492
|
+
0x9159015a, 0x3070dd17,
|
|
1493
|
+
0x152fecd8, 0xf70e5939,
|
|
1494
|
+
0x67332667, 0xffc00b31,
|
|
1495
|
+
0x8eb44a87, 0x68581511,
|
|
1496
|
+
0xdb0c2e0d, 0x64f98fa7,
|
|
1497
|
+
0x47b5481d, 0xbefa4fa4 ];
|
|
1498
|
+
}
|
|
1499
|
+
utils$2.inherits(SHA384, SHA512);
|
|
1500
|
+
var _384 = SHA384;
|
|
1501
|
+
|
|
1502
|
+
SHA384.blockSize = 1024;
|
|
1503
|
+
SHA384.outSize = 384;
|
|
1504
|
+
SHA384.hmacStrength = 192;
|
|
1505
|
+
SHA384.padLength = 128;
|
|
1506
|
+
|
|
1507
|
+
SHA384.prototype._digest = function digest(enc) {
|
|
1508
|
+
if (enc === 'hex')
|
|
1509
|
+
return utils$2.toHex32(this.h.slice(0, 12), 'big');
|
|
1510
|
+
else
|
|
1511
|
+
return utils$2.split32(this.h.slice(0, 12), 'big');
|
|
1512
|
+
};
|
|
1513
|
+
|
|
1514
|
+
sha.sha1 = _1;
|
|
1515
|
+
sha.sha224 = _224;
|
|
1516
|
+
sha.sha256 = _256;
|
|
1517
|
+
sha.sha384 = _384;
|
|
1518
|
+
sha.sha512 = _512;
|
|
1519
|
+
|
|
1520
|
+
var ripemd = {};
|
|
1521
|
+
|
|
1522
|
+
var utils$1 = utils$9;
|
|
1523
|
+
var common = common$5;
|
|
1524
|
+
|
|
1525
|
+
var rotl32 = utils$1.rotl32;
|
|
1526
|
+
var sum32 = utils$1.sum32;
|
|
1527
|
+
var sum32_3 = utils$1.sum32_3;
|
|
1528
|
+
var sum32_4 = utils$1.sum32_4;
|
|
1529
|
+
var BlockHash = common.BlockHash;
|
|
1530
|
+
|
|
1531
|
+
function RIPEMD160() {
|
|
1532
|
+
if (!(this instanceof RIPEMD160))
|
|
1533
|
+
return new RIPEMD160();
|
|
1534
|
+
|
|
1535
|
+
BlockHash.call(this);
|
|
1536
|
+
|
|
1537
|
+
this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
|
|
1538
|
+
this.endian = 'little';
|
|
1539
|
+
}
|
|
1540
|
+
utils$1.inherits(RIPEMD160, BlockHash);
|
|
1541
|
+
ripemd.ripemd160 = RIPEMD160;
|
|
1542
|
+
|
|
1543
|
+
RIPEMD160.blockSize = 512;
|
|
1544
|
+
RIPEMD160.outSize = 160;
|
|
1545
|
+
RIPEMD160.hmacStrength = 192;
|
|
1546
|
+
RIPEMD160.padLength = 64;
|
|
1547
|
+
|
|
1548
|
+
RIPEMD160.prototype._update = function update(msg, start) {
|
|
1549
|
+
var A = this.h[0];
|
|
1550
|
+
var B = this.h[1];
|
|
1551
|
+
var C = this.h[2];
|
|
1552
|
+
var D = this.h[3];
|
|
1553
|
+
var E = this.h[4];
|
|
1554
|
+
var Ah = A;
|
|
1555
|
+
var Bh = B;
|
|
1556
|
+
var Ch = C;
|
|
1557
|
+
var Dh = D;
|
|
1558
|
+
var Eh = E;
|
|
1559
|
+
for (var j = 0; j < 80; j++) {
|
|
1560
|
+
var T = sum32(
|
|
1561
|
+
rotl32(
|
|
1562
|
+
sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
|
|
1563
|
+
s[j]),
|
|
1564
|
+
E);
|
|
1565
|
+
A = E;
|
|
1566
|
+
E = D;
|
|
1567
|
+
D = rotl32(C, 10);
|
|
1568
|
+
C = B;
|
|
1569
|
+
B = T;
|
|
1570
|
+
T = sum32(
|
|
1571
|
+
rotl32(
|
|
1572
|
+
sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
|
|
1573
|
+
sh[j]),
|
|
1574
|
+
Eh);
|
|
1575
|
+
Ah = Eh;
|
|
1576
|
+
Eh = Dh;
|
|
1577
|
+
Dh = rotl32(Ch, 10);
|
|
1578
|
+
Ch = Bh;
|
|
1579
|
+
Bh = T;
|
|
1580
|
+
}
|
|
1581
|
+
T = sum32_3(this.h[1], C, Dh);
|
|
1582
|
+
this.h[1] = sum32_3(this.h[2], D, Eh);
|
|
1583
|
+
this.h[2] = sum32_3(this.h[3], E, Ah);
|
|
1584
|
+
this.h[3] = sum32_3(this.h[4], A, Bh);
|
|
1585
|
+
this.h[4] = sum32_3(this.h[0], B, Ch);
|
|
1586
|
+
this.h[0] = T;
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
RIPEMD160.prototype._digest = function digest(enc) {
|
|
1590
|
+
if (enc === 'hex')
|
|
1591
|
+
return utils$1.toHex32(this.h, 'little');
|
|
1592
|
+
else
|
|
1593
|
+
return utils$1.split32(this.h, 'little');
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
function f(j, x, y, z) {
|
|
1597
|
+
if (j <= 15)
|
|
1598
|
+
return x ^ y ^ z;
|
|
1599
|
+
else if (j <= 31)
|
|
1600
|
+
return (x & y) | ((~x) & z);
|
|
1601
|
+
else if (j <= 47)
|
|
1602
|
+
return (x | (~y)) ^ z;
|
|
1603
|
+
else if (j <= 63)
|
|
1604
|
+
return (x & z) | (y & (~z));
|
|
1605
|
+
else
|
|
1606
|
+
return x ^ (y | (~z));
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
function K(j) {
|
|
1610
|
+
if (j <= 15)
|
|
1611
|
+
return 0x00000000;
|
|
1612
|
+
else if (j <= 31)
|
|
1613
|
+
return 0x5a827999;
|
|
1614
|
+
else if (j <= 47)
|
|
1615
|
+
return 0x6ed9eba1;
|
|
1616
|
+
else if (j <= 63)
|
|
1617
|
+
return 0x8f1bbcdc;
|
|
1618
|
+
else
|
|
1619
|
+
return 0xa953fd4e;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
function Kh(j) {
|
|
1623
|
+
if (j <= 15)
|
|
1624
|
+
return 0x50a28be6;
|
|
1625
|
+
else if (j <= 31)
|
|
1626
|
+
return 0x5c4dd124;
|
|
1627
|
+
else if (j <= 47)
|
|
1628
|
+
return 0x6d703ef3;
|
|
1629
|
+
else if (j <= 63)
|
|
1630
|
+
return 0x7a6d76e9;
|
|
1631
|
+
else
|
|
1632
|
+
return 0x00000000;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
var r = [
|
|
1636
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
1637
|
+
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
|
1638
|
+
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
|
|
1639
|
+
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
|
|
1640
|
+
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
|
|
1641
|
+
];
|
|
1642
|
+
|
|
1643
|
+
var rh = [
|
|
1644
|
+
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
|
|
1645
|
+
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
|
|
1646
|
+
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
|
|
1647
|
+
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
|
|
1648
|
+
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
|
|
1649
|
+
];
|
|
1650
|
+
|
|
1651
|
+
var s = [
|
|
1652
|
+
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
|
|
1653
|
+
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
|
|
1654
|
+
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
|
|
1655
|
+
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
|
|
1656
|
+
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
|
|
1657
|
+
];
|
|
1658
|
+
|
|
1659
|
+
var sh = [
|
|
1660
|
+
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
|
|
1661
|
+
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
|
|
1662
|
+
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
|
|
1663
|
+
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
|
|
1664
|
+
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
|
|
1665
|
+
];
|
|
1666
|
+
|
|
1667
|
+
var utils = utils$9;
|
|
1668
|
+
var assert$1 = minimalisticAssert;
|
|
1669
|
+
|
|
1670
|
+
function Hmac(hash, key, enc) {
|
|
1671
|
+
if (!(this instanceof Hmac))
|
|
1672
|
+
return new Hmac(hash, key, enc);
|
|
1673
|
+
this.Hash = hash;
|
|
1674
|
+
this.blockSize = hash.blockSize / 8;
|
|
1675
|
+
this.outSize = hash.outSize / 8;
|
|
1676
|
+
this.inner = null;
|
|
1677
|
+
this.outer = null;
|
|
1678
|
+
|
|
1679
|
+
this._init(utils.toArray(key, enc));
|
|
1680
|
+
}
|
|
1681
|
+
var hmac = Hmac;
|
|
1682
|
+
|
|
1683
|
+
Hmac.prototype._init = function init(key) {
|
|
1684
|
+
// Shorten key, if needed
|
|
1685
|
+
if (key.length > this.blockSize)
|
|
1686
|
+
key = new this.Hash().update(key).digest();
|
|
1687
|
+
assert$1(key.length <= this.blockSize);
|
|
1688
|
+
|
|
1689
|
+
// Add padding to key
|
|
1690
|
+
for (var i = key.length; i < this.blockSize; i++)
|
|
1691
|
+
key.push(0);
|
|
1692
|
+
|
|
1693
|
+
for (i = 0; i < key.length; i++)
|
|
1694
|
+
key[i] ^= 0x36;
|
|
1695
|
+
this.inner = new this.Hash().update(key);
|
|
1696
|
+
|
|
1697
|
+
// 0x36 ^ 0x5c = 0x6a
|
|
1698
|
+
for (i = 0; i < key.length; i++)
|
|
1699
|
+
key[i] ^= 0x6a;
|
|
1700
|
+
this.outer = new this.Hash().update(key);
|
|
1701
|
+
};
|
|
1702
|
+
|
|
1703
|
+
Hmac.prototype.update = function update(msg, enc) {
|
|
1704
|
+
this.inner.update(msg, enc);
|
|
1705
|
+
return this;
|
|
1706
|
+
};
|
|
1707
|
+
|
|
1708
|
+
Hmac.prototype.digest = function digest(enc) {
|
|
1709
|
+
this.outer.update(this.inner.digest());
|
|
1710
|
+
return this.outer.digest(enc);
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
(function (exports) {
|
|
1714
|
+
var hash = exports;
|
|
1715
|
+
|
|
1716
|
+
hash.utils = utils$9;
|
|
1717
|
+
hash.common = common$5;
|
|
1718
|
+
hash.sha = sha;
|
|
1719
|
+
hash.ripemd = ripemd;
|
|
1720
|
+
hash.hmac = hmac;
|
|
1721
|
+
|
|
1722
|
+
// Proxy hash functions to the main object
|
|
1723
|
+
hash.sha1 = hash.sha.sha1;
|
|
1724
|
+
hash.sha256 = hash.sha.sha256;
|
|
1725
|
+
hash.sha224 = hash.sha.sha224;
|
|
1726
|
+
hash.sha384 = hash.sha.sha384;
|
|
1727
|
+
hash.sha512 = hash.sha.sha512;
|
|
1728
|
+
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1729
|
+
}(hash$1));
|
|
1730
|
+
|
|
1731
|
+
var hash = hash$1;
|
|
1732
|
+
|
|
1733
|
+
const version = "sha2/5.5.0";
|
|
1734
|
+
|
|
1735
|
+
new Logger(version);
|
|
1736
|
+
function sha256(data) {
|
|
1737
|
+
return "0x" + (hash.sha256().update(arrayify(data)).digest("hex"));
|
|
1738
|
+
}
|
|
1739
|
+
|
|
64
1740
|
class Struct {
|
|
65
1741
|
constructor(properties) {
|
|
66
1742
|
Object.assign(this, properties);
|
|
@@ -136,7 +1812,7 @@ class PublicKey extends Struct {
|
|
|
136
1812
|
const decoded = bs58__default["default"].decode(value);
|
|
137
1813
|
|
|
138
1814
|
if (decoded.length != 32) {
|
|
139
|
-
throw new Error(
|
|
1815
|
+
throw new Error("Invalid public key input");
|
|
140
1816
|
}
|
|
141
1817
|
|
|
142
1818
|
this._bn = new BN__default["default"](decoded);
|
|
@@ -145,7 +1821,7 @@ class PublicKey extends Struct {
|
|
|
145
1821
|
}
|
|
146
1822
|
|
|
147
1823
|
if (this._bn.byteLength() > 32) {
|
|
148
|
-
throw new Error(
|
|
1824
|
+
throw new Error("Invalid public key input");
|
|
149
1825
|
}
|
|
150
1826
|
}
|
|
151
1827
|
}
|
|
@@ -206,32 +1882,36 @@ class PublicKey extends Struct {
|
|
|
206
1882
|
* it permission to write data to the account.
|
|
207
1883
|
*/
|
|
208
1884
|
|
|
1885
|
+
/* eslint-disable require-await */
|
|
1886
|
+
|
|
209
1887
|
|
|
210
1888
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
211
1889
|
const buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
|
|
212
|
-
const hash =
|
|
1890
|
+
const hash = sha256(new Uint8Array(buffer$1)).slice(2);
|
|
213
1891
|
return new PublicKey(buffer.Buffer.from(hash, 'hex'));
|
|
214
1892
|
}
|
|
215
1893
|
/**
|
|
216
1894
|
* Derive a program address from seeds and a program ID.
|
|
217
1895
|
*/
|
|
218
1896
|
|
|
1897
|
+
/* eslint-disable require-await */
|
|
1898
|
+
|
|
219
1899
|
|
|
220
1900
|
static async createProgramAddress(seeds, programId) {
|
|
221
1901
|
let buffer$1 = buffer.Buffer.alloc(0);
|
|
222
1902
|
seeds.forEach(function (seed) {
|
|
223
1903
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
224
|
-
throw new TypeError(
|
|
1904
|
+
throw new TypeError("Max seed length exceeded");
|
|
225
1905
|
}
|
|
226
1906
|
|
|
227
1907
|
buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
|
|
228
1908
|
});
|
|
229
1909
|
buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
|
|
230
|
-
let hash =
|
|
1910
|
+
let hash = sha256(new Uint8Array(buffer$1)).slice(2);
|
|
231
1911
|
let publicKeyBytes = new BN__default["default"](hash, 16).toArray(undefined, 32);
|
|
232
1912
|
|
|
233
1913
|
if (is_on_curve(publicKeyBytes)) {
|
|
234
|
-
throw new Error(
|
|
1914
|
+
throw new Error("Invalid seeds, address must fall off the curve");
|
|
235
1915
|
}
|
|
236
1916
|
|
|
237
1917
|
return new PublicKey(publicKeyBytes);
|
|
@@ -265,7 +1945,7 @@ class PublicKey extends Struct {
|
|
|
265
1945
|
return [address, nonce];
|
|
266
1946
|
}
|
|
267
1947
|
|
|
268
|
-
throw new Error(
|
|
1948
|
+
throw new Error("Unable to find a viable program address nonce");
|
|
269
1949
|
}
|
|
270
1950
|
/**
|
|
271
1951
|
* Check that a pubkey is on the ed25519 curve.
|
|
@@ -477,6 +2157,36 @@ function encodeLength(bytes, len) {
|
|
|
477
2157
|
}
|
|
478
2158
|
}
|
|
479
2159
|
|
|
2160
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2161
|
+
/**
|
|
2162
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2163
|
+
*/
|
|
2164
|
+
|
|
2165
|
+
function guardedShift(byteArray) {
|
|
2166
|
+
if (byteArray.length === 0) {
|
|
2167
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
return byteArray.shift();
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2174
|
+
* the array.
|
|
2175
|
+
*/
|
|
2176
|
+
|
|
2177
|
+
function guardedSplice(byteArray, ...args) {
|
|
2178
|
+
var _args$;
|
|
2179
|
+
|
|
2180
|
+
const [start] = args;
|
|
2181
|
+
|
|
2182
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2183
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2184
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
return byteArray.splice(...args);
|
|
2188
|
+
}
|
|
2189
|
+
|
|
480
2190
|
/**
|
|
481
2191
|
* The message header, identifying signed and read-only account
|
|
482
2192
|
*/
|
|
@@ -580,32 +2290,28 @@ class Message {
|
|
|
580
2290
|
static from(buffer$1) {
|
|
581
2291
|
// Slice up wire data
|
|
582
2292
|
let byteArray = [...buffer$1];
|
|
583
|
-
const numRequiredSignatures = byteArray
|
|
584
|
-
const numReadonlySignedAccounts = byteArray
|
|
585
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2293
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2294
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2295
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
586
2296
|
const accountCount = decodeLength(byteArray);
|
|
587
2297
|
let accountKeys = [];
|
|
588
2298
|
|
|
589
2299
|
for (let i = 0; i < accountCount; i++) {
|
|
590
|
-
const account = byteArray
|
|
591
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2300
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
592
2301
|
accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
|
|
593
2302
|
}
|
|
594
2303
|
|
|
595
|
-
const recentBlockhash = byteArray
|
|
596
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2304
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
597
2305
|
const instructionCount = decodeLength(byteArray);
|
|
598
2306
|
let instructions = [];
|
|
599
2307
|
|
|
600
2308
|
for (let i = 0; i < instructionCount; i++) {
|
|
601
|
-
const programIdIndex = byteArray
|
|
2309
|
+
const programIdIndex = guardedShift(byteArray);
|
|
602
2310
|
const accountCount = decodeLength(byteArray);
|
|
603
|
-
const accounts = byteArray
|
|
604
|
-
byteArray = byteArray.slice(accountCount);
|
|
2311
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
605
2312
|
const dataLength = decodeLength(byteArray);
|
|
606
|
-
const dataSlice = byteArray
|
|
2313
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
607
2314
|
const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
|
|
608
|
-
byteArray = byteArray.slice(dataLength);
|
|
609
2315
|
instructions.push({
|
|
610
2316
|
programIdIndex,
|
|
611
2317
|
accounts,
|
|
@@ -634,6 +2340,10 @@ function assert (condition, message) {
|
|
|
634
2340
|
}
|
|
635
2341
|
}
|
|
636
2342
|
|
|
2343
|
+
/**
|
|
2344
|
+
* Transaction signature as base-58 encoded string
|
|
2345
|
+
*/
|
|
2346
|
+
|
|
637
2347
|
/**
|
|
638
2348
|
* Default (empty) signature
|
|
639
2349
|
*
|
|
@@ -791,7 +2501,7 @@ class Transaction {
|
|
|
791
2501
|
|
|
792
2502
|
for (let i = 0; i < this.instructions.length; i++) {
|
|
793
2503
|
if (this.instructions[i].programId === undefined) {
|
|
794
|
-
throw new Error(
|
|
2504
|
+
throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
|
|
795
2505
|
}
|
|
796
2506
|
}
|
|
797
2507
|
|
|
@@ -866,7 +2576,7 @@ class Transaction {
|
|
|
866
2576
|
console.warn('Transaction references a signature that is unnecessary, ' + 'only the fee payer and instruction signer accounts should sign a transaction. ' + 'This behavior is deprecated and will throw an error in the next major version release.');
|
|
867
2577
|
}
|
|
868
2578
|
} else {
|
|
869
|
-
throw new Error(
|
|
2579
|
+
throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
|
|
870
2580
|
}
|
|
871
2581
|
}
|
|
872
2582
|
|
|
@@ -1101,7 +2811,7 @@ class Transaction {
|
|
|
1101
2811
|
const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
|
|
1102
2812
|
|
|
1103
2813
|
if (index < 0) {
|
|
1104
|
-
throw new Error(
|
|
2814
|
+
throw new Error("unknown signer: ".concat(pubkey.toString()));
|
|
1105
2815
|
}
|
|
1106
2816
|
|
|
1107
2817
|
this.signatures[index].signature = buffer.Buffer.from(signature);
|
|
@@ -1177,12 +2887,12 @@ class Transaction {
|
|
|
1177
2887
|
signature
|
|
1178
2888
|
}, index) => {
|
|
1179
2889
|
if (signature !== null) {
|
|
1180
|
-
assert(signature.length === 64,
|
|
2890
|
+
assert(signature.length === 64, "signature has invalid length");
|
|
1181
2891
|
buffer.Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
1182
2892
|
}
|
|
1183
2893
|
});
|
|
1184
2894
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
1185
|
-
assert(wireTransaction.length <= PACKET_DATA_SIZE,
|
|
2895
|
+
assert(wireTransaction.length <= PACKET_DATA_SIZE, "Transaction too large: ".concat(wireTransaction.length, " > ").concat(PACKET_DATA_SIZE));
|
|
1186
2896
|
return wireTransaction;
|
|
1187
2897
|
}
|
|
1188
2898
|
/**
|
|
@@ -1227,8 +2937,7 @@ class Transaction {
|
|
|
1227
2937
|
let signatures = [];
|
|
1228
2938
|
|
|
1229
2939
|
for (let i = 0; i < signatureCount; i++) {
|
|
1230
|
-
const signature = byteArray
|
|
1231
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
2940
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
1232
2941
|
signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
|
|
1233
2942
|
}
|
|
1234
2943
|
|
|
@@ -1301,7 +3010,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
1301
3010
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
1302
3011
|
|
|
1303
3012
|
if (status.err) {
|
|
1304
|
-
throw new Error(
|
|
3013
|
+
throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
|
|
1305
3014
|
}
|
|
1306
3015
|
|
|
1307
3016
|
return signature;
|
|
@@ -1344,7 +3053,7 @@ function decodeData(type, buffer) {
|
|
|
1344
3053
|
}
|
|
1345
3054
|
|
|
1346
3055
|
if (data.instruction !== type.index) {
|
|
1347
|
-
throw new Error(
|
|
3056
|
+
throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
|
|
1348
3057
|
}
|
|
1349
3058
|
|
|
1350
3059
|
return data;
|
|
@@ -1684,7 +3393,7 @@ class SystemInstruction {
|
|
|
1684
3393
|
|
|
1685
3394
|
static checkKeyLength(keys, expectedLength) {
|
|
1686
3395
|
if (keys.length < expectedLength) {
|
|
1687
|
-
throw new Error(
|
|
3396
|
+
throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
|
|
1688
3397
|
}
|
|
1689
3398
|
}
|
|
1690
3399
|
|
|
@@ -2146,7 +3855,8 @@ class Loader {
|
|
|
2146
3855
|
* Can be used to calculate transaction fees
|
|
2147
3856
|
*/
|
|
2148
3857
|
static getMinNumSignatures(dataLength) {
|
|
2149
|
-
return 2 * (
|
|
3858
|
+
return 2 * ( // Every transaction requires two signatures (payer + program)
|
|
3859
|
+
Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
|
|
2150
3860
|
1) // Add one for Finalize transaction
|
|
2151
3861
|
;
|
|
2152
3862
|
}
|
|
@@ -2764,7 +4474,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
2764
4474
|
break;
|
|
2765
4475
|
}
|
|
2766
4476
|
|
|
2767
|
-
console.log(
|
|
4477
|
+
console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
|
|
2768
4478
|
await sleep(waitTime);
|
|
2769
4479
|
waitTime *= 2;
|
|
2770
4480
|
}
|
|
@@ -2774,7 +4484,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
2774
4484
|
if (res.ok) {
|
|
2775
4485
|
callback(null, text);
|
|
2776
4486
|
} else {
|
|
2777
|
-
callback(new Error(
|
|
4487
|
+
callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
|
|
2778
4488
|
}
|
|
2779
4489
|
} catch (err) {
|
|
2780
4490
|
if (err instanceof Error) callback(err);
|
|
@@ -3860,7 +5570,7 @@ class Connection {
|
|
|
3860
5570
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
3861
5571
|
|
|
3862
5572
|
if ('error' in res) {
|
|
3863
|
-
throw new Error(
|
|
5573
|
+
throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
|
|
3864
5574
|
}
|
|
3865
5575
|
|
|
3866
5576
|
return res.result;
|
|
@@ -3996,7 +5706,7 @@ class Connection {
|
|
|
3996
5706
|
|
|
3997
5707
|
if (response === null) {
|
|
3998
5708
|
const duration = (Date.now() - start) / 1000;
|
|
3999
|
-
throw new Error(
|
|
5709
|
+
throw new Error("Transaction was not confirmed in ".concat(duration.toFixed(2), " seconds. It is unknown if it succeeded or failed. Check signature ").concat(signature, " using the Solana Explorer or CLI tools."));
|
|
4000
5710
|
}
|
|
4001
5711
|
|
|
4002
5712
|
return response;
|
|
@@ -4775,7 +6485,7 @@ class Connection {
|
|
|
4775
6485
|
await sleep(MS_PER_SLOT / 2);
|
|
4776
6486
|
}
|
|
4777
6487
|
|
|
4778
|
-
throw new Error(
|
|
6488
|
+
throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
|
|
4779
6489
|
} finally {
|
|
4780
6490
|
this._pollingBlockhash = false;
|
|
4781
6491
|
}
|
|
@@ -5032,7 +6742,7 @@ class Connection {
|
|
|
5032
6742
|
}
|
|
5033
6743
|
|
|
5034
6744
|
if (err instanceof Error) {
|
|
5035
|
-
console.error(
|
|
6745
|
+
console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
|
|
5036
6746
|
}
|
|
5037
6747
|
}
|
|
5038
6748
|
}
|
|
@@ -5052,7 +6762,7 @@ class Connection {
|
|
|
5052
6762
|
await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
|
|
5053
6763
|
} catch (err) {
|
|
5054
6764
|
if (err instanceof Error) {
|
|
5055
|
-
console.error(
|
|
6765
|
+
console.error("".concat(rpcMethod, " error:"), err.message);
|
|
5056
6766
|
}
|
|
5057
6767
|
}
|
|
5058
6768
|
}
|
|
@@ -5217,7 +6927,7 @@ class Connection {
|
|
|
5217
6927
|
|
|
5218
6928
|
this._updateSubscriptions();
|
|
5219
6929
|
} else {
|
|
5220
|
-
throw new Error(
|
|
6930
|
+
throw new Error("Unknown account change id: ".concat(id));
|
|
5221
6931
|
}
|
|
5222
6932
|
}
|
|
5223
6933
|
/**
|
|
@@ -5283,7 +6993,7 @@ class Connection {
|
|
|
5283
6993
|
|
|
5284
6994
|
this._updateSubscriptions();
|
|
5285
6995
|
} else {
|
|
5286
|
-
throw new Error(
|
|
6996
|
+
throw new Error("Unknown program account change id: ".concat(id));
|
|
5287
6997
|
}
|
|
5288
6998
|
}
|
|
5289
6999
|
/**
|
|
@@ -5313,7 +7023,7 @@ class Connection {
|
|
|
5313
7023
|
|
|
5314
7024
|
async removeOnLogsListener(id) {
|
|
5315
7025
|
if (!this._logsSubscriptions[id]) {
|
|
5316
|
-
throw new Error(
|
|
7026
|
+
throw new Error("Unknown logs id: ".concat(id));
|
|
5317
7027
|
}
|
|
5318
7028
|
|
|
5319
7029
|
const subInfo = this._logsSubscriptions[id];
|
|
@@ -5389,7 +7099,7 @@ class Connection {
|
|
|
5389
7099
|
|
|
5390
7100
|
this._updateSubscriptions();
|
|
5391
7101
|
} else {
|
|
5392
|
-
throw new Error(
|
|
7102
|
+
throw new Error("Unknown slot change id: ".concat(id));
|
|
5393
7103
|
}
|
|
5394
7104
|
}
|
|
5395
7105
|
/**
|
|
@@ -5442,7 +7152,7 @@ class Connection {
|
|
|
5442
7152
|
|
|
5443
7153
|
this._updateSubscriptions();
|
|
5444
7154
|
} else {
|
|
5445
|
-
throw new Error(
|
|
7155
|
+
throw new Error("Unknown slot update id: ".concat(id));
|
|
5446
7156
|
}
|
|
5447
7157
|
}
|
|
5448
7158
|
|
|
@@ -5583,7 +7293,7 @@ class Connection {
|
|
|
5583
7293
|
|
|
5584
7294
|
this._updateSubscriptions();
|
|
5585
7295
|
} else {
|
|
5586
|
-
throw new Error(
|
|
7296
|
+
throw new Error("Unknown signature result id: ".concat(id));
|
|
5587
7297
|
}
|
|
5588
7298
|
}
|
|
5589
7299
|
/**
|
|
@@ -5635,7 +7345,7 @@ class Connection {
|
|
|
5635
7345
|
|
|
5636
7346
|
this._updateSubscriptions();
|
|
5637
7347
|
} else {
|
|
5638
|
-
throw new Error(
|
|
7348
|
+
throw new Error("Unknown root change id: ".concat(id));
|
|
5639
7349
|
}
|
|
5640
7350
|
}
|
|
5641
7351
|
|
|
@@ -5760,8 +7470,8 @@ class Ed25519Program {
|
|
|
5760
7470
|
signature,
|
|
5761
7471
|
instructionIndex
|
|
5762
7472
|
} = params;
|
|
5763
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES$1,
|
|
5764
|
-
assert(signature.length === SIGNATURE_BYTES,
|
|
7473
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES$1, "Public Key must be ".concat(PUBLIC_KEY_BYTES$1, " bytes but received ").concat(publicKey.length, " bytes"));
|
|
7474
|
+
assert(signature.length === SIGNATURE_BYTES, "Signature must be ".concat(SIGNATURE_BYTES, " bytes but received ").concat(signature.length, " bytes"));
|
|
5765
7475
|
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
5766
7476
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
5767
7477
|
const messageDataOffset = signatureOffset + signature.length;
|
|
@@ -5799,7 +7509,7 @@ class Ed25519Program {
|
|
|
5799
7509
|
message,
|
|
5800
7510
|
instructionIndex
|
|
5801
7511
|
} = params;
|
|
5802
|
-
assert(privateKey.length === PRIVATE_KEY_BYTES$1,
|
|
7512
|
+
assert(privateKey.length === PRIVATE_KEY_BYTES$1, "Private key must be ".concat(PRIVATE_KEY_BYTES$1, " bytes but received ").concat(privateKey.length, " bytes"));
|
|
5803
7513
|
|
|
5804
7514
|
try {
|
|
5805
7515
|
const keypair = Keypair.fromSecretKey(privateKey);
|
|
@@ -5812,7 +7522,7 @@ class Ed25519Program {
|
|
|
5812
7522
|
instructionIndex
|
|
5813
7523
|
});
|
|
5814
7524
|
} catch (error) {
|
|
5815
|
-
throw new Error(
|
|
7525
|
+
throw new Error("Error creating instruction; ".concat(error));
|
|
5816
7526
|
}
|
|
5817
7527
|
}
|
|
5818
7528
|
|
|
@@ -6098,7 +7808,7 @@ class StakeInstruction {
|
|
|
6098
7808
|
|
|
6099
7809
|
static checkKeyLength(keys, expectedLength) {
|
|
6100
7810
|
if (keys.length < expectedLength) {
|
|
6101
|
-
throw new Error(
|
|
7811
|
+
throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
|
|
6102
7812
|
}
|
|
6103
7813
|
}
|
|
6104
7814
|
|
|
@@ -6606,12 +8316,12 @@ class Secp256k1Program {
|
|
|
6606
8316
|
* @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
|
|
6607
8317
|
*/
|
|
6608
8318
|
static publicKeyToEthAddress(publicKey) {
|
|
6609
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES,
|
|
8319
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES, "Public key must be ".concat(PUBLIC_KEY_BYTES, " bytes but received ").concat(publicKey.length, " bytes"));
|
|
6610
8320
|
|
|
6611
8321
|
try {
|
|
6612
|
-
return buffer.Buffer.from(
|
|
8322
|
+
return buffer.Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
6613
8323
|
} catch (error) {
|
|
6614
|
-
throw new Error(
|
|
8324
|
+
throw new Error("Error constructing Ethereum address: ".concat(error));
|
|
6615
8325
|
}
|
|
6616
8326
|
}
|
|
6617
8327
|
/**
|
|
@@ -6662,7 +8372,7 @@ class Secp256k1Program {
|
|
|
6662
8372
|
ethAddress = rawAddress;
|
|
6663
8373
|
}
|
|
6664
8374
|
|
|
6665
|
-
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES,
|
|
8375
|
+
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
|
|
6666
8376
|
const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
|
|
6667
8377
|
const ethAddressOffset = dataStart;
|
|
6668
8378
|
const signatureOffset = dataStart + ethAddress.length;
|
|
@@ -6701,13 +8411,13 @@ class Secp256k1Program {
|
|
|
6701
8411
|
message,
|
|
6702
8412
|
instructionIndex
|
|
6703
8413
|
} = params;
|
|
6704
|
-
assert(pkey.length === PRIVATE_KEY_BYTES,
|
|
8414
|
+
assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
|
|
6705
8415
|
|
|
6706
8416
|
try {
|
|
6707
8417
|
const privateKey = toBuffer(pkey);
|
|
6708
8418
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
6709
8419
|
|
|
6710
|
-
const messageHash = buffer.Buffer.from(
|
|
8420
|
+
const messageHash = buffer.Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
6711
8421
|
const {
|
|
6712
8422
|
signature,
|
|
6713
8423
|
recid: recoveryId
|
|
@@ -6720,7 +8430,7 @@ class Secp256k1Program {
|
|
|
6720
8430
|
instructionIndex
|
|
6721
8431
|
});
|
|
6722
8432
|
} catch (error) {
|
|
6723
|
-
throw new Error(
|
|
8433
|
+
throw new Error("Error creating instruction; ".concat(error));
|
|
6724
8434
|
}
|
|
6725
8435
|
}
|
|
6726
8436
|
|
|
@@ -6783,10 +8493,8 @@ class ValidatorInfo {
|
|
|
6783
8493
|
const configKeys = [];
|
|
6784
8494
|
|
|
6785
8495
|
for (let i = 0; i < 2; i++) {
|
|
6786
|
-
const publicKey = new PublicKey(byteArray
|
|
6787
|
-
|
|
6788
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
6789
|
-
byteArray = byteArray.slice(1);
|
|
8496
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
8497
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
6790
8498
|
configKeys.push({
|
|
6791
8499
|
publicKey,
|
|
6792
8500
|
isSigner
|
|
@@ -6908,7 +8616,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
|
|
|
6908
8616
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
6909
8617
|
|
|
6910
8618
|
if (status.err) {
|
|
6911
|
-
throw new Error(
|
|
8619
|
+
throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
|
|
6912
8620
|
}
|
|
6913
8621
|
|
|
6914
8622
|
return signature;
|
|
@@ -6940,7 +8648,7 @@ function clusterApiUrl(cluster, tls) {
|
|
|
6940
8648
|
const url = endpoint[key][cluster];
|
|
6941
8649
|
|
|
6942
8650
|
if (!url) {
|
|
6943
|
-
throw new Error(
|
|
8651
|
+
throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
|
|
6944
8652
|
}
|
|
6945
8653
|
|
|
6946
8654
|
return url;
|