koilib 9.1.1 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/koinos.js +1682 -393
- package/dist/koinos.min.js +1 -1
- package/lib/Multicall.d.ts +79 -0
- package/lib/Multicall.js +104 -0
- package/lib/Multicall.js.map +1 -0
- package/lib/abis/multicallAbi.d.ts +2 -0
- package/lib/abis/multicallAbi.js +127 -0
- package/lib/abis/multicallAbi.js.map +1 -0
- package/lib/browser/Multicall.d.ts +79 -0
- package/lib/browser/Multicall.js +104 -0
- package/lib/browser/Multicall.js.map +1 -0
- package/lib/browser/abis/multicallAbi.d.ts +2 -0
- package/lib/browser/abis/multicallAbi.js +127 -0
- package/lib/browser/abis/multicallAbi.js.map +1 -0
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index2.js +2 -0
- package/lib/browser/index2.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index2.js +2 -0
- package/lib/index2.js.map +1 -1
- package/package.json +1 -1
- package/src/Multicall.ts +139 -0
- package/src/abis/multicallAbi.ts +127 -0
- package/src/index.ts +1 -0
- package/src/index2.ts +2 -0
package/dist/koinos.js
CHANGED
|
@@ -153,9 +153,9 @@ function bool(b) {
|
|
|
153
153
|
exports.bool = bool;
|
|
154
154
|
function bytes(b, ...lengths) {
|
|
155
155
|
if (!(b instanceof Uint8Array))
|
|
156
|
-
throw new
|
|
156
|
+
throw new Error('Expected Uint8Array');
|
|
157
157
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
158
|
-
throw new
|
|
158
|
+
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
159
159
|
}
|
|
160
160
|
exports.bytes = bytes;
|
|
161
161
|
function hash(hash) {
|
|
@@ -189,7 +189,7 @@ const assert = {
|
|
|
189
189
|
output,
|
|
190
190
|
};
|
|
191
191
|
exports["default"] = assert;
|
|
192
|
-
|
|
192
|
+
//# sourceMappingURL=_assert.js.map
|
|
193
193
|
|
|
194
194
|
/***/ }),
|
|
195
195
|
|
|
@@ -282,7 +282,16 @@ class SHA2 extends utils_js_1.Hash {
|
|
|
282
282
|
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
283
283
|
this.process(view, 0);
|
|
284
284
|
const oview = (0, utils_js_1.createView)(out);
|
|
285
|
-
|
|
285
|
+
const len = this.outputLen;
|
|
286
|
+
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
287
|
+
if (len % 4)
|
|
288
|
+
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
289
|
+
const outLen = len / 4;
|
|
290
|
+
const state = this.get();
|
|
291
|
+
if (outLen > state.length)
|
|
292
|
+
throw new Error('_sha2: outputLen bigger than state');
|
|
293
|
+
for (let i = 0; i < outLen; i++)
|
|
294
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
286
295
|
}
|
|
287
296
|
digest() {
|
|
288
297
|
const { buffer, outputLen } = this;
|
|
@@ -305,22 +314,19 @@ class SHA2 extends utils_js_1.Hash {
|
|
|
305
314
|
}
|
|
306
315
|
}
|
|
307
316
|
exports.SHA2 = SHA2;
|
|
308
|
-
|
|
317
|
+
//# sourceMappingURL=_sha2.js.map
|
|
309
318
|
|
|
310
319
|
/***/ }),
|
|
311
320
|
|
|
312
|
-
/***/
|
|
321
|
+
/***/ 1945:
|
|
313
322
|
/***/ ((__unused_webpack_module, exports) => {
|
|
314
323
|
|
|
315
324
|
"use strict";
|
|
316
325
|
|
|
317
326
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
318
327
|
exports.crypto = void 0;
|
|
319
|
-
exports.crypto =
|
|
320
|
-
|
|
321
|
-
web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,
|
|
322
|
-
};
|
|
323
|
-
|
|
328
|
+
exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
329
|
+
//# sourceMappingURL=crypto.js.map
|
|
324
330
|
|
|
325
331
|
/***/ }),
|
|
326
332
|
|
|
@@ -431,7 +437,7 @@ exports.RIPEMD160 = RIPEMD160;
|
|
|
431
437
|
* @param message - msg that would be hashed
|
|
432
438
|
*/
|
|
433
439
|
exports.ripemd160 = (0, utils_js_1.wrapConstructor)(() => new RIPEMD160());
|
|
434
|
-
|
|
440
|
+
//# sourceMappingURL=ripemd160.js.map
|
|
435
441
|
|
|
436
442
|
/***/ }),
|
|
437
443
|
|
|
@@ -441,7 +447,7 @@ exports.ripemd160 = (0, utils_js_1.wrapConstructor)(() => new RIPEMD160());
|
|
|
441
447
|
"use strict";
|
|
442
448
|
|
|
443
449
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
444
|
-
exports.sha256 = void 0;
|
|
450
|
+
exports.sha224 = exports.sha256 = void 0;
|
|
445
451
|
const _sha2_js_1 = __webpack_require__(7505);
|
|
446
452
|
const utils_js_1 = __webpack_require__(8089);
|
|
447
453
|
// Choice: a ? b : c
|
|
@@ -544,12 +550,28 @@ class SHA256 extends _sha2_js_1.SHA2 {
|
|
|
544
550
|
this.buffer.fill(0);
|
|
545
551
|
}
|
|
546
552
|
}
|
|
553
|
+
// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
|
|
554
|
+
class SHA224 extends SHA256 {
|
|
555
|
+
constructor() {
|
|
556
|
+
super();
|
|
557
|
+
this.A = 0xc1059ed8 | 0;
|
|
558
|
+
this.B = 0x367cd507 | 0;
|
|
559
|
+
this.C = 0x3070dd17 | 0;
|
|
560
|
+
this.D = 0xf70e5939 | 0;
|
|
561
|
+
this.E = 0xffc00b31 | 0;
|
|
562
|
+
this.F = 0x68581511 | 0;
|
|
563
|
+
this.G = 0x64f98fa7 | 0;
|
|
564
|
+
this.H = 0xbefa4fa4 | 0;
|
|
565
|
+
this.outputLen = 28;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
547
568
|
/**
|
|
548
569
|
* SHA2-256 hash function
|
|
549
570
|
* @param message - data that would be hashed
|
|
550
571
|
*/
|
|
551
572
|
exports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256());
|
|
552
|
-
|
|
573
|
+
exports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224());
|
|
574
|
+
//# sourceMappingURL=sha256.js.map
|
|
553
575
|
|
|
554
576
|
/***/ }),
|
|
555
577
|
|
|
@@ -560,10 +582,15 @@ exports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256());
|
|
|
560
582
|
|
|
561
583
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
562
584
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
563
|
-
exports.randomBytes = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;
|
|
564
|
-
//
|
|
565
|
-
//
|
|
566
|
-
|
|
585
|
+
exports.randomBytes = exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;
|
|
586
|
+
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
587
|
+
// node.js versions earlier than v19 don't declare it in global scope.
|
|
588
|
+
// For node.js, package.json#exports field mapping rewrites import
|
|
589
|
+
// from `crypto` to `cryptoNode`, which imports native module.
|
|
590
|
+
// Makes the utils un-importable in browsers without a bundler.
|
|
591
|
+
// Once node.js 18 is deprecated, we can just drop the import.
|
|
592
|
+
const crypto_1 = __webpack_require__(1945);
|
|
593
|
+
const u8a = (a) => a instanceof Uint8Array;
|
|
567
594
|
// Cast array to different type
|
|
568
595
|
const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
569
596
|
exports.u8 = u8;
|
|
@@ -575,36 +602,36 @@ exports.createView = createView;
|
|
|
575
602
|
// The rotate right (circular right shift) operation for uint32
|
|
576
603
|
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
577
604
|
exports.rotr = rotr;
|
|
605
|
+
// big-endian hardware is rare. Just in case someone still decides to run hashes:
|
|
606
|
+
// early-throw an error because we don't support BE yet.
|
|
578
607
|
exports.isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
579
|
-
// There is almost no big endian hardware, but js typed arrays uses platform specific endianness.
|
|
580
|
-
// So, just to be sure not to corrupt anything.
|
|
581
608
|
if (!exports.isLE)
|
|
582
609
|
throw new Error('Non little-endian hardware is not supported');
|
|
583
610
|
const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
|
|
584
611
|
/**
|
|
585
|
-
* @example bytesToHex(Uint8Array.from([
|
|
612
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
586
613
|
*/
|
|
587
|
-
function bytesToHex(
|
|
588
|
-
|
|
589
|
-
if (!(uint8a instanceof Uint8Array))
|
|
614
|
+
function bytesToHex(bytes) {
|
|
615
|
+
if (!u8a(bytes))
|
|
590
616
|
throw new Error('Uint8Array expected');
|
|
617
|
+
// pre-caching improves the speed 6x
|
|
591
618
|
let hex = '';
|
|
592
|
-
for (let i = 0; i <
|
|
593
|
-
hex += hexes[
|
|
619
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
620
|
+
hex += hexes[bytes[i]];
|
|
594
621
|
}
|
|
595
622
|
return hex;
|
|
596
623
|
}
|
|
597
624
|
exports.bytesToHex = bytesToHex;
|
|
598
625
|
/**
|
|
599
|
-
* @example hexToBytes('
|
|
626
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
600
627
|
*/
|
|
601
628
|
function hexToBytes(hex) {
|
|
602
|
-
if (typeof hex !== 'string')
|
|
603
|
-
throw new
|
|
604
|
-
|
|
605
|
-
if (
|
|
606
|
-
throw new Error('
|
|
607
|
-
const array = new Uint8Array(
|
|
629
|
+
if (typeof hex !== 'string')
|
|
630
|
+
throw new Error('hex string expected, got ' + typeof hex);
|
|
631
|
+
const len = hex.length;
|
|
632
|
+
if (len % 2)
|
|
633
|
+
throw new Error('padded hex string expected, got unpadded hex of length ' + len);
|
|
634
|
+
const array = new Uint8Array(len / 2);
|
|
608
635
|
for (let i = 0; i < array.length; i++) {
|
|
609
636
|
const j = i * 2;
|
|
610
637
|
const hexByte = hex.slice(j, j + 2);
|
|
@@ -616,8 +643,9 @@ function hexToBytes(hex) {
|
|
|
616
643
|
return array;
|
|
617
644
|
}
|
|
618
645
|
exports.hexToBytes = hexToBytes;
|
|
619
|
-
// There is no setImmediate in browser and setTimeout is slow.
|
|
620
|
-
//
|
|
646
|
+
// There is no setImmediate in browser and setTimeout is slow.
|
|
647
|
+
// call of async fn will return Promise, which will be fullfiled only on
|
|
648
|
+
// next scheduler queue processing step and this is exactly what we need.
|
|
621
649
|
const nextTick = async () => { };
|
|
622
650
|
exports.nextTick = nextTick;
|
|
623
651
|
// Returns control to thread each 'tick' ms to avoid blocking
|
|
@@ -634,38 +662,41 @@ async function asyncLoop(iters, tick, cb) {
|
|
|
634
662
|
}
|
|
635
663
|
}
|
|
636
664
|
exports.asyncLoop = asyncLoop;
|
|
665
|
+
/**
|
|
666
|
+
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
|
667
|
+
*/
|
|
637
668
|
function utf8ToBytes(str) {
|
|
638
|
-
if (typeof str !== 'string')
|
|
639
|
-
throw new
|
|
640
|
-
|
|
641
|
-
return new TextEncoder().encode(str);
|
|
669
|
+
if (typeof str !== 'string')
|
|
670
|
+
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
671
|
+
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
642
672
|
}
|
|
643
673
|
exports.utf8ToBytes = utf8ToBytes;
|
|
674
|
+
/**
|
|
675
|
+
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
676
|
+
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
677
|
+
* Keep in mind for future mutable operations.
|
|
678
|
+
*/
|
|
644
679
|
function toBytes(data) {
|
|
645
680
|
if (typeof data === 'string')
|
|
646
681
|
data = utf8ToBytes(data);
|
|
647
|
-
if (!(data
|
|
648
|
-
throw new
|
|
682
|
+
if (!u8a(data))
|
|
683
|
+
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
649
684
|
return data;
|
|
650
685
|
}
|
|
651
686
|
exports.toBytes = toBytes;
|
|
652
687
|
/**
|
|
653
|
-
*
|
|
654
|
-
* @example concatBytes(buf1, buf2)
|
|
688
|
+
* Copies several Uint8Arrays into one.
|
|
655
689
|
*/
|
|
656
690
|
function concatBytes(...arrays) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
pad += arr.length;
|
|
667
|
-
}
|
|
668
|
-
return result;
|
|
691
|
+
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
692
|
+
let pad = 0; // walk through each item, ensure they have proper type
|
|
693
|
+
arrays.forEach((a) => {
|
|
694
|
+
if (!u8a(a))
|
|
695
|
+
throw new Error('Uint8Array expected');
|
|
696
|
+
r.set(a, pad);
|
|
697
|
+
pad += a.length;
|
|
698
|
+
});
|
|
699
|
+
return r;
|
|
669
700
|
}
|
|
670
701
|
exports.concatBytes = concatBytes;
|
|
671
702
|
// For runtime check if class implements interface
|
|
@@ -680,17 +711,17 @@ exports.Hash = Hash;
|
|
|
680
711
|
const isPlainObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object;
|
|
681
712
|
function checkOpts(defaults, opts) {
|
|
682
713
|
if (opts !== undefined && (typeof opts !== 'object' || !isPlainObject(opts)))
|
|
683
|
-
throw new
|
|
714
|
+
throw new Error('Options should be object or undefined');
|
|
684
715
|
const merged = Object.assign(defaults, opts);
|
|
685
716
|
return merged;
|
|
686
717
|
}
|
|
687
718
|
exports.checkOpts = checkOpts;
|
|
688
|
-
function wrapConstructor(
|
|
689
|
-
const hashC = (
|
|
690
|
-
const tmp =
|
|
719
|
+
function wrapConstructor(hashCons) {
|
|
720
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
721
|
+
const tmp = hashCons();
|
|
691
722
|
hashC.outputLen = tmp.outputLen;
|
|
692
723
|
hashC.blockLen = tmp.blockLen;
|
|
693
|
-
hashC.create = () =>
|
|
724
|
+
hashC.create = () => hashCons();
|
|
694
725
|
return hashC;
|
|
695
726
|
}
|
|
696
727
|
exports.wrapConstructor = wrapConstructor;
|
|
@@ -703,22 +734,26 @@ function wrapConstructorWithOpts(hashCons) {
|
|
|
703
734
|
return hashC;
|
|
704
735
|
}
|
|
705
736
|
exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
|
|
737
|
+
function wrapXOFConstructorWithOpts(hashCons) {
|
|
738
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
739
|
+
const tmp = hashCons({});
|
|
740
|
+
hashC.outputLen = tmp.outputLen;
|
|
741
|
+
hashC.blockLen = tmp.blockLen;
|
|
742
|
+
hashC.create = (opts) => hashCons(opts);
|
|
743
|
+
return hashC;
|
|
744
|
+
}
|
|
745
|
+
exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
|
|
706
746
|
/**
|
|
707
|
-
* Secure PRNG
|
|
747
|
+
* Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
|
|
708
748
|
*/
|
|
709
749
|
function randomBytes(bytesLength = 32) {
|
|
710
|
-
if (crypto_1.crypto.
|
|
711
|
-
return crypto_1.crypto.
|
|
712
|
-
}
|
|
713
|
-
else if (crypto_1.crypto.node) {
|
|
714
|
-
return new Uint8Array(crypto_1.crypto.node.randomBytes(bytesLength).buffer);
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
throw new Error("The environment doesn't have randomBytes function");
|
|
750
|
+
if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') {
|
|
751
|
+
return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
718
752
|
}
|
|
753
|
+
throw new Error('crypto.getRandomValues must be defined');
|
|
719
754
|
}
|
|
720
755
|
exports.randomBytes = randomBytes;
|
|
721
|
-
|
|
756
|
+
//# sourceMappingURL=utils.js.map
|
|
722
757
|
|
|
723
758
|
/***/ }),
|
|
724
759
|
|
|
@@ -736,25 +771,64 @@ const _1n = BigInt(1);
|
|
|
736
771
|
const _2n = BigInt(2);
|
|
737
772
|
const _3n = BigInt(3);
|
|
738
773
|
const _8n = BigInt(8);
|
|
739
|
-
const
|
|
740
|
-
const CURVE = {
|
|
774
|
+
const CURVE = Object.freeze({
|
|
741
775
|
a: _0n,
|
|
742
776
|
b: BigInt(7),
|
|
743
|
-
P:
|
|
744
|
-
n:
|
|
777
|
+
P: BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f'),
|
|
778
|
+
n: BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'),
|
|
745
779
|
h: _1n,
|
|
746
780
|
Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),
|
|
747
781
|
Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),
|
|
748
782
|
beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),
|
|
749
|
-
};
|
|
783
|
+
});
|
|
750
784
|
exports.CURVE = CURVE;
|
|
751
|
-
|
|
785
|
+
const divNearest = (a, b) => (a + b / _2n) / b;
|
|
786
|
+
const endo = {
|
|
787
|
+
beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),
|
|
788
|
+
splitScalar(k) {
|
|
789
|
+
const { n } = CURVE;
|
|
790
|
+
const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');
|
|
791
|
+
const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');
|
|
792
|
+
const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');
|
|
793
|
+
const b2 = a1;
|
|
794
|
+
const POW_2_128 = BigInt('0x100000000000000000000000000000000');
|
|
795
|
+
const c1 = divNearest(b2 * k, n);
|
|
796
|
+
const c2 = divNearest(-b1 * k, n);
|
|
797
|
+
let k1 = mod(k - c1 * a1 - c2 * a2, n);
|
|
798
|
+
let k2 = mod(-c1 * b1 - c2 * b2, n);
|
|
799
|
+
const k1neg = k1 > POW_2_128;
|
|
800
|
+
const k2neg = k2 > POW_2_128;
|
|
801
|
+
if (k1neg)
|
|
802
|
+
k1 = n - k1;
|
|
803
|
+
if (k2neg)
|
|
804
|
+
k2 = n - k2;
|
|
805
|
+
if (k1 > POW_2_128 || k2 > POW_2_128) {
|
|
806
|
+
throw new Error('splitScalarEndo: Endomorphism failed, k=' + k);
|
|
807
|
+
}
|
|
808
|
+
return { k1neg, k1, k2neg, k2 };
|
|
809
|
+
},
|
|
810
|
+
};
|
|
811
|
+
const fieldLen = 32;
|
|
812
|
+
const groupLen = 32;
|
|
813
|
+
const hashLen = 32;
|
|
814
|
+
const compressedLen = fieldLen + 1;
|
|
815
|
+
const uncompressedLen = 2 * fieldLen + 1;
|
|
816
|
+
function weierstrass(x) {
|
|
752
817
|
const { a, b } = CURVE;
|
|
753
818
|
const x2 = mod(x * x);
|
|
754
819
|
const x3 = mod(x2 * x);
|
|
755
820
|
return mod(x3 + a * x + b);
|
|
756
821
|
}
|
|
757
822
|
const USE_ENDOMORPHISM = CURVE.a === _0n;
|
|
823
|
+
class ShaError extends Error {
|
|
824
|
+
constructor(message) {
|
|
825
|
+
super(message);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
function assertJacPoint(other) {
|
|
829
|
+
if (!(other instanceof JacobianPoint))
|
|
830
|
+
throw new TypeError('JacobianPoint expected');
|
|
831
|
+
}
|
|
758
832
|
class JacobianPoint {
|
|
759
833
|
constructor(x, y, z) {
|
|
760
834
|
this.x = x;
|
|
@@ -765,6 +839,8 @@ class JacobianPoint {
|
|
|
765
839
|
if (!(p instanceof Point)) {
|
|
766
840
|
throw new TypeError('JacobianPoint#fromAffine: expected Point');
|
|
767
841
|
}
|
|
842
|
+
if (p.equals(Point.ZERO))
|
|
843
|
+
return JacobianPoint.ZERO;
|
|
768
844
|
return new JacobianPoint(p.x, p.y, _1n);
|
|
769
845
|
}
|
|
770
846
|
static toAffineBatch(points) {
|
|
@@ -775,12 +851,11 @@ class JacobianPoint {
|
|
|
775
851
|
return JacobianPoint.toAffineBatch(points).map(JacobianPoint.fromAffine);
|
|
776
852
|
}
|
|
777
853
|
equals(other) {
|
|
778
|
-
|
|
779
|
-
throw new TypeError('JacobianPoint expected');
|
|
854
|
+
assertJacPoint(other);
|
|
780
855
|
const { x: X1, y: Y1, z: Z1 } = this;
|
|
781
856
|
const { x: X2, y: Y2, z: Z2 } = other;
|
|
782
|
-
const Z1Z1 = mod(Z1
|
|
783
|
-
const Z2Z2 = mod(Z2
|
|
857
|
+
const Z1Z1 = mod(Z1 * Z1);
|
|
858
|
+
const Z2Z2 = mod(Z2 * Z2);
|
|
784
859
|
const U1 = mod(X1 * Z2Z2);
|
|
785
860
|
const U2 = mod(X2 * Z1Z1);
|
|
786
861
|
const S1 = mod(mod(Y1 * Z2) * Z2Z2);
|
|
@@ -792,28 +867,28 @@ class JacobianPoint {
|
|
|
792
867
|
}
|
|
793
868
|
double() {
|
|
794
869
|
const { x: X1, y: Y1, z: Z1 } = this;
|
|
795
|
-
const A = mod(X1
|
|
796
|
-
const B = mod(Y1
|
|
797
|
-
const C = mod(B
|
|
798
|
-
const
|
|
870
|
+
const A = mod(X1 * X1);
|
|
871
|
+
const B = mod(Y1 * Y1);
|
|
872
|
+
const C = mod(B * B);
|
|
873
|
+
const x1b = X1 + B;
|
|
874
|
+
const D = mod(_2n * (mod(x1b * x1b) - A - C));
|
|
799
875
|
const E = mod(_3n * A);
|
|
800
|
-
const F = mod(E
|
|
876
|
+
const F = mod(E * E);
|
|
801
877
|
const X3 = mod(F - _2n * D);
|
|
802
878
|
const Y3 = mod(E * (D - X3) - _8n * C);
|
|
803
879
|
const Z3 = mod(_2n * Y1 * Z1);
|
|
804
880
|
return new JacobianPoint(X3, Y3, Z3);
|
|
805
881
|
}
|
|
806
882
|
add(other) {
|
|
807
|
-
|
|
808
|
-
throw new TypeError('JacobianPoint expected');
|
|
883
|
+
assertJacPoint(other);
|
|
809
884
|
const { x: X1, y: Y1, z: Z1 } = this;
|
|
810
885
|
const { x: X2, y: Y2, z: Z2 } = other;
|
|
811
886
|
if (X2 === _0n || Y2 === _0n)
|
|
812
887
|
return this;
|
|
813
888
|
if (X1 === _0n || Y1 === _0n)
|
|
814
889
|
return other;
|
|
815
|
-
const Z1Z1 = mod(Z1
|
|
816
|
-
const Z2Z2 = mod(Z2
|
|
890
|
+
const Z1Z1 = mod(Z1 * Z1);
|
|
891
|
+
const Z2Z2 = mod(Z2 * Z2);
|
|
817
892
|
const U1 = mod(X1 * Z2Z2);
|
|
818
893
|
const U2 = mod(X2 * Z1Z1);
|
|
819
894
|
const S1 = mod(mod(Y1 * Z2) * Z2Z2);
|
|
@@ -828,10 +903,10 @@ class JacobianPoint {
|
|
|
828
903
|
return JacobianPoint.ZERO;
|
|
829
904
|
}
|
|
830
905
|
}
|
|
831
|
-
const HH = mod(H
|
|
906
|
+
const HH = mod(H * H);
|
|
832
907
|
const HHH = mod(H * HH);
|
|
833
908
|
const V = mod(U1 * HH);
|
|
834
|
-
const X3 = mod(r
|
|
909
|
+
const X3 = mod(r * r - HHH - _2n * V);
|
|
835
910
|
const Y3 = mod(r * (V - X3) - S1 * HHH);
|
|
836
911
|
const Z3 = mod(Z1 * Z2 * H);
|
|
837
912
|
return new JacobianPoint(X3, Y3, Z3);
|
|
@@ -857,7 +932,7 @@ class JacobianPoint {
|
|
|
857
932
|
}
|
|
858
933
|
return p;
|
|
859
934
|
}
|
|
860
|
-
let { k1neg, k1, k2neg, k2 } =
|
|
935
|
+
let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);
|
|
861
936
|
let k1p = P0;
|
|
862
937
|
let k2p = P0;
|
|
863
938
|
let d = this;
|
|
@@ -874,7 +949,7 @@ class JacobianPoint {
|
|
|
874
949
|
k1p = k1p.negate();
|
|
875
950
|
if (k2neg)
|
|
876
951
|
k2p = k2p.negate();
|
|
877
|
-
k2p = new JacobianPoint(mod(k2p.x *
|
|
952
|
+
k2p = new JacobianPoint(mod(k2p.x * endo.beta), k2p.y, k2p.z);
|
|
878
953
|
return k1p.add(k2p);
|
|
879
954
|
}
|
|
880
955
|
precomputeWindow(W) {
|
|
@@ -909,7 +984,7 @@ class JacobianPoint {
|
|
|
909
984
|
}
|
|
910
985
|
}
|
|
911
986
|
let p = JacobianPoint.ZERO;
|
|
912
|
-
let f = JacobianPoint.
|
|
987
|
+
let f = JacobianPoint.BASE;
|
|
913
988
|
const windows = 1 + (USE_ENDOMORPHISM ? 128 / W : 256 / W);
|
|
914
989
|
const windowSize = 2 ** (W - 1);
|
|
915
990
|
const mask = BigInt(2 ** W - 1);
|
|
@@ -923,17 +998,15 @@ class JacobianPoint {
|
|
|
923
998
|
wbits -= maxNumber;
|
|
924
999
|
n += _1n;
|
|
925
1000
|
}
|
|
1001
|
+
const offset1 = offset;
|
|
1002
|
+
const offset2 = offset + Math.abs(wbits) - 1;
|
|
1003
|
+
const cond1 = window % 2 !== 0;
|
|
1004
|
+
const cond2 = wbits < 0;
|
|
926
1005
|
if (wbits === 0) {
|
|
927
|
-
|
|
928
|
-
if (window % 2)
|
|
929
|
-
pr = pr.negate();
|
|
930
|
-
f = f.add(pr);
|
|
1006
|
+
f = f.add(constTimeNegate(cond1, precomputes[offset1]));
|
|
931
1007
|
}
|
|
932
1008
|
else {
|
|
933
|
-
|
|
934
|
-
if (wbits < 0)
|
|
935
|
-
cached = cached.negate();
|
|
936
|
-
p = p.add(cached);
|
|
1009
|
+
p = p.add(constTimeNegate(cond2, precomputes[offset2]));
|
|
937
1010
|
}
|
|
938
1011
|
}
|
|
939
1012
|
return { p, f };
|
|
@@ -943,14 +1016,12 @@ class JacobianPoint {
|
|
|
943
1016
|
let point;
|
|
944
1017
|
let fake;
|
|
945
1018
|
if (USE_ENDOMORPHISM) {
|
|
946
|
-
const { k1neg, k1, k2neg, k2 } =
|
|
1019
|
+
const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);
|
|
947
1020
|
let { p: k1p, f: f1p } = this.wNAF(k1, affinePoint);
|
|
948
1021
|
let { p: k2p, f: f2p } = this.wNAF(k2, affinePoint);
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
k2p = k2p.negate();
|
|
953
|
-
k2p = new JacobianPoint(mod(k2p.x * CURVE.beta), k2p.y, k2p.z);
|
|
1022
|
+
k1p = constTimeNegate(k1neg, k1p);
|
|
1023
|
+
k2p = constTimeNegate(k2neg, k2p);
|
|
1024
|
+
k2p = new JacobianPoint(mod(k2p.x * endo.beta), k2p.y, k2p.z);
|
|
954
1025
|
point = k1p.add(k2p);
|
|
955
1026
|
fake = f1p.add(f2p);
|
|
956
1027
|
}
|
|
@@ -961,14 +1032,19 @@ class JacobianPoint {
|
|
|
961
1032
|
}
|
|
962
1033
|
return JacobianPoint.normalizeZ([point, fake])[0];
|
|
963
1034
|
}
|
|
964
|
-
toAffine(invZ
|
|
1035
|
+
toAffine(invZ) {
|
|
965
1036
|
const { x, y, z } = this;
|
|
1037
|
+
const is0 = this.equals(JacobianPoint.ZERO);
|
|
1038
|
+
if (invZ == null)
|
|
1039
|
+
invZ = is0 ? _8n : invert(z);
|
|
966
1040
|
const iz1 = invZ;
|
|
967
1041
|
const iz2 = mod(iz1 * iz1);
|
|
968
1042
|
const iz3 = mod(iz2 * iz1);
|
|
969
1043
|
const ax = mod(x * iz2);
|
|
970
1044
|
const ay = mod(y * iz3);
|
|
971
1045
|
const zz = mod(z * iz1);
|
|
1046
|
+
if (is0)
|
|
1047
|
+
return Point.ZERO;
|
|
972
1048
|
if (zz !== _1n)
|
|
973
1049
|
throw new Error('invZ was invalid');
|
|
974
1050
|
return new Point(ax, ay);
|
|
@@ -976,6 +1052,10 @@ class JacobianPoint {
|
|
|
976
1052
|
}
|
|
977
1053
|
JacobianPoint.BASE = new JacobianPoint(CURVE.Gx, CURVE.Gy, _1n);
|
|
978
1054
|
JacobianPoint.ZERO = new JacobianPoint(_0n, _1n, _0n);
|
|
1055
|
+
function constTimeNegate(condition, item) {
|
|
1056
|
+
const neg = item.negate();
|
|
1057
|
+
return condition ? neg : item;
|
|
1058
|
+
}
|
|
979
1059
|
const pointPrecomputes = new WeakMap();
|
|
980
1060
|
class Point {
|
|
981
1061
|
constructor(x, y) {
|
|
@@ -986,12 +1066,15 @@ class Point {
|
|
|
986
1066
|
this._WINDOW_SIZE = windowSize;
|
|
987
1067
|
pointPrecomputes.delete(this);
|
|
988
1068
|
}
|
|
1069
|
+
hasEvenY() {
|
|
1070
|
+
return this.y % _2n === _0n;
|
|
1071
|
+
}
|
|
989
1072
|
static fromCompressedHex(bytes) {
|
|
990
1073
|
const isShort = bytes.length === 32;
|
|
991
1074
|
const x = bytesToNumber(isShort ? bytes : bytes.subarray(1));
|
|
992
1075
|
if (!isValidFieldElement(x))
|
|
993
1076
|
throw new Error('Point is not on curve');
|
|
994
|
-
const y2 =
|
|
1077
|
+
const y2 = weierstrass(x);
|
|
995
1078
|
let y = sqrtMod(y2);
|
|
996
1079
|
const isYOdd = (y & _1n) === _1n;
|
|
997
1080
|
if (isShort) {
|
|
@@ -1008,8 +1091,8 @@ class Point {
|
|
|
1008
1091
|
return point;
|
|
1009
1092
|
}
|
|
1010
1093
|
static fromUncompressedHex(bytes) {
|
|
1011
|
-
const x = bytesToNumber(bytes.subarray(1,
|
|
1012
|
-
const y = bytesToNumber(bytes.subarray(
|
|
1094
|
+
const x = bytesToNumber(bytes.subarray(1, fieldLen + 1));
|
|
1095
|
+
const y = bytesToNumber(bytes.subarray(fieldLen + 1, fieldLen * 2 + 1));
|
|
1013
1096
|
const point = new Point(x, y);
|
|
1014
1097
|
point.assertValidity();
|
|
1015
1098
|
return point;
|
|
@@ -1018,29 +1101,30 @@ class Point {
|
|
|
1018
1101
|
const bytes = ensureBytes(hex);
|
|
1019
1102
|
const len = bytes.length;
|
|
1020
1103
|
const header = bytes[0];
|
|
1021
|
-
if (len ===
|
|
1104
|
+
if (len === fieldLen)
|
|
1105
|
+
return this.fromCompressedHex(bytes);
|
|
1106
|
+
if (len === compressedLen && (header === 0x02 || header === 0x03)) {
|
|
1022
1107
|
return this.fromCompressedHex(bytes);
|
|
1023
1108
|
}
|
|
1024
|
-
if (len ===
|
|
1109
|
+
if (len === uncompressedLen && header === 0x04)
|
|
1025
1110
|
return this.fromUncompressedHex(bytes);
|
|
1026
|
-
throw new Error(`Point.fromHex: received invalid point. Expected 32
|
|
1111
|
+
throw new Error(`Point.fromHex: received invalid point. Expected 32-${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes, not ${len}`);
|
|
1027
1112
|
}
|
|
1028
1113
|
static fromPrivateKey(privateKey) {
|
|
1029
1114
|
return Point.BASE.multiply(normalizePrivateKey(privateKey));
|
|
1030
1115
|
}
|
|
1031
1116
|
static fromSignature(msgHash, signature, recovery) {
|
|
1032
|
-
msgHash = ensureBytes(msgHash);
|
|
1033
|
-
const h = truncateHash(msgHash);
|
|
1034
1117
|
const { r, s } = normalizeSignature(signature);
|
|
1035
|
-
if (
|
|
1036
|
-
throw new Error('Cannot recover
|
|
1037
|
-
|
|
1038
|
-
const prefix = recovery & 1 ? '03' : '02';
|
|
1039
|
-
const R = Point.fromHex(prefix + numTo32bStr(r));
|
|
1118
|
+
if (![0, 1, 2, 3].includes(recovery))
|
|
1119
|
+
throw new Error('Cannot recover: invalid recovery bit');
|
|
1120
|
+
const h = truncateHash(ensureBytes(msgHash));
|
|
1040
1121
|
const { n } = CURVE;
|
|
1041
|
-
const
|
|
1122
|
+
const radj = recovery === 2 || recovery === 3 ? r + n : r;
|
|
1123
|
+
const rinv = invert(radj, n);
|
|
1042
1124
|
const u1 = mod(-h * rinv, n);
|
|
1043
1125
|
const u2 = mod(s * rinv, n);
|
|
1126
|
+
const prefix = recovery & 1 ? '03' : '02';
|
|
1127
|
+
const R = Point.fromHex(prefix + numTo32bStr(radj));
|
|
1044
1128
|
const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2);
|
|
1045
1129
|
if (!Q)
|
|
1046
1130
|
throw new Error('Cannot recover signature: point at infinify');
|
|
@@ -1053,7 +1137,7 @@ class Point {
|
|
|
1053
1137
|
toHex(isCompressed = false) {
|
|
1054
1138
|
const x = numTo32bStr(this.x);
|
|
1055
1139
|
if (isCompressed) {
|
|
1056
|
-
const prefix = this.
|
|
1140
|
+
const prefix = this.hasEvenY() ? '02' : '03';
|
|
1057
1141
|
return `${prefix}${x}`;
|
|
1058
1142
|
}
|
|
1059
1143
|
else {
|
|
@@ -1072,7 +1156,7 @@ class Point {
|
|
|
1072
1156
|
if (!isValidFieldElement(x) || !isValidFieldElement(y))
|
|
1073
1157
|
throw new Error(msg);
|
|
1074
1158
|
const left = mod(y * y);
|
|
1075
|
-
const right =
|
|
1159
|
+
const right = weierstrass(x);
|
|
1076
1160
|
if (mod(left - right) !== _0n)
|
|
1077
1161
|
throw new Error(msg);
|
|
1078
1162
|
}
|
|
@@ -1143,7 +1227,7 @@ class Signature {
|
|
|
1143
1227
|
this.assertValidity();
|
|
1144
1228
|
}
|
|
1145
1229
|
static fromCompact(hex) {
|
|
1146
|
-
const arr =
|
|
1230
|
+
const arr = hex instanceof Uint8Array;
|
|
1147
1231
|
const name = 'Signature.fromCompact';
|
|
1148
1232
|
if (typeof hex !== 'string' && !arr)
|
|
1149
1233
|
throw new TypeError(`${name}: Expected string or Uint8Array`);
|
|
@@ -1153,7 +1237,7 @@ class Signature {
|
|
|
1153
1237
|
return new Signature(hexToNumber(str.slice(0, 64)), hexToNumber(str.slice(64, 128)));
|
|
1154
1238
|
}
|
|
1155
1239
|
static fromDER(hex) {
|
|
1156
|
-
const arr =
|
|
1240
|
+
const arr = hex instanceof Uint8Array;
|
|
1157
1241
|
if (typeof hex !== 'string' && !arr)
|
|
1158
1242
|
throw new TypeError(`Signature.fromDER: Expected string or Uint8Array`);
|
|
1159
1243
|
const { r, s } = parseDERSignature(arr ? hex : hexToBytes(hex));
|
|
@@ -1174,19 +1258,19 @@ class Signature {
|
|
|
1174
1258
|
return this.s > HALF;
|
|
1175
1259
|
}
|
|
1176
1260
|
normalizeS() {
|
|
1177
|
-
return this.hasHighS() ? new Signature(this.r,
|
|
1261
|
+
return this.hasHighS() ? new Signature(this.r, mod(-this.s, CURVE.n)) : this;
|
|
1178
1262
|
}
|
|
1179
|
-
toDERRawBytes(
|
|
1180
|
-
return hexToBytes(this.toDERHex(
|
|
1263
|
+
toDERRawBytes() {
|
|
1264
|
+
return hexToBytes(this.toDERHex());
|
|
1181
1265
|
}
|
|
1182
|
-
toDERHex(
|
|
1266
|
+
toDERHex() {
|
|
1183
1267
|
const sHex = sliceDER(numberToHexUnpadded(this.s));
|
|
1184
|
-
if (isCompressed)
|
|
1185
|
-
return sHex;
|
|
1186
1268
|
const rHex = sliceDER(numberToHexUnpadded(this.r));
|
|
1187
|
-
const
|
|
1188
|
-
const
|
|
1189
|
-
const
|
|
1269
|
+
const sHexL = sHex.length / 2;
|
|
1270
|
+
const rHexL = rHex.length / 2;
|
|
1271
|
+
const sLen = numberToHexUnpadded(sHexL);
|
|
1272
|
+
const rLen = numberToHexUnpadded(rHexL);
|
|
1273
|
+
const length = numberToHexUnpadded(rHexL + sHexL + 4);
|
|
1190
1274
|
return `30${length}02${rLen}${rHex}02${sLen}${sHex}`;
|
|
1191
1275
|
}
|
|
1192
1276
|
toRawBytes() {
|
|
@@ -1204,7 +1288,7 @@ class Signature {
|
|
|
1204
1288
|
}
|
|
1205
1289
|
exports.Signature = Signature;
|
|
1206
1290
|
function concatBytes(...arrays) {
|
|
1207
|
-
if (!arrays.every(
|
|
1291
|
+
if (!arrays.every((b) => b instanceof Uint8Array))
|
|
1208
1292
|
throw new Error('Uint8Array list expected');
|
|
1209
1293
|
if (arrays.length === 1)
|
|
1210
1294
|
return arrays[0];
|
|
@@ -1217,9 +1301,6 @@ function concatBytes(...arrays) {
|
|
|
1217
1301
|
}
|
|
1218
1302
|
return result;
|
|
1219
1303
|
}
|
|
1220
|
-
function isUint8a(bytes) {
|
|
1221
|
-
return bytes instanceof Uint8Array;
|
|
1222
|
-
}
|
|
1223
1304
|
const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
|
|
1224
1305
|
function bytesToHex(uint8a) {
|
|
1225
1306
|
if (!(uint8a instanceof Uint8Array))
|
|
@@ -1230,13 +1311,19 @@ function bytesToHex(uint8a) {
|
|
|
1230
1311
|
}
|
|
1231
1312
|
return hex;
|
|
1232
1313
|
}
|
|
1314
|
+
const POW_2_256 = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000');
|
|
1233
1315
|
function numTo32bStr(num) {
|
|
1234
|
-
if (num
|
|
1235
|
-
throw new Error('Expected
|
|
1316
|
+
if (typeof num !== 'bigint')
|
|
1317
|
+
throw new Error('Expected bigint');
|
|
1318
|
+
if (!(_0n <= num && num < POW_2_256))
|
|
1319
|
+
throw new Error('Expected number 0 <= n < 2^256');
|
|
1236
1320
|
return num.toString(16).padStart(64, '0');
|
|
1237
1321
|
}
|
|
1238
1322
|
function numTo32b(num) {
|
|
1239
|
-
|
|
1323
|
+
const b = hexToBytes(numTo32bStr(num));
|
|
1324
|
+
if (b.length !== 32)
|
|
1325
|
+
throw new Error('Error: expected 32 bytes');
|
|
1326
|
+
return b;
|
|
1240
1327
|
}
|
|
1241
1328
|
function numberToHexUnpadded(num) {
|
|
1242
1329
|
const hex = num.toString(16);
|
|
@@ -1312,7 +1399,11 @@ function sqrtMod(x) {
|
|
|
1312
1399
|
const b223 = (pow2(b220, _3n) * b3) % P;
|
|
1313
1400
|
const t1 = (pow2(b223, _23n) * b22) % P;
|
|
1314
1401
|
const t2 = (pow2(t1, _6n) * b2) % P;
|
|
1315
|
-
|
|
1402
|
+
const rt = pow2(t2, _2n);
|
|
1403
|
+
const xc = (rt * rt) % P;
|
|
1404
|
+
if (xc !== x)
|
|
1405
|
+
throw new Error('Cannot find square root');
|
|
1406
|
+
return rt;
|
|
1316
1407
|
}
|
|
1317
1408
|
function invert(number, modulo = CURVE.P) {
|
|
1318
1409
|
if (number === _0n || modulo <= _0n) {
|
|
@@ -1350,61 +1441,45 @@ function invertBatch(nums, p = CURVE.P) {
|
|
|
1350
1441
|
}, inverted);
|
|
1351
1442
|
return scratch;
|
|
1352
1443
|
}
|
|
1353
|
-
|
|
1354
|
-
const
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');
|
|
1358
|
-
const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');
|
|
1359
|
-
const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');
|
|
1360
|
-
const b2 = a1;
|
|
1361
|
-
const c1 = divNearest(b2 * k, n);
|
|
1362
|
-
const c2 = divNearest(-b1 * k, n);
|
|
1363
|
-
let k1 = mod(k - c1 * a1 - c2 * a2, n);
|
|
1364
|
-
let k2 = mod(-c1 * b1 - c2 * b2, n);
|
|
1365
|
-
const k1neg = k1 > POW_2_128;
|
|
1366
|
-
const k2neg = k2 > POW_2_128;
|
|
1367
|
-
if (k1neg)
|
|
1368
|
-
k1 = n - k1;
|
|
1369
|
-
if (k2neg)
|
|
1370
|
-
k2 = n - k2;
|
|
1371
|
-
if (k1 > POW_2_128 || k2 > POW_2_128) {
|
|
1372
|
-
throw new Error('splitScalarEndo: Endomorphism failed, k=' + k);
|
|
1373
|
-
}
|
|
1374
|
-
return { k1neg, k1, k2neg, k2 };
|
|
1444
|
+
function bits2int_2(bytes) {
|
|
1445
|
+
const delta = bytes.length * 8 - groupLen * 8;
|
|
1446
|
+
const num = bytesToNumber(bytes);
|
|
1447
|
+
return delta > 0 ? num >> BigInt(delta) : num;
|
|
1375
1448
|
}
|
|
1376
|
-
function truncateHash(hash) {
|
|
1449
|
+
function truncateHash(hash, truncateOnly = false) {
|
|
1450
|
+
const h = bits2int_2(hash);
|
|
1451
|
+
if (truncateOnly)
|
|
1452
|
+
return h;
|
|
1377
1453
|
const { n } = CURVE;
|
|
1378
|
-
|
|
1379
|
-
const delta = byteLength * 8 - 256;
|
|
1380
|
-
let h = bytesToNumber(hash);
|
|
1381
|
-
if (delta > 0)
|
|
1382
|
-
h = h >> BigInt(delta);
|
|
1383
|
-
if (h >= n)
|
|
1384
|
-
h -= n;
|
|
1385
|
-
return h;
|
|
1454
|
+
return h >= n ? h - n : h;
|
|
1386
1455
|
}
|
|
1456
|
+
let _sha256Sync;
|
|
1457
|
+
let _hmacSha256Sync;
|
|
1387
1458
|
class HmacDrbg {
|
|
1388
|
-
constructor() {
|
|
1389
|
-
this.
|
|
1390
|
-
this.
|
|
1459
|
+
constructor(hashLen, qByteLen) {
|
|
1460
|
+
this.hashLen = hashLen;
|
|
1461
|
+
this.qByteLen = qByteLen;
|
|
1462
|
+
if (typeof hashLen !== 'number' || hashLen < 2)
|
|
1463
|
+
throw new Error('hashLen must be a number');
|
|
1464
|
+
if (typeof qByteLen !== 'number' || qByteLen < 2)
|
|
1465
|
+
throw new Error('qByteLen must be a number');
|
|
1466
|
+
this.v = new Uint8Array(hashLen).fill(1);
|
|
1467
|
+
this.k = new Uint8Array(hashLen).fill(0);
|
|
1391
1468
|
this.counter = 0;
|
|
1392
1469
|
}
|
|
1393
1470
|
hmac(...values) {
|
|
1394
1471
|
return exports.utils.hmacSha256(this.k, ...values);
|
|
1395
1472
|
}
|
|
1396
1473
|
hmacSync(...values) {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
if (
|
|
1401
|
-
throw new
|
|
1402
|
-
return res;
|
|
1474
|
+
return _hmacSha256Sync(this.k, ...values);
|
|
1475
|
+
}
|
|
1476
|
+
checkSync() {
|
|
1477
|
+
if (typeof _hmacSha256Sync !== 'function')
|
|
1478
|
+
throw new ShaError('hmacSha256Sync needs to be set');
|
|
1403
1479
|
}
|
|
1404
1480
|
incr() {
|
|
1405
|
-
if (this.counter >= 1000)
|
|
1481
|
+
if (this.counter >= 1000)
|
|
1406
1482
|
throw new Error('Tried 1,000 k values for sign(), all were invalid');
|
|
1407
|
-
}
|
|
1408
1483
|
this.counter += 1;
|
|
1409
1484
|
}
|
|
1410
1485
|
async reseed(seed = new Uint8Array()) {
|
|
@@ -1416,6 +1491,7 @@ class HmacDrbg {
|
|
|
1416
1491
|
this.v = await this.hmac(this.v);
|
|
1417
1492
|
}
|
|
1418
1493
|
reseedSync(seed = new Uint8Array()) {
|
|
1494
|
+
this.checkSync();
|
|
1419
1495
|
this.k = this.hmacSync(this.v, Uint8Array.from([0x00]), seed);
|
|
1420
1496
|
this.v = this.hmacSync(this.v);
|
|
1421
1497
|
if (seed.length === 0)
|
|
@@ -1425,13 +1501,28 @@ class HmacDrbg {
|
|
|
1425
1501
|
}
|
|
1426
1502
|
async generate() {
|
|
1427
1503
|
this.incr();
|
|
1428
|
-
|
|
1429
|
-
|
|
1504
|
+
let len = 0;
|
|
1505
|
+
const out = [];
|
|
1506
|
+
while (len < this.qByteLen) {
|
|
1507
|
+
this.v = await this.hmac(this.v);
|
|
1508
|
+
const sl = this.v.slice();
|
|
1509
|
+
out.push(sl);
|
|
1510
|
+
len += this.v.length;
|
|
1511
|
+
}
|
|
1512
|
+
return concatBytes(...out);
|
|
1430
1513
|
}
|
|
1431
1514
|
generateSync() {
|
|
1515
|
+
this.checkSync();
|
|
1432
1516
|
this.incr();
|
|
1433
|
-
|
|
1434
|
-
|
|
1517
|
+
let len = 0;
|
|
1518
|
+
const out = [];
|
|
1519
|
+
while (len < this.qByteLen) {
|
|
1520
|
+
this.v = this.hmacSync(this.v);
|
|
1521
|
+
const sl = this.v.slice();
|
|
1522
|
+
out.push(sl);
|
|
1523
|
+
len += this.v.length;
|
|
1524
|
+
}
|
|
1525
|
+
return concatBytes(...out);
|
|
1435
1526
|
}
|
|
1436
1527
|
}
|
|
1437
1528
|
function isWithinCurveOrder(num) {
|
|
@@ -1440,20 +1531,25 @@ function isWithinCurveOrder(num) {
|
|
|
1440
1531
|
function isValidFieldElement(num) {
|
|
1441
1532
|
return _0n < num && num < CURVE.P;
|
|
1442
1533
|
}
|
|
1443
|
-
function kmdToSig(kBytes, m, d) {
|
|
1444
|
-
const
|
|
1534
|
+
function kmdToSig(kBytes, m, d, lowS = true) {
|
|
1535
|
+
const { n } = CURVE;
|
|
1536
|
+
const k = truncateHash(kBytes, true);
|
|
1445
1537
|
if (!isWithinCurveOrder(k))
|
|
1446
1538
|
return;
|
|
1447
|
-
const
|
|
1539
|
+
const kinv = invert(k, n);
|
|
1448
1540
|
const q = Point.BASE.multiply(k);
|
|
1449
1541
|
const r = mod(q.x, n);
|
|
1450
1542
|
if (r === _0n)
|
|
1451
1543
|
return;
|
|
1452
|
-
const s = mod(
|
|
1544
|
+
const s = mod(kinv * mod(m + d * r, n), n);
|
|
1453
1545
|
if (s === _0n)
|
|
1454
1546
|
return;
|
|
1455
|
-
|
|
1456
|
-
|
|
1547
|
+
let sig = new Signature(r, s);
|
|
1548
|
+
let recovery = (q.x === sig.r ? 0 : 2) | Number(q.y & _1n);
|
|
1549
|
+
if (lowS && sig.hasHighS()) {
|
|
1550
|
+
sig = sig.normalizeS();
|
|
1551
|
+
recovery ^= 1;
|
|
1552
|
+
}
|
|
1457
1553
|
return { sig, recovery };
|
|
1458
1554
|
}
|
|
1459
1555
|
function normalizePrivateKey(key) {
|
|
@@ -1465,12 +1561,12 @@ function normalizePrivateKey(key) {
|
|
|
1465
1561
|
num = BigInt(key);
|
|
1466
1562
|
}
|
|
1467
1563
|
else if (typeof key === 'string') {
|
|
1468
|
-
if (key.length !==
|
|
1564
|
+
if (key.length !== 2 * groupLen)
|
|
1469
1565
|
throw new Error('Expected 32 bytes of private key');
|
|
1470
1566
|
num = hexToNumber(key);
|
|
1471
1567
|
}
|
|
1472
|
-
else if (
|
|
1473
|
-
if (key.length !==
|
|
1568
|
+
else if (key instanceof Uint8Array) {
|
|
1569
|
+
if (key.length !== groupLen)
|
|
1474
1570
|
throw new Error('Expected 32 bytes of private key');
|
|
1475
1571
|
num = bytesToNumber(key);
|
|
1476
1572
|
}
|
|
@@ -1510,22 +1606,22 @@ function recoverPublicKey(msgHash, signature, recovery, isCompressed = false) {
|
|
|
1510
1606
|
return Point.fromSignature(msgHash, signature, recovery).toRawBytes(isCompressed);
|
|
1511
1607
|
}
|
|
1512
1608
|
exports.recoverPublicKey = recoverPublicKey;
|
|
1513
|
-
function
|
|
1514
|
-
const arr =
|
|
1609
|
+
function isProbPub(item) {
|
|
1610
|
+
const arr = item instanceof Uint8Array;
|
|
1515
1611
|
const str = typeof item === 'string';
|
|
1516
1612
|
const len = (arr || str) && item.length;
|
|
1517
1613
|
if (arr)
|
|
1518
|
-
return len ===
|
|
1614
|
+
return len === compressedLen || len === uncompressedLen;
|
|
1519
1615
|
if (str)
|
|
1520
|
-
return len ===
|
|
1616
|
+
return len === compressedLen * 2 || len === uncompressedLen * 2;
|
|
1521
1617
|
if (item instanceof Point)
|
|
1522
1618
|
return true;
|
|
1523
1619
|
return false;
|
|
1524
1620
|
}
|
|
1525
1621
|
function getSharedSecret(privateA, publicB, isCompressed = false) {
|
|
1526
|
-
if (
|
|
1622
|
+
if (isProbPub(privateA))
|
|
1527
1623
|
throw new TypeError('getSharedSecret: first arg must be private key');
|
|
1528
|
-
if (!
|
|
1624
|
+
if (!isProbPub(publicB))
|
|
1529
1625
|
throw new TypeError('getSharedSecret: second arg must be public key');
|
|
1530
1626
|
const b = normalizePublicKey(publicB);
|
|
1531
1627
|
b.assertValidity();
|
|
@@ -1533,7 +1629,7 @@ function getSharedSecret(privateA, publicB, isCompressed = false) {
|
|
|
1533
1629
|
}
|
|
1534
1630
|
exports.getSharedSecret = getSharedSecret;
|
|
1535
1631
|
function bits2int(bytes) {
|
|
1536
|
-
const slice = bytes.length >
|
|
1632
|
+
const slice = bytes.length > fieldLen ? bytes.slice(0, fieldLen) : bytes;
|
|
1537
1633
|
return bytesToNumber(slice);
|
|
1538
1634
|
}
|
|
1539
1635
|
function bits2octets(bytes) {
|
|
@@ -1542,10 +1638,7 @@ function bits2octets(bytes) {
|
|
|
1542
1638
|
return int2octets(z2 < _0n ? z1 : z2);
|
|
1543
1639
|
}
|
|
1544
1640
|
function int2octets(num) {
|
|
1545
|
-
|
|
1546
|
-
throw new Error('Expected bigint');
|
|
1547
|
-
const hex = numTo32bStr(num);
|
|
1548
|
-
return hexToBytes(hex);
|
|
1641
|
+
return numTo32b(num);
|
|
1549
1642
|
}
|
|
1550
1643
|
function initSigArgs(msgHash, privateKey, extraEntropy) {
|
|
1551
1644
|
if (msgHash == null)
|
|
@@ -1555,10 +1648,10 @@ function initSigArgs(msgHash, privateKey, extraEntropy) {
|
|
|
1555
1648
|
const seedArgs = [int2octets(d), bits2octets(h1)];
|
|
1556
1649
|
if (extraEntropy != null) {
|
|
1557
1650
|
if (extraEntropy === true)
|
|
1558
|
-
extraEntropy = exports.utils.randomBytes(
|
|
1651
|
+
extraEntropy = exports.utils.randomBytes(fieldLen);
|
|
1559
1652
|
const e = ensureBytes(extraEntropy);
|
|
1560
|
-
if (e.length !==
|
|
1561
|
-
throw new Error(
|
|
1653
|
+
if (e.length !== fieldLen)
|
|
1654
|
+
throw new Error(`sign: Expected ${fieldLen} bytes of extra data`);
|
|
1562
1655
|
seedArgs.push(e);
|
|
1563
1656
|
}
|
|
1564
1657
|
const seed = concatBytes(...seedArgs);
|
|
@@ -1566,31 +1659,27 @@ function initSigArgs(msgHash, privateKey, extraEntropy) {
|
|
|
1566
1659
|
return { seed, m, d };
|
|
1567
1660
|
}
|
|
1568
1661
|
function finalizeSig(recSig, opts) {
|
|
1569
|
-
|
|
1570
|
-
const {
|
|
1571
|
-
if (canonical && sig.hasHighS()) {
|
|
1572
|
-
sig = sig.normalizeS();
|
|
1573
|
-
recovery ^= 1;
|
|
1574
|
-
}
|
|
1662
|
+
const { sig, recovery } = recSig;
|
|
1663
|
+
const { der, recovered } = Object.assign({ canonical: true, der: true }, opts);
|
|
1575
1664
|
const hashed = der ? sig.toDERRawBytes() : sig.toCompactRawBytes();
|
|
1576
1665
|
return recovered ? [hashed, recovery] : hashed;
|
|
1577
1666
|
}
|
|
1578
1667
|
async function sign(msgHash, privKey, opts = {}) {
|
|
1579
1668
|
const { seed, m, d } = initSigArgs(msgHash, privKey, opts.extraEntropy);
|
|
1580
|
-
|
|
1581
|
-
const drbg = new HmacDrbg();
|
|
1669
|
+
const drbg = new HmacDrbg(hashLen, groupLen);
|
|
1582
1670
|
await drbg.reseed(seed);
|
|
1583
|
-
|
|
1671
|
+
let sig;
|
|
1672
|
+
while (!(sig = kmdToSig(await drbg.generate(), m, d, opts.canonical)))
|
|
1584
1673
|
await drbg.reseed();
|
|
1585
1674
|
return finalizeSig(sig, opts);
|
|
1586
1675
|
}
|
|
1587
1676
|
exports.sign = sign;
|
|
1588
1677
|
function signSync(msgHash, privKey, opts = {}) {
|
|
1589
1678
|
const { seed, m, d } = initSigArgs(msgHash, privKey, opts.extraEntropy);
|
|
1590
|
-
|
|
1591
|
-
const drbg = new HmacDrbg();
|
|
1679
|
+
const drbg = new HmacDrbg(hashLen, groupLen);
|
|
1592
1680
|
drbg.reseedSync(seed);
|
|
1593
|
-
|
|
1681
|
+
let sig;
|
|
1682
|
+
while (!(sig = kmdToSig(drbg.generateSync(), m, d, opts.canonical)))
|
|
1594
1683
|
drbg.reseedSync();
|
|
1595
1684
|
return finalizeSig(sig, opts);
|
|
1596
1685
|
}
|
|
@@ -1627,12 +1716,9 @@ function verify(signature, msgHash, publicKey, opts = vopts) {
|
|
|
1627
1716
|
return v === r;
|
|
1628
1717
|
}
|
|
1629
1718
|
exports.verify = verify;
|
|
1630
|
-
function
|
|
1719
|
+
function schnorrChallengeFinalize(ch) {
|
|
1631
1720
|
return mod(bytesToNumber(ch), CURVE.n);
|
|
1632
1721
|
}
|
|
1633
|
-
function hasEvenY(point) {
|
|
1634
|
-
return (point.y & _1n) === _0n;
|
|
1635
|
-
}
|
|
1636
1722
|
class SchnorrSignature {
|
|
1637
1723
|
constructor(r, s) {
|
|
1638
1724
|
this.r = r;
|
|
@@ -1662,55 +1748,67 @@ class SchnorrSignature {
|
|
|
1662
1748
|
function schnorrGetPublicKey(privateKey) {
|
|
1663
1749
|
return Point.fromPrivateKey(privateKey).toRawX();
|
|
1664
1750
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
const { R, rx, k } = finalizeSchnorrNonce(await exports.utils.taggedHash(TAGS.nonce, t, px, m));
|
|
1697
|
-
const e = finalizeSchnorrChallenge(await exports.utils.taggedHash(TAGS.challenge, rx, px, m));
|
|
1698
|
-
const sig = finalizeSchnorrSig(R, k, e, d);
|
|
1699
|
-
const isValid = await schnorrVerify(sig, m, px);
|
|
1700
|
-
if (!isValid)
|
|
1751
|
+
class InternalSchnorrSignature {
|
|
1752
|
+
constructor(message, privateKey, auxRand = exports.utils.randomBytes()) {
|
|
1753
|
+
if (message == null)
|
|
1754
|
+
throw new TypeError(`sign: Expected valid message, not "${message}"`);
|
|
1755
|
+
this.m = ensureBytes(message);
|
|
1756
|
+
const { x, scalar } = this.getScalar(normalizePrivateKey(privateKey));
|
|
1757
|
+
this.px = x;
|
|
1758
|
+
this.d = scalar;
|
|
1759
|
+
this.rand = ensureBytes(auxRand);
|
|
1760
|
+
if (this.rand.length !== 32)
|
|
1761
|
+
throw new TypeError('sign: Expected 32 bytes of aux randomness');
|
|
1762
|
+
}
|
|
1763
|
+
getScalar(priv) {
|
|
1764
|
+
const point = Point.fromPrivateKey(priv);
|
|
1765
|
+
const scalar = point.hasEvenY() ? priv : CURVE.n - priv;
|
|
1766
|
+
return { point, scalar, x: point.toRawX() };
|
|
1767
|
+
}
|
|
1768
|
+
initNonce(d, t0h) {
|
|
1769
|
+
return numTo32b(d ^ bytesToNumber(t0h));
|
|
1770
|
+
}
|
|
1771
|
+
finalizeNonce(k0h) {
|
|
1772
|
+
const k0 = mod(bytesToNumber(k0h), CURVE.n);
|
|
1773
|
+
if (k0 === _0n)
|
|
1774
|
+
throw new Error('sign: Creation of signature failed. k is zero');
|
|
1775
|
+
const { point: R, x: rx, scalar: k } = this.getScalar(k0);
|
|
1776
|
+
return { R, rx, k };
|
|
1777
|
+
}
|
|
1778
|
+
finalizeSig(R, k, e, d) {
|
|
1779
|
+
return new SchnorrSignature(R.x, mod(k + e * d, CURVE.n)).toRawBytes();
|
|
1780
|
+
}
|
|
1781
|
+
error() {
|
|
1701
1782
|
throw new Error('sign: Invalid signature produced');
|
|
1702
|
-
|
|
1783
|
+
}
|
|
1784
|
+
async calc() {
|
|
1785
|
+
const { m, d, px, rand } = this;
|
|
1786
|
+
const tag = exports.utils.taggedHash;
|
|
1787
|
+
const t = this.initNonce(d, await tag(TAGS.aux, rand));
|
|
1788
|
+
const { R, rx, k } = this.finalizeNonce(await tag(TAGS.nonce, t, px, m));
|
|
1789
|
+
const e = schnorrChallengeFinalize(await tag(TAGS.challenge, rx, px, m));
|
|
1790
|
+
const sig = this.finalizeSig(R, k, e, d);
|
|
1791
|
+
if (!(await schnorrVerify(sig, m, px)))
|
|
1792
|
+
this.error();
|
|
1793
|
+
return sig;
|
|
1794
|
+
}
|
|
1795
|
+
calcSync() {
|
|
1796
|
+
const { m, d, px, rand } = this;
|
|
1797
|
+
const tag = exports.utils.taggedHashSync;
|
|
1798
|
+
const t = this.initNonce(d, tag(TAGS.aux, rand));
|
|
1799
|
+
const { R, rx, k } = this.finalizeNonce(tag(TAGS.nonce, t, px, m));
|
|
1800
|
+
const e = schnorrChallengeFinalize(tag(TAGS.challenge, rx, px, m));
|
|
1801
|
+
const sig = this.finalizeSig(R, k, e, d);
|
|
1802
|
+
if (!schnorrVerifySync(sig, m, px))
|
|
1803
|
+
this.error();
|
|
1804
|
+
return sig;
|
|
1805
|
+
}
|
|
1703
1806
|
}
|
|
1704
|
-
function
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
const sig = finalizeSchnorrSig(R, k, e, d);
|
|
1710
|
-
const isValid = schnorrVerifySync(sig, m, px);
|
|
1711
|
-
if (!isValid)
|
|
1712
|
-
throw new Error('sign: Invalid signature produced');
|
|
1713
|
-
return sig;
|
|
1807
|
+
async function schnorrSign(msg, privKey, auxRand) {
|
|
1808
|
+
return new InternalSchnorrSignature(msg, privKey, auxRand).calc();
|
|
1809
|
+
}
|
|
1810
|
+
function schnorrSignSync(msg, privKey, auxRand) {
|
|
1811
|
+
return new InternalSchnorrSignature(msg, privKey, auxRand).calcSync();
|
|
1714
1812
|
}
|
|
1715
1813
|
function initSchnorrVerify(signature, message, publicKey) {
|
|
1716
1814
|
const raw = signature instanceof SchnorrSignature;
|
|
@@ -1725,14 +1823,14 @@ function initSchnorrVerify(signature, message, publicKey) {
|
|
|
1725
1823
|
}
|
|
1726
1824
|
function finalizeSchnorrVerify(r, P, s, e) {
|
|
1727
1825
|
const R = Point.BASE.multiplyAndAddUnsafe(P, normalizePrivateKey(s), mod(-e, CURVE.n));
|
|
1728
|
-
if (!R || !hasEvenY(
|
|
1826
|
+
if (!R || !R.hasEvenY() || R.x !== r)
|
|
1729
1827
|
return false;
|
|
1730
1828
|
return true;
|
|
1731
1829
|
}
|
|
1732
1830
|
async function schnorrVerify(signature, message, publicKey) {
|
|
1733
1831
|
try {
|
|
1734
1832
|
const { r, s, m, P } = initSchnorrVerify(signature, message, publicKey);
|
|
1735
|
-
const e =
|
|
1833
|
+
const e = schnorrChallengeFinalize(await exports.utils.taggedHash(TAGS.challenge, numTo32b(r), P.toRawX(), m));
|
|
1736
1834
|
return finalizeSchnorrVerify(r, P, s, e);
|
|
1737
1835
|
}
|
|
1738
1836
|
catch (error) {
|
|
@@ -1742,10 +1840,12 @@ async function schnorrVerify(signature, message, publicKey) {
|
|
|
1742
1840
|
function schnorrVerifySync(signature, message, publicKey) {
|
|
1743
1841
|
try {
|
|
1744
1842
|
const { r, s, m, P } = initSchnorrVerify(signature, message, publicKey);
|
|
1745
|
-
const e =
|
|
1843
|
+
const e = schnorrChallengeFinalize(exports.utils.taggedHashSync(TAGS.challenge, numTo32b(r), P.toRawX(), m));
|
|
1746
1844
|
return finalizeSchnorrVerify(r, P, s, e);
|
|
1747
1845
|
}
|
|
1748
1846
|
catch (error) {
|
|
1847
|
+
if (error instanceof ShaError)
|
|
1848
|
+
throw error;
|
|
1749
1849
|
return false;
|
|
1750
1850
|
}
|
|
1751
1851
|
}
|
|
@@ -1769,6 +1869,11 @@ const TAGS = {
|
|
|
1769
1869
|
};
|
|
1770
1870
|
const TAGGED_HASH_PREFIXES = {};
|
|
1771
1871
|
exports.utils = {
|
|
1872
|
+
bytesToHex,
|
|
1873
|
+
hexToBytes,
|
|
1874
|
+
concatBytes,
|
|
1875
|
+
mod,
|
|
1876
|
+
invert,
|
|
1772
1877
|
isValidPrivateKey(privateKey) {
|
|
1773
1878
|
try {
|
|
1774
1879
|
normalizePrivateKey(privateKey);
|
|
@@ -1778,32 +1883,14 @@ exports.utils = {
|
|
|
1778
1883
|
return false;
|
|
1779
1884
|
}
|
|
1780
1885
|
},
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
const t = normalizePrivateKey(tweak);
|
|
1784
|
-
return numTo32b(mod(p + t, CURVE.n));
|
|
1785
|
-
},
|
|
1786
|
-
privateNegate: (privateKey) => {
|
|
1787
|
-
const p = normalizePrivateKey(privateKey);
|
|
1788
|
-
return numTo32b(CURVE.n - p);
|
|
1789
|
-
},
|
|
1790
|
-
pointAddScalar: (p, tweak, isCompressed) => {
|
|
1791
|
-
const P = Point.fromHex(p);
|
|
1792
|
-
const t = normalizePrivateKey(tweak);
|
|
1793
|
-
const Q = Point.BASE.multiplyAndAddUnsafe(P, t, _1n);
|
|
1794
|
-
if (!Q)
|
|
1795
|
-
throw new Error('Tweaked point at infinity');
|
|
1796
|
-
return Q.toRawBytes(isCompressed);
|
|
1797
|
-
},
|
|
1798
|
-
pointMultiply: (p, tweak, isCompressed) => {
|
|
1799
|
-
const P = Point.fromHex(p);
|
|
1800
|
-
const t = bytesToNumber(ensureBytes(tweak));
|
|
1801
|
-
return P.multiply(t).toRawBytes(isCompressed);
|
|
1802
|
-
},
|
|
1886
|
+
_bigintTo32Bytes: numTo32b,
|
|
1887
|
+
_normalizePrivateKey: normalizePrivateKey,
|
|
1803
1888
|
hashToPrivateKey: (hash) => {
|
|
1804
1889
|
hash = ensureBytes(hash);
|
|
1805
|
-
|
|
1806
|
-
|
|
1890
|
+
const minLen = groupLen + 8;
|
|
1891
|
+
if (hash.length < minLen || hash.length > 1024) {
|
|
1892
|
+
throw new Error(`Expected valid bytes of private key as per FIPS 186`);
|
|
1893
|
+
}
|
|
1807
1894
|
const num = mod(bytesToNumber(hash), CURVE.n - _1n) + _1n;
|
|
1808
1895
|
return numTo32b(num);
|
|
1809
1896
|
},
|
|
@@ -1819,14 +1906,13 @@ exports.utils = {
|
|
|
1819
1906
|
throw new Error("The environment doesn't have randomBytes function");
|
|
1820
1907
|
}
|
|
1821
1908
|
},
|
|
1822
|
-
randomPrivateKey: () =>
|
|
1823
|
-
|
|
1909
|
+
randomPrivateKey: () => exports.utils.hashToPrivateKey(exports.utils.randomBytes(groupLen + 8)),
|
|
1910
|
+
precompute(windowSize = 8, point = Point.BASE) {
|
|
1911
|
+
const cached = point === Point.BASE ? point : new Point(point.x, point.y);
|
|
1912
|
+
cached._setWindowSize(windowSize);
|
|
1913
|
+
cached.multiply(_3n);
|
|
1914
|
+
return cached;
|
|
1824
1915
|
},
|
|
1825
|
-
bytesToHex,
|
|
1826
|
-
hexToBytes,
|
|
1827
|
-
concatBytes,
|
|
1828
|
-
mod,
|
|
1829
|
-
invert,
|
|
1830
1916
|
sha256: async (...messages) => {
|
|
1831
1917
|
if (crypto.web) {
|
|
1832
1918
|
const buffer = await crypto.web.subtle.digest('SHA-256', concatBytes(...messages));
|
|
@@ -1871,23 +1957,40 @@ exports.utils = {
|
|
|
1871
1957
|
return exports.utils.sha256(tagP, ...messages);
|
|
1872
1958
|
},
|
|
1873
1959
|
taggedHashSync: (tag, ...messages) => {
|
|
1874
|
-
if (typeof
|
|
1875
|
-
throw new
|
|
1960
|
+
if (typeof _sha256Sync !== 'function')
|
|
1961
|
+
throw new ShaError('sha256Sync is undefined, you need to set it');
|
|
1876
1962
|
let tagP = TAGGED_HASH_PREFIXES[tag];
|
|
1877
1963
|
if (tagP === undefined) {
|
|
1878
|
-
const tagH =
|
|
1964
|
+
const tagH = _sha256Sync(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
|
|
1879
1965
|
tagP = concatBytes(tagH, tagH);
|
|
1880
1966
|
TAGGED_HASH_PREFIXES[tag] = tagP;
|
|
1881
1967
|
}
|
|
1882
|
-
return
|
|
1883
|
-
},
|
|
1884
|
-
precompute(windowSize = 8, point = Point.BASE) {
|
|
1885
|
-
const cached = point === Point.BASE ? point : new Point(point.x, point.y);
|
|
1886
|
-
cached._setWindowSize(windowSize);
|
|
1887
|
-
cached.multiply(_3n);
|
|
1888
|
-
return cached;
|
|
1968
|
+
return _sha256Sync(tagP, ...messages);
|
|
1889
1969
|
},
|
|
1970
|
+
_JacobianPoint: JacobianPoint,
|
|
1890
1971
|
};
|
|
1972
|
+
Object.defineProperties(exports.utils, {
|
|
1973
|
+
sha256Sync: {
|
|
1974
|
+
configurable: false,
|
|
1975
|
+
get() {
|
|
1976
|
+
return _sha256Sync;
|
|
1977
|
+
},
|
|
1978
|
+
set(val) {
|
|
1979
|
+
if (!_sha256Sync)
|
|
1980
|
+
_sha256Sync = val;
|
|
1981
|
+
},
|
|
1982
|
+
},
|
|
1983
|
+
hmacSha256Sync: {
|
|
1984
|
+
configurable: false,
|
|
1985
|
+
get() {
|
|
1986
|
+
return _hmacSha256Sync;
|
|
1987
|
+
},
|
|
1988
|
+
set(val) {
|
|
1989
|
+
if (!_hmacSha256Sync)
|
|
1990
|
+
_hmacSha256Sync = val;
|
|
1991
|
+
},
|
|
1992
|
+
},
|
|
1993
|
+
});
|
|
1891
1994
|
|
|
1892
1995
|
|
|
1893
1996
|
/***/ }),
|
|
@@ -15013,13 +15116,21 @@ var Enum = __webpack_require__(7025),
|
|
|
15013
15116
|
* @ignore
|
|
15014
15117
|
*/
|
|
15015
15118
|
function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
15119
|
+
var defaultAlreadyEmitted = false;
|
|
15016
15120
|
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
|
|
15017
15121
|
if (field.resolvedType) {
|
|
15018
15122
|
if (field.resolvedType instanceof Enum) { gen
|
|
15019
15123
|
("switch(d%s){", prop);
|
|
15020
15124
|
for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
|
|
15021
|
-
|
|
15022
|
-
(
|
|
15125
|
+
// enum unknown values passthrough
|
|
15126
|
+
if (values[keys[i]] === field.typeDefault && !defaultAlreadyEmitted) { gen
|
|
15127
|
+
("default:")
|
|
15128
|
+
("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
|
|
15129
|
+
if (!field.repeated) gen // fallback to default value only for
|
|
15130
|
+
// arrays, to avoid leaving holes.
|
|
15131
|
+
("break"); // for non-repeated fields, just ignore
|
|
15132
|
+
defaultAlreadyEmitted = true;
|
|
15133
|
+
}
|
|
15023
15134
|
gen
|
|
15024
15135
|
("case%j:", keys[i])
|
|
15025
15136
|
("case %i:", values[keys[i]])
|
|
@@ -15049,7 +15160,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
|
15049
15160
|
break;
|
|
15050
15161
|
case "uint64":
|
|
15051
15162
|
isUnsigned = true;
|
|
15052
|
-
// eslint-disable-line no-fallthrough
|
|
15163
|
+
// eslint-disable-next-line no-fallthrough
|
|
15053
15164
|
case "int64":
|
|
15054
15165
|
case "sint64":
|
|
15055
15166
|
case "fixed64":
|
|
@@ -15151,7 +15262,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
|
|
|
15151
15262
|
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
|
|
15152
15263
|
if (field.resolvedType) {
|
|
15153
15264
|
if (field.resolvedType instanceof Enum) gen
|
|
15154
|
-
("d%s=o.enums===String?types[%i].values[m%s]:m%s", prop, fieldIndex, prop, prop);
|
|
15265
|
+
("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s", prop, fieldIndex, prop, prop, fieldIndex, prop, prop);
|
|
15155
15266
|
else gen
|
|
15156
15267
|
("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
|
|
15157
15268
|
} else {
|
|
@@ -15163,7 +15274,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
|
|
|
15163
15274
|
break;
|
|
15164
15275
|
case "uint64":
|
|
15165
15276
|
isUnsigned = true;
|
|
15166
|
-
// eslint-disable-line no-fallthrough
|
|
15277
|
+
// eslint-disable-next-line no-fallthrough
|
|
15167
15278
|
case "int64":
|
|
15168
15279
|
case "sint64":
|
|
15169
15280
|
case "fixed64":
|
|
@@ -15559,8 +15670,9 @@ var Namespace = __webpack_require__(9313),
|
|
|
15559
15670
|
* @param {Object.<string,*>} [options] Declared options
|
|
15560
15671
|
* @param {string} [comment] The comment for this enum
|
|
15561
15672
|
* @param {Object.<string,string>} [comments] The value comments for this enum
|
|
15673
|
+
* @param {Object.<string,Object<string,*>>|undefined} [valuesOptions] The value options for this enum
|
|
15562
15674
|
*/
|
|
15563
|
-
function Enum(name, values, options, comment, comments) {
|
|
15675
|
+
function Enum(name, values, options, comment, comments, valuesOptions) {
|
|
15564
15676
|
ReflectionObject.call(this, name, options);
|
|
15565
15677
|
|
|
15566
15678
|
if (values && typeof values !== "object")
|
|
@@ -15590,6 +15702,12 @@ function Enum(name, values, options, comment, comments) {
|
|
|
15590
15702
|
*/
|
|
15591
15703
|
this.comments = comments || {};
|
|
15592
15704
|
|
|
15705
|
+
/**
|
|
15706
|
+
* Values options, if any
|
|
15707
|
+
* @type {Object<string, Object<string, *>>|undefined}
|
|
15708
|
+
*/
|
|
15709
|
+
this.valuesOptions = valuesOptions;
|
|
15710
|
+
|
|
15593
15711
|
/**
|
|
15594
15712
|
* Reserved ranges, if any.
|
|
15595
15713
|
* @type {Array.<number[]|string>}
|
|
@@ -15634,11 +15752,12 @@ Enum.fromJSON = function fromJSON(name, json) {
|
|
|
15634
15752
|
Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
15635
15753
|
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
15636
15754
|
return util.toObject([
|
|
15637
|
-
"options"
|
|
15638
|
-
"
|
|
15639
|
-
"
|
|
15640
|
-
"
|
|
15641
|
-
"
|
|
15755
|
+
"options" , this.options,
|
|
15756
|
+
"valuesOptions" , this.valuesOptions,
|
|
15757
|
+
"values" , this.values,
|
|
15758
|
+
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
15759
|
+
"comment" , keepComments ? this.comment : undefined,
|
|
15760
|
+
"comments" , keepComments ? this.comments : undefined
|
|
15642
15761
|
]);
|
|
15643
15762
|
};
|
|
15644
15763
|
|
|
@@ -15647,11 +15766,12 @@ Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
15647
15766
|
* @param {string} name Value name
|
|
15648
15767
|
* @param {number} id Value id
|
|
15649
15768
|
* @param {string} [comment] Comment, if any
|
|
15769
|
+
* @param {Object.<string, *>|undefined} [options] Options, if any
|
|
15650
15770
|
* @returns {Enum} `this`
|
|
15651
15771
|
* @throws {TypeError} If arguments are invalid
|
|
15652
15772
|
* @throws {Error} If there is already a value with this name or id
|
|
15653
15773
|
*/
|
|
15654
|
-
Enum.prototype.add = function add(name, id, comment) {
|
|
15774
|
+
Enum.prototype.add = function add(name, id, comment, options) {
|
|
15655
15775
|
// utilized by the parser but not by .fromJSON
|
|
15656
15776
|
|
|
15657
15777
|
if (!util.isString(name))
|
|
@@ -15676,6 +15796,12 @@ Enum.prototype.add = function add(name, id, comment) {
|
|
|
15676
15796
|
} else
|
|
15677
15797
|
this.valuesById[this.values[name] = id] = name;
|
|
15678
15798
|
|
|
15799
|
+
if (options) {
|
|
15800
|
+
if (this.valuesOptions === undefined)
|
|
15801
|
+
this.valuesOptions = {};
|
|
15802
|
+
this.valuesOptions[name] = options || null;
|
|
15803
|
+
}
|
|
15804
|
+
|
|
15679
15805
|
this.comments[name] = comment || null;
|
|
15680
15806
|
return this;
|
|
15681
15807
|
};
|
|
@@ -15699,6 +15825,8 @@ Enum.prototype.remove = function remove(name) {
|
|
|
15699
15825
|
delete this.valuesById[val];
|
|
15700
15826
|
delete this.values[name];
|
|
15701
15827
|
delete this.comments[name];
|
|
15828
|
+
if (this.valuesOptions)
|
|
15829
|
+
delete this.valuesOptions[name];
|
|
15702
15830
|
|
|
15703
15831
|
return this;
|
|
15704
15832
|
};
|
|
@@ -16745,7 +16873,8 @@ var ReflectionObject = __webpack_require__(3243);
|
|
|
16745
16873
|
((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
|
|
16746
16874
|
|
|
16747
16875
|
var Field = __webpack_require__(3548),
|
|
16748
|
-
util = __webpack_require__(9935)
|
|
16876
|
+
util = __webpack_require__(9935),
|
|
16877
|
+
OneOf = __webpack_require__(7598);
|
|
16749
16878
|
|
|
16750
16879
|
var Type, // cyclic
|
|
16751
16880
|
Service,
|
|
@@ -16881,9 +17010,8 @@ Object.defineProperty(Namespace.prototype, "nestedArray", {
|
|
|
16881
17010
|
/**
|
|
16882
17011
|
* Any nested object descriptor.
|
|
16883
17012
|
* @typedef AnyNestedObject
|
|
16884
|
-
* @type {IEnum|IType|IService|AnyExtensionField|INamespace}
|
|
17013
|
+
* @type {IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf}
|
|
16885
17014
|
*/
|
|
16886
|
-
// ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place)
|
|
16887
17015
|
|
|
16888
17016
|
/**
|
|
16889
17017
|
* Converts this namespace to a namespace descriptor.
|
|
@@ -16956,7 +17084,7 @@ Namespace.prototype.getEnum = function getEnum(name) {
|
|
|
16956
17084
|
*/
|
|
16957
17085
|
Namespace.prototype.add = function add(object) {
|
|
16958
17086
|
|
|
16959
|
-
if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace))
|
|
17087
|
+
if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof OneOf || object instanceof Enum || object instanceof Service || object instanceof Namespace))
|
|
16960
17088
|
throw TypeError("object must be a valid nested object");
|
|
16961
17089
|
|
|
16962
17090
|
if (!this.nested)
|
|
@@ -17786,7 +17914,24 @@ function parse(source, root, options) {
|
|
|
17786
17914
|
else
|
|
17787
17915
|
target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]);
|
|
17788
17916
|
} while (skip(",", true));
|
|
17789
|
-
|
|
17917
|
+
var dummy = {options: undefined};
|
|
17918
|
+
dummy.setOption = function(name, value) {
|
|
17919
|
+
if (this.options === undefined) this.options = {};
|
|
17920
|
+
this.options[name] = value;
|
|
17921
|
+
};
|
|
17922
|
+
ifBlock(
|
|
17923
|
+
dummy,
|
|
17924
|
+
function parseRange_block(token) {
|
|
17925
|
+
/* istanbul ignore else */
|
|
17926
|
+
if (token === "option") {
|
|
17927
|
+
parseOption(dummy, token); // skip
|
|
17928
|
+
skip(";");
|
|
17929
|
+
} else
|
|
17930
|
+
throw illegal(token);
|
|
17931
|
+
},
|
|
17932
|
+
function parseRange_line() {
|
|
17933
|
+
parseInlineOptions(dummy); // skip
|
|
17934
|
+
});
|
|
17790
17935
|
}
|
|
17791
17936
|
|
|
17792
17937
|
function parseNumber(token, insideTryCatch) {
|
|
@@ -17869,7 +18014,7 @@ function parse(source, root, options) {
|
|
|
17869
18014
|
break;
|
|
17870
18015
|
case "public":
|
|
17871
18016
|
next();
|
|
17872
|
-
// eslint-disable-line no-fallthrough
|
|
18017
|
+
// eslint-disable-next-line no-fallthrough
|
|
17873
18018
|
default:
|
|
17874
18019
|
whichImports = imports || (imports = []);
|
|
17875
18020
|
break;
|
|
@@ -17888,6 +18033,10 @@ function parse(source, root, options) {
|
|
|
17888
18033
|
if (!isProto3 && syntax !== "proto2")
|
|
17889
18034
|
throw illegal(syntax, "syntax");
|
|
17890
18035
|
|
|
18036
|
+
// Syntax is needed to understand the meaning of the optional field rule
|
|
18037
|
+
// Otherwise the meaning is ambiguous between proto2 and proto3
|
|
18038
|
+
root.setOption("syntax", syntax);
|
|
18039
|
+
|
|
17891
18040
|
skip(";");
|
|
17892
18041
|
}
|
|
17893
18042
|
|
|
@@ -18002,6 +18151,16 @@ function parse(source, root, options) {
|
|
|
18002
18151
|
parseGroup(parent, rule);
|
|
18003
18152
|
return;
|
|
18004
18153
|
}
|
|
18154
|
+
// Type names can consume multiple tokens, in multiple variants:
|
|
18155
|
+
// package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
|
|
18156
|
+
// package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
|
|
18157
|
+
// package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
|
|
18158
|
+
// package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
|
|
18159
|
+
// Keep reading tokens until we get a type name with no period at the end,
|
|
18160
|
+
// and the next token does not start with a period.
|
|
18161
|
+
while (type.endsWith(".") || peek().startsWith(".")) {
|
|
18162
|
+
type += next();
|
|
18163
|
+
}
|
|
18005
18164
|
|
|
18006
18165
|
/* istanbul ignore if */
|
|
18007
18166
|
if (!typeRefRe.test(type))
|
|
@@ -18085,6 +18244,14 @@ function parse(source, root, options) {
|
|
|
18085
18244
|
}
|
|
18086
18245
|
break;
|
|
18087
18246
|
|
|
18247
|
+
case "message":
|
|
18248
|
+
parseType(type, token);
|
|
18249
|
+
break;
|
|
18250
|
+
|
|
18251
|
+
case "enum":
|
|
18252
|
+
parseEnum(type, token);
|
|
18253
|
+
break;
|
|
18254
|
+
|
|
18088
18255
|
/* istanbul ignore next */
|
|
18089
18256
|
default:
|
|
18090
18257
|
throw illegal(token); // there are no groups with proto3 semantics
|
|
@@ -18185,7 +18352,14 @@ function parse(source, root, options) {
|
|
|
18185
18352
|
|
|
18186
18353
|
skip("=");
|
|
18187
18354
|
var value = parseId(next(), true),
|
|
18188
|
-
dummy = {
|
|
18355
|
+
dummy = {
|
|
18356
|
+
options: undefined
|
|
18357
|
+
};
|
|
18358
|
+
dummy.setOption = function(name, value) {
|
|
18359
|
+
if (this.options === undefined)
|
|
18360
|
+
this.options = {};
|
|
18361
|
+
this.options[name] = value;
|
|
18362
|
+
};
|
|
18189
18363
|
ifBlock(dummy, function parseEnumValue_block(token) {
|
|
18190
18364
|
|
|
18191
18365
|
/* istanbul ignore else */
|
|
@@ -18198,7 +18372,7 @@ function parse(source, root, options) {
|
|
|
18198
18372
|
}, function parseEnumValue_line() {
|
|
18199
18373
|
parseInlineOptions(dummy); // skip
|
|
18200
18374
|
});
|
|
18201
|
-
parent.add(token, value, dummy.comment);
|
|
18375
|
+
parent.add(token, value, dummy.comment, dummy.options);
|
|
18202
18376
|
}
|
|
18203
18377
|
|
|
18204
18378
|
function parseOption(parent, token) {
|
|
@@ -18238,6 +18412,9 @@ function parse(source, root, options) {
|
|
|
18238
18412
|
if (!nameRe.test(token = next())) {
|
|
18239
18413
|
throw illegal(token, "name");
|
|
18240
18414
|
}
|
|
18415
|
+
if (token === null) {
|
|
18416
|
+
throw illegal(token, "end of input");
|
|
18417
|
+
}
|
|
18241
18418
|
|
|
18242
18419
|
var value;
|
|
18243
18420
|
var propName = token;
|
|
@@ -18806,9 +18983,14 @@ Reader.prototype.bytes = function read_bytes() {
|
|
|
18806
18983
|
this.pos += length;
|
|
18807
18984
|
if (Array.isArray(this.buf)) // plain array
|
|
18808
18985
|
return this.buf.slice(start, end);
|
|
18809
|
-
|
|
18810
|
-
|
|
18811
|
-
|
|
18986
|
+
|
|
18987
|
+
if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
|
|
18988
|
+
var nativeBuffer = util.Buffer;
|
|
18989
|
+
return nativeBuffer
|
|
18990
|
+
? nativeBuffer.alloc(0)
|
|
18991
|
+
: new this.buf.constructor(0);
|
|
18992
|
+
}
|
|
18993
|
+
return this._slice.call(this.buf, start, end);
|
|
18812
18994
|
};
|
|
18813
18995
|
|
|
18814
18996
|
/**
|
|
@@ -19070,10 +19252,10 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
19070
19252
|
/* istanbul ignore if */
|
|
19071
19253
|
if (!callback)
|
|
19072
19254
|
return;
|
|
19073
|
-
var cb = callback;
|
|
19074
|
-
callback = null;
|
|
19075
19255
|
if (sync)
|
|
19076
19256
|
throw err;
|
|
19257
|
+
var cb = callback;
|
|
19258
|
+
callback = null;
|
|
19077
19259
|
cb(err, root);
|
|
19078
19260
|
}
|
|
19079
19261
|
|
|
@@ -19117,6 +19299,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
19117
19299
|
|
|
19118
19300
|
// Fetches a single file
|
|
19119
19301
|
function fetch(filename, weak) {
|
|
19302
|
+
filename = getBundledFileName(filename) || filename;
|
|
19120
19303
|
|
|
19121
19304
|
// Skip if already loaded / attempted
|
|
19122
19305
|
if (self.files.indexOf(filename) > -1)
|
|
@@ -19245,6 +19428,10 @@ function tryHandleExtension(root, field) {
|
|
|
19245
19428
|
var extendedType = field.parent.lookup(field.extend);
|
|
19246
19429
|
if (extendedType) {
|
|
19247
19430
|
var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);
|
|
19431
|
+
//do not allow to extend same field twice to prevent the error
|
|
19432
|
+
if (extendedType.get(sisterField.name)) {
|
|
19433
|
+
return true;
|
|
19434
|
+
}
|
|
19248
19435
|
sisterField.declaringField = field;
|
|
19249
19436
|
field.extensionField = sisterField;
|
|
19250
19437
|
extendedType.add(sisterField);
|
|
@@ -19935,9 +20122,7 @@ function tokenize(source, alternateCommentMode) {
|
|
|
19935
20122
|
|
|
19936
20123
|
// see if remaining line matches comment pattern
|
|
19937
20124
|
var lineText = source.substring(startOffset, endOffset);
|
|
19938
|
-
|
|
19939
|
-
// the first slash that started the comment.
|
|
19940
|
-
var isComment = /^\s*\/{1,2}/.test(lineText);
|
|
20125
|
+
var isComment = /^\s*\/\//.test(lineText);
|
|
19941
20126
|
return isComment;
|
|
19942
20127
|
}
|
|
19943
20128
|
|
|
@@ -20006,7 +20191,7 @@ function tokenize(source, alternateCommentMode) {
|
|
|
20006
20191
|
// check for double-slash comments, consolidating consecutive lines
|
|
20007
20192
|
start = offset;
|
|
20008
20193
|
isDoc = false;
|
|
20009
|
-
if (isDoubleSlashCommentLine(offset)) {
|
|
20194
|
+
if (isDoubleSlashCommentLine(offset - 1)) {
|
|
20010
20195
|
isDoc = true;
|
|
20011
20196
|
do {
|
|
20012
20197
|
offset = findEndOfLine(offset);
|
|
@@ -20388,7 +20573,7 @@ function clearCache(type) {
|
|
|
20388
20573
|
* @property {Object.<string,IOneOf>} [oneofs] Oneof descriptors
|
|
20389
20574
|
* @property {Object.<string,IField>} fields Field descriptors
|
|
20390
20575
|
* @property {number[][]} [extensions] Extension ranges
|
|
20391
|
-
* @property {number[]
|
|
20576
|
+
* @property {Array.<number[]|string>} [reserved] Reserved ranges
|
|
20392
20577
|
* @property {boolean} [group=false] Whether a legacy group or not
|
|
20393
20578
|
*/
|
|
20394
20579
|
|
|
@@ -21141,7 +21326,7 @@ util.decorateEnum = function decorateEnum(object) {
|
|
|
21141
21326
|
util.setProperty = function setProperty(dst, path, value) {
|
|
21142
21327
|
function setProp(dst, path, value) {
|
|
21143
21328
|
var part = path.shift();
|
|
21144
|
-
if (part === "__proto__") {
|
|
21329
|
+
if (part === "__proto__" || part === "prototype") {
|
|
21145
21330
|
return dst;
|
|
21146
21331
|
}
|
|
21147
21332
|
if (path.length > 0) {
|
|
@@ -21179,7 +21364,7 @@ Object.defineProperty(util, "decorateRoot", {
|
|
|
21179
21364
|
|
|
21180
21365
|
/***/ }),
|
|
21181
21366
|
|
|
21182
|
-
/***/
|
|
21367
|
+
/***/ 2630:
|
|
21183
21368
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
21184
21369
|
|
|
21185
21370
|
"use strict";
|
|
@@ -21416,7 +21601,7 @@ util.utf8 = __webpack_require__(4997);
|
|
|
21416
21601
|
util.pool = __webpack_require__(6662);
|
|
21417
21602
|
|
|
21418
21603
|
// utility to work with the low and high bits of a 64 bit value
|
|
21419
|
-
util.LongBits = __webpack_require__(
|
|
21604
|
+
util.LongBits = __webpack_require__(2630);
|
|
21420
21605
|
|
|
21421
21606
|
/**
|
|
21422
21607
|
* Whether running within node or not.
|
|
@@ -21681,7 +21866,7 @@ function newError(name) {
|
|
|
21681
21866
|
configurable: true,
|
|
21682
21867
|
},
|
|
21683
21868
|
name: {
|
|
21684
|
-
get() { return name; },
|
|
21869
|
+
get: function get() { return name; },
|
|
21685
21870
|
set: undefined,
|
|
21686
21871
|
enumerable: false,
|
|
21687
21872
|
// configurable: false would accurately preserve the behavior of
|
|
@@ -21691,7 +21876,7 @@ function newError(name) {
|
|
|
21691
21876
|
configurable: true,
|
|
21692
21877
|
},
|
|
21693
21878
|
toString: {
|
|
21694
|
-
value() { return this.name + ": " + this.message; },
|
|
21879
|
+
value: function value() { return this.name + ": " + this.message; },
|
|
21695
21880
|
writable: true,
|
|
21696
21881
|
enumerable: false,
|
|
21697
21882
|
configurable: true,
|
|
@@ -23147,6 +23332,117 @@ exports.Contract = Contract;
|
|
|
23147
23332
|
exports["default"] = Contract;
|
|
23148
23333
|
|
|
23149
23334
|
|
|
23335
|
+
/***/ }),
|
|
23336
|
+
|
|
23337
|
+
/***/ 2991:
|
|
23338
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
23339
|
+
|
|
23340
|
+
"use strict";
|
|
23341
|
+
|
|
23342
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
23343
|
+
exports.Multicall = void 0;
|
|
23344
|
+
const Contract_1 = __webpack_require__(9822);
|
|
23345
|
+
const Transaction_1 = __webpack_require__(7592);
|
|
23346
|
+
const multicallAbi_1 = __webpack_require__(5496);
|
|
23347
|
+
class Multicall {
|
|
23348
|
+
/**
|
|
23349
|
+
* @example
|
|
23350
|
+
* ```ts
|
|
23351
|
+
* const tokens = [
|
|
23352
|
+
* "19GYjDBVXU7keLbYvMLazsGQn3GTWHjHkK", // koin
|
|
23353
|
+
* "12Y5vW6gk8GceH53YfRkRre2Rrcsgw7Naq", // vhp
|
|
23354
|
+
* "12VoHz41a4HtfiyhTWbg9RXqGMRbYk6pXh", // vortex usdt
|
|
23355
|
+
* "1Tf1QKv3gVYLjq34yURSHw5ErTYbFjqTG", // vortex eth
|
|
23356
|
+
* ];
|
|
23357
|
+
*
|
|
23358
|
+
* const provider = new Provider("https://api.koinos.io");
|
|
23359
|
+
*
|
|
23360
|
+
* // create an array of the different contracts
|
|
23361
|
+
* // used in the multicall
|
|
23362
|
+
* const contracts = [];
|
|
23363
|
+
* for (const token of tokens) {
|
|
23364
|
+
* contracts.push(
|
|
23365
|
+
* new Contract({
|
|
23366
|
+
* id: token,
|
|
23367
|
+
* provider,
|
|
23368
|
+
* abi: utils.tokenAbi,
|
|
23369
|
+
* })
|
|
23370
|
+
* );
|
|
23371
|
+
* }
|
|
23372
|
+
*
|
|
23373
|
+
* // create the multicall instance
|
|
23374
|
+
* const multicall = new Multicall({
|
|
23375
|
+
* provider,
|
|
23376
|
+
* contracts
|
|
23377
|
+
* });
|
|
23378
|
+
*
|
|
23379
|
+
* // add operations to the multicall
|
|
23380
|
+
* for (const contract of contracts) {
|
|
23381
|
+
* await multicall.add(contract.functions.balanceOf, {
|
|
23382
|
+
* owner: "1MdqwaSBy6rbasPJ9vmg2pZFJSVZ29GFpZ",
|
|
23383
|
+
* });
|
|
23384
|
+
* }
|
|
23385
|
+
*
|
|
23386
|
+
* // call the multicall
|
|
23387
|
+
* const results = await multicall.call();
|
|
23388
|
+
* console.log(results);
|
|
23389
|
+
* ```
|
|
23390
|
+
*
|
|
23391
|
+
* For testnet set the id to the multicall contract address for testnet
|
|
23392
|
+
* ```ts
|
|
23393
|
+
* const multicall = new Multicall({
|
|
23394
|
+
* id: "1MM9ydA8SdgXvCTH3LdQ5FS8JvHijCmGSg",
|
|
23395
|
+
* provider: new Provider("https://testnet-api.koinos.io"),
|
|
23396
|
+
* contracts: [ koinContract, fogataPoolContract ],
|
|
23397
|
+
* });
|
|
23398
|
+
* ```
|
|
23399
|
+
*/
|
|
23400
|
+
constructor(c) {
|
|
23401
|
+
if (c.id)
|
|
23402
|
+
this.id = c.id;
|
|
23403
|
+
else
|
|
23404
|
+
this.id = "18dVCqPG3gwgL7DWQAciKYNuXfzEg5LW7"; // multicontract address mainnet
|
|
23405
|
+
this.transaction = new Transaction_1.Transaction({ provider: c.provider });
|
|
23406
|
+
this.contracts = c.contracts || [];
|
|
23407
|
+
}
|
|
23408
|
+
async add(input, args) {
|
|
23409
|
+
await this.transaction.pushOperation(input, args);
|
|
23410
|
+
}
|
|
23411
|
+
async call() {
|
|
23412
|
+
const multicallContract = new Contract_1.Contract({
|
|
23413
|
+
id: this.id,
|
|
23414
|
+
provider: this.transaction.provider,
|
|
23415
|
+
abi: multicallAbi_1.multicallAbi,
|
|
23416
|
+
});
|
|
23417
|
+
const calls = this.transaction.transaction.operations.map((op) => op.call_contract);
|
|
23418
|
+
const { result: multicallResult } = await multicallContract.functions.get({
|
|
23419
|
+
calls,
|
|
23420
|
+
});
|
|
23421
|
+
const results = [];
|
|
23422
|
+
for (let i = 0; i < calls.length; i += 1) {
|
|
23423
|
+
const contract = this.contracts.find((c) => c.getId() === calls[i].contract_id);
|
|
23424
|
+
if (contract && contract.abi) {
|
|
23425
|
+
const method = Object.values(contract.abi.methods).find((method) => {
|
|
23426
|
+
return method.entry_point === calls[i].entry_point;
|
|
23427
|
+
});
|
|
23428
|
+
if (method) {
|
|
23429
|
+
const decoded = (await contract.serializer.deserialize(multicallResult.results[i].res.object, method.return));
|
|
23430
|
+
results.push(decoded);
|
|
23431
|
+
}
|
|
23432
|
+
else {
|
|
23433
|
+
results.push(new Error(`Method ${calls[i].entry_point} not found in contract ${calls[i].contract_id}`));
|
|
23434
|
+
}
|
|
23435
|
+
}
|
|
23436
|
+
else {
|
|
23437
|
+
results.push(new Error(`Contract ${calls[i].contract_id} not found`));
|
|
23438
|
+
}
|
|
23439
|
+
}
|
|
23440
|
+
return results;
|
|
23441
|
+
}
|
|
23442
|
+
}
|
|
23443
|
+
exports.Multicall = Multicall;
|
|
23444
|
+
|
|
23445
|
+
|
|
23150
23446
|
/***/ }),
|
|
23151
23447
|
|
|
23152
23448
|
/***/ 5635:
|
|
@@ -23955,6 +24251,7 @@ exports.Serializer = void 0;
|
|
|
23955
24251
|
const protobufjs_1 = __webpack_require__(3281);
|
|
23956
24252
|
const koinosPbToProto = __importStar(__webpack_require__(9385));
|
|
23957
24253
|
const utils_1 = __webpack_require__(8593);
|
|
24254
|
+
const googleProtobufDescriptor_1 = __webpack_require__(2722);
|
|
23958
24255
|
const OP_BYTES_1 = "(btype)";
|
|
23959
24256
|
const OP_BYTES_2 = "(koinos.btype)";
|
|
23960
24257
|
const nativeTypes = [
|
|
@@ -24053,7 +24350,12 @@ class Serializer {
|
|
|
24053
24350
|
}
|
|
24054
24351
|
}
|
|
24055
24352
|
else {
|
|
24056
|
-
this.root = protobufjs_1.Root.fromJSON(
|
|
24353
|
+
this.root = protobufjs_1.Root.fromJSON({
|
|
24354
|
+
// import google protobuf descriptor if not present
|
|
24355
|
+
...googleProtobufDescriptor_1.googleProtobufDescriptor,
|
|
24356
|
+
// import types
|
|
24357
|
+
...types,
|
|
24358
|
+
});
|
|
24057
24359
|
}
|
|
24058
24360
|
if (opts === null || opts === void 0 ? void 0 : opts.defaultTypeName)
|
|
24059
24361
|
this.defaultType = this.root.lookupType(opts.defaultTypeName);
|
|
@@ -25115,51 +25417,185 @@ exports.Transaction = Transaction;
|
|
|
25115
25417
|
|
|
25116
25418
|
/***/ }),
|
|
25117
25419
|
|
|
25118
|
-
/***/
|
|
25420
|
+
/***/ 5496:
|
|
25119
25421
|
/***/ ((__unused_webpack_module, exports) => {
|
|
25120
25422
|
|
|
25121
25423
|
"use strict";
|
|
25122
25424
|
|
|
25123
25425
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25124
|
-
exports.
|
|
25125
|
-
|
|
25126
|
-
* ABI for Nicknames
|
|
25127
|
-
*
|
|
25128
|
-
* @example
|
|
25129
|
-
* ```ts
|
|
25130
|
-
* import { Contract, Provider, utils } from "koilib";
|
|
25131
|
-
*
|
|
25132
|
-
* const provider = new Provider("https://api.koinos.io");
|
|
25133
|
-
* const nicknamesContract = new Contract({
|
|
25134
|
-
* id: "1KD9Es7LBBjA1FY3ViCgQJ7e6WH1ipKbhz",
|
|
25135
|
-
* provider,
|
|
25136
|
-
* abi: utils.nicknamesAbi,
|
|
25137
|
-
* });
|
|
25138
|
-
* const nicknames = nicknamesContract.functions;
|
|
25139
|
-
*
|
|
25140
|
-
* ...
|
|
25141
|
-
*
|
|
25142
|
-
* // get the address linked to the nickname "pob"
|
|
25143
|
-
* const pobId = `0x${utils.toHexString(new TextEncoder().encode("pob"))}`;
|
|
25144
|
-
* const { result } = await nicknames.owner_of({ token_id: pobId });
|
|
25145
|
-
* console.log(result);
|
|
25146
|
-
*
|
|
25147
|
-
* // { value: '159myq5YUhhoVWu3wsHKHiJYKPKGUrGiyv' }
|
|
25148
|
-
})();
|
|
25149
|
-
* ```
|
|
25150
|
-
*/
|
|
25151
|
-
exports.nicknamesAbi = {
|
|
25426
|
+
exports.multicallAbi = void 0;
|
|
25427
|
+
exports.multicallAbi = {
|
|
25152
25428
|
methods: {
|
|
25153
|
-
|
|
25154
|
-
argument: "
|
|
25155
|
-
return: "
|
|
25156
|
-
description: "
|
|
25157
|
-
entry_point:
|
|
25429
|
+
get: {
|
|
25430
|
+
argument: "multicall.get_args",
|
|
25431
|
+
return: "multicall.get_return",
|
|
25432
|
+
description: "Get the result of a multicall",
|
|
25433
|
+
entry_point: 697873187,
|
|
25158
25434
|
read_only: true,
|
|
25159
25435
|
},
|
|
25160
|
-
|
|
25161
|
-
|
|
25162
|
-
|
|
25436
|
+
},
|
|
25437
|
+
types: "CvEDCg9tdWx0aWNhbGwucHJvdG8SCW11bHRpY2FsbBoUa29pbm9zL29wdGlvbnMucHJvdG8ibAoOY2FsbF9hcmd1bWVudHMSJQoLY29udHJhY3RfaWQYASABKAxCBIC1GAVSCmNvbnRyYWN0SWQSHwoLZW50cnlfcG9pbnQYAiABKA1SCmVudHJ5UG9pbnQSEgoEYXJncxgDIAEoDFIEYXJncyJaCgZyZXN1bHQSGAoGb2JqZWN0GAEgASgMSABSBm9iamVjdBItCgVlcnJvchgCIAEoCzIVLm11bHRpY2FsbC5lcnJvcl9kYXRhSABSBWVycm9yQgcKBXZhbHVlIiYKCmVycm9yX2RhdGESGAoHbWVzc2FnZRgBIAEoCVIHbWVzc2FnZSI7CghnZXRfYXJncxIvCgVjYWxscxgBIAMoCzIZLm11bHRpY2FsbC5jYWxsX2FyZ3VtZW50c1IFY2FsbHMiRgoLY2FsbF9yZXR1cm4SEgoEY29kZRgBIAEoBVIEY29kZRIjCgNyZXMYAiABKAsyES5tdWx0aWNhbGwucmVzdWx0UgNyZXMiPgoKZ2V0X3JldHVybhIwCgdyZXN1bHRzGAEgAygLMhYubXVsdGljYWxsLmNhbGxfcmV0dXJuUgdyZXN1bHRzYgZwcm90bzM=",
|
|
25438
|
+
koilib_types: {
|
|
25439
|
+
nested: {
|
|
25440
|
+
multicall: {
|
|
25441
|
+
nested: {
|
|
25442
|
+
call_arguments: {
|
|
25443
|
+
fields: {
|
|
25444
|
+
contract_id: {
|
|
25445
|
+
type: "bytes",
|
|
25446
|
+
id: 1,
|
|
25447
|
+
options: {
|
|
25448
|
+
"(koinos.btype)": "CONTRACT_ID",
|
|
25449
|
+
},
|
|
25450
|
+
},
|
|
25451
|
+
entry_point: {
|
|
25452
|
+
type: "uint32",
|
|
25453
|
+
id: 2,
|
|
25454
|
+
},
|
|
25455
|
+
args: {
|
|
25456
|
+
type: "bytes",
|
|
25457
|
+
id: 3,
|
|
25458
|
+
},
|
|
25459
|
+
},
|
|
25460
|
+
},
|
|
25461
|
+
result: {
|
|
25462
|
+
oneofs: {
|
|
25463
|
+
value: {
|
|
25464
|
+
oneof: ["object", "error"],
|
|
25465
|
+
},
|
|
25466
|
+
},
|
|
25467
|
+
fields: {
|
|
25468
|
+
object: {
|
|
25469
|
+
type: "bytes",
|
|
25470
|
+
id: 1,
|
|
25471
|
+
},
|
|
25472
|
+
error: {
|
|
25473
|
+
type: "error_data",
|
|
25474
|
+
id: 2,
|
|
25475
|
+
},
|
|
25476
|
+
},
|
|
25477
|
+
},
|
|
25478
|
+
error_data: {
|
|
25479
|
+
fields: {
|
|
25480
|
+
message: {
|
|
25481
|
+
type: "string",
|
|
25482
|
+
id: 1,
|
|
25483
|
+
},
|
|
25484
|
+
},
|
|
25485
|
+
},
|
|
25486
|
+
get_args: {
|
|
25487
|
+
fields: {
|
|
25488
|
+
calls: {
|
|
25489
|
+
rule: "repeated",
|
|
25490
|
+
type: "call_arguments",
|
|
25491
|
+
id: 1,
|
|
25492
|
+
},
|
|
25493
|
+
},
|
|
25494
|
+
},
|
|
25495
|
+
call_return: {
|
|
25496
|
+
fields: {
|
|
25497
|
+
code: {
|
|
25498
|
+
type: "int32",
|
|
25499
|
+
id: 1,
|
|
25500
|
+
},
|
|
25501
|
+
res: {
|
|
25502
|
+
type: "result",
|
|
25503
|
+
id: 2,
|
|
25504
|
+
},
|
|
25505
|
+
},
|
|
25506
|
+
},
|
|
25507
|
+
get_return: {
|
|
25508
|
+
fields: {
|
|
25509
|
+
results: {
|
|
25510
|
+
rule: "repeated",
|
|
25511
|
+
type: "call_return",
|
|
25512
|
+
id: 1,
|
|
25513
|
+
},
|
|
25514
|
+
},
|
|
25515
|
+
},
|
|
25516
|
+
},
|
|
25517
|
+
},
|
|
25518
|
+
koinos: {
|
|
25519
|
+
options: {
|
|
25520
|
+
go_package: "github.com/koinos/koinos-proto-golang/koinos",
|
|
25521
|
+
},
|
|
25522
|
+
nested: {
|
|
25523
|
+
bytes_type: {
|
|
25524
|
+
values: {
|
|
25525
|
+
BASE64: 0,
|
|
25526
|
+
BASE58: 1,
|
|
25527
|
+
HEX: 2,
|
|
25528
|
+
BLOCK_ID: 3,
|
|
25529
|
+
TRANSACTION_ID: 4,
|
|
25530
|
+
CONTRACT_ID: 5,
|
|
25531
|
+
ADDRESS: 6,
|
|
25532
|
+
},
|
|
25533
|
+
},
|
|
25534
|
+
_btype: {
|
|
25535
|
+
oneof: ["btype"],
|
|
25536
|
+
},
|
|
25537
|
+
btype: {
|
|
25538
|
+
type: "bytes_type",
|
|
25539
|
+
id: 50000,
|
|
25540
|
+
extend: "google.protobuf.FieldOptions",
|
|
25541
|
+
options: {
|
|
25542
|
+
proto3_optional: true,
|
|
25543
|
+
},
|
|
25544
|
+
},
|
|
25545
|
+
},
|
|
25546
|
+
},
|
|
25547
|
+
},
|
|
25548
|
+
},
|
|
25549
|
+
};
|
|
25550
|
+
|
|
25551
|
+
|
|
25552
|
+
/***/ }),
|
|
25553
|
+
|
|
25554
|
+
/***/ 9154:
|
|
25555
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
25556
|
+
|
|
25557
|
+
"use strict";
|
|
25558
|
+
|
|
25559
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25560
|
+
exports.nicknamesAbi = void 0;
|
|
25561
|
+
/**
|
|
25562
|
+
* ABI for Nicknames
|
|
25563
|
+
*
|
|
25564
|
+
* @example
|
|
25565
|
+
* ```ts
|
|
25566
|
+
* import { Contract, Provider, utils } from "koilib";
|
|
25567
|
+
*
|
|
25568
|
+
* const provider = new Provider("https://api.koinos.io");
|
|
25569
|
+
* const nicknamesContract = new Contract({
|
|
25570
|
+
* id: "1KD9Es7LBBjA1FY3ViCgQJ7e6WH1ipKbhz",
|
|
25571
|
+
* provider,
|
|
25572
|
+
* abi: utils.nicknamesAbi,
|
|
25573
|
+
* });
|
|
25574
|
+
* const nicknames = nicknamesContract.functions;
|
|
25575
|
+
*
|
|
25576
|
+
* ...
|
|
25577
|
+
*
|
|
25578
|
+
* // get the address linked to the nickname "pob"
|
|
25579
|
+
* const pobId = `0x${utils.toHexString(new TextEncoder().encode("pob"))}`;
|
|
25580
|
+
* const { result } = await nicknames.owner_of({ token_id: pobId });
|
|
25581
|
+
* console.log(result);
|
|
25582
|
+
*
|
|
25583
|
+
* // { value: '159myq5YUhhoVWu3wsHKHiJYKPKGUrGiyv' }
|
|
25584
|
+
})();
|
|
25585
|
+
* ```
|
|
25586
|
+
*/
|
|
25587
|
+
exports.nicknamesAbi = {
|
|
25588
|
+
methods: {
|
|
25589
|
+
verify_valid_name: {
|
|
25590
|
+
argument: "common.str",
|
|
25591
|
+
return: "common.str",
|
|
25592
|
+
description: "Verify if a new name is valid",
|
|
25593
|
+
entry_point: 0x5ad33d9a,
|
|
25594
|
+
read_only: true,
|
|
25595
|
+
},
|
|
25596
|
+
get_tabi: {
|
|
25597
|
+
argument: "nft.token",
|
|
25598
|
+
return: "nicknames.get_tabi_result",
|
|
25163
25599
|
description: "Get TABI",
|
|
25164
25600
|
entry_point: 0x653c5618,
|
|
25165
25601
|
read_only: true,
|
|
@@ -26074,12 +26510,865 @@ const Signer_1 = __webpack_require__(6991);
|
|
|
26074
26510
|
const Provider_1 = __webpack_require__(5635);
|
|
26075
26511
|
const Transaction_1 = __webpack_require__(7592);
|
|
26076
26512
|
const Serializer_1 = __webpack_require__(7187);
|
|
26513
|
+
const Multicall_1 = __webpack_require__(2991);
|
|
26077
26514
|
window.utils = utils;
|
|
26078
26515
|
window.Contract = Contract_1.Contract;
|
|
26079
26516
|
window.Signer = Signer_1.Signer;
|
|
26080
26517
|
window.Provider = Provider_1.Provider;
|
|
26081
26518
|
window.Transaction = Transaction_1.Transaction;
|
|
26082
26519
|
window.Serializer = Serializer_1.Serializer;
|
|
26520
|
+
window.Multicall = Multicall_1.Multicall;
|
|
26521
|
+
|
|
26522
|
+
|
|
26523
|
+
/***/ }),
|
|
26524
|
+
|
|
26525
|
+
/***/ 2722:
|
|
26526
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
26527
|
+
|
|
26528
|
+
"use strict";
|
|
26529
|
+
|
|
26530
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
26531
|
+
exports.googleProtobufDescriptor = void 0;
|
|
26532
|
+
exports.googleProtobufDescriptor = {
|
|
26533
|
+
google: {
|
|
26534
|
+
nested: {
|
|
26535
|
+
protobuf: {
|
|
26536
|
+
options: {
|
|
26537
|
+
go_package: "google.golang.org/protobuf/types/descriptorpb",
|
|
26538
|
+
java_package: "com.google.protobuf",
|
|
26539
|
+
java_outer_classname: "DescriptorProtos",
|
|
26540
|
+
csharp_namespace: "Google.Protobuf.Reflection",
|
|
26541
|
+
objc_class_prefix: "GPB",
|
|
26542
|
+
cc_enable_arenas: true,
|
|
26543
|
+
optimize_for: "SPEED",
|
|
26544
|
+
},
|
|
26545
|
+
nested: {
|
|
26546
|
+
FileDescriptorSet: {
|
|
26547
|
+
fields: {
|
|
26548
|
+
file: {
|
|
26549
|
+
rule: "repeated",
|
|
26550
|
+
type: "FileDescriptorProto",
|
|
26551
|
+
id: 1,
|
|
26552
|
+
},
|
|
26553
|
+
},
|
|
26554
|
+
},
|
|
26555
|
+
FileDescriptorProto: {
|
|
26556
|
+
fields: {
|
|
26557
|
+
name: {
|
|
26558
|
+
type: "string",
|
|
26559
|
+
id: 1,
|
|
26560
|
+
},
|
|
26561
|
+
package: {
|
|
26562
|
+
type: "string",
|
|
26563
|
+
id: 2,
|
|
26564
|
+
},
|
|
26565
|
+
dependency: {
|
|
26566
|
+
rule: "repeated",
|
|
26567
|
+
type: "string",
|
|
26568
|
+
id: 3,
|
|
26569
|
+
},
|
|
26570
|
+
public_dependency: {
|
|
26571
|
+
rule: "repeated",
|
|
26572
|
+
type: "int32",
|
|
26573
|
+
id: 10,
|
|
26574
|
+
options: {
|
|
26575
|
+
packed: false,
|
|
26576
|
+
},
|
|
26577
|
+
},
|
|
26578
|
+
weak_dependency: {
|
|
26579
|
+
rule: "repeated",
|
|
26580
|
+
type: "int32",
|
|
26581
|
+
id: 11,
|
|
26582
|
+
options: {
|
|
26583
|
+
packed: false,
|
|
26584
|
+
},
|
|
26585
|
+
},
|
|
26586
|
+
message_type: {
|
|
26587
|
+
rule: "repeated",
|
|
26588
|
+
type: "DescriptorProto",
|
|
26589
|
+
id: 4,
|
|
26590
|
+
},
|
|
26591
|
+
enum_type: {
|
|
26592
|
+
rule: "repeated",
|
|
26593
|
+
type: "EnumDescriptorProto",
|
|
26594
|
+
id: 5,
|
|
26595
|
+
},
|
|
26596
|
+
service: {
|
|
26597
|
+
rule: "repeated",
|
|
26598
|
+
type: "ServiceDescriptorProto",
|
|
26599
|
+
id: 6,
|
|
26600
|
+
},
|
|
26601
|
+
extension: {
|
|
26602
|
+
rule: "repeated",
|
|
26603
|
+
type: "FieldDescriptorProto",
|
|
26604
|
+
id: 7,
|
|
26605
|
+
},
|
|
26606
|
+
options: {
|
|
26607
|
+
type: "FileOptions",
|
|
26608
|
+
id: 8,
|
|
26609
|
+
},
|
|
26610
|
+
source_code_info: {
|
|
26611
|
+
type: "SourceCodeInfo",
|
|
26612
|
+
id: 9,
|
|
26613
|
+
},
|
|
26614
|
+
syntax: {
|
|
26615
|
+
type: "string",
|
|
26616
|
+
id: 12,
|
|
26617
|
+
},
|
|
26618
|
+
},
|
|
26619
|
+
},
|
|
26620
|
+
DescriptorProto: {
|
|
26621
|
+
fields: {
|
|
26622
|
+
name: {
|
|
26623
|
+
type: "string",
|
|
26624
|
+
id: 1,
|
|
26625
|
+
},
|
|
26626
|
+
field: {
|
|
26627
|
+
rule: "repeated",
|
|
26628
|
+
type: "FieldDescriptorProto",
|
|
26629
|
+
id: 2,
|
|
26630
|
+
},
|
|
26631
|
+
extension: {
|
|
26632
|
+
rule: "repeated",
|
|
26633
|
+
type: "FieldDescriptorProto",
|
|
26634
|
+
id: 6,
|
|
26635
|
+
},
|
|
26636
|
+
nested_type: {
|
|
26637
|
+
rule: "repeated",
|
|
26638
|
+
type: "DescriptorProto",
|
|
26639
|
+
id: 3,
|
|
26640
|
+
},
|
|
26641
|
+
enum_type: {
|
|
26642
|
+
rule: "repeated",
|
|
26643
|
+
type: "EnumDescriptorProto",
|
|
26644
|
+
id: 4,
|
|
26645
|
+
},
|
|
26646
|
+
extension_range: {
|
|
26647
|
+
rule: "repeated",
|
|
26648
|
+
type: "ExtensionRange",
|
|
26649
|
+
id: 5,
|
|
26650
|
+
},
|
|
26651
|
+
oneof_decl: {
|
|
26652
|
+
rule: "repeated",
|
|
26653
|
+
type: "OneofDescriptorProto",
|
|
26654
|
+
id: 8,
|
|
26655
|
+
},
|
|
26656
|
+
options: {
|
|
26657
|
+
type: "MessageOptions",
|
|
26658
|
+
id: 7,
|
|
26659
|
+
},
|
|
26660
|
+
reserved_range: {
|
|
26661
|
+
rule: "repeated",
|
|
26662
|
+
type: "ReservedRange",
|
|
26663
|
+
id: 9,
|
|
26664
|
+
},
|
|
26665
|
+
reserved_name: {
|
|
26666
|
+
rule: "repeated",
|
|
26667
|
+
type: "string",
|
|
26668
|
+
id: 10,
|
|
26669
|
+
},
|
|
26670
|
+
},
|
|
26671
|
+
nested: {
|
|
26672
|
+
ExtensionRange: {
|
|
26673
|
+
fields: {
|
|
26674
|
+
start: {
|
|
26675
|
+
type: "int32",
|
|
26676
|
+
id: 1,
|
|
26677
|
+
},
|
|
26678
|
+
end: {
|
|
26679
|
+
type: "int32",
|
|
26680
|
+
id: 2,
|
|
26681
|
+
},
|
|
26682
|
+
options: {
|
|
26683
|
+
type: "ExtensionRangeOptions",
|
|
26684
|
+
id: 3,
|
|
26685
|
+
},
|
|
26686
|
+
},
|
|
26687
|
+
},
|
|
26688
|
+
ReservedRange: {
|
|
26689
|
+
fields: {
|
|
26690
|
+
start: {
|
|
26691
|
+
type: "int32",
|
|
26692
|
+
id: 1,
|
|
26693
|
+
},
|
|
26694
|
+
end: {
|
|
26695
|
+
type: "int32",
|
|
26696
|
+
id: 2,
|
|
26697
|
+
},
|
|
26698
|
+
},
|
|
26699
|
+
},
|
|
26700
|
+
},
|
|
26701
|
+
},
|
|
26702
|
+
ExtensionRangeOptions: {
|
|
26703
|
+
fields: {
|
|
26704
|
+
uninterpreted_option: {
|
|
26705
|
+
rule: "repeated",
|
|
26706
|
+
type: "UninterpretedOption",
|
|
26707
|
+
id: 999,
|
|
26708
|
+
},
|
|
26709
|
+
},
|
|
26710
|
+
extensions: [[1000, 536870911]],
|
|
26711
|
+
},
|
|
26712
|
+
FieldDescriptorProto: {
|
|
26713
|
+
fields: {
|
|
26714
|
+
name: {
|
|
26715
|
+
type: "string",
|
|
26716
|
+
id: 1,
|
|
26717
|
+
},
|
|
26718
|
+
number: {
|
|
26719
|
+
type: "int32",
|
|
26720
|
+
id: 3,
|
|
26721
|
+
},
|
|
26722
|
+
label: {
|
|
26723
|
+
type: "Label",
|
|
26724
|
+
id: 4,
|
|
26725
|
+
},
|
|
26726
|
+
type: {
|
|
26727
|
+
type: "Type",
|
|
26728
|
+
id: 5,
|
|
26729
|
+
},
|
|
26730
|
+
type_name: {
|
|
26731
|
+
type: "string",
|
|
26732
|
+
id: 6,
|
|
26733
|
+
},
|
|
26734
|
+
extendee: {
|
|
26735
|
+
type: "string",
|
|
26736
|
+
id: 2,
|
|
26737
|
+
},
|
|
26738
|
+
default_value: {
|
|
26739
|
+
type: "string",
|
|
26740
|
+
id: 7,
|
|
26741
|
+
},
|
|
26742
|
+
oneof_index: {
|
|
26743
|
+
type: "int32",
|
|
26744
|
+
id: 9,
|
|
26745
|
+
},
|
|
26746
|
+
json_name: {
|
|
26747
|
+
type: "string",
|
|
26748
|
+
id: 10,
|
|
26749
|
+
},
|
|
26750
|
+
options: {
|
|
26751
|
+
type: "FieldOptions",
|
|
26752
|
+
id: 8,
|
|
26753
|
+
},
|
|
26754
|
+
proto3_optional: {
|
|
26755
|
+
type: "bool",
|
|
26756
|
+
id: 17,
|
|
26757
|
+
},
|
|
26758
|
+
},
|
|
26759
|
+
nested: {
|
|
26760
|
+
Type: {
|
|
26761
|
+
values: {
|
|
26762
|
+
TYPE_DOUBLE: 1,
|
|
26763
|
+
TYPE_FLOAT: 2,
|
|
26764
|
+
TYPE_INT64: 3,
|
|
26765
|
+
TYPE_UINT64: 4,
|
|
26766
|
+
TYPE_INT32: 5,
|
|
26767
|
+
TYPE_FIXED64: 6,
|
|
26768
|
+
TYPE_FIXED32: 7,
|
|
26769
|
+
TYPE_BOOL: 8,
|
|
26770
|
+
TYPE_STRING: 9,
|
|
26771
|
+
TYPE_GROUP: 10,
|
|
26772
|
+
TYPE_MESSAGE: 11,
|
|
26773
|
+
TYPE_BYTES: 12,
|
|
26774
|
+
TYPE_UINT32: 13,
|
|
26775
|
+
TYPE_ENUM: 14,
|
|
26776
|
+
TYPE_SFIXED32: 15,
|
|
26777
|
+
TYPE_SFIXED64: 16,
|
|
26778
|
+
TYPE_SINT32: 17,
|
|
26779
|
+
TYPE_SINT64: 18,
|
|
26780
|
+
},
|
|
26781
|
+
},
|
|
26782
|
+
Label: {
|
|
26783
|
+
values: {
|
|
26784
|
+
LABEL_OPTIONAL: 1,
|
|
26785
|
+
LABEL_REQUIRED: 2,
|
|
26786
|
+
LABEL_REPEATED: 3,
|
|
26787
|
+
},
|
|
26788
|
+
},
|
|
26789
|
+
},
|
|
26790
|
+
},
|
|
26791
|
+
OneofDescriptorProto: {
|
|
26792
|
+
fields: {
|
|
26793
|
+
name: {
|
|
26794
|
+
type: "string",
|
|
26795
|
+
id: 1,
|
|
26796
|
+
},
|
|
26797
|
+
options: {
|
|
26798
|
+
type: "OneofOptions",
|
|
26799
|
+
id: 2,
|
|
26800
|
+
},
|
|
26801
|
+
},
|
|
26802
|
+
},
|
|
26803
|
+
EnumDescriptorProto: {
|
|
26804
|
+
fields: {
|
|
26805
|
+
name: {
|
|
26806
|
+
type: "string",
|
|
26807
|
+
id: 1,
|
|
26808
|
+
},
|
|
26809
|
+
value: {
|
|
26810
|
+
rule: "repeated",
|
|
26811
|
+
type: "EnumValueDescriptorProto",
|
|
26812
|
+
id: 2,
|
|
26813
|
+
},
|
|
26814
|
+
options: {
|
|
26815
|
+
type: "EnumOptions",
|
|
26816
|
+
id: 3,
|
|
26817
|
+
},
|
|
26818
|
+
reserved_range: {
|
|
26819
|
+
rule: "repeated",
|
|
26820
|
+
type: "EnumReservedRange",
|
|
26821
|
+
id: 4,
|
|
26822
|
+
},
|
|
26823
|
+
reserved_name: {
|
|
26824
|
+
rule: "repeated",
|
|
26825
|
+
type: "string",
|
|
26826
|
+
id: 5,
|
|
26827
|
+
},
|
|
26828
|
+
},
|
|
26829
|
+
nested: {
|
|
26830
|
+
EnumReservedRange: {
|
|
26831
|
+
fields: {
|
|
26832
|
+
start: {
|
|
26833
|
+
type: "int32",
|
|
26834
|
+
id: 1,
|
|
26835
|
+
},
|
|
26836
|
+
end: {
|
|
26837
|
+
type: "int32",
|
|
26838
|
+
id: 2,
|
|
26839
|
+
},
|
|
26840
|
+
},
|
|
26841
|
+
},
|
|
26842
|
+
},
|
|
26843
|
+
},
|
|
26844
|
+
EnumValueDescriptorProto: {
|
|
26845
|
+
fields: {
|
|
26846
|
+
name: {
|
|
26847
|
+
type: "string",
|
|
26848
|
+
id: 1,
|
|
26849
|
+
},
|
|
26850
|
+
number: {
|
|
26851
|
+
type: "int32",
|
|
26852
|
+
id: 2,
|
|
26853
|
+
},
|
|
26854
|
+
options: {
|
|
26855
|
+
type: "EnumValueOptions",
|
|
26856
|
+
id: 3,
|
|
26857
|
+
},
|
|
26858
|
+
},
|
|
26859
|
+
},
|
|
26860
|
+
ServiceDescriptorProto: {
|
|
26861
|
+
fields: {
|
|
26862
|
+
name: {
|
|
26863
|
+
type: "string",
|
|
26864
|
+
id: 1,
|
|
26865
|
+
},
|
|
26866
|
+
method: {
|
|
26867
|
+
rule: "repeated",
|
|
26868
|
+
type: "MethodDescriptorProto",
|
|
26869
|
+
id: 2,
|
|
26870
|
+
},
|
|
26871
|
+
options: {
|
|
26872
|
+
type: "ServiceOptions",
|
|
26873
|
+
id: 3,
|
|
26874
|
+
},
|
|
26875
|
+
},
|
|
26876
|
+
},
|
|
26877
|
+
MethodDescriptorProto: {
|
|
26878
|
+
fields: {
|
|
26879
|
+
name: {
|
|
26880
|
+
type: "string",
|
|
26881
|
+
id: 1,
|
|
26882
|
+
},
|
|
26883
|
+
input_type: {
|
|
26884
|
+
type: "string",
|
|
26885
|
+
id: 2,
|
|
26886
|
+
},
|
|
26887
|
+
output_type: {
|
|
26888
|
+
type: "string",
|
|
26889
|
+
id: 3,
|
|
26890
|
+
},
|
|
26891
|
+
options: {
|
|
26892
|
+
type: "MethodOptions",
|
|
26893
|
+
id: 4,
|
|
26894
|
+
},
|
|
26895
|
+
client_streaming: {
|
|
26896
|
+
type: "bool",
|
|
26897
|
+
id: 5,
|
|
26898
|
+
options: {
|
|
26899
|
+
default: false,
|
|
26900
|
+
},
|
|
26901
|
+
},
|
|
26902
|
+
server_streaming: {
|
|
26903
|
+
type: "bool",
|
|
26904
|
+
id: 6,
|
|
26905
|
+
options: {
|
|
26906
|
+
default: false,
|
|
26907
|
+
},
|
|
26908
|
+
},
|
|
26909
|
+
},
|
|
26910
|
+
},
|
|
26911
|
+
FileOptions: {
|
|
26912
|
+
fields: {
|
|
26913
|
+
java_package: {
|
|
26914
|
+
type: "string",
|
|
26915
|
+
id: 1,
|
|
26916
|
+
},
|
|
26917
|
+
java_outer_classname: {
|
|
26918
|
+
type: "string",
|
|
26919
|
+
id: 8,
|
|
26920
|
+
},
|
|
26921
|
+
java_multiple_files: {
|
|
26922
|
+
type: "bool",
|
|
26923
|
+
id: 10,
|
|
26924
|
+
options: {
|
|
26925
|
+
default: false,
|
|
26926
|
+
},
|
|
26927
|
+
},
|
|
26928
|
+
java_generate_equals_and_hash: {
|
|
26929
|
+
type: "bool",
|
|
26930
|
+
id: 20,
|
|
26931
|
+
options: {
|
|
26932
|
+
deprecated: true,
|
|
26933
|
+
},
|
|
26934
|
+
},
|
|
26935
|
+
java_string_check_utf8: {
|
|
26936
|
+
type: "bool",
|
|
26937
|
+
id: 27,
|
|
26938
|
+
options: {
|
|
26939
|
+
default: false,
|
|
26940
|
+
},
|
|
26941
|
+
},
|
|
26942
|
+
optimize_for: {
|
|
26943
|
+
type: "OptimizeMode",
|
|
26944
|
+
id: 9,
|
|
26945
|
+
options: {
|
|
26946
|
+
default: "SPEED",
|
|
26947
|
+
},
|
|
26948
|
+
},
|
|
26949
|
+
go_package: {
|
|
26950
|
+
type: "string",
|
|
26951
|
+
id: 11,
|
|
26952
|
+
},
|
|
26953
|
+
cc_generic_services: {
|
|
26954
|
+
type: "bool",
|
|
26955
|
+
id: 16,
|
|
26956
|
+
options: {
|
|
26957
|
+
default: false,
|
|
26958
|
+
},
|
|
26959
|
+
},
|
|
26960
|
+
java_generic_services: {
|
|
26961
|
+
type: "bool",
|
|
26962
|
+
id: 17,
|
|
26963
|
+
options: {
|
|
26964
|
+
default: false,
|
|
26965
|
+
},
|
|
26966
|
+
},
|
|
26967
|
+
py_generic_services: {
|
|
26968
|
+
type: "bool",
|
|
26969
|
+
id: 18,
|
|
26970
|
+
options: {
|
|
26971
|
+
default: false,
|
|
26972
|
+
},
|
|
26973
|
+
},
|
|
26974
|
+
php_generic_services: {
|
|
26975
|
+
type: "bool",
|
|
26976
|
+
id: 42,
|
|
26977
|
+
options: {
|
|
26978
|
+
default: false,
|
|
26979
|
+
},
|
|
26980
|
+
},
|
|
26981
|
+
deprecated: {
|
|
26982
|
+
type: "bool",
|
|
26983
|
+
id: 23,
|
|
26984
|
+
options: {
|
|
26985
|
+
default: false,
|
|
26986
|
+
},
|
|
26987
|
+
},
|
|
26988
|
+
cc_enable_arenas: {
|
|
26989
|
+
type: "bool",
|
|
26990
|
+
id: 31,
|
|
26991
|
+
options: {
|
|
26992
|
+
default: true,
|
|
26993
|
+
},
|
|
26994
|
+
},
|
|
26995
|
+
objc_class_prefix: {
|
|
26996
|
+
type: "string",
|
|
26997
|
+
id: 36,
|
|
26998
|
+
},
|
|
26999
|
+
csharp_namespace: {
|
|
27000
|
+
type: "string",
|
|
27001
|
+
id: 37,
|
|
27002
|
+
},
|
|
27003
|
+
swift_prefix: {
|
|
27004
|
+
type: "string",
|
|
27005
|
+
id: 39,
|
|
27006
|
+
},
|
|
27007
|
+
php_class_prefix: {
|
|
27008
|
+
type: "string",
|
|
27009
|
+
id: 40,
|
|
27010
|
+
},
|
|
27011
|
+
php_namespace: {
|
|
27012
|
+
type: "string",
|
|
27013
|
+
id: 41,
|
|
27014
|
+
},
|
|
27015
|
+
php_metadata_namespace: {
|
|
27016
|
+
type: "string",
|
|
27017
|
+
id: 44,
|
|
27018
|
+
},
|
|
27019
|
+
ruby_package: {
|
|
27020
|
+
type: "string",
|
|
27021
|
+
id: 45,
|
|
27022
|
+
},
|
|
27023
|
+
uninterpreted_option: {
|
|
27024
|
+
rule: "repeated",
|
|
27025
|
+
type: "UninterpretedOption",
|
|
27026
|
+
id: 999,
|
|
27027
|
+
},
|
|
27028
|
+
},
|
|
27029
|
+
extensions: [[1000, 536870911]],
|
|
27030
|
+
reserved: [[38, 38]],
|
|
27031
|
+
nested: {
|
|
27032
|
+
OptimizeMode: {
|
|
27033
|
+
values: {
|
|
27034
|
+
SPEED: 1,
|
|
27035
|
+
CODE_SIZE: 2,
|
|
27036
|
+
LITE_RUNTIME: 3,
|
|
27037
|
+
},
|
|
27038
|
+
},
|
|
27039
|
+
},
|
|
27040
|
+
},
|
|
27041
|
+
MessageOptions: {
|
|
27042
|
+
fields: {
|
|
27043
|
+
message_set_wire_format: {
|
|
27044
|
+
type: "bool",
|
|
27045
|
+
id: 1,
|
|
27046
|
+
options: {
|
|
27047
|
+
default: false,
|
|
27048
|
+
},
|
|
27049
|
+
},
|
|
27050
|
+
no_standard_descriptor_accessor: {
|
|
27051
|
+
type: "bool",
|
|
27052
|
+
id: 2,
|
|
27053
|
+
options: {
|
|
27054
|
+
default: false,
|
|
27055
|
+
},
|
|
27056
|
+
},
|
|
27057
|
+
deprecated: {
|
|
27058
|
+
type: "bool",
|
|
27059
|
+
id: 3,
|
|
27060
|
+
options: {
|
|
27061
|
+
default: false,
|
|
27062
|
+
},
|
|
27063
|
+
},
|
|
27064
|
+
map_entry: {
|
|
27065
|
+
type: "bool",
|
|
27066
|
+
id: 7,
|
|
27067
|
+
},
|
|
27068
|
+
uninterpreted_option: {
|
|
27069
|
+
rule: "repeated",
|
|
27070
|
+
type: "UninterpretedOption",
|
|
27071
|
+
id: 999,
|
|
27072
|
+
},
|
|
27073
|
+
},
|
|
27074
|
+
extensions: [[1000, 536870911]],
|
|
27075
|
+
reserved: [
|
|
27076
|
+
[4, 4],
|
|
27077
|
+
[5, 5],
|
|
27078
|
+
[6, 6],
|
|
27079
|
+
[8, 8],
|
|
27080
|
+
[9, 9],
|
|
27081
|
+
],
|
|
27082
|
+
},
|
|
27083
|
+
FieldOptions: {
|
|
27084
|
+
fields: {
|
|
27085
|
+
ctype: {
|
|
27086
|
+
type: "CType",
|
|
27087
|
+
id: 1,
|
|
27088
|
+
options: {
|
|
27089
|
+
default: "STRING",
|
|
27090
|
+
},
|
|
27091
|
+
},
|
|
27092
|
+
packed: {
|
|
27093
|
+
type: "bool",
|
|
27094
|
+
id: 2,
|
|
27095
|
+
},
|
|
27096
|
+
jstype: {
|
|
27097
|
+
type: "JSType",
|
|
27098
|
+
id: 6,
|
|
27099
|
+
options: {
|
|
27100
|
+
default: "JS_NORMAL",
|
|
27101
|
+
},
|
|
27102
|
+
},
|
|
27103
|
+
lazy: {
|
|
27104
|
+
type: "bool",
|
|
27105
|
+
id: 5,
|
|
27106
|
+
options: {
|
|
27107
|
+
default: false,
|
|
27108
|
+
},
|
|
27109
|
+
},
|
|
27110
|
+
deprecated: {
|
|
27111
|
+
type: "bool",
|
|
27112
|
+
id: 3,
|
|
27113
|
+
options: {
|
|
27114
|
+
default: false,
|
|
27115
|
+
},
|
|
27116
|
+
},
|
|
27117
|
+
weak: {
|
|
27118
|
+
type: "bool",
|
|
27119
|
+
id: 10,
|
|
27120
|
+
options: {
|
|
27121
|
+
default: false,
|
|
27122
|
+
},
|
|
27123
|
+
},
|
|
27124
|
+
uninterpreted_option: {
|
|
27125
|
+
rule: "repeated",
|
|
27126
|
+
type: "UninterpretedOption",
|
|
27127
|
+
id: 999,
|
|
27128
|
+
},
|
|
27129
|
+
},
|
|
27130
|
+
extensions: [[1000, 536870911]],
|
|
27131
|
+
reserved: [[4, 4]],
|
|
27132
|
+
nested: {
|
|
27133
|
+
CType: {
|
|
27134
|
+
values: {
|
|
27135
|
+
STRING: 0,
|
|
27136
|
+
CORD: 1,
|
|
27137
|
+
STRING_PIECE: 2,
|
|
27138
|
+
},
|
|
27139
|
+
},
|
|
27140
|
+
JSType: {
|
|
27141
|
+
values: {
|
|
27142
|
+
JS_NORMAL: 0,
|
|
27143
|
+
JS_STRING: 1,
|
|
27144
|
+
JS_NUMBER: 2,
|
|
27145
|
+
},
|
|
27146
|
+
},
|
|
27147
|
+
},
|
|
27148
|
+
},
|
|
27149
|
+
OneofOptions: {
|
|
27150
|
+
fields: {
|
|
27151
|
+
uninterpreted_option: {
|
|
27152
|
+
rule: "repeated",
|
|
27153
|
+
type: "UninterpretedOption",
|
|
27154
|
+
id: 999,
|
|
27155
|
+
},
|
|
27156
|
+
},
|
|
27157
|
+
extensions: [[1000, 536870911]],
|
|
27158
|
+
},
|
|
27159
|
+
EnumOptions: {
|
|
27160
|
+
fields: {
|
|
27161
|
+
allow_alias: {
|
|
27162
|
+
type: "bool",
|
|
27163
|
+
id: 2,
|
|
27164
|
+
},
|
|
27165
|
+
deprecated: {
|
|
27166
|
+
type: "bool",
|
|
27167
|
+
id: 3,
|
|
27168
|
+
options: {
|
|
27169
|
+
default: false,
|
|
27170
|
+
},
|
|
27171
|
+
},
|
|
27172
|
+
uninterpreted_option: {
|
|
27173
|
+
rule: "repeated",
|
|
27174
|
+
type: "UninterpretedOption",
|
|
27175
|
+
id: 999,
|
|
27176
|
+
},
|
|
27177
|
+
},
|
|
27178
|
+
extensions: [[1000, 536870911]],
|
|
27179
|
+
reserved: [[5, 5]],
|
|
27180
|
+
},
|
|
27181
|
+
EnumValueOptions: {
|
|
27182
|
+
fields: {
|
|
27183
|
+
deprecated: {
|
|
27184
|
+
type: "bool",
|
|
27185
|
+
id: 1,
|
|
27186
|
+
options: {
|
|
27187
|
+
default: false,
|
|
27188
|
+
},
|
|
27189
|
+
},
|
|
27190
|
+
uninterpreted_option: {
|
|
27191
|
+
rule: "repeated",
|
|
27192
|
+
type: "UninterpretedOption",
|
|
27193
|
+
id: 999,
|
|
27194
|
+
},
|
|
27195
|
+
},
|
|
27196
|
+
extensions: [[1000, 536870911]],
|
|
27197
|
+
},
|
|
27198
|
+
ServiceOptions: {
|
|
27199
|
+
fields: {
|
|
27200
|
+
deprecated: {
|
|
27201
|
+
type: "bool",
|
|
27202
|
+
id: 33,
|
|
27203
|
+
options: {
|
|
27204
|
+
default: false,
|
|
27205
|
+
},
|
|
27206
|
+
},
|
|
27207
|
+
uninterpreted_option: {
|
|
27208
|
+
rule: "repeated",
|
|
27209
|
+
type: "UninterpretedOption",
|
|
27210
|
+
id: 999,
|
|
27211
|
+
},
|
|
27212
|
+
},
|
|
27213
|
+
extensions: [[1000, 536870911]],
|
|
27214
|
+
},
|
|
27215
|
+
MethodOptions: {
|
|
27216
|
+
fields: {
|
|
27217
|
+
deprecated: {
|
|
27218
|
+
type: "bool",
|
|
27219
|
+
id: 33,
|
|
27220
|
+
options: {
|
|
27221
|
+
default: false,
|
|
27222
|
+
},
|
|
27223
|
+
},
|
|
27224
|
+
idempotency_level: {
|
|
27225
|
+
type: "IdempotencyLevel",
|
|
27226
|
+
id: 34,
|
|
27227
|
+
options: {
|
|
27228
|
+
default: "IDEMPOTENCY_UNKNOWN",
|
|
27229
|
+
},
|
|
27230
|
+
},
|
|
27231
|
+
uninterpreted_option: {
|
|
27232
|
+
rule: "repeated",
|
|
27233
|
+
type: "UninterpretedOption",
|
|
27234
|
+
id: 999,
|
|
27235
|
+
},
|
|
27236
|
+
},
|
|
27237
|
+
extensions: [[1000, 536870911]],
|
|
27238
|
+
nested: {
|
|
27239
|
+
IdempotencyLevel: {
|
|
27240
|
+
values: {
|
|
27241
|
+
IDEMPOTENCY_UNKNOWN: 0,
|
|
27242
|
+
NO_SIDE_EFFECTS: 1,
|
|
27243
|
+
IDEMPOTENT: 2,
|
|
27244
|
+
},
|
|
27245
|
+
},
|
|
27246
|
+
},
|
|
27247
|
+
},
|
|
27248
|
+
UninterpretedOption: {
|
|
27249
|
+
fields: {
|
|
27250
|
+
name: {
|
|
27251
|
+
rule: "repeated",
|
|
27252
|
+
type: "NamePart",
|
|
27253
|
+
id: 2,
|
|
27254
|
+
},
|
|
27255
|
+
identifier_value: {
|
|
27256
|
+
type: "string",
|
|
27257
|
+
id: 3,
|
|
27258
|
+
},
|
|
27259
|
+
positive_int_value: {
|
|
27260
|
+
type: "uint64",
|
|
27261
|
+
id: 4,
|
|
27262
|
+
},
|
|
27263
|
+
negative_int_value: {
|
|
27264
|
+
type: "int64",
|
|
27265
|
+
id: 5,
|
|
27266
|
+
},
|
|
27267
|
+
double_value: {
|
|
27268
|
+
type: "double",
|
|
27269
|
+
id: 6,
|
|
27270
|
+
},
|
|
27271
|
+
string_value: {
|
|
27272
|
+
type: "bytes",
|
|
27273
|
+
id: 7,
|
|
27274
|
+
},
|
|
27275
|
+
aggregate_value: {
|
|
27276
|
+
type: "string",
|
|
27277
|
+
id: 8,
|
|
27278
|
+
},
|
|
27279
|
+
},
|
|
27280
|
+
nested: {
|
|
27281
|
+
NamePart: {
|
|
27282
|
+
fields: {
|
|
27283
|
+
name_part: {
|
|
27284
|
+
rule: "required",
|
|
27285
|
+
type: "string",
|
|
27286
|
+
id: 1,
|
|
27287
|
+
},
|
|
27288
|
+
is_extension: {
|
|
27289
|
+
rule: "required",
|
|
27290
|
+
type: "bool",
|
|
27291
|
+
id: 2,
|
|
27292
|
+
},
|
|
27293
|
+
},
|
|
27294
|
+
},
|
|
27295
|
+
},
|
|
27296
|
+
},
|
|
27297
|
+
SourceCodeInfo: {
|
|
27298
|
+
fields: {
|
|
27299
|
+
location: {
|
|
27300
|
+
rule: "repeated",
|
|
27301
|
+
type: "Location",
|
|
27302
|
+
id: 1,
|
|
27303
|
+
},
|
|
27304
|
+
},
|
|
27305
|
+
nested: {
|
|
27306
|
+
Location: {
|
|
27307
|
+
fields: {
|
|
27308
|
+
path: {
|
|
27309
|
+
rule: "repeated",
|
|
27310
|
+
type: "int32",
|
|
27311
|
+
id: 1,
|
|
27312
|
+
},
|
|
27313
|
+
span: {
|
|
27314
|
+
rule: "repeated",
|
|
27315
|
+
type: "int32",
|
|
27316
|
+
id: 2,
|
|
27317
|
+
},
|
|
27318
|
+
leading_comments: {
|
|
27319
|
+
type: "string",
|
|
27320
|
+
id: 3,
|
|
27321
|
+
},
|
|
27322
|
+
trailing_comments: {
|
|
27323
|
+
type: "string",
|
|
27324
|
+
id: 4,
|
|
27325
|
+
},
|
|
27326
|
+
leading_detached_comments: {
|
|
27327
|
+
rule: "repeated",
|
|
27328
|
+
type: "string",
|
|
27329
|
+
id: 6,
|
|
27330
|
+
},
|
|
27331
|
+
},
|
|
27332
|
+
},
|
|
27333
|
+
},
|
|
27334
|
+
},
|
|
27335
|
+
GeneratedCodeInfo: {
|
|
27336
|
+
fields: {
|
|
27337
|
+
annotation: {
|
|
27338
|
+
rule: "repeated",
|
|
27339
|
+
type: "Annotation",
|
|
27340
|
+
id: 1,
|
|
27341
|
+
},
|
|
27342
|
+
},
|
|
27343
|
+
nested: {
|
|
27344
|
+
Annotation: {
|
|
27345
|
+
fields: {
|
|
27346
|
+
path: {
|
|
27347
|
+
rule: "repeated",
|
|
27348
|
+
type: "int32",
|
|
27349
|
+
id: 1,
|
|
27350
|
+
},
|
|
27351
|
+
source_file: {
|
|
27352
|
+
type: "string",
|
|
27353
|
+
id: 2,
|
|
27354
|
+
},
|
|
27355
|
+
begin: {
|
|
27356
|
+
type: "int32",
|
|
27357
|
+
id: 3,
|
|
27358
|
+
},
|
|
27359
|
+
end: {
|
|
27360
|
+
type: "int32",
|
|
27361
|
+
id: 4,
|
|
27362
|
+
},
|
|
27363
|
+
},
|
|
27364
|
+
},
|
|
27365
|
+
},
|
|
27366
|
+
},
|
|
27367
|
+
},
|
|
27368
|
+
},
|
|
27369
|
+
},
|
|
27370
|
+
},
|
|
27371
|
+
};
|
|
26083
27372
|
|
|
26084
27373
|
|
|
26085
27374
|
/***/ }),
|