@taquito/utils 24.2.0 → 24.3.0-beta.1
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/dist/lib/constants.js +3 -3
- package/dist/lib/encoding.js +23 -23
- package/dist/lib/errors.js +2 -2
- package/dist/lib/validators.js +13 -13
- package/dist/lib/verify-signature.js +7 -7
- package/dist/lib/version.js +2 -2
- package/dist/taquito-utils.es6.js +50 -50
- package/dist/taquito-utils.umd.js +50 -50
- package/dist/types/constants.d.ts +3 -3
- package/dist/types/encoding.d.ts +30 -30
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/validators.d.ts +11 -11
- package/dist/types/verify-signature.d.ts +2 -2
- package/package.json +23 -10
- package/LICENSE +0 -202
|
@@ -1992,7 +1992,7 @@ function isSlowBuffer (obj) {
|
|
|
1992
1992
|
|
|
1993
1993
|
// ref https://gitlab.com/tezos/tezos/-/blob/master/src/lib_crypto/base58.ml
|
|
1994
1994
|
/**
|
|
1995
|
-
*
|
|
1995
|
+
* base58 name to prefix mapping
|
|
1996
1996
|
*/
|
|
1997
1997
|
var PrefixV2;
|
|
1998
1998
|
(function (PrefixV2) {
|
|
@@ -2059,7 +2059,7 @@ var PrefixV2;
|
|
|
2059
2059
|
PrefixV2["SlotHeader"] = "sh";
|
|
2060
2060
|
})(PrefixV2 || (PrefixV2 = {}));
|
|
2061
2061
|
/**
|
|
2062
|
-
*
|
|
2062
|
+
* base58 prefix to bytes mapping
|
|
2063
2063
|
*/
|
|
2064
2064
|
const prefixV2 = {
|
|
2065
2065
|
[PrefixV2.BlockHash]: new Uint8Array([1, 52]),
|
|
@@ -2125,7 +2125,7 @@ const prefixV2 = {
|
|
|
2125
2125
|
[PrefixV2.SlotHeader]: new Uint8Array([2, 116, 180]),
|
|
2126
2126
|
};
|
|
2127
2127
|
/**
|
|
2128
|
-
*
|
|
2128
|
+
* base58 prefix to payload length mapping
|
|
2129
2129
|
*/
|
|
2130
2130
|
const payloadLength = {
|
|
2131
2131
|
[PrefixV2.BlockHash]: 32,
|
|
@@ -2201,7 +2201,7 @@ const payloadLength = {
|
|
|
2201
2201
|
* Copyright (c) 2017 Stephen Andrews
|
|
2202
2202
|
*/
|
|
2203
2203
|
/**
|
|
2204
|
-
*
|
|
2204
|
+
* list of prefixes that can be used to decode an address
|
|
2205
2205
|
*/
|
|
2206
2206
|
const addressPrefixes = [
|
|
2207
2207
|
PrefixV2.P256PublicKeyHash,
|
|
@@ -2213,7 +2213,7 @@ const addressPrefixes = [
|
|
|
2213
2213
|
// PrefixV2.ZkRollupHash,
|
|
2214
2214
|
];
|
|
2215
2215
|
/**
|
|
2216
|
-
*
|
|
2216
|
+
* list of prefixes that can be used to decode a public key
|
|
2217
2217
|
*/
|
|
2218
2218
|
const publicKeyPrefixes = [
|
|
2219
2219
|
PrefixV2.P256PublicKey,
|
|
@@ -2222,7 +2222,7 @@ const publicKeyPrefixes = [
|
|
|
2222
2222
|
PrefixV2.BLS12_381PublicKey,
|
|
2223
2223
|
];
|
|
2224
2224
|
/**
|
|
2225
|
-
*
|
|
2225
|
+
* list of prefixes that can be used to decode a public key hash
|
|
2226
2226
|
*/
|
|
2227
2227
|
const publicKeyHashPrefixes = [
|
|
2228
2228
|
PrefixV2.P256PublicKeyHash,
|
|
@@ -2231,7 +2231,7 @@ const publicKeyHashPrefixes = [
|
|
|
2231
2231
|
PrefixV2.BLS12_381PublicKeyHash,
|
|
2232
2232
|
];
|
|
2233
2233
|
/**
|
|
2234
|
-
*
|
|
2234
|
+
* list of prefixes that can be used to decode a signature
|
|
2235
2235
|
*/
|
|
2236
2236
|
const signaturePrefixes = [
|
|
2237
2237
|
PrefixV2.P256Signature,
|
|
@@ -2403,7 +2403,7 @@ function b58DecodeAddress(value, fmt) {
|
|
|
2403
2403
|
}
|
|
2404
2404
|
}
|
|
2405
2405
|
/**
|
|
2406
|
-
*
|
|
2406
|
+
* Gets Tezos address (PKH) from Public Key
|
|
2407
2407
|
* @param publicKey Base58 Public Key
|
|
2408
2408
|
* @returns A string of the Tezos address (PKH) that was derived from the given Public Key
|
|
2409
2409
|
* @example getPkhfromPk('edpkuNjKKT48xBoT5asPrWdmuM1Yw8D93MwgFgVvtca8jb5pstzaCh') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
@@ -2431,7 +2431,7 @@ function getPkhfromPk(publicKey) {
|
|
|
2431
2431
|
return b58Encode(hashed, pkhPre);
|
|
2432
2432
|
}
|
|
2433
2433
|
/**
|
|
2434
|
-
*
|
|
2434
|
+
* Add the prefix to a hex string or Uint8Array and Base58 encode it
|
|
2435
2435
|
* @param value Value to Base58 encode
|
|
2436
2436
|
* @param pre prefix ID to append to the encoded string
|
|
2437
2437
|
* @example b58Encode('e96b9f8b19af9c7ffa0c0480e1977b295850961f', PrefixV2.Ed25519PublicKeyHash) // returns 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
@@ -2445,7 +2445,7 @@ function b58Encode(value, pre) {
|
|
|
2445
2445
|
return bs58check.encode(toBuffer(n));
|
|
2446
2446
|
}
|
|
2447
2447
|
/**
|
|
2448
|
-
*
|
|
2448
|
+
* Parse binary public key and return Base58 representation
|
|
2449
2449
|
* @param value Binary key data
|
|
2450
2450
|
* @returns return prefixed public key
|
|
2451
2451
|
* @example encodeKey('02033aba7da4a2e7b5dd9f074555c118829aff16213ea1b65859686bd5fcfeaf3616') // return 'p2pk66xmhjiN7LpfrDGFwpxPtJxkLtPjQ6HUxJbKmRbxSR7RMpamDwi'
|
|
@@ -2478,7 +2478,7 @@ function encodeKey(value) {
|
|
|
2478
2478
|
return b58Encode(buf.slice(1), pre);
|
|
2479
2479
|
}
|
|
2480
2480
|
/**
|
|
2481
|
-
*
|
|
2481
|
+
* Parse binary public key hash and return Base58 representation
|
|
2482
2482
|
* @param value Key hash to parse
|
|
2483
2483
|
* @returns return prefixed public key hash
|
|
2484
2484
|
* @example encodeKeyHash('0001907d6a7e9f084df840d6e67ffa8db5464f87d4d1') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
@@ -2511,7 +2511,7 @@ function encodeKeyHash(value) {
|
|
|
2511
2511
|
return b58Encode(buf.slice(1, 21), pre);
|
|
2512
2512
|
}
|
|
2513
2513
|
/**
|
|
2514
|
-
*
|
|
2514
|
+
* Parse binary Contract ID and return Base58 representation
|
|
2515
2515
|
* @param value Address to parse (tz1, tz2, tz3, KT1, or sr1).
|
|
2516
2516
|
* @example encodeAddress('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f') // return 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
2517
2517
|
*/
|
|
@@ -2537,7 +2537,7 @@ function encodeAddress(value) {
|
|
|
2537
2537
|
}
|
|
2538
2538
|
}
|
|
2539
2539
|
/**
|
|
2540
|
-
*
|
|
2540
|
+
* Base58 encode an address without predefined prefix
|
|
2541
2541
|
* @param value Address to base58 encode (tz4) hex dec
|
|
2542
2542
|
* @returns return address
|
|
2543
2543
|
* @example encodeBlsAddress('af2dc3c40667abc0e89c0ef40171d22aed08d5eb') // return 'tz4QyWfEiv56CVDATV3DT3CDVhPaMKif2Ce8'
|
|
@@ -2546,7 +2546,7 @@ function encodeBlsAddress(value) {
|
|
|
2546
2546
|
return b58Encode(value, PrefixV2.BLS12_381PublicKeyHash);
|
|
2547
2547
|
}
|
|
2548
2548
|
/**
|
|
2549
|
-
*
|
|
2549
|
+
* convert a fragment of Michelson code in hex string to an 'expr' prefix + base58 encoded BLAKE2b hash string
|
|
2550
2550
|
* @param value a fragment of Michelson code in hex string
|
|
2551
2551
|
* @returns return 'expr' prefix + base58 encoded BLAKE2b hash
|
|
2552
2552
|
* @example encodeExpr('050a000000160000b2e19a9e74440d86c59f13dab8a18ff873e889ea') // return 'exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN'
|
|
@@ -2556,7 +2556,7 @@ function encodeExpr(value) {
|
|
|
2556
2556
|
return b58Encode(blakeHash, PrefixV2.ScriptExpr);
|
|
2557
2557
|
}
|
|
2558
2558
|
/**
|
|
2559
|
-
*
|
|
2559
|
+
* convert a signed operation in hex string to an 'op' prefix + base58 encoded BLAKE2b hash string
|
|
2560
2560
|
* @param value signed operation in hex string
|
|
2561
2561
|
* @returns return 'op' prefix + base58 encoded BLAKE2b hash
|
|
2562
2562
|
* @example encodeOpHash('0f185d8a30061e8134c162dbb7a6c3ab8f5fdb153363ccd6149b49a33481156a6c00b2e19a9e74440d86c59f13dab8a18ff873e889eaa304ab05da13000001f1585a7384f36e45fb43dc37e8ce172bced3e05700ff0000000002002110c033f3a990c2e46a3d6054ecc2f74072aae7a34b5ac4d9ce9edc11c2410a97695682108951786f05b361da03b97245dc9897e1955e08b5b8d9e153b0bdeb0d') // return 'opapqvVXmebRTCFd2GQFydr4tJj3V5QocQuTmuhbatcHm4Seo2t'
|
|
@@ -2566,7 +2566,7 @@ function encodeOpHash(value) {
|
|
|
2566
2566
|
return b58Encode(blakeHash, PrefixV2.OperationHash);
|
|
2567
2567
|
}
|
|
2568
2568
|
/**
|
|
2569
|
-
*
|
|
2569
|
+
* Convert an hex string to a Uint8Array
|
|
2570
2570
|
* @param hex Hex string to convert
|
|
2571
2571
|
* @throws {@link ValueConversionError}
|
|
2572
2572
|
*/
|
|
@@ -2591,7 +2591,7 @@ function hex2buf(hex) {
|
|
|
2591
2591
|
return res;
|
|
2592
2592
|
}
|
|
2593
2593
|
/**
|
|
2594
|
-
*
|
|
2594
|
+
* Merge 2 buffers together
|
|
2595
2595
|
* @param b1 First buffer
|
|
2596
2596
|
* @param b2 Second buffer
|
|
2597
2597
|
*/
|
|
@@ -2602,7 +2602,7 @@ function mergebuf(b1, b2) {
|
|
|
2602
2602
|
return r;
|
|
2603
2603
|
}
|
|
2604
2604
|
/**
|
|
2605
|
-
*
|
|
2605
|
+
* Flatten a michelson json representation to an array
|
|
2606
2606
|
* @param s michelson json
|
|
2607
2607
|
*/
|
|
2608
2608
|
function mic2arr(s) {
|
|
@@ -2656,8 +2656,8 @@ function mic2arr(s) {
|
|
|
2656
2656
|
return ret;
|
|
2657
2657
|
}
|
|
2658
2658
|
/**
|
|
2659
|
-
*
|
|
2660
|
-
* @param
|
|
2659
|
+
* Convert a Uint8Array to an hex string
|
|
2660
|
+
* @param bytes Uint8Array to convert
|
|
2661
2661
|
*/
|
|
2662
2662
|
function buf2hex(bytes) {
|
|
2663
2663
|
return Array.from(bytes)
|
|
@@ -2665,21 +2665,21 @@ function buf2hex(bytes) {
|
|
|
2665
2665
|
.join('');
|
|
2666
2666
|
}
|
|
2667
2667
|
/**
|
|
2668
|
-
*
|
|
2668
|
+
* Convert a string to a byte string representation
|
|
2669
2669
|
* @param str String to convert
|
|
2670
2670
|
*/
|
|
2671
2671
|
function stringToBytes(str) {
|
|
2672
2672
|
return Buffer.from(str, 'utf8').toString('hex');
|
|
2673
2673
|
}
|
|
2674
2674
|
/**
|
|
2675
|
-
*
|
|
2675
|
+
* Convert byte string representation to string
|
|
2676
2676
|
* @param hex byte string to convert
|
|
2677
2677
|
*/
|
|
2678
2678
|
function bytesToString(hex) {
|
|
2679
2679
|
return Buffer.from(hex2buf(hex)).toString('utf8');
|
|
2680
2680
|
}
|
|
2681
2681
|
/**
|
|
2682
|
-
*
|
|
2682
|
+
* Convert hex string/UintArray/Buffer to bytes
|
|
2683
2683
|
* @param hex String value to convert to bytes
|
|
2684
2684
|
*/
|
|
2685
2685
|
function hex2Bytes(hex) {
|
|
@@ -2690,7 +2690,7 @@ function hex2Bytes(hex) {
|
|
|
2690
2690
|
return Buffer.from(hexDigits, 'hex');
|
|
2691
2691
|
}
|
|
2692
2692
|
/**
|
|
2693
|
-
*
|
|
2693
|
+
* Converts a number or Bignumber to hexadecimal string
|
|
2694
2694
|
* @param val The value that will be converted to a hexadecimal string value
|
|
2695
2695
|
*/
|
|
2696
2696
|
function toHexBuf(val, bitLength = 8) {
|
|
@@ -2700,7 +2700,7 @@ function numToHexBuffer(val, bitLength = 8) {
|
|
|
2700
2700
|
return Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
2701
2701
|
}
|
|
2702
2702
|
/**
|
|
2703
|
-
*
|
|
2703
|
+
* Converts a number or BigNumber to a padded hexadecimal string
|
|
2704
2704
|
* @param val The value that will be converted into a padded hexadecimal string value
|
|
2705
2705
|
* @param bitLength The length of bits
|
|
2706
2706
|
*
|
|
@@ -2734,7 +2734,7 @@ function padHexWithZero(hex, targetLength) {
|
|
|
2734
2734
|
}
|
|
2735
2735
|
/**
|
|
2736
2736
|
*
|
|
2737
|
-
*
|
|
2737
|
+
* Strips the first 2 characters of a hex string (0x)
|
|
2738
2738
|
*
|
|
2739
2739
|
* @param hex string to strip prefix from
|
|
2740
2740
|
*/
|
|
@@ -2760,7 +2760,7 @@ function compareArrays(a, b) {
|
|
|
2760
2760
|
}
|
|
2761
2761
|
|
|
2762
2762
|
/**
|
|
2763
|
-
*
|
|
2763
|
+
* Used to check if a value has one of the allowed prefixes.
|
|
2764
2764
|
* @returns true if the value has one of the allowed prefixes, false otherwise
|
|
2765
2765
|
* @example
|
|
2766
2766
|
* ```
|
|
@@ -2774,7 +2774,7 @@ function isValidPrefixedValue(value, prefixes) {
|
|
|
2774
2774
|
return validatePrefixedValue(value, prefixes) === ValidationResult.VALID;
|
|
2775
2775
|
}
|
|
2776
2776
|
/**
|
|
2777
|
-
*
|
|
2777
|
+
* This function is called by the validation functions ([[validateAddress]], [[validateChain]], [[validateContractAddress]], [[validateKeyHash]], [[validateSignature]], [[validatePublicKey]]).
|
|
2778
2778
|
* Verify if the value can be decoded or return `1` (INVALID_CHECKSUM) / `5` (INVALID_ENCODING), then check if the prefix is valid or allowed or return `0` (NO_PREFIX_MATCHED) / `4` (PREFIX_NOT_ALLOWED)
|
|
2779
2779
|
* If all checks pass, return `3` (VALID).
|
|
2780
2780
|
* @param value Value to validate
|
|
@@ -2801,7 +2801,7 @@ function validatePrefixedValue(value, prefixes) {
|
|
|
2801
2801
|
return ValidationResult.VALID;
|
|
2802
2802
|
}
|
|
2803
2803
|
/**
|
|
2804
|
-
*
|
|
2804
|
+
* Used to check if an address or a contract address is valid.
|
|
2805
2805
|
*
|
|
2806
2806
|
* @returns
|
|
2807
2807
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2816,11 +2816,11 @@ function validatePrefixedValue(value, prefixes) {
|
|
|
2816
2816
|
* ```
|
|
2817
2817
|
*/
|
|
2818
2818
|
function validateAddress(value) {
|
|
2819
|
-
const [addr] = splitAddress(value
|
|
2819
|
+
const [addr] = splitAddress(value ?? '');
|
|
2820
2820
|
return validatePrefixedValue(addr, addressPrefixes);
|
|
2821
2821
|
}
|
|
2822
2822
|
/**
|
|
2823
|
-
*
|
|
2823
|
+
* Used to check if a chain id is valid.
|
|
2824
2824
|
*
|
|
2825
2825
|
* @returns
|
|
2826
2826
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2838,7 +2838,7 @@ function validateChain(value) {
|
|
|
2838
2838
|
return validatePrefixedValue(value, [PrefixV2.ChainID]);
|
|
2839
2839
|
}
|
|
2840
2840
|
/**
|
|
2841
|
-
*
|
|
2841
|
+
* Used to check if a contract address is valid.
|
|
2842
2842
|
*
|
|
2843
2843
|
* @returns
|
|
2844
2844
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2856,7 +2856,7 @@ function validateContractAddress(value) {
|
|
|
2856
2856
|
return validatePrefixedValue(value, [PrefixV2.ContractHash]);
|
|
2857
2857
|
}
|
|
2858
2858
|
/**
|
|
2859
|
-
*
|
|
2859
|
+
* Used to check if a key hash is valid.
|
|
2860
2860
|
*
|
|
2861
2861
|
* @returns
|
|
2862
2862
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2874,7 +2874,7 @@ function validateKeyHash(value) {
|
|
|
2874
2874
|
return validatePrefixedValue(value, publicKeyHashPrefixes);
|
|
2875
2875
|
}
|
|
2876
2876
|
/**
|
|
2877
|
-
*
|
|
2877
|
+
* Used to check if a signature is valid.
|
|
2878
2878
|
*
|
|
2879
2879
|
* @returns
|
|
2880
2880
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2892,7 +2892,7 @@ function validateSignature(value) {
|
|
|
2892
2892
|
return validatePrefixedValue(value, signaturePrefixes);
|
|
2893
2893
|
}
|
|
2894
2894
|
/**
|
|
2895
|
-
*
|
|
2895
|
+
* Used to check if a public key is valid.
|
|
2896
2896
|
*
|
|
2897
2897
|
* @returns
|
|
2898
2898
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2910,7 +2910,7 @@ function validatePublicKey(value) {
|
|
|
2910
2910
|
return validatePrefixedValue(value, publicKeyPrefixes);
|
|
2911
2911
|
}
|
|
2912
2912
|
/**
|
|
2913
|
-
*
|
|
2913
|
+
* Used to check if an operation hash is valid.
|
|
2914
2914
|
*
|
|
2915
2915
|
* @returns
|
|
2916
2916
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2928,7 +2928,7 @@ function validateOperation(value) {
|
|
|
2928
2928
|
return validatePrefixedValue(value, [PrefixV2.OperationHash]);
|
|
2929
2929
|
}
|
|
2930
2930
|
/**
|
|
2931
|
-
*
|
|
2931
|
+
* Used to check if a protocol hash is valid.
|
|
2932
2932
|
*
|
|
2933
2933
|
* @returns
|
|
2934
2934
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2946,7 +2946,7 @@ function validateProtocol(value) {
|
|
|
2946
2946
|
return validatePrefixedValue(value, [PrefixV2.ProtocolHash]);
|
|
2947
2947
|
}
|
|
2948
2948
|
/**
|
|
2949
|
-
*
|
|
2949
|
+
* Used to check if a block hash is valid.
|
|
2950
2950
|
*
|
|
2951
2951
|
* @returns
|
|
2952
2952
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2964,7 +2964,7 @@ function validateBlock(value) {
|
|
|
2964
2964
|
return validatePrefixedValue(value, [PrefixV2.BlockHash]);
|
|
2965
2965
|
}
|
|
2966
2966
|
/**
|
|
2967
|
-
*
|
|
2967
|
+
* Used to check if a spending key is valid.
|
|
2968
2968
|
* @returns
|
|
2969
2969
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
2970
2970
|
*
|
|
@@ -2978,21 +2978,21 @@ function validateSmartRollupAddress(value) {
|
|
|
2978
2978
|
|
|
2979
2979
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
2980
2980
|
const VERSION = {
|
|
2981
|
-
"commitHash": "
|
|
2982
|
-
"version": "24.
|
|
2981
|
+
"commitHash": "05df48fee92f846cba793920d6fa829afd6a1847",
|
|
2982
|
+
"version": "24.3.0-beta.1"
|
|
2983
2983
|
};
|
|
2984
2984
|
|
|
2985
2985
|
const BLS12_381_DST = 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_';
|
|
2986
2986
|
const POP_DST = 'BLS_POP_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_';
|
|
2987
2987
|
/**
|
|
2988
|
-
*
|
|
2988
|
+
* Verify signature of a payload
|
|
2989
2989
|
* @param message The forged message including the magic byte (11 for block, 12 for preattestation, 13 for attestation, 3 for generic, 5 for the PACK format of michelson) in string or Uint8Array
|
|
2990
2990
|
* @param publicKey The public key to verify the signature against
|
|
2991
2991
|
* @param signature The signature to verify
|
|
2992
2992
|
* @param watermark Optional if not included in the message
|
|
2993
2993
|
* @param pop Optional if verifying proof of possession signature
|
|
2994
2994
|
* @returns A boolean indicating if the signature matches
|
|
2995
|
-
* @throws
|
|
2995
|
+
* @throws InvalidPublicKeyError | InvalidSignatureError | InvalidMessageError
|
|
2996
2996
|
* @example
|
|
2997
2997
|
* ```
|
|
2998
2998
|
* const message = '03d0c10e3ed11d7c6e3357f6ef335bab9e8f2bd54d0ce20c482e241191a6e4b8ce6c01be917311d9ac46959750e405d57e268e2ed9e174a80794fbd504e12a4a000141eb3781afed2f69679ff2bbe1c5375950b0e40d00ff000000005e05050505050507070100000024747a32526773486e74516b72794670707352466261313652546656503539684b72654a4d07070100000024747a315a6672455263414c42776d4171776f6e525859565142445439426a4e6a42484a750001';
|
|
@@ -3065,7 +3065,7 @@ function verifyEdSignature(sig, msg, publicKey) {
|
|
|
3065
3065
|
try {
|
|
3066
3066
|
return verify(publicKey, hash$1, sig);
|
|
3067
3067
|
}
|
|
3068
|
-
catch
|
|
3068
|
+
catch {
|
|
3069
3069
|
return false;
|
|
3070
3070
|
}
|
|
3071
3071
|
}
|
|
@@ -3074,7 +3074,7 @@ function verifySpSignature(sig, msg, publicKey) {
|
|
|
3074
3074
|
try {
|
|
3075
3075
|
return secp256k1.verify(sig, hash$1, publicKey);
|
|
3076
3076
|
}
|
|
3077
|
-
catch
|
|
3077
|
+
catch {
|
|
3078
3078
|
return false;
|
|
3079
3079
|
}
|
|
3080
3080
|
}
|
|
@@ -3083,7 +3083,7 @@ function verifyP2Signature(sig, msg, publicKey) {
|
|
|
3083
3083
|
try {
|
|
3084
3084
|
return p256.verify(sig, hash$1, publicKey);
|
|
3085
3085
|
}
|
|
3086
|
-
catch
|
|
3086
|
+
catch {
|
|
3087
3087
|
return false;
|
|
3088
3088
|
}
|
|
3089
3089
|
}
|
|
@@ -3093,7 +3093,7 @@ function verifyBLSSignature(sig, msg, publicKey) {
|
|
|
3093
3093
|
const point = bls.hash(msg, BLS12_381_DST);
|
|
3094
3094
|
return bls.verify(sig, point, publicKey);
|
|
3095
3095
|
}
|
|
3096
|
-
catch
|
|
3096
|
+
catch {
|
|
3097
3097
|
return false;
|
|
3098
3098
|
}
|
|
3099
3099
|
}
|
|
@@ -3102,14 +3102,14 @@ function verifyBLSPopSignature(sig, msg, publicKey) {
|
|
|
3102
3102
|
const point = bls.hash(msg, POP_DST);
|
|
3103
3103
|
return bls.verify(sig, point, publicKey);
|
|
3104
3104
|
}
|
|
3105
|
-
catch
|
|
3105
|
+
catch {
|
|
3106
3106
|
return false;
|
|
3107
3107
|
}
|
|
3108
3108
|
}
|
|
3109
3109
|
|
|
3110
3110
|
/**
|
|
3111
3111
|
* @category Error
|
|
3112
|
-
*
|
|
3112
|
+
* Error that indicates invalid protocol hash being passed or used
|
|
3113
3113
|
*/
|
|
3114
3114
|
class InvalidProtocolHashError extends ParameterValidationError {
|
|
3115
3115
|
constructor(protocolHash, errorDetails) {
|
|
@@ -3121,7 +3121,7 @@ class InvalidProtocolHashError extends ParameterValidationError {
|
|
|
3121
3121
|
}
|
|
3122
3122
|
/**
|
|
3123
3123
|
* @category Error
|
|
3124
|
-
*
|
|
3124
|
+
* Error that indicates unable to convert data type from one to another
|
|
3125
3125
|
*/
|
|
3126
3126
|
class ValueConversionError extends UnsupportedActionError {
|
|
3127
3127
|
constructor(value, desiredType) {
|