@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.esm.js
CHANGED
|
@@ -4,11 +4,10 @@ import nacl__default from 'tweetnacl';
|
|
|
4
4
|
import { Buffer } from 'buffer';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
import bs58 from 'bs58';
|
|
7
|
-
import { sha256 } from 'crypto-hash';
|
|
8
7
|
import { serialize, deserialize, deserializeUnchecked } from 'borsh';
|
|
9
8
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
10
9
|
import fetch from 'cross-fetch';
|
|
11
|
-
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$
|
|
10
|
+
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
|
|
12
11
|
import { Client } from 'rpc-websockets';
|
|
13
12
|
import RpcClient from 'jayson/lib/client/browser';
|
|
14
13
|
import http from 'http';
|
|
@@ -26,6 +25,1683 @@ const toBuffer = arr => {
|
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
27
|
|
|
28
|
+
const version$2 = "logger/5.5.0";
|
|
29
|
+
|
|
30
|
+
let _permanentCensorErrors = false;
|
|
31
|
+
let _censorErrors = false;
|
|
32
|
+
const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
|
|
33
|
+
let _logLevel = LogLevels["default"];
|
|
34
|
+
let _globalLogger = null;
|
|
35
|
+
function _checkNormalize() {
|
|
36
|
+
try {
|
|
37
|
+
const missing = [];
|
|
38
|
+
// Make sure all forms of normalization are supported
|
|
39
|
+
["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
|
|
40
|
+
try {
|
|
41
|
+
if ("test".normalize(form) !== "test") {
|
|
42
|
+
throw new Error("bad normalize");
|
|
43
|
+
}
|
|
44
|
+
;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
missing.push(form);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (missing.length) {
|
|
51
|
+
throw new Error("missing " + missing.join(", "));
|
|
52
|
+
}
|
|
53
|
+
if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
|
|
54
|
+
throw new Error("broken implementation");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return error.message;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const _normalizeError = _checkNormalize();
|
|
63
|
+
var LogLevel;
|
|
64
|
+
(function (LogLevel) {
|
|
65
|
+
LogLevel["DEBUG"] = "DEBUG";
|
|
66
|
+
LogLevel["INFO"] = "INFO";
|
|
67
|
+
LogLevel["WARNING"] = "WARNING";
|
|
68
|
+
LogLevel["ERROR"] = "ERROR";
|
|
69
|
+
LogLevel["OFF"] = "OFF";
|
|
70
|
+
})(LogLevel || (LogLevel = {}));
|
|
71
|
+
var ErrorCode;
|
|
72
|
+
(function (ErrorCode) {
|
|
73
|
+
///////////////////
|
|
74
|
+
// Generic Errors
|
|
75
|
+
// Unknown Error
|
|
76
|
+
ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
77
|
+
// Not Implemented
|
|
78
|
+
ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
|
79
|
+
// Unsupported Operation
|
|
80
|
+
// - operation
|
|
81
|
+
ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
|
|
82
|
+
// Network Error (i.e. Ethereum Network, such as an invalid chain ID)
|
|
83
|
+
// - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
|
|
84
|
+
ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
85
|
+
// Some sort of bad response from the server
|
|
86
|
+
ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
87
|
+
// Timeout
|
|
88
|
+
ErrorCode["TIMEOUT"] = "TIMEOUT";
|
|
89
|
+
///////////////////
|
|
90
|
+
// Operational Errors
|
|
91
|
+
// Buffer Overrun
|
|
92
|
+
ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
|
|
93
|
+
// Numeric Fault
|
|
94
|
+
// - operation: the operation being executed
|
|
95
|
+
// - fault: the reason this faulted
|
|
96
|
+
ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
|
|
97
|
+
///////////////////
|
|
98
|
+
// Argument Errors
|
|
99
|
+
// Missing new operator to an object
|
|
100
|
+
// - name: The name of the class
|
|
101
|
+
ErrorCode["MISSING_NEW"] = "MISSING_NEW";
|
|
102
|
+
// Invalid argument (e.g. value is incompatible with type) to a function:
|
|
103
|
+
// - argument: The argument name that was invalid
|
|
104
|
+
// - value: The value of the argument
|
|
105
|
+
ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
|
|
106
|
+
// Missing argument to a function:
|
|
107
|
+
// - count: The number of arguments received
|
|
108
|
+
// - expectedCount: The number of arguments expected
|
|
109
|
+
ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
|
|
110
|
+
// Too many arguments
|
|
111
|
+
// - count: The number of arguments received
|
|
112
|
+
// - expectedCount: The number of arguments expected
|
|
113
|
+
ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
|
|
114
|
+
///////////////////
|
|
115
|
+
// Blockchain Errors
|
|
116
|
+
// Call exception
|
|
117
|
+
// - transaction: the transaction
|
|
118
|
+
// - address?: the contract address
|
|
119
|
+
// - args?: The arguments passed into the function
|
|
120
|
+
// - method?: The Solidity method signature
|
|
121
|
+
// - errorSignature?: The EIP848 error signature
|
|
122
|
+
// - errorArgs?: The EIP848 error parameters
|
|
123
|
+
// - reason: The reason (only for EIP848 "Error(string)")
|
|
124
|
+
ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
|
|
125
|
+
// Insufficient funds (< value + gasLimit * gasPrice)
|
|
126
|
+
// - transaction: the transaction attempted
|
|
127
|
+
ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
128
|
+
// Nonce has already been used
|
|
129
|
+
// - transaction: the transaction attempted
|
|
130
|
+
ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
|
|
131
|
+
// The replacement fee for the transaction is too low
|
|
132
|
+
// - transaction: the transaction attempted
|
|
133
|
+
ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
|
|
134
|
+
// The gas limit could not be estimated
|
|
135
|
+
// - transaction: the transaction passed to estimateGas
|
|
136
|
+
ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
|
137
|
+
// The transaction was replaced by one with a higher gas price
|
|
138
|
+
// - reason: "cancelled", "replaced" or "repriced"
|
|
139
|
+
// - cancelled: true if reason == "cancelled" or reason == "replaced")
|
|
140
|
+
// - hash: original transaction hash
|
|
141
|
+
// - replacement: the full TransactionsResponse for the replacement
|
|
142
|
+
// - receipt: the receipt of the replacement
|
|
143
|
+
ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
|
|
144
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
145
|
+
const HEX = "0123456789abcdef";
|
|
146
|
+
class Logger {
|
|
147
|
+
constructor(version) {
|
|
148
|
+
Object.defineProperty(this, "version", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
value: version,
|
|
151
|
+
writable: false
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
_log(logLevel, args) {
|
|
155
|
+
const level = logLevel.toLowerCase();
|
|
156
|
+
if (LogLevels[level] == null) {
|
|
157
|
+
this.throwArgumentError("invalid log level name", "logLevel", logLevel);
|
|
158
|
+
}
|
|
159
|
+
if (_logLevel > LogLevels[level]) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
console.log.apply(console, args);
|
|
163
|
+
}
|
|
164
|
+
debug(...args) {
|
|
165
|
+
this._log(Logger.levels.DEBUG, args);
|
|
166
|
+
}
|
|
167
|
+
info(...args) {
|
|
168
|
+
this._log(Logger.levels.INFO, args);
|
|
169
|
+
}
|
|
170
|
+
warn(...args) {
|
|
171
|
+
this._log(Logger.levels.WARNING, args);
|
|
172
|
+
}
|
|
173
|
+
makeError(message, code, params) {
|
|
174
|
+
// Errors are being censored
|
|
175
|
+
if (_censorErrors) {
|
|
176
|
+
return this.makeError("censored error", code, {});
|
|
177
|
+
}
|
|
178
|
+
if (!code) {
|
|
179
|
+
code = Logger.errors.UNKNOWN_ERROR;
|
|
180
|
+
}
|
|
181
|
+
if (!params) {
|
|
182
|
+
params = {};
|
|
183
|
+
}
|
|
184
|
+
const messageDetails = [];
|
|
185
|
+
Object.keys(params).forEach((key) => {
|
|
186
|
+
const value = params[key];
|
|
187
|
+
try {
|
|
188
|
+
if (value instanceof Uint8Array) {
|
|
189
|
+
let hex = "";
|
|
190
|
+
for (let i = 0; i < value.length; i++) {
|
|
191
|
+
hex += HEX[value[i] >> 4];
|
|
192
|
+
hex += HEX[value[i] & 0x0f];
|
|
193
|
+
}
|
|
194
|
+
messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
messageDetails.push(key + "=" + JSON.stringify(value));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
messageDetails.push(`code=${code}`);
|
|
205
|
+
messageDetails.push(`version=${this.version}`);
|
|
206
|
+
const reason = message;
|
|
207
|
+
if (messageDetails.length) {
|
|
208
|
+
message += " (" + messageDetails.join(", ") + ")";
|
|
209
|
+
}
|
|
210
|
+
// @TODO: Any??
|
|
211
|
+
const error = new Error(message);
|
|
212
|
+
error.reason = reason;
|
|
213
|
+
error.code = code;
|
|
214
|
+
Object.keys(params).forEach(function (key) {
|
|
215
|
+
error[key] = params[key];
|
|
216
|
+
});
|
|
217
|
+
return error;
|
|
218
|
+
}
|
|
219
|
+
throwError(message, code, params) {
|
|
220
|
+
throw this.makeError(message, code, params);
|
|
221
|
+
}
|
|
222
|
+
throwArgumentError(message, name, value) {
|
|
223
|
+
return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
|
|
224
|
+
argument: name,
|
|
225
|
+
value: value
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
assert(condition, message, code, params) {
|
|
229
|
+
if (!!condition) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
this.throwError(message, code, params);
|
|
233
|
+
}
|
|
234
|
+
assertArgument(condition, message, name, value) {
|
|
235
|
+
if (!!condition) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
this.throwArgumentError(message, name, value);
|
|
239
|
+
}
|
|
240
|
+
checkNormalize(message) {
|
|
241
|
+
if (_normalizeError) {
|
|
242
|
+
this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
243
|
+
operation: "String.prototype.normalize", form: _normalizeError
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
checkSafeUint53(value, message) {
|
|
248
|
+
if (typeof (value) !== "number") {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (message == null) {
|
|
252
|
+
message = "value not safe";
|
|
253
|
+
}
|
|
254
|
+
if (value < 0 || value >= 0x1fffffffffffff) {
|
|
255
|
+
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
|
256
|
+
operation: "checkSafeInteger",
|
|
257
|
+
fault: "out-of-safe-range",
|
|
258
|
+
value: value
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (value % 1) {
|
|
262
|
+
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
|
263
|
+
operation: "checkSafeInteger",
|
|
264
|
+
fault: "non-integer",
|
|
265
|
+
value: value
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
checkArgumentCount(count, expectedCount, message) {
|
|
270
|
+
if (message) {
|
|
271
|
+
message = ": " + message;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
message = "";
|
|
275
|
+
}
|
|
276
|
+
if (count < expectedCount) {
|
|
277
|
+
this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
|
|
278
|
+
count: count,
|
|
279
|
+
expectedCount: expectedCount
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (count > expectedCount) {
|
|
283
|
+
this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
|
|
284
|
+
count: count,
|
|
285
|
+
expectedCount: expectedCount
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
checkNew(target, kind) {
|
|
290
|
+
if (target === Object || target == null) {
|
|
291
|
+
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
checkAbstract(target, kind) {
|
|
295
|
+
if (target === kind) {
|
|
296
|
+
this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
|
|
297
|
+
}
|
|
298
|
+
else if (target === Object || target == null) {
|
|
299
|
+
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
static globalLogger() {
|
|
303
|
+
if (!_globalLogger) {
|
|
304
|
+
_globalLogger = new Logger(version$2);
|
|
305
|
+
}
|
|
306
|
+
return _globalLogger;
|
|
307
|
+
}
|
|
308
|
+
static setCensorship(censorship, permanent) {
|
|
309
|
+
if (!censorship && permanent) {
|
|
310
|
+
this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
311
|
+
operation: "setCensorship"
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (_permanentCensorErrors) {
|
|
315
|
+
if (!censorship) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
319
|
+
operation: "setCensorship"
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
_censorErrors = !!censorship;
|
|
323
|
+
_permanentCensorErrors = !!permanent;
|
|
324
|
+
}
|
|
325
|
+
static setLogLevel(logLevel) {
|
|
326
|
+
const level = LogLevels[logLevel.toLowerCase()];
|
|
327
|
+
if (level == null) {
|
|
328
|
+
Logger.globalLogger().warn("invalid log level - " + logLevel);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
_logLevel = level;
|
|
332
|
+
}
|
|
333
|
+
static from(version) {
|
|
334
|
+
return new Logger(version);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
Logger.errors = ErrorCode;
|
|
338
|
+
Logger.levels = LogLevel;
|
|
339
|
+
|
|
340
|
+
const version$1 = "bytes/5.5.0";
|
|
341
|
+
|
|
342
|
+
const logger = new Logger(version$1);
|
|
343
|
+
///////////////////////////////
|
|
344
|
+
function isHexable(value) {
|
|
345
|
+
return !!(value.toHexString);
|
|
346
|
+
}
|
|
347
|
+
function addSlice(array) {
|
|
348
|
+
if (array.slice) {
|
|
349
|
+
return array;
|
|
350
|
+
}
|
|
351
|
+
array.slice = function () {
|
|
352
|
+
const args = Array.prototype.slice.call(arguments);
|
|
353
|
+
return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
|
|
354
|
+
};
|
|
355
|
+
return array;
|
|
356
|
+
}
|
|
357
|
+
function isInteger(value) {
|
|
358
|
+
return (typeof (value) === "number" && value == value && (value % 1) === 0);
|
|
359
|
+
}
|
|
360
|
+
function isBytes(value) {
|
|
361
|
+
if (value == null) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
if (value.constructor === Uint8Array) {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
if (typeof (value) === "string") {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
if (!isInteger(value.length) || value.length < 0) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
for (let i = 0; i < value.length; i++) {
|
|
374
|
+
const v = value[i];
|
|
375
|
+
if (!isInteger(v) || v < 0 || v >= 256) {
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
function arrayify(value, options) {
|
|
382
|
+
if (!options) {
|
|
383
|
+
options = {};
|
|
384
|
+
}
|
|
385
|
+
if (typeof (value) === "number") {
|
|
386
|
+
logger.checkSafeUint53(value, "invalid arrayify value");
|
|
387
|
+
const result = [];
|
|
388
|
+
while (value) {
|
|
389
|
+
result.unshift(value & 0xff);
|
|
390
|
+
value = parseInt(String(value / 256));
|
|
391
|
+
}
|
|
392
|
+
if (result.length === 0) {
|
|
393
|
+
result.push(0);
|
|
394
|
+
}
|
|
395
|
+
return addSlice(new Uint8Array(result));
|
|
396
|
+
}
|
|
397
|
+
if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
|
|
398
|
+
value = "0x" + value;
|
|
399
|
+
}
|
|
400
|
+
if (isHexable(value)) {
|
|
401
|
+
value = value.toHexString();
|
|
402
|
+
}
|
|
403
|
+
if (isHexString(value)) {
|
|
404
|
+
let hex = value.substring(2);
|
|
405
|
+
if (hex.length % 2) {
|
|
406
|
+
if (options.hexPad === "left") {
|
|
407
|
+
hex = "0x0" + hex.substring(2);
|
|
408
|
+
}
|
|
409
|
+
else if (options.hexPad === "right") {
|
|
410
|
+
hex += "0";
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
logger.throwArgumentError("hex data is odd-length", "value", value);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const result = [];
|
|
417
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
418
|
+
result.push(parseInt(hex.substring(i, i + 2), 16));
|
|
419
|
+
}
|
|
420
|
+
return addSlice(new Uint8Array(result));
|
|
421
|
+
}
|
|
422
|
+
if (isBytes(value)) {
|
|
423
|
+
return addSlice(new Uint8Array(value));
|
|
424
|
+
}
|
|
425
|
+
return logger.throwArgumentError("invalid arrayify value", "value", value);
|
|
426
|
+
}
|
|
427
|
+
function isHexString(value, length) {
|
|
428
|
+
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
if (length && value.length !== 2 + 2 * length) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
var hash$1 = {};
|
|
438
|
+
|
|
439
|
+
var utils$9 = {};
|
|
440
|
+
|
|
441
|
+
var minimalisticAssert = assert$6;
|
|
442
|
+
|
|
443
|
+
function assert$6(val, msg) {
|
|
444
|
+
if (!val)
|
|
445
|
+
throw new Error(msg || 'Assertion failed');
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
assert$6.equal = function assertEqual(l, r, msg) {
|
|
449
|
+
if (l != r)
|
|
450
|
+
throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
var inherits$1 = {exports: {}};
|
|
454
|
+
|
|
455
|
+
var inherits_browser = {exports: {}};
|
|
456
|
+
|
|
457
|
+
if (typeof Object.create === 'function') {
|
|
458
|
+
// implementation from standard node.js 'util' module
|
|
459
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
460
|
+
ctor.super_ = superCtor;
|
|
461
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
462
|
+
constructor: {
|
|
463
|
+
value: ctor,
|
|
464
|
+
enumerable: false,
|
|
465
|
+
writable: true,
|
|
466
|
+
configurable: true
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
} else {
|
|
471
|
+
// old school shim for old browsers
|
|
472
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
473
|
+
ctor.super_ = superCtor;
|
|
474
|
+
var TempCtor = function () {};
|
|
475
|
+
TempCtor.prototype = superCtor.prototype;
|
|
476
|
+
ctor.prototype = new TempCtor();
|
|
477
|
+
ctor.prototype.constructor = ctor;
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
try {
|
|
482
|
+
var util = require('util');
|
|
483
|
+
if (typeof util.inherits !== 'function') throw '';
|
|
484
|
+
inherits$1.exports = util.inherits;
|
|
485
|
+
} catch (e) {
|
|
486
|
+
inherits$1.exports = inherits_browser.exports;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
var assert$5 = minimalisticAssert;
|
|
490
|
+
var inherits = inherits$1.exports;
|
|
491
|
+
|
|
492
|
+
utils$9.inherits = inherits;
|
|
493
|
+
|
|
494
|
+
function isSurrogatePair(msg, i) {
|
|
495
|
+
if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
if (i < 0 || i + 1 >= msg.length) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function toArray(msg, enc) {
|
|
505
|
+
if (Array.isArray(msg))
|
|
506
|
+
return msg.slice();
|
|
507
|
+
if (!msg)
|
|
508
|
+
return [];
|
|
509
|
+
var res = [];
|
|
510
|
+
if (typeof msg === 'string') {
|
|
511
|
+
if (!enc) {
|
|
512
|
+
// Inspired by stringToUtf8ByteArray() in closure-library by Google
|
|
513
|
+
// https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
|
|
514
|
+
// Apache License 2.0
|
|
515
|
+
// https://github.com/google/closure-library/blob/master/LICENSE
|
|
516
|
+
var p = 0;
|
|
517
|
+
for (var i = 0; i < msg.length; i++) {
|
|
518
|
+
var c = msg.charCodeAt(i);
|
|
519
|
+
if (c < 128) {
|
|
520
|
+
res[p++] = c;
|
|
521
|
+
} else if (c < 2048) {
|
|
522
|
+
res[p++] = (c >> 6) | 192;
|
|
523
|
+
res[p++] = (c & 63) | 128;
|
|
524
|
+
} else if (isSurrogatePair(msg, i)) {
|
|
525
|
+
c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
|
|
526
|
+
res[p++] = (c >> 18) | 240;
|
|
527
|
+
res[p++] = ((c >> 12) & 63) | 128;
|
|
528
|
+
res[p++] = ((c >> 6) & 63) | 128;
|
|
529
|
+
res[p++] = (c & 63) | 128;
|
|
530
|
+
} else {
|
|
531
|
+
res[p++] = (c >> 12) | 224;
|
|
532
|
+
res[p++] = ((c >> 6) & 63) | 128;
|
|
533
|
+
res[p++] = (c & 63) | 128;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
} else if (enc === 'hex') {
|
|
537
|
+
msg = msg.replace(/[^a-z0-9]+/ig, '');
|
|
538
|
+
if (msg.length % 2 !== 0)
|
|
539
|
+
msg = '0' + msg;
|
|
540
|
+
for (i = 0; i < msg.length; i += 2)
|
|
541
|
+
res.push(parseInt(msg[i] + msg[i + 1], 16));
|
|
542
|
+
}
|
|
543
|
+
} else {
|
|
544
|
+
for (i = 0; i < msg.length; i++)
|
|
545
|
+
res[i] = msg[i] | 0;
|
|
546
|
+
}
|
|
547
|
+
return res;
|
|
548
|
+
}
|
|
549
|
+
utils$9.toArray = toArray;
|
|
550
|
+
|
|
551
|
+
function toHex(msg) {
|
|
552
|
+
var res = '';
|
|
553
|
+
for (var i = 0; i < msg.length; i++)
|
|
554
|
+
res += zero2(msg[i].toString(16));
|
|
555
|
+
return res;
|
|
556
|
+
}
|
|
557
|
+
utils$9.toHex = toHex;
|
|
558
|
+
|
|
559
|
+
function htonl(w) {
|
|
560
|
+
var res = (w >>> 24) |
|
|
561
|
+
((w >>> 8) & 0xff00) |
|
|
562
|
+
((w << 8) & 0xff0000) |
|
|
563
|
+
((w & 0xff) << 24);
|
|
564
|
+
return res >>> 0;
|
|
565
|
+
}
|
|
566
|
+
utils$9.htonl = htonl;
|
|
567
|
+
|
|
568
|
+
function toHex32(msg, endian) {
|
|
569
|
+
var res = '';
|
|
570
|
+
for (var i = 0; i < msg.length; i++) {
|
|
571
|
+
var w = msg[i];
|
|
572
|
+
if (endian === 'little')
|
|
573
|
+
w = htonl(w);
|
|
574
|
+
res += zero8(w.toString(16));
|
|
575
|
+
}
|
|
576
|
+
return res;
|
|
577
|
+
}
|
|
578
|
+
utils$9.toHex32 = toHex32;
|
|
579
|
+
|
|
580
|
+
function zero2(word) {
|
|
581
|
+
if (word.length === 1)
|
|
582
|
+
return '0' + word;
|
|
583
|
+
else
|
|
584
|
+
return word;
|
|
585
|
+
}
|
|
586
|
+
utils$9.zero2 = zero2;
|
|
587
|
+
|
|
588
|
+
function zero8(word) {
|
|
589
|
+
if (word.length === 7)
|
|
590
|
+
return '0' + word;
|
|
591
|
+
else if (word.length === 6)
|
|
592
|
+
return '00' + word;
|
|
593
|
+
else if (word.length === 5)
|
|
594
|
+
return '000' + word;
|
|
595
|
+
else if (word.length === 4)
|
|
596
|
+
return '0000' + word;
|
|
597
|
+
else if (word.length === 3)
|
|
598
|
+
return '00000' + word;
|
|
599
|
+
else if (word.length === 2)
|
|
600
|
+
return '000000' + word;
|
|
601
|
+
else if (word.length === 1)
|
|
602
|
+
return '0000000' + word;
|
|
603
|
+
else
|
|
604
|
+
return word;
|
|
605
|
+
}
|
|
606
|
+
utils$9.zero8 = zero8;
|
|
607
|
+
|
|
608
|
+
function join32(msg, start, end, endian) {
|
|
609
|
+
var len = end - start;
|
|
610
|
+
assert$5(len % 4 === 0);
|
|
611
|
+
var res = new Array(len / 4);
|
|
612
|
+
for (var i = 0, k = start; i < res.length; i++, k += 4) {
|
|
613
|
+
var w;
|
|
614
|
+
if (endian === 'big')
|
|
615
|
+
w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
|
|
616
|
+
else
|
|
617
|
+
w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
|
|
618
|
+
res[i] = w >>> 0;
|
|
619
|
+
}
|
|
620
|
+
return res;
|
|
621
|
+
}
|
|
622
|
+
utils$9.join32 = join32;
|
|
623
|
+
|
|
624
|
+
function split32(msg, endian) {
|
|
625
|
+
var res = new Array(msg.length * 4);
|
|
626
|
+
for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
|
|
627
|
+
var m = msg[i];
|
|
628
|
+
if (endian === 'big') {
|
|
629
|
+
res[k] = m >>> 24;
|
|
630
|
+
res[k + 1] = (m >>> 16) & 0xff;
|
|
631
|
+
res[k + 2] = (m >>> 8) & 0xff;
|
|
632
|
+
res[k + 3] = m & 0xff;
|
|
633
|
+
} else {
|
|
634
|
+
res[k + 3] = m >>> 24;
|
|
635
|
+
res[k + 2] = (m >>> 16) & 0xff;
|
|
636
|
+
res[k + 1] = (m >>> 8) & 0xff;
|
|
637
|
+
res[k] = m & 0xff;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return res;
|
|
641
|
+
}
|
|
642
|
+
utils$9.split32 = split32;
|
|
643
|
+
|
|
644
|
+
function rotr32$1(w, b) {
|
|
645
|
+
return (w >>> b) | (w << (32 - b));
|
|
646
|
+
}
|
|
647
|
+
utils$9.rotr32 = rotr32$1;
|
|
648
|
+
|
|
649
|
+
function rotl32$2(w, b) {
|
|
650
|
+
return (w << b) | (w >>> (32 - b));
|
|
651
|
+
}
|
|
652
|
+
utils$9.rotl32 = rotl32$2;
|
|
653
|
+
|
|
654
|
+
function sum32$3(a, b) {
|
|
655
|
+
return (a + b) >>> 0;
|
|
656
|
+
}
|
|
657
|
+
utils$9.sum32 = sum32$3;
|
|
658
|
+
|
|
659
|
+
function sum32_3$1(a, b, c) {
|
|
660
|
+
return (a + b + c) >>> 0;
|
|
661
|
+
}
|
|
662
|
+
utils$9.sum32_3 = sum32_3$1;
|
|
663
|
+
|
|
664
|
+
function sum32_4$2(a, b, c, d) {
|
|
665
|
+
return (a + b + c + d) >>> 0;
|
|
666
|
+
}
|
|
667
|
+
utils$9.sum32_4 = sum32_4$2;
|
|
668
|
+
|
|
669
|
+
function sum32_5$2(a, b, c, d, e) {
|
|
670
|
+
return (a + b + c + d + e) >>> 0;
|
|
671
|
+
}
|
|
672
|
+
utils$9.sum32_5 = sum32_5$2;
|
|
673
|
+
|
|
674
|
+
function sum64$1(buf, pos, ah, al) {
|
|
675
|
+
var bh = buf[pos];
|
|
676
|
+
var bl = buf[pos + 1];
|
|
677
|
+
|
|
678
|
+
var lo = (al + bl) >>> 0;
|
|
679
|
+
var hi = (lo < al ? 1 : 0) + ah + bh;
|
|
680
|
+
buf[pos] = hi >>> 0;
|
|
681
|
+
buf[pos + 1] = lo;
|
|
682
|
+
}
|
|
683
|
+
utils$9.sum64 = sum64$1;
|
|
684
|
+
|
|
685
|
+
function sum64_hi$1(ah, al, bh, bl) {
|
|
686
|
+
var lo = (al + bl) >>> 0;
|
|
687
|
+
var hi = (lo < al ? 1 : 0) + ah + bh;
|
|
688
|
+
return hi >>> 0;
|
|
689
|
+
}
|
|
690
|
+
utils$9.sum64_hi = sum64_hi$1;
|
|
691
|
+
|
|
692
|
+
function sum64_lo$1(ah, al, bh, bl) {
|
|
693
|
+
var lo = al + bl;
|
|
694
|
+
return lo >>> 0;
|
|
695
|
+
}
|
|
696
|
+
utils$9.sum64_lo = sum64_lo$1;
|
|
697
|
+
|
|
698
|
+
function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
|
|
699
|
+
var carry = 0;
|
|
700
|
+
var lo = al;
|
|
701
|
+
lo = (lo + bl) >>> 0;
|
|
702
|
+
carry += lo < al ? 1 : 0;
|
|
703
|
+
lo = (lo + cl) >>> 0;
|
|
704
|
+
carry += lo < cl ? 1 : 0;
|
|
705
|
+
lo = (lo + dl) >>> 0;
|
|
706
|
+
carry += lo < dl ? 1 : 0;
|
|
707
|
+
|
|
708
|
+
var hi = ah + bh + ch + dh + carry;
|
|
709
|
+
return hi >>> 0;
|
|
710
|
+
}
|
|
711
|
+
utils$9.sum64_4_hi = sum64_4_hi$1;
|
|
712
|
+
|
|
713
|
+
function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
|
|
714
|
+
var lo = al + bl + cl + dl;
|
|
715
|
+
return lo >>> 0;
|
|
716
|
+
}
|
|
717
|
+
utils$9.sum64_4_lo = sum64_4_lo$1;
|
|
718
|
+
|
|
719
|
+
function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
|
|
720
|
+
var carry = 0;
|
|
721
|
+
var lo = al;
|
|
722
|
+
lo = (lo + bl) >>> 0;
|
|
723
|
+
carry += lo < al ? 1 : 0;
|
|
724
|
+
lo = (lo + cl) >>> 0;
|
|
725
|
+
carry += lo < cl ? 1 : 0;
|
|
726
|
+
lo = (lo + dl) >>> 0;
|
|
727
|
+
carry += lo < dl ? 1 : 0;
|
|
728
|
+
lo = (lo + el) >>> 0;
|
|
729
|
+
carry += lo < el ? 1 : 0;
|
|
730
|
+
|
|
731
|
+
var hi = ah + bh + ch + dh + eh + carry;
|
|
732
|
+
return hi >>> 0;
|
|
733
|
+
}
|
|
734
|
+
utils$9.sum64_5_hi = sum64_5_hi$1;
|
|
735
|
+
|
|
736
|
+
function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
|
|
737
|
+
var lo = al + bl + cl + dl + el;
|
|
738
|
+
|
|
739
|
+
return lo >>> 0;
|
|
740
|
+
}
|
|
741
|
+
utils$9.sum64_5_lo = sum64_5_lo$1;
|
|
742
|
+
|
|
743
|
+
function rotr64_hi$1(ah, al, num) {
|
|
744
|
+
var r = (al << (32 - num)) | (ah >>> num);
|
|
745
|
+
return r >>> 0;
|
|
746
|
+
}
|
|
747
|
+
utils$9.rotr64_hi = rotr64_hi$1;
|
|
748
|
+
|
|
749
|
+
function rotr64_lo$1(ah, al, num) {
|
|
750
|
+
var r = (ah << (32 - num)) | (al >>> num);
|
|
751
|
+
return r >>> 0;
|
|
752
|
+
}
|
|
753
|
+
utils$9.rotr64_lo = rotr64_lo$1;
|
|
754
|
+
|
|
755
|
+
function shr64_hi$1(ah, al, num) {
|
|
756
|
+
return ah >>> num;
|
|
757
|
+
}
|
|
758
|
+
utils$9.shr64_hi = shr64_hi$1;
|
|
759
|
+
|
|
760
|
+
function shr64_lo$1(ah, al, num) {
|
|
761
|
+
var r = (ah << (32 - num)) | (al >>> num);
|
|
762
|
+
return r >>> 0;
|
|
763
|
+
}
|
|
764
|
+
utils$9.shr64_lo = shr64_lo$1;
|
|
765
|
+
|
|
766
|
+
var common$5 = {};
|
|
767
|
+
|
|
768
|
+
var utils$8 = utils$9;
|
|
769
|
+
var assert$4 = minimalisticAssert;
|
|
770
|
+
|
|
771
|
+
function BlockHash$4() {
|
|
772
|
+
this.pending = null;
|
|
773
|
+
this.pendingTotal = 0;
|
|
774
|
+
this.blockSize = this.constructor.blockSize;
|
|
775
|
+
this.outSize = this.constructor.outSize;
|
|
776
|
+
this.hmacStrength = this.constructor.hmacStrength;
|
|
777
|
+
this.padLength = this.constructor.padLength / 8;
|
|
778
|
+
this.endian = 'big';
|
|
779
|
+
|
|
780
|
+
this._delta8 = this.blockSize / 8;
|
|
781
|
+
this._delta32 = this.blockSize / 32;
|
|
782
|
+
}
|
|
783
|
+
common$5.BlockHash = BlockHash$4;
|
|
784
|
+
|
|
785
|
+
BlockHash$4.prototype.update = function update(msg, enc) {
|
|
786
|
+
// Convert message to array, pad it, and join into 32bit blocks
|
|
787
|
+
msg = utils$8.toArray(msg, enc);
|
|
788
|
+
if (!this.pending)
|
|
789
|
+
this.pending = msg;
|
|
790
|
+
else
|
|
791
|
+
this.pending = this.pending.concat(msg);
|
|
792
|
+
this.pendingTotal += msg.length;
|
|
793
|
+
|
|
794
|
+
// Enough data, try updating
|
|
795
|
+
if (this.pending.length >= this._delta8) {
|
|
796
|
+
msg = this.pending;
|
|
797
|
+
|
|
798
|
+
// Process pending data in blocks
|
|
799
|
+
var r = msg.length % this._delta8;
|
|
800
|
+
this.pending = msg.slice(msg.length - r, msg.length);
|
|
801
|
+
if (this.pending.length === 0)
|
|
802
|
+
this.pending = null;
|
|
803
|
+
|
|
804
|
+
msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
|
|
805
|
+
for (var i = 0; i < msg.length; i += this._delta32)
|
|
806
|
+
this._update(msg, i, i + this._delta32);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
return this;
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
BlockHash$4.prototype.digest = function digest(enc) {
|
|
813
|
+
this.update(this._pad());
|
|
814
|
+
assert$4(this.pending === null);
|
|
815
|
+
|
|
816
|
+
return this._digest(enc);
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
BlockHash$4.prototype._pad = function pad() {
|
|
820
|
+
var len = this.pendingTotal;
|
|
821
|
+
var bytes = this._delta8;
|
|
822
|
+
var k = bytes - ((len + this.padLength) % bytes);
|
|
823
|
+
var res = new Array(k + this.padLength);
|
|
824
|
+
res[0] = 0x80;
|
|
825
|
+
for (var i = 1; i < k; i++)
|
|
826
|
+
res[i] = 0;
|
|
827
|
+
|
|
828
|
+
// Append length
|
|
829
|
+
len <<= 3;
|
|
830
|
+
if (this.endian === 'big') {
|
|
831
|
+
for (var t = 8; t < this.padLength; t++)
|
|
832
|
+
res[i++] = 0;
|
|
833
|
+
|
|
834
|
+
res[i++] = 0;
|
|
835
|
+
res[i++] = 0;
|
|
836
|
+
res[i++] = 0;
|
|
837
|
+
res[i++] = 0;
|
|
838
|
+
res[i++] = (len >>> 24) & 0xff;
|
|
839
|
+
res[i++] = (len >>> 16) & 0xff;
|
|
840
|
+
res[i++] = (len >>> 8) & 0xff;
|
|
841
|
+
res[i++] = len & 0xff;
|
|
842
|
+
} else {
|
|
843
|
+
res[i++] = len & 0xff;
|
|
844
|
+
res[i++] = (len >>> 8) & 0xff;
|
|
845
|
+
res[i++] = (len >>> 16) & 0xff;
|
|
846
|
+
res[i++] = (len >>> 24) & 0xff;
|
|
847
|
+
res[i++] = 0;
|
|
848
|
+
res[i++] = 0;
|
|
849
|
+
res[i++] = 0;
|
|
850
|
+
res[i++] = 0;
|
|
851
|
+
|
|
852
|
+
for (t = 8; t < this.padLength; t++)
|
|
853
|
+
res[i++] = 0;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
return res;
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
var sha = {};
|
|
860
|
+
|
|
861
|
+
var common$4 = {};
|
|
862
|
+
|
|
863
|
+
var utils$7 = utils$9;
|
|
864
|
+
var rotr32 = utils$7.rotr32;
|
|
865
|
+
|
|
866
|
+
function ft_1$1(s, x, y, z) {
|
|
867
|
+
if (s === 0)
|
|
868
|
+
return ch32$1(x, y, z);
|
|
869
|
+
if (s === 1 || s === 3)
|
|
870
|
+
return p32(x, y, z);
|
|
871
|
+
if (s === 2)
|
|
872
|
+
return maj32$1(x, y, z);
|
|
873
|
+
}
|
|
874
|
+
common$4.ft_1 = ft_1$1;
|
|
875
|
+
|
|
876
|
+
function ch32$1(x, y, z) {
|
|
877
|
+
return (x & y) ^ ((~x) & z);
|
|
878
|
+
}
|
|
879
|
+
common$4.ch32 = ch32$1;
|
|
880
|
+
|
|
881
|
+
function maj32$1(x, y, z) {
|
|
882
|
+
return (x & y) ^ (x & z) ^ (y & z);
|
|
883
|
+
}
|
|
884
|
+
common$4.maj32 = maj32$1;
|
|
885
|
+
|
|
886
|
+
function p32(x, y, z) {
|
|
887
|
+
return x ^ y ^ z;
|
|
888
|
+
}
|
|
889
|
+
common$4.p32 = p32;
|
|
890
|
+
|
|
891
|
+
function s0_256$1(x) {
|
|
892
|
+
return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
|
|
893
|
+
}
|
|
894
|
+
common$4.s0_256 = s0_256$1;
|
|
895
|
+
|
|
896
|
+
function s1_256$1(x) {
|
|
897
|
+
return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
|
|
898
|
+
}
|
|
899
|
+
common$4.s1_256 = s1_256$1;
|
|
900
|
+
|
|
901
|
+
function g0_256$1(x) {
|
|
902
|
+
return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
|
|
903
|
+
}
|
|
904
|
+
common$4.g0_256 = g0_256$1;
|
|
905
|
+
|
|
906
|
+
function g1_256$1(x) {
|
|
907
|
+
return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
|
|
908
|
+
}
|
|
909
|
+
common$4.g1_256 = g1_256$1;
|
|
910
|
+
|
|
911
|
+
var utils$6 = utils$9;
|
|
912
|
+
var common$3 = common$5;
|
|
913
|
+
var shaCommon$1 = common$4;
|
|
914
|
+
|
|
915
|
+
var rotl32$1 = utils$6.rotl32;
|
|
916
|
+
var sum32$2 = utils$6.sum32;
|
|
917
|
+
var sum32_5$1 = utils$6.sum32_5;
|
|
918
|
+
var ft_1 = shaCommon$1.ft_1;
|
|
919
|
+
var BlockHash$3 = common$3.BlockHash;
|
|
920
|
+
|
|
921
|
+
var sha1_K = [
|
|
922
|
+
0x5A827999, 0x6ED9EBA1,
|
|
923
|
+
0x8F1BBCDC, 0xCA62C1D6
|
|
924
|
+
];
|
|
925
|
+
|
|
926
|
+
function SHA1() {
|
|
927
|
+
if (!(this instanceof SHA1))
|
|
928
|
+
return new SHA1();
|
|
929
|
+
|
|
930
|
+
BlockHash$3.call(this);
|
|
931
|
+
this.h = [
|
|
932
|
+
0x67452301, 0xefcdab89, 0x98badcfe,
|
|
933
|
+
0x10325476, 0xc3d2e1f0 ];
|
|
934
|
+
this.W = new Array(80);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
utils$6.inherits(SHA1, BlockHash$3);
|
|
938
|
+
var _1 = SHA1;
|
|
939
|
+
|
|
940
|
+
SHA1.blockSize = 512;
|
|
941
|
+
SHA1.outSize = 160;
|
|
942
|
+
SHA1.hmacStrength = 80;
|
|
943
|
+
SHA1.padLength = 64;
|
|
944
|
+
|
|
945
|
+
SHA1.prototype._update = function _update(msg, start) {
|
|
946
|
+
var W = this.W;
|
|
947
|
+
|
|
948
|
+
for (var i = 0; i < 16; i++)
|
|
949
|
+
W[i] = msg[start + i];
|
|
950
|
+
|
|
951
|
+
for(; i < W.length; i++)
|
|
952
|
+
W[i] = rotl32$1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
|
|
953
|
+
|
|
954
|
+
var a = this.h[0];
|
|
955
|
+
var b = this.h[1];
|
|
956
|
+
var c = this.h[2];
|
|
957
|
+
var d = this.h[3];
|
|
958
|
+
var e = this.h[4];
|
|
959
|
+
|
|
960
|
+
for (i = 0; i < W.length; i++) {
|
|
961
|
+
var s = ~~(i / 20);
|
|
962
|
+
var t = sum32_5$1(rotl32$1(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
|
|
963
|
+
e = d;
|
|
964
|
+
d = c;
|
|
965
|
+
c = rotl32$1(b, 30);
|
|
966
|
+
b = a;
|
|
967
|
+
a = t;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
this.h[0] = sum32$2(this.h[0], a);
|
|
971
|
+
this.h[1] = sum32$2(this.h[1], b);
|
|
972
|
+
this.h[2] = sum32$2(this.h[2], c);
|
|
973
|
+
this.h[3] = sum32$2(this.h[3], d);
|
|
974
|
+
this.h[4] = sum32$2(this.h[4], e);
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
SHA1.prototype._digest = function digest(enc) {
|
|
978
|
+
if (enc === 'hex')
|
|
979
|
+
return utils$6.toHex32(this.h, 'big');
|
|
980
|
+
else
|
|
981
|
+
return utils$6.split32(this.h, 'big');
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
var utils$5 = utils$9;
|
|
985
|
+
var common$2 = common$5;
|
|
986
|
+
var shaCommon = common$4;
|
|
987
|
+
var assert$3 = minimalisticAssert;
|
|
988
|
+
|
|
989
|
+
var sum32$1 = utils$5.sum32;
|
|
990
|
+
var sum32_4$1 = utils$5.sum32_4;
|
|
991
|
+
var sum32_5 = utils$5.sum32_5;
|
|
992
|
+
var ch32 = shaCommon.ch32;
|
|
993
|
+
var maj32 = shaCommon.maj32;
|
|
994
|
+
var s0_256 = shaCommon.s0_256;
|
|
995
|
+
var s1_256 = shaCommon.s1_256;
|
|
996
|
+
var g0_256 = shaCommon.g0_256;
|
|
997
|
+
var g1_256 = shaCommon.g1_256;
|
|
998
|
+
|
|
999
|
+
var BlockHash$2 = common$2.BlockHash;
|
|
1000
|
+
|
|
1001
|
+
var sha256_K = [
|
|
1002
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
|
1003
|
+
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
1004
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
1005
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
1006
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
|
1007
|
+
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
1008
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
|
1009
|
+
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
1010
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
1011
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
1012
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
|
1013
|
+
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
1014
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
|
1015
|
+
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
1016
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
1017
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
1018
|
+
];
|
|
1019
|
+
|
|
1020
|
+
function SHA256$1() {
|
|
1021
|
+
if (!(this instanceof SHA256$1))
|
|
1022
|
+
return new SHA256$1();
|
|
1023
|
+
|
|
1024
|
+
BlockHash$2.call(this);
|
|
1025
|
+
this.h = [
|
|
1026
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
|
1027
|
+
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
1028
|
+
];
|
|
1029
|
+
this.k = sha256_K;
|
|
1030
|
+
this.W = new Array(64);
|
|
1031
|
+
}
|
|
1032
|
+
utils$5.inherits(SHA256$1, BlockHash$2);
|
|
1033
|
+
var _256 = SHA256$1;
|
|
1034
|
+
|
|
1035
|
+
SHA256$1.blockSize = 512;
|
|
1036
|
+
SHA256$1.outSize = 256;
|
|
1037
|
+
SHA256$1.hmacStrength = 192;
|
|
1038
|
+
SHA256$1.padLength = 64;
|
|
1039
|
+
|
|
1040
|
+
SHA256$1.prototype._update = function _update(msg, start) {
|
|
1041
|
+
var W = this.W;
|
|
1042
|
+
|
|
1043
|
+
for (var i = 0; i < 16; i++)
|
|
1044
|
+
W[i] = msg[start + i];
|
|
1045
|
+
for (; i < W.length; i++)
|
|
1046
|
+
W[i] = sum32_4$1(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
|
|
1047
|
+
|
|
1048
|
+
var a = this.h[0];
|
|
1049
|
+
var b = this.h[1];
|
|
1050
|
+
var c = this.h[2];
|
|
1051
|
+
var d = this.h[3];
|
|
1052
|
+
var e = this.h[4];
|
|
1053
|
+
var f = this.h[5];
|
|
1054
|
+
var g = this.h[6];
|
|
1055
|
+
var h = this.h[7];
|
|
1056
|
+
|
|
1057
|
+
assert$3(this.k.length === W.length);
|
|
1058
|
+
for (i = 0; i < W.length; i++) {
|
|
1059
|
+
var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
|
|
1060
|
+
var T2 = sum32$1(s0_256(a), maj32(a, b, c));
|
|
1061
|
+
h = g;
|
|
1062
|
+
g = f;
|
|
1063
|
+
f = e;
|
|
1064
|
+
e = sum32$1(d, T1);
|
|
1065
|
+
d = c;
|
|
1066
|
+
c = b;
|
|
1067
|
+
b = a;
|
|
1068
|
+
a = sum32$1(T1, T2);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
this.h[0] = sum32$1(this.h[0], a);
|
|
1072
|
+
this.h[1] = sum32$1(this.h[1], b);
|
|
1073
|
+
this.h[2] = sum32$1(this.h[2], c);
|
|
1074
|
+
this.h[3] = sum32$1(this.h[3], d);
|
|
1075
|
+
this.h[4] = sum32$1(this.h[4], e);
|
|
1076
|
+
this.h[5] = sum32$1(this.h[5], f);
|
|
1077
|
+
this.h[6] = sum32$1(this.h[6], g);
|
|
1078
|
+
this.h[7] = sum32$1(this.h[7], h);
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
SHA256$1.prototype._digest = function digest(enc) {
|
|
1082
|
+
if (enc === 'hex')
|
|
1083
|
+
return utils$5.toHex32(this.h, 'big');
|
|
1084
|
+
else
|
|
1085
|
+
return utils$5.split32(this.h, 'big');
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
var utils$4 = utils$9;
|
|
1089
|
+
var SHA256 = _256;
|
|
1090
|
+
|
|
1091
|
+
function SHA224() {
|
|
1092
|
+
if (!(this instanceof SHA224))
|
|
1093
|
+
return new SHA224();
|
|
1094
|
+
|
|
1095
|
+
SHA256.call(this);
|
|
1096
|
+
this.h = [
|
|
1097
|
+
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
|
|
1098
|
+
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
|
|
1099
|
+
}
|
|
1100
|
+
utils$4.inherits(SHA224, SHA256);
|
|
1101
|
+
var _224 = SHA224;
|
|
1102
|
+
|
|
1103
|
+
SHA224.blockSize = 512;
|
|
1104
|
+
SHA224.outSize = 224;
|
|
1105
|
+
SHA224.hmacStrength = 192;
|
|
1106
|
+
SHA224.padLength = 64;
|
|
1107
|
+
|
|
1108
|
+
SHA224.prototype._digest = function digest(enc) {
|
|
1109
|
+
// Just truncate output
|
|
1110
|
+
if (enc === 'hex')
|
|
1111
|
+
return utils$4.toHex32(this.h.slice(0, 7), 'big');
|
|
1112
|
+
else
|
|
1113
|
+
return utils$4.split32(this.h.slice(0, 7), 'big');
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
var utils$3 = utils$9;
|
|
1117
|
+
var common$1 = common$5;
|
|
1118
|
+
var assert$2 = minimalisticAssert;
|
|
1119
|
+
|
|
1120
|
+
var rotr64_hi = utils$3.rotr64_hi;
|
|
1121
|
+
var rotr64_lo = utils$3.rotr64_lo;
|
|
1122
|
+
var shr64_hi = utils$3.shr64_hi;
|
|
1123
|
+
var shr64_lo = utils$3.shr64_lo;
|
|
1124
|
+
var sum64 = utils$3.sum64;
|
|
1125
|
+
var sum64_hi = utils$3.sum64_hi;
|
|
1126
|
+
var sum64_lo = utils$3.sum64_lo;
|
|
1127
|
+
var sum64_4_hi = utils$3.sum64_4_hi;
|
|
1128
|
+
var sum64_4_lo = utils$3.sum64_4_lo;
|
|
1129
|
+
var sum64_5_hi = utils$3.sum64_5_hi;
|
|
1130
|
+
var sum64_5_lo = utils$3.sum64_5_lo;
|
|
1131
|
+
|
|
1132
|
+
var BlockHash$1 = common$1.BlockHash;
|
|
1133
|
+
|
|
1134
|
+
var sha512_K = [
|
|
1135
|
+
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
|
|
1136
|
+
0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
|
|
1137
|
+
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
|
|
1138
|
+
0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
|
|
1139
|
+
0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
|
|
1140
|
+
0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
|
|
1141
|
+
0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
|
|
1142
|
+
0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
|
|
1143
|
+
0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
|
|
1144
|
+
0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
|
|
1145
|
+
0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
|
|
1146
|
+
0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
|
|
1147
|
+
0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
|
|
1148
|
+
0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
|
|
1149
|
+
0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
|
|
1150
|
+
0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
|
|
1151
|
+
0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
|
|
1152
|
+
0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
|
|
1153
|
+
0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
|
|
1154
|
+
0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
|
|
1155
|
+
0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
|
|
1156
|
+
0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
|
|
1157
|
+
0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
|
|
1158
|
+
0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
|
|
1159
|
+
0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
|
|
1160
|
+
0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
|
|
1161
|
+
0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
|
|
1162
|
+
0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
|
|
1163
|
+
0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
|
|
1164
|
+
0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
|
|
1165
|
+
0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
|
|
1166
|
+
0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
|
|
1167
|
+
0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
|
|
1168
|
+
0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
|
|
1169
|
+
0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
|
|
1170
|
+
0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
|
|
1171
|
+
0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
|
|
1172
|
+
0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
|
|
1173
|
+
0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
|
|
1174
|
+
0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
|
|
1175
|
+
];
|
|
1176
|
+
|
|
1177
|
+
function SHA512$1() {
|
|
1178
|
+
if (!(this instanceof SHA512$1))
|
|
1179
|
+
return new SHA512$1();
|
|
1180
|
+
|
|
1181
|
+
BlockHash$1.call(this);
|
|
1182
|
+
this.h = [
|
|
1183
|
+
0x6a09e667, 0xf3bcc908,
|
|
1184
|
+
0xbb67ae85, 0x84caa73b,
|
|
1185
|
+
0x3c6ef372, 0xfe94f82b,
|
|
1186
|
+
0xa54ff53a, 0x5f1d36f1,
|
|
1187
|
+
0x510e527f, 0xade682d1,
|
|
1188
|
+
0x9b05688c, 0x2b3e6c1f,
|
|
1189
|
+
0x1f83d9ab, 0xfb41bd6b,
|
|
1190
|
+
0x5be0cd19, 0x137e2179 ];
|
|
1191
|
+
this.k = sha512_K;
|
|
1192
|
+
this.W = new Array(160);
|
|
1193
|
+
}
|
|
1194
|
+
utils$3.inherits(SHA512$1, BlockHash$1);
|
|
1195
|
+
var _512 = SHA512$1;
|
|
1196
|
+
|
|
1197
|
+
SHA512$1.blockSize = 1024;
|
|
1198
|
+
SHA512$1.outSize = 512;
|
|
1199
|
+
SHA512$1.hmacStrength = 192;
|
|
1200
|
+
SHA512$1.padLength = 128;
|
|
1201
|
+
|
|
1202
|
+
SHA512$1.prototype._prepareBlock = function _prepareBlock(msg, start) {
|
|
1203
|
+
var W = this.W;
|
|
1204
|
+
|
|
1205
|
+
// 32 x 32bit words
|
|
1206
|
+
for (var i = 0; i < 32; i++)
|
|
1207
|
+
W[i] = msg[start + i];
|
|
1208
|
+
for (; i < W.length; i += 2) {
|
|
1209
|
+
var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
|
|
1210
|
+
var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
|
|
1211
|
+
var c1_hi = W[i - 14]; // i - 7
|
|
1212
|
+
var c1_lo = W[i - 13];
|
|
1213
|
+
var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
|
|
1214
|
+
var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
|
|
1215
|
+
var c3_hi = W[i - 32]; // i - 16
|
|
1216
|
+
var c3_lo = W[i - 31];
|
|
1217
|
+
|
|
1218
|
+
W[i] = sum64_4_hi(
|
|
1219
|
+
c0_hi, c0_lo,
|
|
1220
|
+
c1_hi, c1_lo,
|
|
1221
|
+
c2_hi, c2_lo,
|
|
1222
|
+
c3_hi, c3_lo);
|
|
1223
|
+
W[i + 1] = sum64_4_lo(
|
|
1224
|
+
c0_hi, c0_lo,
|
|
1225
|
+
c1_hi, c1_lo,
|
|
1226
|
+
c2_hi, c2_lo,
|
|
1227
|
+
c3_hi, c3_lo);
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
SHA512$1.prototype._update = function _update(msg, start) {
|
|
1232
|
+
this._prepareBlock(msg, start);
|
|
1233
|
+
|
|
1234
|
+
var W = this.W;
|
|
1235
|
+
|
|
1236
|
+
var ah = this.h[0];
|
|
1237
|
+
var al = this.h[1];
|
|
1238
|
+
var bh = this.h[2];
|
|
1239
|
+
var bl = this.h[3];
|
|
1240
|
+
var ch = this.h[4];
|
|
1241
|
+
var cl = this.h[5];
|
|
1242
|
+
var dh = this.h[6];
|
|
1243
|
+
var dl = this.h[7];
|
|
1244
|
+
var eh = this.h[8];
|
|
1245
|
+
var el = this.h[9];
|
|
1246
|
+
var fh = this.h[10];
|
|
1247
|
+
var fl = this.h[11];
|
|
1248
|
+
var gh = this.h[12];
|
|
1249
|
+
var gl = this.h[13];
|
|
1250
|
+
var hh = this.h[14];
|
|
1251
|
+
var hl = this.h[15];
|
|
1252
|
+
|
|
1253
|
+
assert$2(this.k.length === W.length);
|
|
1254
|
+
for (var i = 0; i < W.length; i += 2) {
|
|
1255
|
+
var c0_hi = hh;
|
|
1256
|
+
var c0_lo = hl;
|
|
1257
|
+
var c1_hi = s1_512_hi(eh, el);
|
|
1258
|
+
var c1_lo = s1_512_lo(eh, el);
|
|
1259
|
+
var c2_hi = ch64_hi(eh, el, fh, fl, gh);
|
|
1260
|
+
var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
|
|
1261
|
+
var c3_hi = this.k[i];
|
|
1262
|
+
var c3_lo = this.k[i + 1];
|
|
1263
|
+
var c4_hi = W[i];
|
|
1264
|
+
var c4_lo = W[i + 1];
|
|
1265
|
+
|
|
1266
|
+
var T1_hi = sum64_5_hi(
|
|
1267
|
+
c0_hi, c0_lo,
|
|
1268
|
+
c1_hi, c1_lo,
|
|
1269
|
+
c2_hi, c2_lo,
|
|
1270
|
+
c3_hi, c3_lo,
|
|
1271
|
+
c4_hi, c4_lo);
|
|
1272
|
+
var T1_lo = sum64_5_lo(
|
|
1273
|
+
c0_hi, c0_lo,
|
|
1274
|
+
c1_hi, c1_lo,
|
|
1275
|
+
c2_hi, c2_lo,
|
|
1276
|
+
c3_hi, c3_lo,
|
|
1277
|
+
c4_hi, c4_lo);
|
|
1278
|
+
|
|
1279
|
+
c0_hi = s0_512_hi(ah, al);
|
|
1280
|
+
c0_lo = s0_512_lo(ah, al);
|
|
1281
|
+
c1_hi = maj64_hi(ah, al, bh, bl, ch);
|
|
1282
|
+
c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
|
|
1283
|
+
|
|
1284
|
+
var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
|
|
1285
|
+
var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
|
|
1286
|
+
|
|
1287
|
+
hh = gh;
|
|
1288
|
+
hl = gl;
|
|
1289
|
+
|
|
1290
|
+
gh = fh;
|
|
1291
|
+
gl = fl;
|
|
1292
|
+
|
|
1293
|
+
fh = eh;
|
|
1294
|
+
fl = el;
|
|
1295
|
+
|
|
1296
|
+
eh = sum64_hi(dh, dl, T1_hi, T1_lo);
|
|
1297
|
+
el = sum64_lo(dl, dl, T1_hi, T1_lo);
|
|
1298
|
+
|
|
1299
|
+
dh = ch;
|
|
1300
|
+
dl = cl;
|
|
1301
|
+
|
|
1302
|
+
ch = bh;
|
|
1303
|
+
cl = bl;
|
|
1304
|
+
|
|
1305
|
+
bh = ah;
|
|
1306
|
+
bl = al;
|
|
1307
|
+
|
|
1308
|
+
ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
|
|
1309
|
+
al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
sum64(this.h, 0, ah, al);
|
|
1313
|
+
sum64(this.h, 2, bh, bl);
|
|
1314
|
+
sum64(this.h, 4, ch, cl);
|
|
1315
|
+
sum64(this.h, 6, dh, dl);
|
|
1316
|
+
sum64(this.h, 8, eh, el);
|
|
1317
|
+
sum64(this.h, 10, fh, fl);
|
|
1318
|
+
sum64(this.h, 12, gh, gl);
|
|
1319
|
+
sum64(this.h, 14, hh, hl);
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
SHA512$1.prototype._digest = function digest(enc) {
|
|
1323
|
+
if (enc === 'hex')
|
|
1324
|
+
return utils$3.toHex32(this.h, 'big');
|
|
1325
|
+
else
|
|
1326
|
+
return utils$3.split32(this.h, 'big');
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
function ch64_hi(xh, xl, yh, yl, zh) {
|
|
1330
|
+
var r = (xh & yh) ^ ((~xh) & zh);
|
|
1331
|
+
if (r < 0)
|
|
1332
|
+
r += 0x100000000;
|
|
1333
|
+
return r;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function ch64_lo(xh, xl, yh, yl, zh, zl) {
|
|
1337
|
+
var r = (xl & yl) ^ ((~xl) & zl);
|
|
1338
|
+
if (r < 0)
|
|
1339
|
+
r += 0x100000000;
|
|
1340
|
+
return r;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
function maj64_hi(xh, xl, yh, yl, zh) {
|
|
1344
|
+
var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
|
|
1345
|
+
if (r < 0)
|
|
1346
|
+
r += 0x100000000;
|
|
1347
|
+
return r;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
function maj64_lo(xh, xl, yh, yl, zh, zl) {
|
|
1351
|
+
var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
|
|
1352
|
+
if (r < 0)
|
|
1353
|
+
r += 0x100000000;
|
|
1354
|
+
return r;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
function s0_512_hi(xh, xl) {
|
|
1358
|
+
var c0_hi = rotr64_hi(xh, xl, 28);
|
|
1359
|
+
var c1_hi = rotr64_hi(xl, xh, 2); // 34
|
|
1360
|
+
var c2_hi = rotr64_hi(xl, xh, 7); // 39
|
|
1361
|
+
|
|
1362
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1363
|
+
if (r < 0)
|
|
1364
|
+
r += 0x100000000;
|
|
1365
|
+
return r;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
function s0_512_lo(xh, xl) {
|
|
1369
|
+
var c0_lo = rotr64_lo(xh, xl, 28);
|
|
1370
|
+
var c1_lo = rotr64_lo(xl, xh, 2); // 34
|
|
1371
|
+
var c2_lo = rotr64_lo(xl, xh, 7); // 39
|
|
1372
|
+
|
|
1373
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1374
|
+
if (r < 0)
|
|
1375
|
+
r += 0x100000000;
|
|
1376
|
+
return r;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
function s1_512_hi(xh, xl) {
|
|
1380
|
+
var c0_hi = rotr64_hi(xh, xl, 14);
|
|
1381
|
+
var c1_hi = rotr64_hi(xh, xl, 18);
|
|
1382
|
+
var c2_hi = rotr64_hi(xl, xh, 9); // 41
|
|
1383
|
+
|
|
1384
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1385
|
+
if (r < 0)
|
|
1386
|
+
r += 0x100000000;
|
|
1387
|
+
return r;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
function s1_512_lo(xh, xl) {
|
|
1391
|
+
var c0_lo = rotr64_lo(xh, xl, 14);
|
|
1392
|
+
var c1_lo = rotr64_lo(xh, xl, 18);
|
|
1393
|
+
var c2_lo = rotr64_lo(xl, xh, 9); // 41
|
|
1394
|
+
|
|
1395
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1396
|
+
if (r < 0)
|
|
1397
|
+
r += 0x100000000;
|
|
1398
|
+
return r;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function g0_512_hi(xh, xl) {
|
|
1402
|
+
var c0_hi = rotr64_hi(xh, xl, 1);
|
|
1403
|
+
var c1_hi = rotr64_hi(xh, xl, 8);
|
|
1404
|
+
var c2_hi = shr64_hi(xh, xl, 7);
|
|
1405
|
+
|
|
1406
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1407
|
+
if (r < 0)
|
|
1408
|
+
r += 0x100000000;
|
|
1409
|
+
return r;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
function g0_512_lo(xh, xl) {
|
|
1413
|
+
var c0_lo = rotr64_lo(xh, xl, 1);
|
|
1414
|
+
var c1_lo = rotr64_lo(xh, xl, 8);
|
|
1415
|
+
var c2_lo = shr64_lo(xh, xl, 7);
|
|
1416
|
+
|
|
1417
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1418
|
+
if (r < 0)
|
|
1419
|
+
r += 0x100000000;
|
|
1420
|
+
return r;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
function g1_512_hi(xh, xl) {
|
|
1424
|
+
var c0_hi = rotr64_hi(xh, xl, 19);
|
|
1425
|
+
var c1_hi = rotr64_hi(xl, xh, 29); // 61
|
|
1426
|
+
var c2_hi = shr64_hi(xh, xl, 6);
|
|
1427
|
+
|
|
1428
|
+
var r = c0_hi ^ c1_hi ^ c2_hi;
|
|
1429
|
+
if (r < 0)
|
|
1430
|
+
r += 0x100000000;
|
|
1431
|
+
return r;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
function g1_512_lo(xh, xl) {
|
|
1435
|
+
var c0_lo = rotr64_lo(xh, xl, 19);
|
|
1436
|
+
var c1_lo = rotr64_lo(xl, xh, 29); // 61
|
|
1437
|
+
var c2_lo = shr64_lo(xh, xl, 6);
|
|
1438
|
+
|
|
1439
|
+
var r = c0_lo ^ c1_lo ^ c2_lo;
|
|
1440
|
+
if (r < 0)
|
|
1441
|
+
r += 0x100000000;
|
|
1442
|
+
return r;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
var utils$2 = utils$9;
|
|
1446
|
+
|
|
1447
|
+
var SHA512 = _512;
|
|
1448
|
+
|
|
1449
|
+
function SHA384() {
|
|
1450
|
+
if (!(this instanceof SHA384))
|
|
1451
|
+
return new SHA384();
|
|
1452
|
+
|
|
1453
|
+
SHA512.call(this);
|
|
1454
|
+
this.h = [
|
|
1455
|
+
0xcbbb9d5d, 0xc1059ed8,
|
|
1456
|
+
0x629a292a, 0x367cd507,
|
|
1457
|
+
0x9159015a, 0x3070dd17,
|
|
1458
|
+
0x152fecd8, 0xf70e5939,
|
|
1459
|
+
0x67332667, 0xffc00b31,
|
|
1460
|
+
0x8eb44a87, 0x68581511,
|
|
1461
|
+
0xdb0c2e0d, 0x64f98fa7,
|
|
1462
|
+
0x47b5481d, 0xbefa4fa4 ];
|
|
1463
|
+
}
|
|
1464
|
+
utils$2.inherits(SHA384, SHA512);
|
|
1465
|
+
var _384 = SHA384;
|
|
1466
|
+
|
|
1467
|
+
SHA384.blockSize = 1024;
|
|
1468
|
+
SHA384.outSize = 384;
|
|
1469
|
+
SHA384.hmacStrength = 192;
|
|
1470
|
+
SHA384.padLength = 128;
|
|
1471
|
+
|
|
1472
|
+
SHA384.prototype._digest = function digest(enc) {
|
|
1473
|
+
if (enc === 'hex')
|
|
1474
|
+
return utils$2.toHex32(this.h.slice(0, 12), 'big');
|
|
1475
|
+
else
|
|
1476
|
+
return utils$2.split32(this.h.slice(0, 12), 'big');
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1479
|
+
sha.sha1 = _1;
|
|
1480
|
+
sha.sha224 = _224;
|
|
1481
|
+
sha.sha256 = _256;
|
|
1482
|
+
sha.sha384 = _384;
|
|
1483
|
+
sha.sha512 = _512;
|
|
1484
|
+
|
|
1485
|
+
var ripemd = {};
|
|
1486
|
+
|
|
1487
|
+
var utils$1 = utils$9;
|
|
1488
|
+
var common = common$5;
|
|
1489
|
+
|
|
1490
|
+
var rotl32 = utils$1.rotl32;
|
|
1491
|
+
var sum32 = utils$1.sum32;
|
|
1492
|
+
var sum32_3 = utils$1.sum32_3;
|
|
1493
|
+
var sum32_4 = utils$1.sum32_4;
|
|
1494
|
+
var BlockHash = common.BlockHash;
|
|
1495
|
+
|
|
1496
|
+
function RIPEMD160() {
|
|
1497
|
+
if (!(this instanceof RIPEMD160))
|
|
1498
|
+
return new RIPEMD160();
|
|
1499
|
+
|
|
1500
|
+
BlockHash.call(this);
|
|
1501
|
+
|
|
1502
|
+
this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
|
|
1503
|
+
this.endian = 'little';
|
|
1504
|
+
}
|
|
1505
|
+
utils$1.inherits(RIPEMD160, BlockHash);
|
|
1506
|
+
ripemd.ripemd160 = RIPEMD160;
|
|
1507
|
+
|
|
1508
|
+
RIPEMD160.blockSize = 512;
|
|
1509
|
+
RIPEMD160.outSize = 160;
|
|
1510
|
+
RIPEMD160.hmacStrength = 192;
|
|
1511
|
+
RIPEMD160.padLength = 64;
|
|
1512
|
+
|
|
1513
|
+
RIPEMD160.prototype._update = function update(msg, start) {
|
|
1514
|
+
var A = this.h[0];
|
|
1515
|
+
var B = this.h[1];
|
|
1516
|
+
var C = this.h[2];
|
|
1517
|
+
var D = this.h[3];
|
|
1518
|
+
var E = this.h[4];
|
|
1519
|
+
var Ah = A;
|
|
1520
|
+
var Bh = B;
|
|
1521
|
+
var Ch = C;
|
|
1522
|
+
var Dh = D;
|
|
1523
|
+
var Eh = E;
|
|
1524
|
+
for (var j = 0; j < 80; j++) {
|
|
1525
|
+
var T = sum32(
|
|
1526
|
+
rotl32(
|
|
1527
|
+
sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
|
|
1528
|
+
s[j]),
|
|
1529
|
+
E);
|
|
1530
|
+
A = E;
|
|
1531
|
+
E = D;
|
|
1532
|
+
D = rotl32(C, 10);
|
|
1533
|
+
C = B;
|
|
1534
|
+
B = T;
|
|
1535
|
+
T = sum32(
|
|
1536
|
+
rotl32(
|
|
1537
|
+
sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
|
|
1538
|
+
sh[j]),
|
|
1539
|
+
Eh);
|
|
1540
|
+
Ah = Eh;
|
|
1541
|
+
Eh = Dh;
|
|
1542
|
+
Dh = rotl32(Ch, 10);
|
|
1543
|
+
Ch = Bh;
|
|
1544
|
+
Bh = T;
|
|
1545
|
+
}
|
|
1546
|
+
T = sum32_3(this.h[1], C, Dh);
|
|
1547
|
+
this.h[1] = sum32_3(this.h[2], D, Eh);
|
|
1548
|
+
this.h[2] = sum32_3(this.h[3], E, Ah);
|
|
1549
|
+
this.h[3] = sum32_3(this.h[4], A, Bh);
|
|
1550
|
+
this.h[4] = sum32_3(this.h[0], B, Ch);
|
|
1551
|
+
this.h[0] = T;
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
RIPEMD160.prototype._digest = function digest(enc) {
|
|
1555
|
+
if (enc === 'hex')
|
|
1556
|
+
return utils$1.toHex32(this.h, 'little');
|
|
1557
|
+
else
|
|
1558
|
+
return utils$1.split32(this.h, 'little');
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
function f(j, x, y, z) {
|
|
1562
|
+
if (j <= 15)
|
|
1563
|
+
return x ^ y ^ z;
|
|
1564
|
+
else if (j <= 31)
|
|
1565
|
+
return (x & y) | ((~x) & z);
|
|
1566
|
+
else if (j <= 47)
|
|
1567
|
+
return (x | (~y)) ^ z;
|
|
1568
|
+
else if (j <= 63)
|
|
1569
|
+
return (x & z) | (y & (~z));
|
|
1570
|
+
else
|
|
1571
|
+
return x ^ (y | (~z));
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
function K(j) {
|
|
1575
|
+
if (j <= 15)
|
|
1576
|
+
return 0x00000000;
|
|
1577
|
+
else if (j <= 31)
|
|
1578
|
+
return 0x5a827999;
|
|
1579
|
+
else if (j <= 47)
|
|
1580
|
+
return 0x6ed9eba1;
|
|
1581
|
+
else if (j <= 63)
|
|
1582
|
+
return 0x8f1bbcdc;
|
|
1583
|
+
else
|
|
1584
|
+
return 0xa953fd4e;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
function Kh(j) {
|
|
1588
|
+
if (j <= 15)
|
|
1589
|
+
return 0x50a28be6;
|
|
1590
|
+
else if (j <= 31)
|
|
1591
|
+
return 0x5c4dd124;
|
|
1592
|
+
else if (j <= 47)
|
|
1593
|
+
return 0x6d703ef3;
|
|
1594
|
+
else if (j <= 63)
|
|
1595
|
+
return 0x7a6d76e9;
|
|
1596
|
+
else
|
|
1597
|
+
return 0x00000000;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
var r = [
|
|
1601
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
1602
|
+
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
|
1603
|
+
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
|
|
1604
|
+
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
|
|
1605
|
+
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
|
|
1606
|
+
];
|
|
1607
|
+
|
|
1608
|
+
var rh = [
|
|
1609
|
+
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
|
|
1610
|
+
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
|
|
1611
|
+
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
|
|
1612
|
+
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
|
|
1613
|
+
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
|
|
1614
|
+
];
|
|
1615
|
+
|
|
1616
|
+
var s = [
|
|
1617
|
+
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
|
|
1618
|
+
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
|
|
1619
|
+
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
|
|
1620
|
+
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
|
|
1621
|
+
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
|
|
1622
|
+
];
|
|
1623
|
+
|
|
1624
|
+
var sh = [
|
|
1625
|
+
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
|
|
1626
|
+
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
|
|
1627
|
+
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
|
|
1628
|
+
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
|
|
1629
|
+
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
|
|
1630
|
+
];
|
|
1631
|
+
|
|
1632
|
+
var utils = utils$9;
|
|
1633
|
+
var assert$1 = minimalisticAssert;
|
|
1634
|
+
|
|
1635
|
+
function Hmac(hash, key, enc) {
|
|
1636
|
+
if (!(this instanceof Hmac))
|
|
1637
|
+
return new Hmac(hash, key, enc);
|
|
1638
|
+
this.Hash = hash;
|
|
1639
|
+
this.blockSize = hash.blockSize / 8;
|
|
1640
|
+
this.outSize = hash.outSize / 8;
|
|
1641
|
+
this.inner = null;
|
|
1642
|
+
this.outer = null;
|
|
1643
|
+
|
|
1644
|
+
this._init(utils.toArray(key, enc));
|
|
1645
|
+
}
|
|
1646
|
+
var hmac = Hmac;
|
|
1647
|
+
|
|
1648
|
+
Hmac.prototype._init = function init(key) {
|
|
1649
|
+
// Shorten key, if needed
|
|
1650
|
+
if (key.length > this.blockSize)
|
|
1651
|
+
key = new this.Hash().update(key).digest();
|
|
1652
|
+
assert$1(key.length <= this.blockSize);
|
|
1653
|
+
|
|
1654
|
+
// Add padding to key
|
|
1655
|
+
for (var i = key.length; i < this.blockSize; i++)
|
|
1656
|
+
key.push(0);
|
|
1657
|
+
|
|
1658
|
+
for (i = 0; i < key.length; i++)
|
|
1659
|
+
key[i] ^= 0x36;
|
|
1660
|
+
this.inner = new this.Hash().update(key);
|
|
1661
|
+
|
|
1662
|
+
// 0x36 ^ 0x5c = 0x6a
|
|
1663
|
+
for (i = 0; i < key.length; i++)
|
|
1664
|
+
key[i] ^= 0x6a;
|
|
1665
|
+
this.outer = new this.Hash().update(key);
|
|
1666
|
+
};
|
|
1667
|
+
|
|
1668
|
+
Hmac.prototype.update = function update(msg, enc) {
|
|
1669
|
+
this.inner.update(msg, enc);
|
|
1670
|
+
return this;
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
Hmac.prototype.digest = function digest(enc) {
|
|
1674
|
+
this.outer.update(this.inner.digest());
|
|
1675
|
+
return this.outer.digest(enc);
|
|
1676
|
+
};
|
|
1677
|
+
|
|
1678
|
+
(function (exports) {
|
|
1679
|
+
var hash = exports;
|
|
1680
|
+
|
|
1681
|
+
hash.utils = utils$9;
|
|
1682
|
+
hash.common = common$5;
|
|
1683
|
+
hash.sha = sha;
|
|
1684
|
+
hash.ripemd = ripemd;
|
|
1685
|
+
hash.hmac = hmac;
|
|
1686
|
+
|
|
1687
|
+
// Proxy hash functions to the main object
|
|
1688
|
+
hash.sha1 = hash.sha.sha1;
|
|
1689
|
+
hash.sha256 = hash.sha.sha256;
|
|
1690
|
+
hash.sha224 = hash.sha.sha224;
|
|
1691
|
+
hash.sha384 = hash.sha.sha384;
|
|
1692
|
+
hash.sha512 = hash.sha.sha512;
|
|
1693
|
+
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1694
|
+
}(hash$1));
|
|
1695
|
+
|
|
1696
|
+
var hash = hash$1;
|
|
1697
|
+
|
|
1698
|
+
const version = "sha2/5.5.0";
|
|
1699
|
+
|
|
1700
|
+
new Logger(version);
|
|
1701
|
+
function sha256(data) {
|
|
1702
|
+
return "0x" + (hash.sha256().update(arrayify(data)).digest("hex"));
|
|
1703
|
+
}
|
|
1704
|
+
|
|
29
1705
|
class Struct {
|
|
30
1706
|
constructor(properties) {
|
|
31
1707
|
Object.assign(this, properties);
|
|
@@ -101,7 +1777,7 @@ class PublicKey extends Struct {
|
|
|
101
1777
|
const decoded = bs58.decode(value);
|
|
102
1778
|
|
|
103
1779
|
if (decoded.length != 32) {
|
|
104
|
-
throw new Error(
|
|
1780
|
+
throw new Error("Invalid public key input");
|
|
105
1781
|
}
|
|
106
1782
|
|
|
107
1783
|
this._bn = new BN(decoded);
|
|
@@ -110,7 +1786,7 @@ class PublicKey extends Struct {
|
|
|
110
1786
|
}
|
|
111
1787
|
|
|
112
1788
|
if (this._bn.byteLength() > 32) {
|
|
113
|
-
throw new Error(
|
|
1789
|
+
throw new Error("Invalid public key input");
|
|
114
1790
|
}
|
|
115
1791
|
}
|
|
116
1792
|
}
|
|
@@ -171,32 +1847,36 @@ class PublicKey extends Struct {
|
|
|
171
1847
|
* it permission to write data to the account.
|
|
172
1848
|
*/
|
|
173
1849
|
|
|
1850
|
+
/* eslint-disable require-await */
|
|
1851
|
+
|
|
174
1852
|
|
|
175
1853
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
176
1854
|
const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);
|
|
177
|
-
const hash =
|
|
1855
|
+
const hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
178
1856
|
return new PublicKey(Buffer.from(hash, 'hex'));
|
|
179
1857
|
}
|
|
180
1858
|
/**
|
|
181
1859
|
* Derive a program address from seeds and a program ID.
|
|
182
1860
|
*/
|
|
183
1861
|
|
|
1862
|
+
/* eslint-disable require-await */
|
|
1863
|
+
|
|
184
1864
|
|
|
185
1865
|
static async createProgramAddress(seeds, programId) {
|
|
186
1866
|
let buffer = Buffer.alloc(0);
|
|
187
1867
|
seeds.forEach(function (seed) {
|
|
188
1868
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
189
|
-
throw new TypeError(
|
|
1869
|
+
throw new TypeError("Max seed length exceeded");
|
|
190
1870
|
}
|
|
191
1871
|
|
|
192
1872
|
buffer = Buffer.concat([buffer, toBuffer(seed)]);
|
|
193
1873
|
});
|
|
194
1874
|
buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);
|
|
195
|
-
let hash =
|
|
1875
|
+
let hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
196
1876
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
|
197
1877
|
|
|
198
1878
|
if (is_on_curve(publicKeyBytes)) {
|
|
199
|
-
throw new Error(
|
|
1879
|
+
throw new Error("Invalid seeds, address must fall off the curve");
|
|
200
1880
|
}
|
|
201
1881
|
|
|
202
1882
|
return new PublicKey(publicKeyBytes);
|
|
@@ -230,7 +1910,7 @@ class PublicKey extends Struct {
|
|
|
230
1910
|
return [address, nonce];
|
|
231
1911
|
}
|
|
232
1912
|
|
|
233
|
-
throw new Error(
|
|
1913
|
+
throw new Error("Unable to find a viable program address nonce");
|
|
234
1914
|
}
|
|
235
1915
|
/**
|
|
236
1916
|
* Check that a pubkey is on the ed25519 curve.
|
|
@@ -442,6 +2122,36 @@ function encodeLength(bytes, len) {
|
|
|
442
2122
|
}
|
|
443
2123
|
}
|
|
444
2124
|
|
|
2125
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2126
|
+
/**
|
|
2127
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
2128
|
+
*/
|
|
2129
|
+
|
|
2130
|
+
function guardedShift(byteArray) {
|
|
2131
|
+
if (byteArray.length === 0) {
|
|
2132
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
return byteArray.shift();
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
2139
|
+
* the array.
|
|
2140
|
+
*/
|
|
2141
|
+
|
|
2142
|
+
function guardedSplice(byteArray, ...args) {
|
|
2143
|
+
var _args$;
|
|
2144
|
+
|
|
2145
|
+
const [start] = args;
|
|
2146
|
+
|
|
2147
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
2148
|
+
? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
|
|
2149
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
return byteArray.splice(...args);
|
|
2153
|
+
}
|
|
2154
|
+
|
|
445
2155
|
/**
|
|
446
2156
|
* The message header, identifying signed and read-only account
|
|
447
2157
|
*/
|
|
@@ -545,32 +2255,28 @@ class Message {
|
|
|
545
2255
|
static from(buffer) {
|
|
546
2256
|
// Slice up wire data
|
|
547
2257
|
let byteArray = [...buffer];
|
|
548
|
-
const numRequiredSignatures = byteArray
|
|
549
|
-
const numReadonlySignedAccounts = byteArray
|
|
550
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
2258
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
2259
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
2260
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
551
2261
|
const accountCount = decodeLength(byteArray);
|
|
552
2262
|
let accountKeys = [];
|
|
553
2263
|
|
|
554
2264
|
for (let i = 0; i < accountCount; i++) {
|
|
555
|
-
const account = byteArray
|
|
556
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2265
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
557
2266
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
558
2267
|
}
|
|
559
2268
|
|
|
560
|
-
const recentBlockhash = byteArray
|
|
561
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2269
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
562
2270
|
const instructionCount = decodeLength(byteArray);
|
|
563
2271
|
let instructions = [];
|
|
564
2272
|
|
|
565
2273
|
for (let i = 0; i < instructionCount; i++) {
|
|
566
|
-
const programIdIndex = byteArray
|
|
2274
|
+
const programIdIndex = guardedShift(byteArray);
|
|
567
2275
|
const accountCount = decodeLength(byteArray);
|
|
568
|
-
const accounts = byteArray
|
|
569
|
-
byteArray = byteArray.slice(accountCount);
|
|
2276
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
570
2277
|
const dataLength = decodeLength(byteArray);
|
|
571
|
-
const dataSlice = byteArray
|
|
2278
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
572
2279
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
573
|
-
byteArray = byteArray.slice(dataLength);
|
|
574
2280
|
instructions.push({
|
|
575
2281
|
programIdIndex,
|
|
576
2282
|
accounts,
|
|
@@ -599,6 +2305,10 @@ function assert (condition, message) {
|
|
|
599
2305
|
}
|
|
600
2306
|
}
|
|
601
2307
|
|
|
2308
|
+
/**
|
|
2309
|
+
* Transaction signature as base-58 encoded string
|
|
2310
|
+
*/
|
|
2311
|
+
|
|
602
2312
|
/**
|
|
603
2313
|
* Default (empty) signature
|
|
604
2314
|
*
|
|
@@ -756,7 +2466,7 @@ class Transaction {
|
|
|
756
2466
|
|
|
757
2467
|
for (let i = 0; i < this.instructions.length; i++) {
|
|
758
2468
|
if (this.instructions[i].programId === undefined) {
|
|
759
|
-
throw new Error(
|
|
2469
|
+
throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
|
|
760
2470
|
}
|
|
761
2471
|
}
|
|
762
2472
|
|
|
@@ -831,7 +2541,7 @@ class Transaction {
|
|
|
831
2541
|
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.');
|
|
832
2542
|
}
|
|
833
2543
|
} else {
|
|
834
|
-
throw new Error(
|
|
2544
|
+
throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
|
|
835
2545
|
}
|
|
836
2546
|
}
|
|
837
2547
|
|
|
@@ -1066,7 +2776,7 @@ class Transaction {
|
|
|
1066
2776
|
const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
|
|
1067
2777
|
|
|
1068
2778
|
if (index < 0) {
|
|
1069
|
-
throw new Error(
|
|
2779
|
+
throw new Error("unknown signer: ".concat(pubkey.toString()));
|
|
1070
2780
|
}
|
|
1071
2781
|
|
|
1072
2782
|
this.signatures[index].signature = Buffer.from(signature);
|
|
@@ -1142,12 +2852,12 @@ class Transaction {
|
|
|
1142
2852
|
signature
|
|
1143
2853
|
}, index) => {
|
|
1144
2854
|
if (signature !== null) {
|
|
1145
|
-
assert(signature.length === 64,
|
|
2855
|
+
assert(signature.length === 64, "signature has invalid length");
|
|
1146
2856
|
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
1147
2857
|
}
|
|
1148
2858
|
});
|
|
1149
2859
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
1150
|
-
assert(wireTransaction.length <= PACKET_DATA_SIZE,
|
|
2860
|
+
assert(wireTransaction.length <= PACKET_DATA_SIZE, "Transaction too large: ".concat(wireTransaction.length, " > ").concat(PACKET_DATA_SIZE));
|
|
1151
2861
|
return wireTransaction;
|
|
1152
2862
|
}
|
|
1153
2863
|
/**
|
|
@@ -1192,8 +2902,7 @@ class Transaction {
|
|
|
1192
2902
|
let signatures = [];
|
|
1193
2903
|
|
|
1194
2904
|
for (let i = 0; i < signatureCount; i++) {
|
|
1195
|
-
const signature = byteArray
|
|
1196
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
2905
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
1197
2906
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
1198
2907
|
}
|
|
1199
2908
|
|
|
@@ -1266,7 +2975,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
1266
2975
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
1267
2976
|
|
|
1268
2977
|
if (status.err) {
|
|
1269
|
-
throw new Error(
|
|
2978
|
+
throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
|
|
1270
2979
|
}
|
|
1271
2980
|
|
|
1272
2981
|
return signature;
|
|
@@ -1309,7 +3018,7 @@ function decodeData(type, buffer) {
|
|
|
1309
3018
|
}
|
|
1310
3019
|
|
|
1311
3020
|
if (data.instruction !== type.index) {
|
|
1312
|
-
throw new Error(
|
|
3021
|
+
throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
|
|
1313
3022
|
}
|
|
1314
3023
|
|
|
1315
3024
|
return data;
|
|
@@ -1649,7 +3358,7 @@ class SystemInstruction {
|
|
|
1649
3358
|
|
|
1650
3359
|
static checkKeyLength(keys, expectedLength) {
|
|
1651
3360
|
if (keys.length < expectedLength) {
|
|
1652
|
-
throw new Error(
|
|
3361
|
+
throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
|
|
1653
3362
|
}
|
|
1654
3363
|
}
|
|
1655
3364
|
|
|
@@ -2111,7 +3820,8 @@ class Loader {
|
|
|
2111
3820
|
* Can be used to calculate transaction fees
|
|
2112
3821
|
*/
|
|
2113
3822
|
static getMinNumSignatures(dataLength) {
|
|
2114
|
-
return 2 * (
|
|
3823
|
+
return 2 * ( // Every transaction requires two signatures (payer + program)
|
|
3824
|
+
Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
|
|
2115
3825
|
1) // Add one for Finalize transaction
|
|
2116
3826
|
;
|
|
2117
3827
|
}
|
|
@@ -2729,7 +4439,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
2729
4439
|
break;
|
|
2730
4440
|
}
|
|
2731
4441
|
|
|
2732
|
-
console.log(
|
|
4442
|
+
console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
|
|
2733
4443
|
await sleep(waitTime);
|
|
2734
4444
|
waitTime *= 2;
|
|
2735
4445
|
}
|
|
@@ -2739,7 +4449,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
2739
4449
|
if (res.ok) {
|
|
2740
4450
|
callback(null, text);
|
|
2741
4451
|
} else {
|
|
2742
|
-
callback(new Error(
|
|
4452
|
+
callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
|
|
2743
4453
|
}
|
|
2744
4454
|
} catch (err) {
|
|
2745
4455
|
if (err instanceof Error) callback(err);
|
|
@@ -3825,7 +5535,7 @@ class Connection {
|
|
|
3825
5535
|
const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
3826
5536
|
|
|
3827
5537
|
if ('error' in res) {
|
|
3828
|
-
throw new Error(
|
|
5538
|
+
throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
|
|
3829
5539
|
}
|
|
3830
5540
|
|
|
3831
5541
|
return res.result;
|
|
@@ -3961,7 +5671,7 @@ class Connection {
|
|
|
3961
5671
|
|
|
3962
5672
|
if (response === null) {
|
|
3963
5673
|
const duration = (Date.now() - start) / 1000;
|
|
3964
|
-
throw new Error(
|
|
5674
|
+
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."));
|
|
3965
5675
|
}
|
|
3966
5676
|
|
|
3967
5677
|
return response;
|
|
@@ -4740,7 +6450,7 @@ class Connection {
|
|
|
4740
6450
|
await sleep(MS_PER_SLOT / 2);
|
|
4741
6451
|
}
|
|
4742
6452
|
|
|
4743
|
-
throw new Error(
|
|
6453
|
+
throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
|
|
4744
6454
|
} finally {
|
|
4745
6455
|
this._pollingBlockhash = false;
|
|
4746
6456
|
}
|
|
@@ -4997,7 +6707,7 @@ class Connection {
|
|
|
4997
6707
|
}
|
|
4998
6708
|
|
|
4999
6709
|
if (err instanceof Error) {
|
|
5000
|
-
console.error(
|
|
6710
|
+
console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
|
|
5001
6711
|
}
|
|
5002
6712
|
}
|
|
5003
6713
|
}
|
|
@@ -5017,7 +6727,7 @@ class Connection {
|
|
|
5017
6727
|
await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
|
|
5018
6728
|
} catch (err) {
|
|
5019
6729
|
if (err instanceof Error) {
|
|
5020
|
-
console.error(
|
|
6730
|
+
console.error("".concat(rpcMethod, " error:"), err.message);
|
|
5021
6731
|
}
|
|
5022
6732
|
}
|
|
5023
6733
|
}
|
|
@@ -5182,7 +6892,7 @@ class Connection {
|
|
|
5182
6892
|
|
|
5183
6893
|
this._updateSubscriptions();
|
|
5184
6894
|
} else {
|
|
5185
|
-
throw new Error(
|
|
6895
|
+
throw new Error("Unknown account change id: ".concat(id));
|
|
5186
6896
|
}
|
|
5187
6897
|
}
|
|
5188
6898
|
/**
|
|
@@ -5248,7 +6958,7 @@ class Connection {
|
|
|
5248
6958
|
|
|
5249
6959
|
this._updateSubscriptions();
|
|
5250
6960
|
} else {
|
|
5251
|
-
throw new Error(
|
|
6961
|
+
throw new Error("Unknown program account change id: ".concat(id));
|
|
5252
6962
|
}
|
|
5253
6963
|
}
|
|
5254
6964
|
/**
|
|
@@ -5278,7 +6988,7 @@ class Connection {
|
|
|
5278
6988
|
|
|
5279
6989
|
async removeOnLogsListener(id) {
|
|
5280
6990
|
if (!this._logsSubscriptions[id]) {
|
|
5281
|
-
throw new Error(
|
|
6991
|
+
throw new Error("Unknown logs id: ".concat(id));
|
|
5282
6992
|
}
|
|
5283
6993
|
|
|
5284
6994
|
const subInfo = this._logsSubscriptions[id];
|
|
@@ -5354,7 +7064,7 @@ class Connection {
|
|
|
5354
7064
|
|
|
5355
7065
|
this._updateSubscriptions();
|
|
5356
7066
|
} else {
|
|
5357
|
-
throw new Error(
|
|
7067
|
+
throw new Error("Unknown slot change id: ".concat(id));
|
|
5358
7068
|
}
|
|
5359
7069
|
}
|
|
5360
7070
|
/**
|
|
@@ -5407,7 +7117,7 @@ class Connection {
|
|
|
5407
7117
|
|
|
5408
7118
|
this._updateSubscriptions();
|
|
5409
7119
|
} else {
|
|
5410
|
-
throw new Error(
|
|
7120
|
+
throw new Error("Unknown slot update id: ".concat(id));
|
|
5411
7121
|
}
|
|
5412
7122
|
}
|
|
5413
7123
|
|
|
@@ -5548,7 +7258,7 @@ class Connection {
|
|
|
5548
7258
|
|
|
5549
7259
|
this._updateSubscriptions();
|
|
5550
7260
|
} else {
|
|
5551
|
-
throw new Error(
|
|
7261
|
+
throw new Error("Unknown signature result id: ".concat(id));
|
|
5552
7262
|
}
|
|
5553
7263
|
}
|
|
5554
7264
|
/**
|
|
@@ -5600,7 +7310,7 @@ class Connection {
|
|
|
5600
7310
|
|
|
5601
7311
|
this._updateSubscriptions();
|
|
5602
7312
|
} else {
|
|
5603
|
-
throw new Error(
|
|
7313
|
+
throw new Error("Unknown root change id: ".concat(id));
|
|
5604
7314
|
}
|
|
5605
7315
|
}
|
|
5606
7316
|
|
|
@@ -5725,8 +7435,8 @@ class Ed25519Program {
|
|
|
5725
7435
|
signature,
|
|
5726
7436
|
instructionIndex
|
|
5727
7437
|
} = params;
|
|
5728
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES$1,
|
|
5729
|
-
assert(signature.length === SIGNATURE_BYTES,
|
|
7438
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES$1, "Public Key must be ".concat(PUBLIC_KEY_BYTES$1, " bytes but received ").concat(publicKey.length, " bytes"));
|
|
7439
|
+
assert(signature.length === SIGNATURE_BYTES, "Signature must be ".concat(SIGNATURE_BYTES, " bytes but received ").concat(signature.length, " bytes"));
|
|
5730
7440
|
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
5731
7441
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
5732
7442
|
const messageDataOffset = signatureOffset + signature.length;
|
|
@@ -5764,7 +7474,7 @@ class Ed25519Program {
|
|
|
5764
7474
|
message,
|
|
5765
7475
|
instructionIndex
|
|
5766
7476
|
} = params;
|
|
5767
|
-
assert(privateKey.length === PRIVATE_KEY_BYTES$1,
|
|
7477
|
+
assert(privateKey.length === PRIVATE_KEY_BYTES$1, "Private key must be ".concat(PRIVATE_KEY_BYTES$1, " bytes but received ").concat(privateKey.length, " bytes"));
|
|
5768
7478
|
|
|
5769
7479
|
try {
|
|
5770
7480
|
const keypair = Keypair.fromSecretKey(privateKey);
|
|
@@ -5777,7 +7487,7 @@ class Ed25519Program {
|
|
|
5777
7487
|
instructionIndex
|
|
5778
7488
|
});
|
|
5779
7489
|
} catch (error) {
|
|
5780
|
-
throw new Error(
|
|
7490
|
+
throw new Error("Error creating instruction; ".concat(error));
|
|
5781
7491
|
}
|
|
5782
7492
|
}
|
|
5783
7493
|
|
|
@@ -6063,7 +7773,7 @@ class StakeInstruction {
|
|
|
6063
7773
|
|
|
6064
7774
|
static checkKeyLength(keys, expectedLength) {
|
|
6065
7775
|
if (keys.length < expectedLength) {
|
|
6066
|
-
throw new Error(
|
|
7776
|
+
throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
|
|
6067
7777
|
}
|
|
6068
7778
|
}
|
|
6069
7779
|
|
|
@@ -6571,12 +8281,12 @@ class Secp256k1Program {
|
|
|
6571
8281
|
* @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
|
|
6572
8282
|
*/
|
|
6573
8283
|
static publicKeyToEthAddress(publicKey) {
|
|
6574
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES,
|
|
8284
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES, "Public key must be ".concat(PUBLIC_KEY_BYTES, " bytes but received ").concat(publicKey.length, " bytes"));
|
|
6575
8285
|
|
|
6576
8286
|
try {
|
|
6577
8287
|
return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
6578
8288
|
} catch (error) {
|
|
6579
|
-
throw new Error(
|
|
8289
|
+
throw new Error("Error constructing Ethereum address: ".concat(error));
|
|
6580
8290
|
}
|
|
6581
8291
|
}
|
|
6582
8292
|
/**
|
|
@@ -6627,7 +8337,7 @@ class Secp256k1Program {
|
|
|
6627
8337
|
ethAddress = rawAddress;
|
|
6628
8338
|
}
|
|
6629
8339
|
|
|
6630
|
-
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES,
|
|
8340
|
+
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
|
|
6631
8341
|
const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
|
|
6632
8342
|
const ethAddressOffset = dataStart;
|
|
6633
8343
|
const signatureOffset = dataStart + ethAddress.length;
|
|
@@ -6666,7 +8376,7 @@ class Secp256k1Program {
|
|
|
6666
8376
|
message,
|
|
6667
8377
|
instructionIndex
|
|
6668
8378
|
} = params;
|
|
6669
|
-
assert(pkey.length === PRIVATE_KEY_BYTES,
|
|
8379
|
+
assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
|
|
6670
8380
|
|
|
6671
8381
|
try {
|
|
6672
8382
|
const privateKey = toBuffer(pkey);
|
|
@@ -6685,7 +8395,7 @@ class Secp256k1Program {
|
|
|
6685
8395
|
instructionIndex
|
|
6686
8396
|
});
|
|
6687
8397
|
} catch (error) {
|
|
6688
|
-
throw new Error(
|
|
8398
|
+
throw new Error("Error creating instruction; ".concat(error));
|
|
6689
8399
|
}
|
|
6690
8400
|
}
|
|
6691
8401
|
|
|
@@ -6748,10 +8458,8 @@ class ValidatorInfo {
|
|
|
6748
8458
|
const configKeys = [];
|
|
6749
8459
|
|
|
6750
8460
|
for (let i = 0; i < 2; i++) {
|
|
6751
|
-
const publicKey = new PublicKey(byteArray
|
|
6752
|
-
|
|
6753
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
6754
|
-
byteArray = byteArray.slice(1);
|
|
8461
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
|
|
8462
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
6755
8463
|
configKeys.push({
|
|
6756
8464
|
publicKey,
|
|
6757
8465
|
isSigner
|
|
@@ -6762,7 +8470,7 @@ class ValidatorInfo {
|
|
|
6762
8470
|
if (configKeys[1].isSigner) {
|
|
6763
8471
|
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
6764
8472
|
const info = JSON.parse(rawInfo);
|
|
6765
|
-
assert$
|
|
8473
|
+
assert$7(info, InfoString);
|
|
6766
8474
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|
|
6767
8475
|
}
|
|
6768
8476
|
}
|
|
@@ -6873,7 +8581,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
|
|
|
6873
8581
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
6874
8582
|
|
|
6875
8583
|
if (status.err) {
|
|
6876
|
-
throw new Error(
|
|
8584
|
+
throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
|
|
6877
8585
|
}
|
|
6878
8586
|
|
|
6879
8587
|
return signature;
|
|
@@ -6905,7 +8613,7 @@ function clusterApiUrl(cluster, tls) {
|
|
|
6905
8613
|
const url = endpoint[key][cluster];
|
|
6906
8614
|
|
|
6907
8615
|
if (!url) {
|
|
6908
|
-
throw new Error(
|
|
8616
|
+
throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
|
|
6909
8617
|
}
|
|
6910
8618
|
|
|
6911
8619
|
return url;
|