@leofcoin/chain 1.5.63 → 1.5.64
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/exports/browser/{_polyfill-node.child_process-JsWeMPst.js → _polyfill-node.child_process-rc1HO9Xs.js} +46 -47
- package/exports/browser/{_polyfill-node.url-0PWARF9f.js → _polyfill-node.url-1q06MepH.js} +1 -1
- package/exports/browser/{browser-dc41c03f-8RoAu8QY.js → browser-1GyRaZxg-C9SpI6hG.js} +2 -2
- package/exports/browser/chain.js +98 -61
- package/exports/browser/{client-f193279c-xoTAp1Bg.js → client-UOCjJBGl-pbv-pTHd.js} +18 -14
- package/exports/browser/{index-fd97ecae-DMIypRPM.js → index-K4Kwju30-vS3fNpxy.js} +2 -2
- package/exports/browser/{index-81687e93-rKzKdyEa.js → index-ub31QSed-EMPr2oeb.js} +2 -2
- package/exports/browser/{messages-cccb78db-bQaa1gST.js → messages-guyZfse6-JeAlT5Nb.js} +2 -2
- package/exports/browser/{node-browser-cqEqYlW7.js → node-browser-0Ly80awM.js} +625 -609
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +1 -4
- package/exports/browser/workers/machine-worker.js +57 -35
- package/exports/browser/workers/{worker-Suy0gj0S.js → worker-hbo9s9AT.js} +47 -59
- package/exports/chain.d.ts +1 -0
- package/exports/chain.js +63 -51
- package/exports/workers/block-worker.js +1 -4
- package/exports/workers/machine-worker.js +57 -35
- package/exports/workers/{worker-Suy0gj0S.js → worker-hbo9s9AT.js} +47 -59
- package/package.json +4 -3
- /package/exports/browser/{browser-2c73e2ef-AyxSBUXj.js → browser-AyxSBUXj-AyxSBUXj.js} +0 -0
- /package/exports/browser/{qr-scanner-worker.min-c002e984-RaSiJc_R.js → qr-scanner-worker.min-RaSiJc_R-RaSiJc_R.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ContractMessage, T as TransactionMessage, B as BlockMessage, a as BWMessage, b as BWRequestMessage, V as ValidatorMessage } from './_polyfill-node.child_process-
|
|
1
|
+
import { C as ContractMessage, T as TransactionMessage, B as BlockMessage, a as BWMessage, b as BWRequestMessage, V as ValidatorMessage } from './_polyfill-node.child_process-rc1HO9Xs.js';
|
|
2
2
|
|
|
3
3
|
var nodeConfig = async (config = {
|
|
4
4
|
network: 'leofcoin:peach',
|
|
@@ -94,12 +94,30 @@ class KeyValue {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (!globalThis.DEBUG) {
|
|
97
|
-
|
|
97
|
+
let DEBUG = [];
|
|
98
|
+
if (globalThis.localStorage) {
|
|
99
|
+
DEBUG = globalThis.localStorage.getItem('DEBUG');
|
|
100
|
+
globalThis.DEBUG = DEBUG ? DEBUG.split(',') : [DEBUG];
|
|
101
|
+
}
|
|
98
102
|
}
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
if (globalThis.DEBUG
|
|
102
|
-
|
|
104
|
+
const debug$1 = (target, text) => {
|
|
105
|
+
if (!globalThis.DEBUG && globalThis.DEBUG.length === 0) return;
|
|
106
|
+
if (
|
|
107
|
+
globalThis.DEBUG === 'true' ||
|
|
108
|
+
globalThis.DEBUG === true ||
|
|
109
|
+
globalThis.DEBUG?.indexOf(target) !== -1 ||
|
|
110
|
+
globalThis.DEBUG?.indexOf('*') !== -1
|
|
111
|
+
)
|
|
112
|
+
if (text) console.log('\x1b[34m\x1b[1m%s', `${target}: ${text}`, '\x1b[0m');
|
|
113
|
+
else console.log('\x1b[34m\x1b[1m%s', `${target}`, '\x1b[0m');
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (!globalThis.debug) {
|
|
117
|
+
globalThis.debug = debug$1;
|
|
118
|
+
|
|
119
|
+
globalThis.createDebugger = (target) => (text) => debug$1(target, text);
|
|
120
|
+
}
|
|
103
121
|
|
|
104
122
|
class LittlePubSub {
|
|
105
123
|
subscribers = {};
|
|
@@ -762,10 +780,7 @@ function getAugmentedNamespace(n) {
|
|
|
762
780
|
if (typeof f == "function") {
|
|
763
781
|
var a = function a () {
|
|
764
782
|
if (this instanceof a) {
|
|
765
|
-
|
|
766
|
-
args.push.apply(args, arguments);
|
|
767
|
-
var Ctor = Function.bind.apply(f, args);
|
|
768
|
-
return new Ctor();
|
|
783
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
769
784
|
}
|
|
770
785
|
return f.apply(this, arguments);
|
|
771
786
|
};
|
|
@@ -12842,7 +12857,7 @@ const nothingFoundError = (hash) => {
|
|
|
12842
12857
|
return new Error(`nothing found for ${hash}`)
|
|
12843
12858
|
};
|
|
12844
12859
|
|
|
12845
|
-
const isBrowser = globalThis.
|
|
12860
|
+
const isBrowser = globalThis.process?.versions?.node ? false : true;
|
|
12846
12861
|
let LeofcoinStorage$1 = class LeofcoinStorage {
|
|
12847
12862
|
name;
|
|
12848
12863
|
root;
|
|
@@ -13091,512 +13106,175 @@ var index$1 = {
|
|
|
13091
13106
|
}
|
|
13092
13107
|
};
|
|
13093
13108
|
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13109
|
+
var elliptic$2 = {};
|
|
13110
|
+
|
|
13111
|
+
var name = "elliptic";
|
|
13112
|
+
var version$1 = "6.5.4";
|
|
13113
|
+
var description = "EC cryptography";
|
|
13114
|
+
var main = "lib/elliptic.js";
|
|
13115
|
+
var files = [
|
|
13116
|
+
"lib"
|
|
13117
|
+
];
|
|
13118
|
+
var scripts = {
|
|
13119
|
+
lint: "eslint lib test",
|
|
13120
|
+
"lint:fix": "npm run lint -- --fix",
|
|
13121
|
+
unit: "istanbul test _mocha --reporter=spec test/index.js",
|
|
13122
|
+
test: "npm run lint && npm run unit",
|
|
13123
|
+
version: "grunt dist && git add dist/"
|
|
13124
|
+
};
|
|
13125
|
+
var repository = {
|
|
13126
|
+
type: "git",
|
|
13127
|
+
url: "git@github.com:indutny/elliptic"
|
|
13128
|
+
};
|
|
13129
|
+
var keywords = [
|
|
13130
|
+
"EC",
|
|
13131
|
+
"Elliptic",
|
|
13132
|
+
"curve",
|
|
13133
|
+
"Cryptography"
|
|
13134
|
+
];
|
|
13135
|
+
var author = "Fedor Indutny <fedor@indutny.com>";
|
|
13136
|
+
var license = "MIT";
|
|
13137
|
+
var bugs = {
|
|
13138
|
+
url: "https://github.com/indutny/elliptic/issues"
|
|
13139
|
+
};
|
|
13140
|
+
var homepage = "https://github.com/indutny/elliptic";
|
|
13141
|
+
var devDependencies = {
|
|
13142
|
+
brfs: "^2.0.2",
|
|
13143
|
+
coveralls: "^3.1.0",
|
|
13144
|
+
eslint: "^7.6.0",
|
|
13145
|
+
grunt: "^1.2.1",
|
|
13146
|
+
"grunt-browserify": "^5.3.0",
|
|
13147
|
+
"grunt-cli": "^1.3.2",
|
|
13148
|
+
"grunt-contrib-connect": "^3.0.0",
|
|
13149
|
+
"grunt-contrib-copy": "^1.0.0",
|
|
13150
|
+
"grunt-contrib-uglify": "^5.0.0",
|
|
13151
|
+
"grunt-mocha-istanbul": "^5.0.2",
|
|
13152
|
+
"grunt-saucelabs": "^9.0.1",
|
|
13153
|
+
istanbul: "^0.4.5",
|
|
13154
|
+
mocha: "^8.0.1"
|
|
13155
|
+
};
|
|
13156
|
+
var dependencies = {
|
|
13157
|
+
"bn.js": "^4.11.9",
|
|
13158
|
+
brorand: "^1.1.0",
|
|
13159
|
+
"hash.js": "^1.0.0",
|
|
13160
|
+
"hmac-drbg": "^1.0.1",
|
|
13161
|
+
inherits: "^2.0.4",
|
|
13162
|
+
"minimalistic-assert": "^1.0.1",
|
|
13163
|
+
"minimalistic-crypto-utils": "^1.0.1"
|
|
13164
|
+
};
|
|
13165
|
+
var require$$0 = {
|
|
13166
|
+
name: name,
|
|
13167
|
+
version: version$1,
|
|
13168
|
+
description: description,
|
|
13169
|
+
main: main,
|
|
13170
|
+
files: files,
|
|
13171
|
+
scripts: scripts,
|
|
13172
|
+
repository: repository,
|
|
13173
|
+
keywords: keywords,
|
|
13174
|
+
author: author,
|
|
13175
|
+
license: license,
|
|
13176
|
+
bugs: bugs,
|
|
13177
|
+
homepage: homepage,
|
|
13178
|
+
devDependencies: devDependencies,
|
|
13179
|
+
dependencies: dependencies
|
|
13108
13180
|
};
|
|
13109
13181
|
|
|
13110
|
-
|
|
13111
|
-
if (!cond) throw new Error(msg)
|
|
13112
|
-
}
|
|
13182
|
+
var utils$o = {};
|
|
13113
13183
|
|
|
13114
|
-
|
|
13115
|
-
assert$g(value instanceof Uint8Array, `Expected ${name} to be an Uint8Array`);
|
|
13184
|
+
var bn = {exports: {}};
|
|
13116
13185
|
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
const numbers = length.join(', ');
|
|
13120
|
-
const msg = `Expected ${name} to be an Uint8Array with length [${numbers}]`;
|
|
13121
|
-
assert$g(length.includes(value.length), msg);
|
|
13122
|
-
} else {
|
|
13123
|
-
const msg = `Expected ${name} to be an Uint8Array with length ${length}`;
|
|
13124
|
-
assert$g(value.length === length, msg);
|
|
13125
|
-
}
|
|
13126
|
-
}
|
|
13127
|
-
}
|
|
13186
|
+
(function (module) {
|
|
13187
|
+
(function (module, exports) {
|
|
13128
13188
|
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13189
|
+
// Utils
|
|
13190
|
+
function assert (val, msg) {
|
|
13191
|
+
if (!val) throw new Error(msg || 'Assertion failed');
|
|
13192
|
+
}
|
|
13132
13193
|
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
}
|
|
13194
|
+
// Could use `inherits` module, but don't want to move from single file
|
|
13195
|
+
// architecture yet.
|
|
13196
|
+
function inherits (ctor, superCtor) {
|
|
13197
|
+
ctor.super_ = superCtor;
|
|
13198
|
+
var TempCtor = function () {};
|
|
13199
|
+
TempCtor.prototype = superCtor.prototype;
|
|
13200
|
+
ctor.prototype = new TempCtor();
|
|
13201
|
+
ctor.prototype.constructor = ctor;
|
|
13202
|
+
}
|
|
13138
13203
|
|
|
13139
|
-
|
|
13140
|
-
return Object.prototype.toString.call(value).slice(8, -1)
|
|
13141
|
-
}
|
|
13204
|
+
// BN
|
|
13142
13205
|
|
|
13143
|
-
|
|
13144
|
-
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
seed === null || seed instanceof Uint8Array,
|
|
13148
|
-
'Expected seed to be an Uint8Array or null'
|
|
13149
|
-
);
|
|
13150
|
-
if (seed !== null) isUint8Array('seed', seed, 32);
|
|
13206
|
+
function BN (number, base, endian) {
|
|
13207
|
+
if (BN.isBN(number)) {
|
|
13208
|
+
return number;
|
|
13209
|
+
}
|
|
13151
13210
|
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
}
|
|
13156
|
-
},
|
|
13211
|
+
this.negative = 0;
|
|
13212
|
+
this.words = null;
|
|
13213
|
+
this.length = 0;
|
|
13157
13214
|
|
|
13158
|
-
|
|
13159
|
-
|
|
13215
|
+
// Reduction context
|
|
13216
|
+
this.red = null;
|
|
13160
13217
|
|
|
13161
|
-
|
|
13162
|
-
|
|
13218
|
+
if (number !== null) {
|
|
13219
|
+
if (base === 'le' || base === 'be') {
|
|
13220
|
+
endian = base;
|
|
13221
|
+
base = 10;
|
|
13222
|
+
}
|
|
13163
13223
|
|
|
13164
|
-
|
|
13165
|
-
|
|
13224
|
+
this._init(number || 0, base || 10, endian || 'be');
|
|
13225
|
+
}
|
|
13226
|
+
}
|
|
13227
|
+
if (typeof module === 'object') {
|
|
13228
|
+
module.exports = BN;
|
|
13229
|
+
} else {
|
|
13230
|
+
exports.BN = BN;
|
|
13231
|
+
}
|
|
13166
13232
|
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
return seckey
|
|
13170
|
-
case 1:
|
|
13171
|
-
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
13172
|
-
}
|
|
13173
|
-
},
|
|
13233
|
+
BN.BN = BN;
|
|
13234
|
+
BN.wordSize = 26;
|
|
13174
13235
|
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13236
|
+
var Buffer;
|
|
13237
|
+
try {
|
|
13238
|
+
if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
|
|
13239
|
+
Buffer = window.Buffer;
|
|
13240
|
+
} else {
|
|
13241
|
+
Buffer = require$$3.Buffer;
|
|
13242
|
+
}
|
|
13243
|
+
} catch (e) {
|
|
13244
|
+
}
|
|
13178
13245
|
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
throw new Error(errors.TWEAK_ADD)
|
|
13184
|
-
}
|
|
13185
|
-
},
|
|
13246
|
+
BN.isBN = function isBN (num) {
|
|
13247
|
+
if (num instanceof BN) {
|
|
13248
|
+
return true;
|
|
13249
|
+
}
|
|
13186
13250
|
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13251
|
+
return num !== null && typeof num === 'object' &&
|
|
13252
|
+
num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
|
|
13253
|
+
};
|
|
13190
13254
|
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
throw new Error(errors.TWEAK_MUL)
|
|
13196
|
-
}
|
|
13197
|
-
},
|
|
13255
|
+
BN.max = function max (left, right) {
|
|
13256
|
+
if (left.cmp(right) > 0) return left;
|
|
13257
|
+
return right;
|
|
13258
|
+
};
|
|
13198
13259
|
|
|
13199
|
-
|
|
13200
|
-
|
|
13260
|
+
BN.min = function min (left, right) {
|
|
13261
|
+
if (left.cmp(right) < 0) return left;
|
|
13262
|
+
return right;
|
|
13263
|
+
};
|
|
13201
13264
|
|
|
13202
|
-
|
|
13203
|
-
|
|
13265
|
+
BN.prototype._init = function init (number, base, endian) {
|
|
13266
|
+
if (typeof number === 'number') {
|
|
13267
|
+
return this._initNumber(number, base, endian);
|
|
13268
|
+
}
|
|
13204
13269
|
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
13270
|
+
if (typeof number === 'object') {
|
|
13271
|
+
return this._initArray(number, base, endian);
|
|
13272
|
+
}
|
|
13209
13273
|
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
throw new Error(errors.SECKEY_INVALID)
|
|
13215
|
-
case 2:
|
|
13216
|
-
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
13217
|
-
}
|
|
13218
|
-
},
|
|
13219
|
-
|
|
13220
|
-
publicKeyConvert (pubkey, compressed = true, output) {
|
|
13221
|
-
isUint8Array('public key', pubkey, [33, 65]);
|
|
13222
|
-
isCompressed(compressed);
|
|
13223
|
-
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
13224
|
-
|
|
13225
|
-
switch (secp256k1.publicKeyConvert(output, pubkey)) {
|
|
13226
|
-
case 0:
|
|
13227
|
-
return output
|
|
13228
|
-
case 1:
|
|
13229
|
-
throw new Error(errors.PUBKEY_PARSE)
|
|
13230
|
-
case 2:
|
|
13231
|
-
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
13232
|
-
}
|
|
13233
|
-
},
|
|
13234
|
-
|
|
13235
|
-
publicKeyNegate (pubkey, compressed = true, output) {
|
|
13236
|
-
isUint8Array('public key', pubkey, [33, 65]);
|
|
13237
|
-
isCompressed(compressed);
|
|
13238
|
-
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
13239
|
-
|
|
13240
|
-
switch (secp256k1.publicKeyNegate(output, pubkey)) {
|
|
13241
|
-
case 0:
|
|
13242
|
-
return output
|
|
13243
|
-
case 1:
|
|
13244
|
-
throw new Error(errors.PUBKEY_PARSE)
|
|
13245
|
-
case 2:
|
|
13246
|
-
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
13247
|
-
case 3:
|
|
13248
|
-
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
13249
|
-
}
|
|
13250
|
-
},
|
|
13251
|
-
|
|
13252
|
-
publicKeyCombine (pubkeys, compressed = true, output) {
|
|
13253
|
-
assert$g(Array.isArray(pubkeys), 'Expected public keys to be an Array');
|
|
13254
|
-
assert$g(pubkeys.length > 0, 'Expected public keys array will have more than zero items');
|
|
13255
|
-
for (const pubkey of pubkeys) {
|
|
13256
|
-
isUint8Array('public key', pubkey, [33, 65]);
|
|
13257
|
-
}
|
|
13258
|
-
isCompressed(compressed);
|
|
13259
|
-
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
13260
|
-
|
|
13261
|
-
switch (secp256k1.publicKeyCombine(output, pubkeys)) {
|
|
13262
|
-
case 0:
|
|
13263
|
-
return output
|
|
13264
|
-
case 1:
|
|
13265
|
-
throw new Error(errors.PUBKEY_PARSE)
|
|
13266
|
-
case 2:
|
|
13267
|
-
throw new Error(errors.PUBKEY_COMBINE)
|
|
13268
|
-
case 3:
|
|
13269
|
-
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
13270
|
-
}
|
|
13271
|
-
},
|
|
13272
|
-
|
|
13273
|
-
publicKeyTweakAdd (pubkey, tweak, compressed = true, output) {
|
|
13274
|
-
isUint8Array('public key', pubkey, [33, 65]);
|
|
13275
|
-
isUint8Array('tweak', tweak, 32);
|
|
13276
|
-
isCompressed(compressed);
|
|
13277
|
-
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
13278
|
-
|
|
13279
|
-
switch (secp256k1.publicKeyTweakAdd(output, pubkey, tweak)) {
|
|
13280
|
-
case 0:
|
|
13281
|
-
return output
|
|
13282
|
-
case 1:
|
|
13283
|
-
throw new Error(errors.PUBKEY_PARSE)
|
|
13284
|
-
case 2:
|
|
13285
|
-
throw new Error(errors.TWEAK_ADD)
|
|
13286
|
-
}
|
|
13287
|
-
},
|
|
13288
|
-
|
|
13289
|
-
publicKeyTweakMul (pubkey, tweak, compressed = true, output) {
|
|
13290
|
-
isUint8Array('public key', pubkey, [33, 65]);
|
|
13291
|
-
isUint8Array('tweak', tweak, 32);
|
|
13292
|
-
isCompressed(compressed);
|
|
13293
|
-
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
13294
|
-
|
|
13295
|
-
switch (secp256k1.publicKeyTweakMul(output, pubkey, tweak)) {
|
|
13296
|
-
case 0:
|
|
13297
|
-
return output
|
|
13298
|
-
case 1:
|
|
13299
|
-
throw new Error(errors.PUBKEY_PARSE)
|
|
13300
|
-
case 2:
|
|
13301
|
-
throw new Error(errors.TWEAK_MUL)
|
|
13302
|
-
}
|
|
13303
|
-
},
|
|
13304
|
-
|
|
13305
|
-
signatureNormalize (sig) {
|
|
13306
|
-
isUint8Array('signature', sig, 64);
|
|
13307
|
-
|
|
13308
|
-
switch (secp256k1.signatureNormalize(sig)) {
|
|
13309
|
-
case 0:
|
|
13310
|
-
return sig
|
|
13311
|
-
case 1:
|
|
13312
|
-
throw new Error(errors.SIG_PARSE)
|
|
13313
|
-
}
|
|
13314
|
-
},
|
|
13315
|
-
|
|
13316
|
-
signatureExport (sig, output) {
|
|
13317
|
-
isUint8Array('signature', sig, 64);
|
|
13318
|
-
output = getAssertedOutput(output, 72);
|
|
13319
|
-
|
|
13320
|
-
const obj = { output, outputlen: 72 };
|
|
13321
|
-
switch (secp256k1.signatureExport(obj, sig)) {
|
|
13322
|
-
case 0:
|
|
13323
|
-
return output.slice(0, obj.outputlen)
|
|
13324
|
-
case 1:
|
|
13325
|
-
throw new Error(errors.SIG_PARSE)
|
|
13326
|
-
case 2:
|
|
13327
|
-
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
13328
|
-
}
|
|
13329
|
-
},
|
|
13330
|
-
|
|
13331
|
-
signatureImport (sig, output) {
|
|
13332
|
-
isUint8Array('signature', sig);
|
|
13333
|
-
output = getAssertedOutput(output, 64);
|
|
13334
|
-
|
|
13335
|
-
switch (secp256k1.signatureImport(output, sig)) {
|
|
13336
|
-
case 0:
|
|
13337
|
-
return output
|
|
13338
|
-
case 1:
|
|
13339
|
-
throw new Error(errors.SIG_PARSE)
|
|
13340
|
-
case 2:
|
|
13341
|
-
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
13342
|
-
}
|
|
13343
|
-
},
|
|
13344
|
-
|
|
13345
|
-
ecdsaSign (msg32, seckey, options = {}, output) {
|
|
13346
|
-
isUint8Array('message', msg32, 32);
|
|
13347
|
-
isUint8Array('private key', seckey, 32);
|
|
13348
|
-
assert$g(toTypeString(options) === 'Object', 'Expected options to be an Object');
|
|
13349
|
-
if (options.data !== undefined) isUint8Array('options.data', options.data);
|
|
13350
|
-
if (options.noncefn !== undefined) assert$g(toTypeString(options.noncefn) === 'Function', 'Expected options.noncefn to be a Function');
|
|
13351
|
-
output = getAssertedOutput(output, 64);
|
|
13352
|
-
|
|
13353
|
-
const obj = { signature: output, recid: null };
|
|
13354
|
-
switch (secp256k1.ecdsaSign(obj, msg32, seckey, options.data, options.noncefn)) {
|
|
13355
|
-
case 0:
|
|
13356
|
-
return obj
|
|
13357
|
-
case 1:
|
|
13358
|
-
throw new Error(errors.SIGN)
|
|
13359
|
-
case 2:
|
|
13360
|
-
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
13361
|
-
}
|
|
13362
|
-
},
|
|
13363
|
-
|
|
13364
|
-
ecdsaVerify (sig, msg32, pubkey) {
|
|
13365
|
-
isUint8Array('signature', sig, 64);
|
|
13366
|
-
isUint8Array('message', msg32, 32);
|
|
13367
|
-
isUint8Array('public key', pubkey, [33, 65]);
|
|
13368
|
-
|
|
13369
|
-
switch (secp256k1.ecdsaVerify(sig, msg32, pubkey)) {
|
|
13370
|
-
case 0:
|
|
13371
|
-
return true
|
|
13372
|
-
case 3:
|
|
13373
|
-
return false
|
|
13374
|
-
case 1:
|
|
13375
|
-
throw new Error(errors.SIG_PARSE)
|
|
13376
|
-
case 2:
|
|
13377
|
-
throw new Error(errors.PUBKEY_PARSE)
|
|
13378
|
-
}
|
|
13379
|
-
},
|
|
13380
|
-
|
|
13381
|
-
ecdsaRecover (sig, recid, msg32, compressed = true, output) {
|
|
13382
|
-
isUint8Array('signature', sig, 64);
|
|
13383
|
-
assert$g(
|
|
13384
|
-
toTypeString(recid) === 'Number' &&
|
|
13385
|
-
recid >= 0 &&
|
|
13386
|
-
recid <= 3,
|
|
13387
|
-
'Expected recovery id to be a Number within interval [0, 3]'
|
|
13388
|
-
);
|
|
13389
|
-
isUint8Array('message', msg32, 32);
|
|
13390
|
-
isCompressed(compressed);
|
|
13391
|
-
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
13392
|
-
|
|
13393
|
-
switch (secp256k1.ecdsaRecover(output, sig, recid, msg32)) {
|
|
13394
|
-
case 0:
|
|
13395
|
-
return output
|
|
13396
|
-
case 1:
|
|
13397
|
-
throw new Error(errors.SIG_PARSE)
|
|
13398
|
-
case 2:
|
|
13399
|
-
throw new Error(errors.RECOVER)
|
|
13400
|
-
case 3:
|
|
13401
|
-
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
13402
|
-
}
|
|
13403
|
-
},
|
|
13404
|
-
|
|
13405
|
-
ecdh (pubkey, seckey, options = {}, output) {
|
|
13406
|
-
isUint8Array('public key', pubkey, [33, 65]);
|
|
13407
|
-
isUint8Array('private key', seckey, 32);
|
|
13408
|
-
assert$g(toTypeString(options) === 'Object', 'Expected options to be an Object');
|
|
13409
|
-
if (options.data !== undefined) isUint8Array('options.data', options.data);
|
|
13410
|
-
if (options.hashfn !== undefined) {
|
|
13411
|
-
assert$g(toTypeString(options.hashfn) === 'Function', 'Expected options.hashfn to be a Function');
|
|
13412
|
-
if (options.xbuf !== undefined) isUint8Array('options.xbuf', options.xbuf, 32);
|
|
13413
|
-
if (options.ybuf !== undefined) isUint8Array('options.ybuf', options.ybuf, 32);
|
|
13414
|
-
isUint8Array('output', output);
|
|
13415
|
-
} else {
|
|
13416
|
-
output = getAssertedOutput(output, 32);
|
|
13417
|
-
}
|
|
13418
|
-
|
|
13419
|
-
switch (secp256k1.ecdh(output, pubkey, seckey, options.data, options.hashfn, options.xbuf, options.ybuf)) {
|
|
13420
|
-
case 0:
|
|
13421
|
-
return output
|
|
13422
|
-
case 1:
|
|
13423
|
-
throw new Error(errors.PUBKEY_PARSE)
|
|
13424
|
-
case 2:
|
|
13425
|
-
throw new Error(errors.ECDH)
|
|
13426
|
-
}
|
|
13427
|
-
}
|
|
13428
|
-
}
|
|
13429
|
-
};
|
|
13430
|
-
|
|
13431
|
-
var elliptic$2 = {};
|
|
13432
|
-
|
|
13433
|
-
var name = "elliptic";
|
|
13434
|
-
var version$1 = "6.5.4";
|
|
13435
|
-
var description = "EC cryptography";
|
|
13436
|
-
var main = "lib/elliptic.js";
|
|
13437
|
-
var files = [
|
|
13438
|
-
"lib"
|
|
13439
|
-
];
|
|
13440
|
-
var scripts = {
|
|
13441
|
-
lint: "eslint lib test",
|
|
13442
|
-
"lint:fix": "npm run lint -- --fix",
|
|
13443
|
-
unit: "istanbul test _mocha --reporter=spec test/index.js",
|
|
13444
|
-
test: "npm run lint && npm run unit",
|
|
13445
|
-
version: "grunt dist && git add dist/"
|
|
13446
|
-
};
|
|
13447
|
-
var repository = {
|
|
13448
|
-
type: "git",
|
|
13449
|
-
url: "git@github.com:indutny/elliptic"
|
|
13450
|
-
};
|
|
13451
|
-
var keywords = [
|
|
13452
|
-
"EC",
|
|
13453
|
-
"Elliptic",
|
|
13454
|
-
"curve",
|
|
13455
|
-
"Cryptography"
|
|
13456
|
-
];
|
|
13457
|
-
var author = "Fedor Indutny <fedor@indutny.com>";
|
|
13458
|
-
var license = "MIT";
|
|
13459
|
-
var bugs = {
|
|
13460
|
-
url: "https://github.com/indutny/elliptic/issues"
|
|
13461
|
-
};
|
|
13462
|
-
var homepage = "https://github.com/indutny/elliptic";
|
|
13463
|
-
var devDependencies = {
|
|
13464
|
-
brfs: "^2.0.2",
|
|
13465
|
-
coveralls: "^3.1.0",
|
|
13466
|
-
eslint: "^7.6.0",
|
|
13467
|
-
grunt: "^1.2.1",
|
|
13468
|
-
"grunt-browserify": "^5.3.0",
|
|
13469
|
-
"grunt-cli": "^1.3.2",
|
|
13470
|
-
"grunt-contrib-connect": "^3.0.0",
|
|
13471
|
-
"grunt-contrib-copy": "^1.0.0",
|
|
13472
|
-
"grunt-contrib-uglify": "^5.0.0",
|
|
13473
|
-
"grunt-mocha-istanbul": "^5.0.2",
|
|
13474
|
-
"grunt-saucelabs": "^9.0.1",
|
|
13475
|
-
istanbul: "^0.4.5",
|
|
13476
|
-
mocha: "^8.0.1"
|
|
13477
|
-
};
|
|
13478
|
-
var dependencies = {
|
|
13479
|
-
"bn.js": "^4.11.9",
|
|
13480
|
-
brorand: "^1.1.0",
|
|
13481
|
-
"hash.js": "^1.0.0",
|
|
13482
|
-
"hmac-drbg": "^1.0.1",
|
|
13483
|
-
inherits: "^2.0.4",
|
|
13484
|
-
"minimalistic-assert": "^1.0.1",
|
|
13485
|
-
"minimalistic-crypto-utils": "^1.0.1"
|
|
13486
|
-
};
|
|
13487
|
-
var require$$0 = {
|
|
13488
|
-
name: name,
|
|
13489
|
-
version: version$1,
|
|
13490
|
-
description: description,
|
|
13491
|
-
main: main,
|
|
13492
|
-
files: files,
|
|
13493
|
-
scripts: scripts,
|
|
13494
|
-
repository: repository,
|
|
13495
|
-
keywords: keywords,
|
|
13496
|
-
author: author,
|
|
13497
|
-
license: license,
|
|
13498
|
-
bugs: bugs,
|
|
13499
|
-
homepage: homepage,
|
|
13500
|
-
devDependencies: devDependencies,
|
|
13501
|
-
dependencies: dependencies
|
|
13502
|
-
};
|
|
13503
|
-
|
|
13504
|
-
var utils$o = {};
|
|
13505
|
-
|
|
13506
|
-
var bn = {exports: {}};
|
|
13507
|
-
|
|
13508
|
-
(function (module) {
|
|
13509
|
-
(function (module, exports) {
|
|
13510
|
-
|
|
13511
|
-
// Utils
|
|
13512
|
-
function assert (val, msg) {
|
|
13513
|
-
if (!val) throw new Error(msg || 'Assertion failed');
|
|
13514
|
-
}
|
|
13515
|
-
|
|
13516
|
-
// Could use `inherits` module, but don't want to move from single file
|
|
13517
|
-
// architecture yet.
|
|
13518
|
-
function inherits (ctor, superCtor) {
|
|
13519
|
-
ctor.super_ = superCtor;
|
|
13520
|
-
var TempCtor = function () {};
|
|
13521
|
-
TempCtor.prototype = superCtor.prototype;
|
|
13522
|
-
ctor.prototype = new TempCtor();
|
|
13523
|
-
ctor.prototype.constructor = ctor;
|
|
13524
|
-
}
|
|
13525
|
-
|
|
13526
|
-
// BN
|
|
13527
|
-
|
|
13528
|
-
function BN (number, base, endian) {
|
|
13529
|
-
if (BN.isBN(number)) {
|
|
13530
|
-
return number;
|
|
13531
|
-
}
|
|
13532
|
-
|
|
13533
|
-
this.negative = 0;
|
|
13534
|
-
this.words = null;
|
|
13535
|
-
this.length = 0;
|
|
13536
|
-
|
|
13537
|
-
// Reduction context
|
|
13538
|
-
this.red = null;
|
|
13539
|
-
|
|
13540
|
-
if (number !== null) {
|
|
13541
|
-
if (base === 'le' || base === 'be') {
|
|
13542
|
-
endian = base;
|
|
13543
|
-
base = 10;
|
|
13544
|
-
}
|
|
13545
|
-
|
|
13546
|
-
this._init(number || 0, base || 10, endian || 'be');
|
|
13547
|
-
}
|
|
13548
|
-
}
|
|
13549
|
-
if (typeof module === 'object') {
|
|
13550
|
-
module.exports = BN;
|
|
13551
|
-
} else {
|
|
13552
|
-
exports.BN = BN;
|
|
13553
|
-
}
|
|
13554
|
-
|
|
13555
|
-
BN.BN = BN;
|
|
13556
|
-
BN.wordSize = 26;
|
|
13557
|
-
|
|
13558
|
-
var Buffer;
|
|
13559
|
-
try {
|
|
13560
|
-
if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
|
|
13561
|
-
Buffer = window.Buffer;
|
|
13562
|
-
} else {
|
|
13563
|
-
Buffer = require$$3.Buffer;
|
|
13564
|
-
}
|
|
13565
|
-
} catch (e) {
|
|
13566
|
-
}
|
|
13567
|
-
|
|
13568
|
-
BN.isBN = function isBN (num) {
|
|
13569
|
-
if (num instanceof BN) {
|
|
13570
|
-
return true;
|
|
13571
|
-
}
|
|
13572
|
-
|
|
13573
|
-
return num !== null && typeof num === 'object' &&
|
|
13574
|
-
num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
|
|
13575
|
-
};
|
|
13576
|
-
|
|
13577
|
-
BN.max = function max (left, right) {
|
|
13578
|
-
if (left.cmp(right) > 0) return left;
|
|
13579
|
-
return right;
|
|
13580
|
-
};
|
|
13581
|
-
|
|
13582
|
-
BN.min = function min (left, right) {
|
|
13583
|
-
if (left.cmp(right) < 0) return left;
|
|
13584
|
-
return right;
|
|
13585
|
-
};
|
|
13586
|
-
|
|
13587
|
-
BN.prototype._init = function init (number, base, endian) {
|
|
13588
|
-
if (typeof number === 'number') {
|
|
13589
|
-
return this._initNumber(number, base, endian);
|
|
13590
|
-
}
|
|
13591
|
-
|
|
13592
|
-
if (typeof number === 'object') {
|
|
13593
|
-
return this._initArray(number, base, endian);
|
|
13594
|
-
}
|
|
13595
|
-
|
|
13596
|
-
if (base === 'hex') {
|
|
13597
|
-
base = 16;
|
|
13598
|
-
}
|
|
13599
|
-
assert(base === (base | 0) && base >= 2 && base <= 36);
|
|
13274
|
+
if (base === 'hex') {
|
|
13275
|
+
base = 16;
|
|
13276
|
+
}
|
|
13277
|
+
assert(base === (base | 0) && base >= 2 && base <= 36);
|
|
13600
13278
|
|
|
13601
13279
|
number = number.toString().replace(/\s+/g, '');
|
|
13602
13280
|
var start = 0;
|
|
@@ -16953,14 +16631,14 @@ var bn = {exports: {}};
|
|
|
16953
16631
|
|
|
16954
16632
|
var bnExports = bn.exports;
|
|
16955
16633
|
|
|
16956
|
-
var minimalisticAssert = assert$
|
|
16634
|
+
var minimalisticAssert = assert$g;
|
|
16957
16635
|
|
|
16958
|
-
function assert$
|
|
16636
|
+
function assert$g(val, msg) {
|
|
16959
16637
|
if (!val)
|
|
16960
16638
|
throw new Error(msg || 'Assertion failed');
|
|
16961
16639
|
}
|
|
16962
16640
|
|
|
16963
|
-
assert$
|
|
16641
|
+
assert$g.equal = function assertEqual(l, r, msg) {
|
|
16964
16642
|
if (l != r)
|
|
16965
16643
|
throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
|
|
16966
16644
|
};
|
|
@@ -17223,7 +16901,7 @@ var BN$8 = bnExports;
|
|
|
17223
16901
|
var utils$m = utils$o;
|
|
17224
16902
|
var getNAF = utils$m.getNAF;
|
|
17225
16903
|
var getJSF = utils$m.getJSF;
|
|
17226
|
-
var assert$
|
|
16904
|
+
var assert$f = utils$m.assert;
|
|
17227
16905
|
|
|
17228
16906
|
function BaseCurve(type, conf) {
|
|
17229
16907
|
this.type = type;
|
|
@@ -17269,7 +16947,7 @@ BaseCurve.prototype.validate = function validate() {
|
|
|
17269
16947
|
};
|
|
17270
16948
|
|
|
17271
16949
|
BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
|
|
17272
|
-
assert$
|
|
16950
|
+
assert$f(p.precomputed);
|
|
17273
16951
|
var doubles = p._getDoubles();
|
|
17274
16952
|
|
|
17275
16953
|
var naf = getNAF(k, 1, this._bitLength);
|
|
@@ -17326,7 +17004,7 @@ BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
|
|
|
17326
17004
|
if (i < 0)
|
|
17327
17005
|
break;
|
|
17328
17006
|
var z = naf[i];
|
|
17329
|
-
assert$
|
|
17007
|
+
assert$f(z !== 0);
|
|
17330
17008
|
if (p.type === 'affine') {
|
|
17331
17009
|
// J +- P
|
|
17332
17010
|
if (z > 0)
|
|
@@ -17494,9 +17172,9 @@ BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
|
|
|
17494
17172
|
if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
|
|
17495
17173
|
bytes.length - 1 === 2 * len) {
|
|
17496
17174
|
if (bytes[0] === 0x06)
|
|
17497
|
-
assert$
|
|
17175
|
+
assert$f(bytes[bytes.length - 1] % 2 === 0);
|
|
17498
17176
|
else if (bytes[0] === 0x07)
|
|
17499
|
-
assert$
|
|
17177
|
+
assert$f(bytes[bytes.length - 1] % 2 === 1);
|
|
17500
17178
|
|
|
17501
17179
|
var res = this.point(bytes.slice(1, 1 + len),
|
|
17502
17180
|
bytes.slice(1 + len, 1 + 2 * len));
|
|
@@ -17635,7 +17313,7 @@ var BN$7 = bnExports;
|
|
|
17635
17313
|
var inherits$3 = inherits_browserExports;
|
|
17636
17314
|
var Base$2 = base;
|
|
17637
17315
|
|
|
17638
|
-
var assert$
|
|
17316
|
+
var assert$e = utils$l.assert;
|
|
17639
17317
|
|
|
17640
17318
|
function ShortCurve(conf) {
|
|
17641
17319
|
Base$2.call(this, 'short', conf);
|
|
@@ -17680,7 +17358,7 @@ ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
|
|
|
17680
17358
|
lambda = lambdas[0];
|
|
17681
17359
|
} else {
|
|
17682
17360
|
lambda = lambdas[1];
|
|
17683
|
-
assert$
|
|
17361
|
+
assert$e(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
|
|
17684
17362
|
}
|
|
17685
17363
|
}
|
|
17686
17364
|
|
|
@@ -18749,7 +18427,7 @@ var BN$5 = bnExports;
|
|
|
18749
18427
|
var inherits$1 = inherits_browserExports;
|
|
18750
18428
|
var Base = base;
|
|
18751
18429
|
|
|
18752
|
-
var assert$
|
|
18430
|
+
var assert$d = utils$j.assert;
|
|
18753
18431
|
|
|
18754
18432
|
function EdwardsCurve(conf) {
|
|
18755
18433
|
// NOTE: Important as we are creating point in Base.call()
|
|
@@ -18766,7 +18444,7 @@ function EdwardsCurve(conf) {
|
|
|
18766
18444
|
this.d = new BN$5(conf.d, 16).toRed(this.red);
|
|
18767
18445
|
this.dd = this.d.redAdd(this.d);
|
|
18768
18446
|
|
|
18769
|
-
assert$
|
|
18447
|
+
assert$d(!this.twisted || this.c.fromRed().cmpn(1) === 0);
|
|
18770
18448
|
this.oneC = (conf.c | 0) === 1;
|
|
18771
18449
|
}
|
|
18772
18450
|
inherits$1(EdwardsCurve, Base);
|
|
@@ -19194,7 +18872,7 @@ var hash$2 = {};
|
|
|
19194
18872
|
|
|
19195
18873
|
var utils$i = {};
|
|
19196
18874
|
|
|
19197
|
-
var assert$
|
|
18875
|
+
var assert$c = minimalisticAssert;
|
|
19198
18876
|
var inherits = inherits_browserExports;
|
|
19199
18877
|
|
|
19200
18878
|
utils$i.inherits = inherits;
|
|
@@ -19315,7 +18993,7 @@ utils$i.zero8 = zero8;
|
|
|
19315
18993
|
|
|
19316
18994
|
function join32(msg, start, end, endian) {
|
|
19317
18995
|
var len = end - start;
|
|
19318
|
-
assert$
|
|
18996
|
+
assert$c(len % 4 === 0);
|
|
19319
18997
|
var res = new Array(len / 4);
|
|
19320
18998
|
for (var i = 0, k = start; i < res.length; i++, k += 4) {
|
|
19321
18999
|
var w;
|
|
@@ -19474,7 +19152,7 @@ utils$i.shr64_lo = shr64_lo$1;
|
|
|
19474
19152
|
var common$5 = {};
|
|
19475
19153
|
|
|
19476
19154
|
var utils$h = utils$i;
|
|
19477
|
-
var assert$
|
|
19155
|
+
var assert$b = minimalisticAssert;
|
|
19478
19156
|
|
|
19479
19157
|
function BlockHash$4() {
|
|
19480
19158
|
this.pending = null;
|
|
@@ -19519,7 +19197,7 @@ BlockHash$4.prototype.update = function update(msg, enc) {
|
|
|
19519
19197
|
|
|
19520
19198
|
BlockHash$4.prototype.digest = function digest(enc) {
|
|
19521
19199
|
this.update(this._pad());
|
|
19522
|
-
assert$
|
|
19200
|
+
assert$b(this.pending === null);
|
|
19523
19201
|
|
|
19524
19202
|
return this._digest(enc);
|
|
19525
19203
|
};
|
|
@@ -19692,7 +19370,7 @@ SHA1.prototype._digest = function digest(enc) {
|
|
|
19692
19370
|
var utils$e = utils$i;
|
|
19693
19371
|
var common$2 = common$5;
|
|
19694
19372
|
var shaCommon = common$4;
|
|
19695
|
-
var assert$
|
|
19373
|
+
var assert$a = minimalisticAssert;
|
|
19696
19374
|
|
|
19697
19375
|
var sum32$1 = utils$e.sum32;
|
|
19698
19376
|
var sum32_4$1 = utils$e.sum32_4;
|
|
@@ -19762,7 +19440,7 @@ SHA256$1.prototype._update = function _update(msg, start) {
|
|
|
19762
19440
|
var g = this.h[6];
|
|
19763
19441
|
var h = this.h[7];
|
|
19764
19442
|
|
|
19765
|
-
assert$
|
|
19443
|
+
assert$a(this.k.length === W.length);
|
|
19766
19444
|
for (i = 0; i < W.length; i++) {
|
|
19767
19445
|
var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
|
|
19768
19446
|
var T2 = sum32$1(s0_256(a), maj32(a, b, c));
|
|
@@ -19823,7 +19501,7 @@ SHA224.prototype._digest = function digest(enc) {
|
|
|
19823
19501
|
|
|
19824
19502
|
var utils$c = utils$i;
|
|
19825
19503
|
var common$1 = common$5;
|
|
19826
|
-
var assert$
|
|
19504
|
+
var assert$9 = minimalisticAssert;
|
|
19827
19505
|
|
|
19828
19506
|
var rotr64_hi = utils$c.rotr64_hi;
|
|
19829
19507
|
var rotr64_lo = utils$c.rotr64_lo;
|
|
@@ -19958,7 +19636,7 @@ SHA512$1.prototype._update = function _update(msg, start) {
|
|
|
19958
19636
|
var hh = this.h[14];
|
|
19959
19637
|
var hl = this.h[15];
|
|
19960
19638
|
|
|
19961
|
-
assert$
|
|
19639
|
+
assert$9(this.k.length === W.length);
|
|
19962
19640
|
for (var i = 0; i < W.length; i += 2) {
|
|
19963
19641
|
var c0_hi = hh;
|
|
19964
19642
|
var c0_lo = hl;
|
|
@@ -20338,7 +20016,7 @@ var sh = [
|
|
|
20338
20016
|
];
|
|
20339
20017
|
|
|
20340
20018
|
var utils$9 = utils$i;
|
|
20341
|
-
var assert$
|
|
20019
|
+
var assert$8 = minimalisticAssert;
|
|
20342
20020
|
|
|
20343
20021
|
function Hmac(hash, key, enc) {
|
|
20344
20022
|
if (!(this instanceof Hmac))
|
|
@@ -20357,7 +20035,7 @@ Hmac.prototype._init = function init(key) {
|
|
|
20357
20035
|
// Shorten key, if needed
|
|
20358
20036
|
if (key.length > this.blockSize)
|
|
20359
20037
|
key = new this.Hash().update(key).digest();
|
|
20360
|
-
assert$
|
|
20038
|
+
assert$8(key.length <= this.blockSize);
|
|
20361
20039
|
|
|
20362
20040
|
// Add padding to key
|
|
20363
20041
|
for (var i = key.length; i < this.blockSize; i++)
|
|
@@ -21400,7 +21078,7 @@ function requireSecp256k1 () {
|
|
|
21400
21078
|
|
|
21401
21079
|
var hash$1 = hash$2;
|
|
21402
21080
|
var utils$8 = utils$n;
|
|
21403
|
-
var assert$
|
|
21081
|
+
var assert$7 = minimalisticAssert;
|
|
21404
21082
|
|
|
21405
21083
|
function HmacDRBG$1(options) {
|
|
21406
21084
|
if (!(this instanceof HmacDRBG$1))
|
|
@@ -21419,7 +21097,7 @@ function HmacDRBG$1(options) {
|
|
|
21419
21097
|
var entropy = utils$8.toArray(options.entropy, options.entropyEnc || 'hex');
|
|
21420
21098
|
var nonce = utils$8.toArray(options.nonce, options.nonceEnc || 'hex');
|
|
21421
21099
|
var pers = utils$8.toArray(options.pers, options.persEnc || 'hex');
|
|
21422
|
-
assert$
|
|
21100
|
+
assert$7(entropy.length >= (this.minEntropy / 8),
|
|
21423
21101
|
'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
|
|
21424
21102
|
this._init(entropy, nonce, pers);
|
|
21425
21103
|
}
|
|
@@ -21474,7 +21152,7 @@ HmacDRBG$1.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc)
|
|
|
21474
21152
|
entropy = utils$8.toArray(entropy, entropyEnc);
|
|
21475
21153
|
add = utils$8.toArray(add, addEnc);
|
|
21476
21154
|
|
|
21477
|
-
assert$
|
|
21155
|
+
assert$7(entropy.length >= (this.minEntropy / 8),
|
|
21478
21156
|
'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
|
|
21479
21157
|
|
|
21480
21158
|
this._update(entropy.concat(add || []));
|
|
@@ -21512,7 +21190,7 @@ HmacDRBG$1.prototype.generate = function generate(len, enc, add, addEnc) {
|
|
|
21512
21190
|
|
|
21513
21191
|
var BN$4 = bnExports;
|
|
21514
21192
|
var utils$7 = utils$o;
|
|
21515
|
-
var assert$
|
|
21193
|
+
var assert$6 = utils$7.assert;
|
|
21516
21194
|
|
|
21517
21195
|
function KeyPair$3(ec, options) {
|
|
21518
21196
|
this.ec = ec;
|
|
@@ -21597,10 +21275,10 @@ KeyPair$3.prototype._importPublic = function _importPublic(key, enc) {
|
|
|
21597
21275
|
// Weierstrass/Edwards points on the other hand have both `x` and
|
|
21598
21276
|
// `y` coordinates.
|
|
21599
21277
|
if (this.ec.curve.type === 'mont') {
|
|
21600
|
-
assert$
|
|
21278
|
+
assert$6(key.x, 'Need x coordinate');
|
|
21601
21279
|
} else if (this.ec.curve.type === 'short' ||
|
|
21602
21280
|
this.ec.curve.type === 'edwards') {
|
|
21603
|
-
assert$
|
|
21281
|
+
assert$6(key.x && key.y, 'Need both x and y coordinate');
|
|
21604
21282
|
}
|
|
21605
21283
|
this.pub = this.ec.curve.point(key.x, key.y);
|
|
21606
21284
|
return;
|
|
@@ -21611,7 +21289,7 @@ KeyPair$3.prototype._importPublic = function _importPublic(key, enc) {
|
|
|
21611
21289
|
// ECDH
|
|
21612
21290
|
KeyPair$3.prototype.derive = function derive(pub) {
|
|
21613
21291
|
if(!pub.validate()) {
|
|
21614
|
-
assert$
|
|
21292
|
+
assert$6(pub.validate(), 'public point not validated');
|
|
21615
21293
|
}
|
|
21616
21294
|
return pub.mul(this.priv).getX();
|
|
21617
21295
|
};
|
|
@@ -21633,7 +21311,7 @@ KeyPair$3.prototype.inspect = function inspect() {
|
|
|
21633
21311
|
var BN$3 = bnExports;
|
|
21634
21312
|
|
|
21635
21313
|
var utils$6 = utils$o;
|
|
21636
|
-
var assert$
|
|
21314
|
+
var assert$5 = utils$6.assert;
|
|
21637
21315
|
|
|
21638
21316
|
function Signature$3(options, enc) {
|
|
21639
21317
|
if (options instanceof Signature$3)
|
|
@@ -21642,7 +21320,7 @@ function Signature$3(options, enc) {
|
|
|
21642
21320
|
if (this._importDER(options, enc))
|
|
21643
21321
|
return;
|
|
21644
21322
|
|
|
21645
|
-
assert$
|
|
21323
|
+
assert$5(options.r && options.s, 'Signature without r or s');
|
|
21646
21324
|
this.r = new BN$3(options.r, 16);
|
|
21647
21325
|
this.s = new BN$3(options.s, 16);
|
|
21648
21326
|
if (options.recoveryParam === undefined)
|
|
@@ -21800,7 +21478,7 @@ var HmacDRBG = hmacDrbg;
|
|
|
21800
21478
|
var utils$5 = utils$o;
|
|
21801
21479
|
var curves$1 = curves$2;
|
|
21802
21480
|
var rand = brorandExports;
|
|
21803
|
-
var assert$
|
|
21481
|
+
var assert$4 = utils$5.assert;
|
|
21804
21482
|
|
|
21805
21483
|
var KeyPair$2 = key$1;
|
|
21806
21484
|
var Signature$2 = signature$1;
|
|
@@ -21811,7 +21489,7 @@ function EC$1(options) {
|
|
|
21811
21489
|
|
|
21812
21490
|
// Shortcut `elliptic.ec(curve-name)`
|
|
21813
21491
|
if (typeof options === 'string') {
|
|
21814
|
-
assert$
|
|
21492
|
+
assert$4(Object.prototype.hasOwnProperty.call(curves$1, options),
|
|
21815
21493
|
'Unknown curve ' + options);
|
|
21816
21494
|
|
|
21817
21495
|
options = curves$1[options];
|
|
@@ -21989,7 +21667,7 @@ EC$1.prototype.verify = function verify(msg, signature, key, enc) {
|
|
|
21989
21667
|
};
|
|
21990
21668
|
|
|
21991
21669
|
EC$1.prototype.recoverPubKey = function(msg, signature, j, enc) {
|
|
21992
|
-
assert$
|
|
21670
|
+
assert$4((3 & j) === j, 'The recovery param is more than two bits');
|
|
21993
21671
|
signature = new Signature$2(signature, enc);
|
|
21994
21672
|
|
|
21995
21673
|
var n = this.n;
|
|
@@ -22038,7 +21716,7 @@ EC$1.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
|
|
|
22038
21716
|
};
|
|
22039
21717
|
|
|
22040
21718
|
var utils$4 = utils$o;
|
|
22041
|
-
var assert$
|
|
21719
|
+
var assert$3 = utils$4.assert;
|
|
22042
21720
|
var parseBytes$2 = utils$4.parseBytes;
|
|
22043
21721
|
var cachedProperty$1 = utils$4.cachedProperty;
|
|
22044
21722
|
|
|
@@ -22112,7 +21790,7 @@ cachedProperty$1(KeyPair$1, 'messagePrefix', function messagePrefix() {
|
|
|
22112
21790
|
});
|
|
22113
21791
|
|
|
22114
21792
|
KeyPair$1.prototype.sign = function sign(message) {
|
|
22115
|
-
assert$
|
|
21793
|
+
assert$3(this._secret, 'KeyPair can only verify');
|
|
22116
21794
|
return this.eddsa.sign(message, this);
|
|
22117
21795
|
};
|
|
22118
21796
|
|
|
@@ -22121,7 +21799,7 @@ KeyPair$1.prototype.verify = function verify(message, sig) {
|
|
|
22121
21799
|
};
|
|
22122
21800
|
|
|
22123
21801
|
KeyPair$1.prototype.getSecret = function getSecret(enc) {
|
|
22124
|
-
assert$
|
|
21802
|
+
assert$3(this._secret, 'KeyPair is public only');
|
|
22125
21803
|
return utils$4.encode(this.secret(), enc);
|
|
22126
21804
|
};
|
|
22127
21805
|
|
|
@@ -22133,7 +21811,7 @@ var key = KeyPair$1;
|
|
|
22133
21811
|
|
|
22134
21812
|
var BN$1 = bnExports;
|
|
22135
21813
|
var utils$3 = utils$o;
|
|
22136
|
-
var assert$
|
|
21814
|
+
var assert$2 = utils$3.assert;
|
|
22137
21815
|
var cachedProperty = utils$3.cachedProperty;
|
|
22138
21816
|
var parseBytes$1 = utils$3.parseBytes;
|
|
22139
21817
|
|
|
@@ -22158,7 +21836,7 @@ function Signature$1(eddsa, sig) {
|
|
|
22158
21836
|
};
|
|
22159
21837
|
}
|
|
22160
21838
|
|
|
22161
|
-
assert$
|
|
21839
|
+
assert$2(sig.R && sig.S, 'Signature without R or S');
|
|
22162
21840
|
|
|
22163
21841
|
if (eddsa.isPoint(sig.R))
|
|
22164
21842
|
this._R = sig.R;
|
|
@@ -22198,13 +21876,13 @@ var signature = Signature$1;
|
|
|
22198
21876
|
var hash = hash$2;
|
|
22199
21877
|
var curves = curves$2;
|
|
22200
21878
|
var utils$2 = utils$o;
|
|
22201
|
-
var assert = utils$2.assert;
|
|
21879
|
+
var assert$1 = utils$2.assert;
|
|
22202
21880
|
var parseBytes = utils$2.parseBytes;
|
|
22203
21881
|
var KeyPair = key;
|
|
22204
21882
|
var Signature = signature;
|
|
22205
21883
|
|
|
22206
21884
|
function EDDSA(curve) {
|
|
22207
|
-
assert(curve === 'ed25519', 'only tested with ed25519 so far');
|
|
21885
|
+
assert$1(curve === 'ed25519', 'only tested with ed25519 so far');
|
|
22208
21886
|
|
|
22209
21887
|
if (!(this instanceof EDDSA))
|
|
22210
21888
|
return new EDDSA(curve);
|
|
@@ -22634,99 +22312,436 @@ var elliptic$1 = {
|
|
|
22634
22312
|
noncefn = (counter) => {
|
|
22635
22313
|
const nonce = _noncefn(message, seckey, null, data, counter);
|
|
22636
22314
|
|
|
22637
|
-
const isValid = nonce instanceof Uint8Array && nonce.length === 32;
|
|
22638
|
-
if (!isValid) throw new Error('This is the way')
|
|
22315
|
+
const isValid = nonce instanceof Uint8Array && nonce.length === 32;
|
|
22316
|
+
if (!isValid) throw new Error('This is the way')
|
|
22317
|
+
|
|
22318
|
+
return new BN(nonce)
|
|
22319
|
+
};
|
|
22320
|
+
}
|
|
22321
|
+
|
|
22322
|
+
const d = new BN(seckey);
|
|
22323
|
+
if (d.cmp(ecparams.n) >= 0 || d.isZero()) return 1
|
|
22324
|
+
|
|
22325
|
+
let sig;
|
|
22326
|
+
try {
|
|
22327
|
+
sig = ec.sign(message, seckey, { canonical: true, k: noncefn, pers: data });
|
|
22328
|
+
} catch (err) {
|
|
22329
|
+
return 1
|
|
22330
|
+
}
|
|
22331
|
+
|
|
22332
|
+
obj.signature.set(sig.r.toArrayLike(Uint8Array, 'be', 32), 0);
|
|
22333
|
+
obj.signature.set(sig.s.toArrayLike(Uint8Array, 'be', 32), 32);
|
|
22334
|
+
obj.recid = sig.recoveryParam;
|
|
22335
|
+
|
|
22336
|
+
return 0
|
|
22337
|
+
},
|
|
22338
|
+
|
|
22339
|
+
ecdsaVerify (sig, msg32, pubkey) {
|
|
22340
|
+
const sigObj = { r: sig.subarray(0, 32), s: sig.subarray(32, 64) };
|
|
22341
|
+
|
|
22342
|
+
const sigr = new BN(sigObj.r);
|
|
22343
|
+
const sigs = new BN(sigObj.s);
|
|
22344
|
+
if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) return 1
|
|
22345
|
+
if (sigs.cmp(ec.nh) === 1 || sigr.isZero() || sigs.isZero()) return 3
|
|
22346
|
+
|
|
22347
|
+
const pair = loadPublicKey(pubkey);
|
|
22348
|
+
if (pair === null) return 2
|
|
22349
|
+
|
|
22350
|
+
const point = pair.getPublic();
|
|
22351
|
+
const isValid = ec.verify(msg32, sigObj, point);
|
|
22352
|
+
return isValid ? 0 : 3
|
|
22353
|
+
},
|
|
22354
|
+
|
|
22355
|
+
ecdsaRecover (output, sig, recid, msg32) {
|
|
22356
|
+
const sigObj = { r: sig.slice(0, 32), s: sig.slice(32, 64) };
|
|
22357
|
+
|
|
22358
|
+
const sigr = new BN(sigObj.r);
|
|
22359
|
+
const sigs = new BN(sigObj.s);
|
|
22360
|
+
if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) return 1
|
|
22361
|
+
|
|
22362
|
+
if (sigr.isZero() || sigs.isZero()) return 2
|
|
22363
|
+
|
|
22364
|
+
// Can throw `throw new Error('Unable to find sencond key candinate');`
|
|
22365
|
+
let point;
|
|
22366
|
+
try {
|
|
22367
|
+
point = ec.recoverPubKey(msg32, sigObj, recid);
|
|
22368
|
+
} catch (err) {
|
|
22369
|
+
return 2
|
|
22370
|
+
}
|
|
22371
|
+
|
|
22372
|
+
savePublicKey(output, point);
|
|
22373
|
+
|
|
22374
|
+
return 0
|
|
22375
|
+
},
|
|
22376
|
+
|
|
22377
|
+
ecdh (output, pubkey, seckey, data, hashfn, xbuf, ybuf) {
|
|
22378
|
+
const pair = loadPublicKey(pubkey);
|
|
22379
|
+
if (pair === null) return 1
|
|
22380
|
+
|
|
22381
|
+
const scalar = new BN(seckey);
|
|
22382
|
+
if (scalar.cmp(ecparams.n) >= 0 || scalar.isZero()) return 2
|
|
22383
|
+
|
|
22384
|
+
const point = pair.getPublic().mul(scalar);
|
|
22385
|
+
|
|
22386
|
+
if (hashfn === undefined) {
|
|
22387
|
+
const data = point.encode(null, true);
|
|
22388
|
+
const sha256 = ec.hash().update(data).digest();
|
|
22389
|
+
for (let i = 0; i < 32; ++i) output[i] = sha256[i];
|
|
22390
|
+
} else {
|
|
22391
|
+
if (!xbuf) xbuf = new Uint8Array(32);
|
|
22392
|
+
const x = point.getX().toArray('be', 32);
|
|
22393
|
+
for (let i = 0; i < 32; ++i) xbuf[i] = x[i];
|
|
22394
|
+
|
|
22395
|
+
if (!ybuf) ybuf = new Uint8Array(32);
|
|
22396
|
+
const y = point.getY().toArray('be', 32);
|
|
22397
|
+
for (let i = 0; i < 32; ++i) ybuf[i] = y[i];
|
|
22398
|
+
|
|
22399
|
+
const hash = hashfn(xbuf, ybuf, data);
|
|
22400
|
+
|
|
22401
|
+
const isValid = hash instanceof Uint8Array && hash.length === output.length;
|
|
22402
|
+
if (!isValid) return 2
|
|
22403
|
+
|
|
22404
|
+
output.set(hash);
|
|
22405
|
+
}
|
|
22406
|
+
|
|
22407
|
+
return 0
|
|
22408
|
+
}
|
|
22409
|
+
};
|
|
22410
|
+
|
|
22411
|
+
const errors = {
|
|
22412
|
+
IMPOSSIBLE_CASE: 'Impossible case. Please create issue.',
|
|
22413
|
+
TWEAK_ADD:
|
|
22414
|
+
'The tweak was out of range or the resulted private key is invalid',
|
|
22415
|
+
TWEAK_MUL: 'The tweak was out of range or equal to zero',
|
|
22416
|
+
CONTEXT_RANDOMIZE_UNKNOW: 'Unknow error on context randomization',
|
|
22417
|
+
SECKEY_INVALID: 'Private Key is invalid',
|
|
22418
|
+
PUBKEY_PARSE: 'Public Key could not be parsed',
|
|
22419
|
+
PUBKEY_SERIALIZE: 'Public Key serialization error',
|
|
22420
|
+
PUBKEY_COMBINE: 'The sum of the public keys is not valid',
|
|
22421
|
+
SIG_PARSE: 'Signature could not be parsed',
|
|
22422
|
+
SIGN: 'The nonce generation function failed, or the private key was invalid',
|
|
22423
|
+
RECOVER: 'Public key could not be recover',
|
|
22424
|
+
ECDH: 'Scalar was invalid (zero or overflow)'
|
|
22425
|
+
};
|
|
22426
|
+
|
|
22427
|
+
function assert (cond, msg) {
|
|
22428
|
+
if (!cond) throw new Error(msg)
|
|
22429
|
+
}
|
|
22430
|
+
|
|
22431
|
+
function isUint8Array (name, value, length) {
|
|
22432
|
+
assert(value instanceof Uint8Array, `Expected ${name} to be an Uint8Array`);
|
|
22433
|
+
|
|
22434
|
+
if (length !== undefined) {
|
|
22435
|
+
if (Array.isArray(length)) {
|
|
22436
|
+
const numbers = length.join(', ');
|
|
22437
|
+
const msg = `Expected ${name} to be an Uint8Array with length [${numbers}]`;
|
|
22438
|
+
assert(length.includes(value.length), msg);
|
|
22439
|
+
} else {
|
|
22440
|
+
const msg = `Expected ${name} to be an Uint8Array with length ${length}`;
|
|
22441
|
+
assert(value.length === length, msg);
|
|
22442
|
+
}
|
|
22443
|
+
}
|
|
22444
|
+
}
|
|
22445
|
+
|
|
22446
|
+
function isCompressed (value) {
|
|
22447
|
+
assert(toTypeString(value) === 'Boolean', 'Expected compressed to be a Boolean');
|
|
22448
|
+
}
|
|
22449
|
+
|
|
22450
|
+
function getAssertedOutput (output = (len) => new Uint8Array(len), length) {
|
|
22451
|
+
if (typeof output === 'function') output = output(length);
|
|
22452
|
+
isUint8Array('output', output, length);
|
|
22453
|
+
return output
|
|
22454
|
+
}
|
|
22455
|
+
|
|
22456
|
+
function toTypeString (value) {
|
|
22457
|
+
return Object.prototype.toString.call(value).slice(8, -1)
|
|
22458
|
+
}
|
|
22459
|
+
|
|
22460
|
+
var lib = (secp256k1) => {
|
|
22461
|
+
return {
|
|
22462
|
+
contextRandomize (seed) {
|
|
22463
|
+
assert(
|
|
22464
|
+
seed === null || seed instanceof Uint8Array,
|
|
22465
|
+
'Expected seed to be an Uint8Array or null'
|
|
22466
|
+
);
|
|
22467
|
+
if (seed !== null) isUint8Array('seed', seed, 32);
|
|
22468
|
+
|
|
22469
|
+
switch (secp256k1.contextRandomize(seed)) {
|
|
22470
|
+
case 1:
|
|
22471
|
+
throw new Error(errors.CONTEXT_RANDOMIZE_UNKNOW)
|
|
22472
|
+
}
|
|
22473
|
+
},
|
|
22474
|
+
|
|
22475
|
+
privateKeyVerify (seckey) {
|
|
22476
|
+
isUint8Array('private key', seckey, 32);
|
|
22477
|
+
|
|
22478
|
+
return secp256k1.privateKeyVerify(seckey) === 0
|
|
22479
|
+
},
|
|
22480
|
+
|
|
22481
|
+
privateKeyNegate (seckey) {
|
|
22482
|
+
isUint8Array('private key', seckey, 32);
|
|
22483
|
+
|
|
22484
|
+
switch (secp256k1.privateKeyNegate(seckey)) {
|
|
22485
|
+
case 0:
|
|
22486
|
+
return seckey
|
|
22487
|
+
case 1:
|
|
22488
|
+
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
22489
|
+
}
|
|
22490
|
+
},
|
|
22491
|
+
|
|
22492
|
+
privateKeyTweakAdd (seckey, tweak) {
|
|
22493
|
+
isUint8Array('private key', seckey, 32);
|
|
22494
|
+
isUint8Array('tweak', tweak, 32);
|
|
22495
|
+
|
|
22496
|
+
switch (secp256k1.privateKeyTweakAdd(seckey, tweak)) {
|
|
22497
|
+
case 0:
|
|
22498
|
+
return seckey
|
|
22499
|
+
case 1:
|
|
22500
|
+
throw new Error(errors.TWEAK_ADD)
|
|
22501
|
+
}
|
|
22502
|
+
},
|
|
22503
|
+
|
|
22504
|
+
privateKeyTweakMul (seckey, tweak) {
|
|
22505
|
+
isUint8Array('private key', seckey, 32);
|
|
22506
|
+
isUint8Array('tweak', tweak, 32);
|
|
22507
|
+
|
|
22508
|
+
switch (secp256k1.privateKeyTweakMul(seckey, tweak)) {
|
|
22509
|
+
case 0:
|
|
22510
|
+
return seckey
|
|
22511
|
+
case 1:
|
|
22512
|
+
throw new Error(errors.TWEAK_MUL)
|
|
22513
|
+
}
|
|
22514
|
+
},
|
|
22515
|
+
|
|
22516
|
+
publicKeyVerify (pubkey) {
|
|
22517
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22518
|
+
|
|
22519
|
+
return secp256k1.publicKeyVerify(pubkey) === 0
|
|
22520
|
+
},
|
|
22521
|
+
|
|
22522
|
+
publicKeyCreate (seckey, compressed = true, output) {
|
|
22523
|
+
isUint8Array('private key', seckey, 32);
|
|
22524
|
+
isCompressed(compressed);
|
|
22525
|
+
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
22526
|
+
|
|
22527
|
+
switch (secp256k1.publicKeyCreate(output, seckey)) {
|
|
22528
|
+
case 0:
|
|
22529
|
+
return output
|
|
22530
|
+
case 1:
|
|
22531
|
+
throw new Error(errors.SECKEY_INVALID)
|
|
22532
|
+
case 2:
|
|
22533
|
+
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
22534
|
+
}
|
|
22535
|
+
},
|
|
22639
22536
|
|
|
22640
|
-
|
|
22641
|
-
|
|
22642
|
-
|
|
22537
|
+
publicKeyConvert (pubkey, compressed = true, output) {
|
|
22538
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22539
|
+
isCompressed(compressed);
|
|
22540
|
+
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
22643
22541
|
|
|
22644
|
-
|
|
22645
|
-
|
|
22542
|
+
switch (secp256k1.publicKeyConvert(output, pubkey)) {
|
|
22543
|
+
case 0:
|
|
22544
|
+
return output
|
|
22545
|
+
case 1:
|
|
22546
|
+
throw new Error(errors.PUBKEY_PARSE)
|
|
22547
|
+
case 2:
|
|
22548
|
+
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
22549
|
+
}
|
|
22550
|
+
},
|
|
22646
22551
|
|
|
22647
|
-
|
|
22648
|
-
|
|
22649
|
-
|
|
22650
|
-
|
|
22651
|
-
return 1
|
|
22652
|
-
}
|
|
22552
|
+
publicKeyNegate (pubkey, compressed = true, output) {
|
|
22553
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22554
|
+
isCompressed(compressed);
|
|
22555
|
+
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
22653
22556
|
|
|
22654
|
-
|
|
22655
|
-
|
|
22656
|
-
|
|
22557
|
+
switch (secp256k1.publicKeyNegate(output, pubkey)) {
|
|
22558
|
+
case 0:
|
|
22559
|
+
return output
|
|
22560
|
+
case 1:
|
|
22561
|
+
throw new Error(errors.PUBKEY_PARSE)
|
|
22562
|
+
case 2:
|
|
22563
|
+
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
22564
|
+
case 3:
|
|
22565
|
+
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
22566
|
+
}
|
|
22567
|
+
},
|
|
22657
22568
|
|
|
22658
|
-
|
|
22659
|
-
|
|
22569
|
+
publicKeyCombine (pubkeys, compressed = true, output) {
|
|
22570
|
+
assert(Array.isArray(pubkeys), 'Expected public keys to be an Array');
|
|
22571
|
+
assert(pubkeys.length > 0, 'Expected public keys array will have more than zero items');
|
|
22572
|
+
for (const pubkey of pubkeys) {
|
|
22573
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22574
|
+
}
|
|
22575
|
+
isCompressed(compressed);
|
|
22576
|
+
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
22660
22577
|
|
|
22661
|
-
|
|
22662
|
-
|
|
22578
|
+
switch (secp256k1.publicKeyCombine(output, pubkeys)) {
|
|
22579
|
+
case 0:
|
|
22580
|
+
return output
|
|
22581
|
+
case 1:
|
|
22582
|
+
throw new Error(errors.PUBKEY_PARSE)
|
|
22583
|
+
case 2:
|
|
22584
|
+
throw new Error(errors.PUBKEY_COMBINE)
|
|
22585
|
+
case 3:
|
|
22586
|
+
throw new Error(errors.PUBKEY_SERIALIZE)
|
|
22587
|
+
}
|
|
22588
|
+
},
|
|
22663
22589
|
|
|
22664
|
-
|
|
22665
|
-
|
|
22666
|
-
|
|
22667
|
-
|
|
22590
|
+
publicKeyTweakAdd (pubkey, tweak, compressed = true, output) {
|
|
22591
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22592
|
+
isUint8Array('tweak', tweak, 32);
|
|
22593
|
+
isCompressed(compressed);
|
|
22594
|
+
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
22668
22595
|
|
|
22669
|
-
|
|
22670
|
-
|
|
22596
|
+
switch (secp256k1.publicKeyTweakAdd(output, pubkey, tweak)) {
|
|
22597
|
+
case 0:
|
|
22598
|
+
return output
|
|
22599
|
+
case 1:
|
|
22600
|
+
throw new Error(errors.PUBKEY_PARSE)
|
|
22601
|
+
case 2:
|
|
22602
|
+
throw new Error(errors.TWEAK_ADD)
|
|
22603
|
+
}
|
|
22604
|
+
},
|
|
22671
22605
|
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
22675
|
-
|
|
22606
|
+
publicKeyTweakMul (pubkey, tweak, compressed = true, output) {
|
|
22607
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22608
|
+
isUint8Array('tweak', tweak, 32);
|
|
22609
|
+
isCompressed(compressed);
|
|
22610
|
+
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
22676
22611
|
|
|
22677
|
-
|
|
22678
|
-
|
|
22612
|
+
switch (secp256k1.publicKeyTweakMul(output, pubkey, tweak)) {
|
|
22613
|
+
case 0:
|
|
22614
|
+
return output
|
|
22615
|
+
case 1:
|
|
22616
|
+
throw new Error(errors.PUBKEY_PARSE)
|
|
22617
|
+
case 2:
|
|
22618
|
+
throw new Error(errors.TWEAK_MUL)
|
|
22619
|
+
}
|
|
22620
|
+
},
|
|
22679
22621
|
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) return 1
|
|
22622
|
+
signatureNormalize (sig) {
|
|
22623
|
+
isUint8Array('signature', sig, 64);
|
|
22683
22624
|
|
|
22684
|
-
|
|
22625
|
+
switch (secp256k1.signatureNormalize(sig)) {
|
|
22626
|
+
case 0:
|
|
22627
|
+
return sig
|
|
22628
|
+
case 1:
|
|
22629
|
+
throw new Error(errors.SIG_PARSE)
|
|
22630
|
+
}
|
|
22631
|
+
},
|
|
22685
22632
|
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
point = ec.recoverPubKey(msg32, sigObj, recid);
|
|
22690
|
-
} catch (err) {
|
|
22691
|
-
return 2
|
|
22692
|
-
}
|
|
22633
|
+
signatureExport (sig, output) {
|
|
22634
|
+
isUint8Array('signature', sig, 64);
|
|
22635
|
+
output = getAssertedOutput(output, 72);
|
|
22693
22636
|
|
|
22694
|
-
|
|
22637
|
+
const obj = { output, outputlen: 72 };
|
|
22638
|
+
switch (secp256k1.signatureExport(obj, sig)) {
|
|
22639
|
+
case 0:
|
|
22640
|
+
return output.slice(0, obj.outputlen)
|
|
22641
|
+
case 1:
|
|
22642
|
+
throw new Error(errors.SIG_PARSE)
|
|
22643
|
+
case 2:
|
|
22644
|
+
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
22645
|
+
}
|
|
22646
|
+
},
|
|
22695
22647
|
|
|
22696
|
-
|
|
22697
|
-
|
|
22648
|
+
signatureImport (sig, output) {
|
|
22649
|
+
isUint8Array('signature', sig);
|
|
22650
|
+
output = getAssertedOutput(output, 64);
|
|
22698
22651
|
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22652
|
+
switch (secp256k1.signatureImport(output, sig)) {
|
|
22653
|
+
case 0:
|
|
22654
|
+
return output
|
|
22655
|
+
case 1:
|
|
22656
|
+
throw new Error(errors.SIG_PARSE)
|
|
22657
|
+
case 2:
|
|
22658
|
+
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
22659
|
+
}
|
|
22660
|
+
},
|
|
22702
22661
|
|
|
22703
|
-
|
|
22704
|
-
|
|
22662
|
+
ecdsaSign (msg32, seckey, options = {}, output) {
|
|
22663
|
+
isUint8Array('message', msg32, 32);
|
|
22664
|
+
isUint8Array('private key', seckey, 32);
|
|
22665
|
+
assert(toTypeString(options) === 'Object', 'Expected options to be an Object');
|
|
22666
|
+
if (options.data !== undefined) isUint8Array('options.data', options.data);
|
|
22667
|
+
if (options.noncefn !== undefined) assert(toTypeString(options.noncefn) === 'Function', 'Expected options.noncefn to be a Function');
|
|
22668
|
+
output = getAssertedOutput(output, 64);
|
|
22705
22669
|
|
|
22706
|
-
|
|
22670
|
+
const obj = { signature: output, recid: null };
|
|
22671
|
+
switch (secp256k1.ecdsaSign(obj, msg32, seckey, options.data, options.noncefn)) {
|
|
22672
|
+
case 0:
|
|
22673
|
+
return obj
|
|
22674
|
+
case 1:
|
|
22675
|
+
throw new Error(errors.SIGN)
|
|
22676
|
+
case 2:
|
|
22677
|
+
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
22678
|
+
}
|
|
22679
|
+
},
|
|
22707
22680
|
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
} else {
|
|
22713
|
-
if (!xbuf) xbuf = new Uint8Array(32);
|
|
22714
|
-
const x = point.getX().toArray('be', 32);
|
|
22715
|
-
for (let i = 0; i < 32; ++i) xbuf[i] = x[i];
|
|
22681
|
+
ecdsaVerify (sig, msg32, pubkey) {
|
|
22682
|
+
isUint8Array('signature', sig, 64);
|
|
22683
|
+
isUint8Array('message', msg32, 32);
|
|
22684
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22716
22685
|
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22686
|
+
switch (secp256k1.ecdsaVerify(sig, msg32, pubkey)) {
|
|
22687
|
+
case 0:
|
|
22688
|
+
return true
|
|
22689
|
+
case 3:
|
|
22690
|
+
return false
|
|
22691
|
+
case 1:
|
|
22692
|
+
throw new Error(errors.SIG_PARSE)
|
|
22693
|
+
case 2:
|
|
22694
|
+
throw new Error(errors.PUBKEY_PARSE)
|
|
22695
|
+
}
|
|
22696
|
+
},
|
|
22720
22697
|
|
|
22721
|
-
|
|
22698
|
+
ecdsaRecover (sig, recid, msg32, compressed = true, output) {
|
|
22699
|
+
isUint8Array('signature', sig, 64);
|
|
22700
|
+
assert(
|
|
22701
|
+
toTypeString(recid) === 'Number' &&
|
|
22702
|
+
recid >= 0 &&
|
|
22703
|
+
recid <= 3,
|
|
22704
|
+
'Expected recovery id to be a Number within interval [0, 3]'
|
|
22705
|
+
);
|
|
22706
|
+
isUint8Array('message', msg32, 32);
|
|
22707
|
+
isCompressed(compressed);
|
|
22708
|
+
output = getAssertedOutput(output, compressed ? 33 : 65);
|
|
22722
22709
|
|
|
22723
|
-
|
|
22724
|
-
|
|
22710
|
+
switch (secp256k1.ecdsaRecover(output, sig, recid, msg32)) {
|
|
22711
|
+
case 0:
|
|
22712
|
+
return output
|
|
22713
|
+
case 1:
|
|
22714
|
+
throw new Error(errors.SIG_PARSE)
|
|
22715
|
+
case 2:
|
|
22716
|
+
throw new Error(errors.RECOVER)
|
|
22717
|
+
case 3:
|
|
22718
|
+
throw new Error(errors.IMPOSSIBLE_CASE)
|
|
22719
|
+
}
|
|
22720
|
+
},
|
|
22725
22721
|
|
|
22726
|
-
|
|
22727
|
-
|
|
22722
|
+
ecdh (pubkey, seckey, options = {}, output) {
|
|
22723
|
+
isUint8Array('public key', pubkey, [33, 65]);
|
|
22724
|
+
isUint8Array('private key', seckey, 32);
|
|
22725
|
+
assert(toTypeString(options) === 'Object', 'Expected options to be an Object');
|
|
22726
|
+
if (options.data !== undefined) isUint8Array('options.data', options.data);
|
|
22727
|
+
if (options.hashfn !== undefined) {
|
|
22728
|
+
assert(toTypeString(options.hashfn) === 'Function', 'Expected options.hashfn to be a Function');
|
|
22729
|
+
if (options.xbuf !== undefined) isUint8Array('options.xbuf', options.xbuf, 32);
|
|
22730
|
+
if (options.ybuf !== undefined) isUint8Array('options.ybuf', options.ybuf, 32);
|
|
22731
|
+
isUint8Array('output', output);
|
|
22732
|
+
} else {
|
|
22733
|
+
output = getAssertedOutput(output, 32);
|
|
22734
|
+
}
|
|
22728
22735
|
|
|
22729
|
-
|
|
22736
|
+
switch (secp256k1.ecdh(output, pubkey, seckey, options.data, options.hashfn, options.xbuf, options.ybuf)) {
|
|
22737
|
+
case 0:
|
|
22738
|
+
return output
|
|
22739
|
+
case 1:
|
|
22740
|
+
throw new Error(errors.PUBKEY_PARSE)
|
|
22741
|
+
case 2:
|
|
22742
|
+
throw new Error(errors.ECDH)
|
|
22743
|
+
}
|
|
22744
|
+
}
|
|
22730
22745
|
}
|
|
22731
22746
|
};
|
|
22732
22747
|
|
|
@@ -24207,7 +24222,7 @@ b||"returnDetailedScanResult"in b)?(m=b.scanRegion,c=b.qrEngine,d=b.canvas,f=b.d
|
|
|
24207
24222
|
[d,k]=e._drawToCanvas(p,m,d,f);let q;if(c instanceof Worker){let g=c;b||e._postWorkerMessageSync(g,"inversionMode","both");q=await new Promise((l,v)=>{let w,u,r,y=-1;u=t=>{t.data.id===y&&(g.removeEventListener("message",u),g.removeEventListener("error",r),clearTimeout(w),null!==t.data.data?l({data:t.data.data,cornerPoints:e._convertPoints(t.data.cornerPoints,m)}):v(e.NO_QR_CODE_FOUND));};r=t=>{g.removeEventListener("message",u);g.removeEventListener("error",r);clearTimeout(w);v("Scanner error: "+(t?
|
|
24208
24223
|
t.message||t:"Unknown Error"));};g.addEventListener("message",u);g.addEventListener("error",r);w=setTimeout(()=>r("timeout"),1E4);let x=k.getImageData(0,0,d.width,d.height);y=e._postWorkerMessageSync(g,"decode",x,[x.data.buffer]);});}else q=await Promise.race([new Promise((g,l)=>window.setTimeout(()=>l("Scanner error: timeout"),1E4)),(async()=>{try{var [g]=await c.detect(d);if(!g)throw e.NO_QR_CODE_FOUND;return {data:g.rawValue,cornerPoints:e._convertPoints(g.cornerPoints,m)}}catch(l){g=l.message||l;
|
|
24209
24224
|
if(/not implemented|service unavailable/.test(g))return e._disableBarcodeDetector=!0,e.scanImage(a,{scanRegion:m,canvas:d,disallowCanvasResizing:f,alsoTryWithoutScanRegion:h});throw `Scanner error: ${g}`;}})()]);return n?q:q.data}catch(p){if(!m||!h)throw p;let k=await e.scanImage(a,{qrEngine:c,canvas:d,disallowCanvasResizing:f});return n?k:k.data}finally{b||e._postWorkerMessage(c,"close");}}setGrayscaleWeights(a,b,c,d=!0){e._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:a,green:b,
|
|
24210
|
-
blue:c,useIntegerApproximation:d});}setInversionMode(a){e._postWorkerMessage(this._qrEnginePromise,"inversionMode",a);}static async createQrEngine(a){a&&console.warn("Specifying a worker path is not required and not supported anymore.");a=()=>import('./qr-scanner-worker.min-
|
|
24225
|
+
blue:c,useIntegerApproximation:d});}setInversionMode(a){e._postWorkerMessage(this._qrEnginePromise,"inversionMode",a);}static async createQrEngine(a){a&&console.warn("Specifying a worker path is not required and not supported anymore.");a=()=>import('./qr-scanner-worker.min-RaSiJc_R-RaSiJc_R.js').then(c=>c.createWorker());if(!(!e._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return a();let b=navigator.userAgentData;
|
|
24211
24226
|
return b&&b.brands.some(({brand:c})=>/Chromium/i.test(c))&&/mac ?OS/i.test(b.platform)&&await b.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:c,platformVersion:d})=>/arm/i.test(c||"arm")&&13<=parseInt(d||"13")).catch(()=>!0)?a():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video);this._updateOverlay();this.$overlay&&(this.$overlay.style.display="");this._scanFrame();}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video);
|
|
24212
24227
|
this._updateOverlay();}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start();}_calculateScanRegion(a){let b=Math.round(2/3*Math.min(a.videoWidth,a.videoHeight));return {x:Math.round((a.videoWidth-b)/2),y:Math.round((a.videoHeight-b)/2),width:b,height:b,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var a=this.$video,b=a.videoWidth,c=a.videoHeight,d=a.offsetWidth,f=a.offsetHeight,h=a.offsetLeft,
|
|
24213
24228
|
m=a.offsetTop,n=window.getComputedStyle(a),p=n.objectFit,k=b/c,q=d/f;switch(p){case "none":var g=b;var l=c;break;case "fill":g=d;l=f;break;default:("cover"===p?k>q:k<q)?(l=f,g=l*k):(g=d,l=g/k),"scale-down"===p&&(g=Math.min(g,b),l=Math.min(l,c));}var [v,w]=n.objectPosition.split(" ").map((r,y)=>{const x=parseFloat(r);return r.endsWith("%")?(y?f-l:d-g)*x/100:x});n=this._scanRegion.width||b;q=this._scanRegion.height||c;p=this._scanRegion.x||0;var u=this._scanRegion.y||0;k=this.$overlay.style;k.width=
|
|
@@ -27181,7 +27196,7 @@ class Identity {
|
|
|
27181
27196
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
27182
27197
|
}
|
|
27183
27198
|
else {
|
|
27184
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
27199
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-ub31QSed-EMPr2oeb.js');
|
|
27185
27200
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
27186
27201
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
27187
27202
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -27231,6 +27246,7 @@ globalThis.LeofcoinStorage = LeofcoinStorage$1;
|
|
|
27231
27246
|
globalThis.leofcoin = globalThis.leofcoin || {};
|
|
27232
27247
|
globalThis.pubsub = globalThis.pubsub || new LittlePubSub();
|
|
27233
27248
|
globalThis.globalSub = globalThis.globalSub || new LittlePubSub();
|
|
27249
|
+
const debug = globalThis.createDebugger('peernet');
|
|
27234
27250
|
/**
|
|
27235
27251
|
* @access public
|
|
27236
27252
|
* @example
|
|
@@ -27372,7 +27388,7 @@ class Peernet {
|
|
|
27372
27388
|
this.root = options.root;
|
|
27373
27389
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
27374
27390
|
// FolderMessageResponse
|
|
27375
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
27391
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-guyZfse6-JeAlT5Nb.js');
|
|
27376
27392
|
/**
|
|
27377
27393
|
* proto Object containing protos
|
|
27378
27394
|
* @type {Object}
|
|
@@ -27466,7 +27482,7 @@ class Peernet {
|
|
|
27466
27482
|
if (this.#starting || this.#started)
|
|
27467
27483
|
return;
|
|
27468
27484
|
this.#starting = true;
|
|
27469
|
-
const importee = await import('./client-
|
|
27485
|
+
const importee = await import('./client-UOCjJBGl-pbv-pTHd.js');
|
|
27470
27486
|
/**
|
|
27471
27487
|
* @access public
|
|
27472
27488
|
* @type {PeernetClient}
|