@taquito/utils 24.2.0-beta.1 → 24.3.0-beta.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/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
package/dist/lib/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.payloadLength = exports.prefixV2 = exports.PrefixV2 = void 0;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* base58 name to prefix mapping
|
|
7
7
|
*/
|
|
8
8
|
var PrefixV2;
|
|
9
9
|
(function (PrefixV2) {
|
|
@@ -70,7 +70,7 @@ var PrefixV2;
|
|
|
70
70
|
PrefixV2["SlotHeader"] = "sh";
|
|
71
71
|
})(PrefixV2 || (exports.PrefixV2 = PrefixV2 = {}));
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* base58 prefix to bytes mapping
|
|
74
74
|
*/
|
|
75
75
|
exports.prefixV2 = {
|
|
76
76
|
[PrefixV2.BlockHash]: new Uint8Array([1, 52]),
|
|
@@ -136,7 +136,7 @@ exports.prefixV2 = {
|
|
|
136
136
|
[PrefixV2.SlotHeader]: new Uint8Array([2, 116, 180]),
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* base58 prefix to payload length mapping
|
|
140
140
|
*/
|
|
141
141
|
exports.payloadLength = {
|
|
142
142
|
[PrefixV2.BlockHash]: 32,
|
package/dist/lib/encoding.js
CHANGED
|
@@ -44,7 +44,7 @@ const bignumber_js_1 = require("bignumber.js");
|
|
|
44
44
|
const typedarray_to_buffer_1 = require("typedarray-to-buffer");
|
|
45
45
|
const core_1 = require("@taquito/core");
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* list of prefixes that can be used to decode an address
|
|
48
48
|
*/
|
|
49
49
|
exports.addressPrefixes = [
|
|
50
50
|
constants_1.PrefixV2.P256PublicKeyHash,
|
|
@@ -56,7 +56,7 @@ exports.addressPrefixes = [
|
|
|
56
56
|
// PrefixV2.ZkRollupHash,
|
|
57
57
|
];
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* list of prefixes that can be used to decode a public key
|
|
60
60
|
*/
|
|
61
61
|
exports.publicKeyPrefixes = [
|
|
62
62
|
constants_1.PrefixV2.P256PublicKey,
|
|
@@ -65,7 +65,7 @@ exports.publicKeyPrefixes = [
|
|
|
65
65
|
constants_1.PrefixV2.BLS12_381PublicKey,
|
|
66
66
|
];
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* list of prefixes that can be used to decode a public key hash
|
|
69
69
|
*/
|
|
70
70
|
exports.publicKeyHashPrefixes = [
|
|
71
71
|
constants_1.PrefixV2.P256PublicKeyHash,
|
|
@@ -74,7 +74,7 @@ exports.publicKeyHashPrefixes = [
|
|
|
74
74
|
constants_1.PrefixV2.BLS12_381PublicKeyHash,
|
|
75
75
|
];
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* list of prefixes that can be used to decode a signature
|
|
78
78
|
*/
|
|
79
79
|
exports.signaturePrefixes = [
|
|
80
80
|
constants_1.PrefixV2.P256Signature,
|
|
@@ -246,7 +246,7 @@ function b58DecodeAddress(value, fmt) {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
|
-
*
|
|
249
|
+
* Gets Tezos address (PKH) from Public Key
|
|
250
250
|
* @param publicKey Base58 Public Key
|
|
251
251
|
* @returns A string of the Tezos address (PKH) that was derived from the given Public Key
|
|
252
252
|
* @example getPkhfromPk('edpkuNjKKT48xBoT5asPrWdmuM1Yw8D93MwgFgVvtca8jb5pstzaCh') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
@@ -274,7 +274,7 @@ function getPkhfromPk(publicKey) {
|
|
|
274
274
|
return b58Encode(hashed, pkhPre);
|
|
275
275
|
}
|
|
276
276
|
/**
|
|
277
|
-
*
|
|
277
|
+
* Add the prefix to a hex string or Uint8Array and Base58 encode it
|
|
278
278
|
* @param value Value to Base58 encode
|
|
279
279
|
* @param pre prefix ID to append to the encoded string
|
|
280
280
|
* @example b58Encode('e96b9f8b19af9c7ffa0c0480e1977b295850961f', PrefixV2.Ed25519PublicKeyHash) // returns 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
@@ -288,7 +288,7 @@ function b58Encode(value, pre) {
|
|
|
288
288
|
return bs58check_1.default.encode((0, typedarray_to_buffer_1.default)(n));
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
291
|
-
*
|
|
291
|
+
* Parse binary public key and return Base58 representation
|
|
292
292
|
* @param value Binary key data
|
|
293
293
|
* @returns return prefixed public key
|
|
294
294
|
* @example encodeKey('02033aba7da4a2e7b5dd9f074555c118829aff16213ea1b65859686bd5fcfeaf3616') // return 'p2pk66xmhjiN7LpfrDGFwpxPtJxkLtPjQ6HUxJbKmRbxSR7RMpamDwi'
|
|
@@ -321,7 +321,7 @@ function encodeKey(value) {
|
|
|
321
321
|
return b58Encode(buf.slice(1), pre);
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
|
-
*
|
|
324
|
+
* Parse binary public key hash and return Base58 representation
|
|
325
325
|
* @param value Key hash to parse
|
|
326
326
|
* @returns return prefixed public key hash
|
|
327
327
|
* @example encodeKeyHash('0001907d6a7e9f084df840d6e67ffa8db5464f87d4d1') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
@@ -354,7 +354,7 @@ function encodeKeyHash(value) {
|
|
|
354
354
|
return b58Encode(buf.slice(1, 21), pre);
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
357
|
+
* Parse binary Contract ID and return Base58 representation
|
|
358
358
|
* @param value Address to parse (tz1, tz2, tz3, KT1, or sr1).
|
|
359
359
|
* @example encodeAddress('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f') // return 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
360
360
|
*/
|
|
@@ -380,7 +380,7 @@ function encodeAddress(value) {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
/**
|
|
383
|
-
*
|
|
383
|
+
* Base58 encode an address without predefined prefix
|
|
384
384
|
* @param value Address to base58 encode (tz4) hex dec
|
|
385
385
|
* @returns return address
|
|
386
386
|
* @example encodeBlsAddress('af2dc3c40667abc0e89c0ef40171d22aed08d5eb') // return 'tz4QyWfEiv56CVDATV3DT3CDVhPaMKif2Ce8'
|
|
@@ -389,7 +389,7 @@ function encodeBlsAddress(value) {
|
|
|
389
389
|
return b58Encode(value, constants_1.PrefixV2.BLS12_381PublicKeyHash);
|
|
390
390
|
}
|
|
391
391
|
/**
|
|
392
|
-
*
|
|
392
|
+
* convert a fragment of Michelson code in hex string to an 'expr' prefix + base58 encoded BLAKE2b hash string
|
|
393
393
|
* @param value a fragment of Michelson code in hex string
|
|
394
394
|
* @returns return 'expr' prefix + base58 encoded BLAKE2b hash
|
|
395
395
|
* @example encodeExpr('050a000000160000b2e19a9e74440d86c59f13dab8a18ff873e889ea') // return 'exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN'
|
|
@@ -399,7 +399,7 @@ function encodeExpr(value) {
|
|
|
399
399
|
return b58Encode(blakeHash, constants_1.PrefixV2.ScriptExpr);
|
|
400
400
|
}
|
|
401
401
|
/**
|
|
402
|
-
*
|
|
402
|
+
* convert a signed operation in hex string to an 'op' prefix + base58 encoded BLAKE2b hash string
|
|
403
403
|
* @param value signed operation in hex string
|
|
404
404
|
* @returns return 'op' prefix + base58 encoded BLAKE2b hash
|
|
405
405
|
* @example encodeOpHash('0f185d8a30061e8134c162dbb7a6c3ab8f5fdb153363ccd6149b49a33481156a6c00b2e19a9e74440d86c59f13dab8a18ff873e889eaa304ab05da13000001f1585a7384f36e45fb43dc37e8ce172bced3e05700ff0000000002002110c033f3a990c2e46a3d6054ecc2f74072aae7a34b5ac4d9ce9edc11c2410a97695682108951786f05b361da03b97245dc9897e1955e08b5b8d9e153b0bdeb0d') // return 'opapqvVXmebRTCFd2GQFydr4tJj3V5QocQuTmuhbatcHm4Seo2t'
|
|
@@ -409,7 +409,7 @@ function encodeOpHash(value) {
|
|
|
409
409
|
return b58Encode(blakeHash, constants_1.PrefixV2.OperationHash);
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
|
-
*
|
|
412
|
+
* Convert an hex string to a Uint8Array
|
|
413
413
|
* @param hex Hex string to convert
|
|
414
414
|
* @throws {@link ValueConversionError}
|
|
415
415
|
*/
|
|
@@ -434,7 +434,7 @@ function hex2buf(hex) {
|
|
|
434
434
|
return res;
|
|
435
435
|
}
|
|
436
436
|
/**
|
|
437
|
-
*
|
|
437
|
+
* Merge 2 buffers together
|
|
438
438
|
* @param b1 First buffer
|
|
439
439
|
* @param b2 Second buffer
|
|
440
440
|
*/
|
|
@@ -445,7 +445,7 @@ function mergebuf(b1, b2) {
|
|
|
445
445
|
return r;
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
|
-
*
|
|
448
|
+
* Flatten a michelson json representation to an array
|
|
449
449
|
* @param s michelson json
|
|
450
450
|
*/
|
|
451
451
|
function mic2arr(s) {
|
|
@@ -499,8 +499,8 @@ function mic2arr(s) {
|
|
|
499
499
|
return ret;
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
|
-
*
|
|
503
|
-
* @param
|
|
502
|
+
* Convert a Uint8Array to an hex string
|
|
503
|
+
* @param bytes Uint8Array to convert
|
|
504
504
|
*/
|
|
505
505
|
function buf2hex(bytes) {
|
|
506
506
|
return Array.from(bytes)
|
|
@@ -508,21 +508,21 @@ function buf2hex(bytes) {
|
|
|
508
508
|
.join('');
|
|
509
509
|
}
|
|
510
510
|
/**
|
|
511
|
-
*
|
|
511
|
+
* Convert a string to a byte string representation
|
|
512
512
|
* @param str String to convert
|
|
513
513
|
*/
|
|
514
514
|
function stringToBytes(str) {
|
|
515
515
|
return buffer_1.Buffer.from(str, 'utf8').toString('hex');
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
|
-
*
|
|
518
|
+
* Convert byte string representation to string
|
|
519
519
|
* @param hex byte string to convert
|
|
520
520
|
*/
|
|
521
521
|
function bytesToString(hex) {
|
|
522
522
|
return buffer_1.Buffer.from(hex2buf(hex)).toString('utf8');
|
|
523
523
|
}
|
|
524
524
|
/**
|
|
525
|
-
*
|
|
525
|
+
* Convert hex string/UintArray/Buffer to bytes
|
|
526
526
|
* @param hex String value to convert to bytes
|
|
527
527
|
*/
|
|
528
528
|
function hex2Bytes(hex) {
|
|
@@ -533,7 +533,7 @@ function hex2Bytes(hex) {
|
|
|
533
533
|
return buffer_1.Buffer.from(hexDigits, 'hex');
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
|
-
*
|
|
536
|
+
* Converts a number or Bignumber to hexadecimal string
|
|
537
537
|
* @param val The value that will be converted to a hexadecimal string value
|
|
538
538
|
*/
|
|
539
539
|
function toHexBuf(val, bitLength = 8) {
|
|
@@ -543,7 +543,7 @@ function numToHexBuffer(val, bitLength = 8) {
|
|
|
543
543
|
return buffer_1.Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
544
544
|
}
|
|
545
545
|
/**
|
|
546
|
-
*
|
|
546
|
+
* Converts a number or BigNumber to a padded hexadecimal string
|
|
547
547
|
* @param val The value that will be converted into a padded hexadecimal string value
|
|
548
548
|
* @param bitLength The length of bits
|
|
549
549
|
*
|
|
@@ -577,7 +577,7 @@ function padHexWithZero(hex, targetLength) {
|
|
|
577
577
|
}
|
|
578
578
|
/**
|
|
579
579
|
*
|
|
580
|
-
*
|
|
580
|
+
* Strips the first 2 characters of a hex string (0x)
|
|
581
581
|
*
|
|
582
582
|
* @param hex string to strip prefix from
|
|
583
583
|
*/
|
package/dist/lib/errors.js
CHANGED
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "DeprecationError", { enumerable: true, get: func
|
|
|
19
19
|
Object.defineProperty(exports, "ProhibitedActionError", { enumerable: true, get: function () { return core_2.ProhibitedActionError; } });
|
|
20
20
|
/**
|
|
21
21
|
* @category Error
|
|
22
|
-
*
|
|
22
|
+
* Error that indicates invalid protocol hash being passed or used
|
|
23
23
|
*/
|
|
24
24
|
class InvalidProtocolHashError extends core_1.ParameterValidationError {
|
|
25
25
|
constructor(protocolHash, errorDetails) {
|
|
@@ -32,7 +32,7 @@ class InvalidProtocolHashError extends core_1.ParameterValidationError {
|
|
|
32
32
|
exports.InvalidProtocolHashError = InvalidProtocolHashError;
|
|
33
33
|
/**
|
|
34
34
|
* @category Error
|
|
35
|
-
*
|
|
35
|
+
* Error that indicates unable to convert data type from one to another
|
|
36
36
|
*/
|
|
37
37
|
class ValueConversionError extends core_1.UnsupportedActionError {
|
|
38
38
|
constructor(value, desiredType) {
|
package/dist/lib/validators.js
CHANGED
|
@@ -19,7 +19,7 @@ const core_1 = require("@taquito/core");
|
|
|
19
19
|
var core_2 = require("@taquito/core");
|
|
20
20
|
Object.defineProperty(exports, "ValidationResult", { enumerable: true, get: function () { return core_2.ValidationResult; } });
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Used to check if a value has one of the allowed prefixes.
|
|
23
23
|
* @returns true if the value has one of the allowed prefixes, false otherwise
|
|
24
24
|
* @example
|
|
25
25
|
* ```
|
|
@@ -33,7 +33,7 @@ function isValidPrefixedValue(value, prefixes) {
|
|
|
33
33
|
return validatePrefixedValue(value, prefixes) === core_1.ValidationResult.VALID;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* This function is called by the validation functions ([[validateAddress]], [[validateChain]], [[validateContractAddress]], [[validateKeyHash]], [[validateSignature]], [[validatePublicKey]]).
|
|
37
37
|
* 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)
|
|
38
38
|
* If all checks pass, return `3` (VALID).
|
|
39
39
|
* @param value Value to validate
|
|
@@ -60,7 +60,7 @@ function validatePrefixedValue(value, prefixes) {
|
|
|
60
60
|
return core_1.ValidationResult.VALID;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Used to check if an address or a contract address is valid.
|
|
64
64
|
*
|
|
65
65
|
* @returns
|
|
66
66
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -75,11 +75,11 @@ function validatePrefixedValue(value, prefixes) {
|
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
77
|
function validateAddress(value) {
|
|
78
|
-
const [addr] = (0, encoding_1.splitAddress)(value
|
|
78
|
+
const [addr] = (0, encoding_1.splitAddress)(value ?? '');
|
|
79
79
|
return validatePrefixedValue(addr, encoding_1.addressPrefixes);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
82
|
+
* Used to check if a chain id is valid.
|
|
83
83
|
*
|
|
84
84
|
* @returns
|
|
85
85
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -97,7 +97,7 @@ function validateChain(value) {
|
|
|
97
97
|
return validatePrefixedValue(value, [constants_1.PrefixV2.ChainID]);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* Used to check if a contract address is valid.
|
|
101
101
|
*
|
|
102
102
|
* @returns
|
|
103
103
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -115,7 +115,7 @@ function validateContractAddress(value) {
|
|
|
115
115
|
return validatePrefixedValue(value, [constants_1.PrefixV2.ContractHash]);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* Used to check if a key hash is valid.
|
|
119
119
|
*
|
|
120
120
|
* @returns
|
|
121
121
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -133,7 +133,7 @@ function validateKeyHash(value) {
|
|
|
133
133
|
return validatePrefixedValue(value, encoding_1.publicKeyHashPrefixes);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
136
|
+
* Used to check if a signature is valid.
|
|
137
137
|
*
|
|
138
138
|
* @returns
|
|
139
139
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -151,7 +151,7 @@ function validateSignature(value) {
|
|
|
151
151
|
return validatePrefixedValue(value, encoding_1.signaturePrefixes);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
154
|
+
* Used to check if a public key is valid.
|
|
155
155
|
*
|
|
156
156
|
* @returns
|
|
157
157
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -169,7 +169,7 @@ function validatePublicKey(value) {
|
|
|
169
169
|
return validatePrefixedValue(value, encoding_1.publicKeyPrefixes);
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
|
-
*
|
|
172
|
+
* Used to check if an operation hash is valid.
|
|
173
173
|
*
|
|
174
174
|
* @returns
|
|
175
175
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -187,7 +187,7 @@ function validateOperation(value) {
|
|
|
187
187
|
return validatePrefixedValue(value, [constants_1.PrefixV2.OperationHash]);
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
|
-
*
|
|
190
|
+
* Used to check if a protocol hash is valid.
|
|
191
191
|
*
|
|
192
192
|
* @returns
|
|
193
193
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -205,7 +205,7 @@ function validateProtocol(value) {
|
|
|
205
205
|
return validatePrefixedValue(value, [constants_1.PrefixV2.ProtocolHash]);
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
|
-
*
|
|
208
|
+
* Used to check if a block hash is valid.
|
|
209
209
|
*
|
|
210
210
|
* @returns
|
|
211
211
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -223,7 +223,7 @@ function validateBlock(value) {
|
|
|
223
223
|
return validatePrefixedValue(value, [constants_1.PrefixV2.BlockHash]);
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
226
|
-
*
|
|
226
|
+
* Used to check if a spending key is valid.
|
|
227
227
|
* @returns
|
|
228
228
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
229
229
|
*
|
|
@@ -13,14 +13,14 @@ const bls12_381_1 = require("@noble/curves/bls12-381");
|
|
|
13
13
|
exports.BLS12_381_DST = 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_';
|
|
14
14
|
exports.POP_DST = 'BLS_POP_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_';
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Verify signature of a payload
|
|
17
17
|
* @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
|
|
18
18
|
* @param publicKey The public key to verify the signature against
|
|
19
19
|
* @param signature The signature to verify
|
|
20
20
|
* @param watermark Optional if not included in the message
|
|
21
21
|
* @param pop Optional if verifying proof of possession signature
|
|
22
22
|
* @returns A boolean indicating if the signature matches
|
|
23
|
-
* @throws
|
|
23
|
+
* @throws InvalidPublicKeyError | InvalidSignatureError | InvalidMessageError
|
|
24
24
|
* @example
|
|
25
25
|
* ```
|
|
26
26
|
* const message = '03d0c10e3ed11d7c6e3357f6ef335bab9e8f2bd54d0ce20c482e241191a6e4b8ce6c01be917311d9ac46959750e405d57e268e2ed9e174a80794fbd504e12a4a000141eb3781afed2f69679ff2bbe1c5375950b0e40d00ff000000005e05050505050507070100000024747a32526773486e74516b72794670707352466261313652546656503539684b72654a4d07070100000024747a315a6672455263414c42776d4171776f6e525859565142445439426a4e6a42484a750001';
|
|
@@ -93,7 +93,7 @@ function verifyEdSignature(sig, msg, publicKey) {
|
|
|
93
93
|
try {
|
|
94
94
|
return (0, ed25519_1.verify)(publicKey, hash, sig);
|
|
95
95
|
}
|
|
96
|
-
catch
|
|
96
|
+
catch {
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -102,7 +102,7 @@ function verifySpSignature(sig, msg, publicKey) {
|
|
|
102
102
|
try {
|
|
103
103
|
return secp256k1_1.secp256k1.verify(sig, hash, publicKey);
|
|
104
104
|
}
|
|
105
|
-
catch
|
|
105
|
+
catch {
|
|
106
106
|
return false;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -111,7 +111,7 @@ function verifyP2Signature(sig, msg, publicKey) {
|
|
|
111
111
|
try {
|
|
112
112
|
return nist_1.p256.verify(sig, hash, publicKey);
|
|
113
113
|
}
|
|
114
|
-
catch
|
|
114
|
+
catch {
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -121,7 +121,7 @@ function verifyBLSSignature(sig, msg, publicKey) {
|
|
|
121
121
|
const point = bls.hash(msg, exports.BLS12_381_DST);
|
|
122
122
|
return bls.verify(sig, point, publicKey);
|
|
123
123
|
}
|
|
124
|
-
catch
|
|
124
|
+
catch {
|
|
125
125
|
return false;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -130,7 +130,7 @@ function verifyBLSPopSignature(sig, msg, publicKey) {
|
|
|
130
130
|
const point = bls.hash(msg, exports.POP_DST);
|
|
131
131
|
return bls.verify(sig, point, publicKey);
|
|
132
132
|
}
|
|
133
|
-
catch
|
|
133
|
+
catch {
|
|
134
134
|
return false;
|
|
135
135
|
}
|
|
136
136
|
}
|
package/dist/lib/version.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "24.
|
|
6
|
+
"commitHash": "27675679db6515e8b092195ef5c58c2c0ea5f5c8",
|
|
7
|
+
"version": "24.3.0-beta.0"
|
|
8
8
|
};
|