@tezos-x/octez.js-utils 0.9.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 ADDED
@@ -0,0 +1,277 @@
1
+ # octez.js Utils package
2
+
3
+ *TypeDoc style documentation is available on-line [here](https://octez.js.io/typedoc/modules/_octez.js_utils.html)*
4
+
5
+ **Maintained by [Nomadic Labs](https://www.nomadic-labs.com/).**
6
+
7
+ `@tezos-x/octez.js-utils` is an npm package that provides developers with utility functionality for octez.js.
8
+
9
+ ## Install
10
+
11
+ ```
12
+ npm i --save @tezos-x/octez.js-utils
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Validation functions
18
+
19
+ octez.js provides functions that allow seeing if an address, a chain, a key hash, a contract address, a public key, a signature, a block hash, an operation hash, or a protocol hash is valid based on checksums.
20
+
21
+ The `ValidationResult` returned by these functions is an enum that can take the following values:
22
+
23
+ ```
24
+ 0 = NO_PREFIX_MATCHED,
25
+ 1 = INVALID_CHECKSUM,
26
+ 2 = INVALID_LENGTH,
27
+ 3 = VALID,
28
+ 4 = PREFIX_NOT_ALLOWED,
29
+ 5 = INVALID_ENCODING,
30
+ 6 = OTHER,
31
+ ```
32
+
33
+ **Address validation (tz1, tz2, tz3, KT1)**
34
+
35
+ ```ts
36
+ import { validateAddress } from '@tezos-x/octez.js-utils';
37
+
38
+ const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx';
39
+ console.log(validateAddress(pkh));
40
+ // output: 3 which is valid
41
+ ```
42
+
43
+ **Key hash validation**
44
+
45
+ ```ts
46
+ import { validateKeyHash } from '@tezos-x/octez.js-utils';
47
+
48
+ const keyHash = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx';
49
+ console.log(validateKeyHash(keyHash));
50
+ // output: 3 which is valid
51
+ ```
52
+
53
+ **Contract address validation**
54
+
55
+ ```ts
56
+ import { validateContractAddress } from '@tezos-x/octez.js-utils';
57
+
58
+ const contractAddress = 'KT1AfxAKKLnEg6rQ6kHdvCWwagjSaxEwURSJ';
59
+ console.log(validateContractAddress(contractAddress));
60
+ // output: 3 which is valid
61
+ ```
62
+
63
+ **Chain id validation**
64
+
65
+ ```ts
66
+ import { validateChain } from '@tezos-x/octez.js-utils';
67
+
68
+ const chainId = 'NetXdQprcVkpaWU';
69
+ console.log(validateChain(chainId));
70
+ // output: 3 which is valid
71
+ ```
72
+
73
+ **Public key validation**
74
+
75
+ ```ts
76
+ import { validatePublicKey } from '@tezos-x/octez.js-utils';
77
+
78
+ const publicKey = 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g';
79
+ console.log(validatePublicKey(publicKey));
80
+ // output: 3 which is valid
81
+ ```
82
+
83
+ **Signature validation**
84
+
85
+ ```ts
86
+ import { validateSignature } from '@tezos-x/octez.js-utils';
87
+
88
+ const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg';
89
+ console.log(validateSignature(signature));
90
+ // output: 3 which is valid
91
+ ```
92
+
93
+ **Block hash validation**
94
+
95
+ ```ts
96
+ import { validateBlock } from '@tezos-x/octez.js-utils';
97
+
98
+ const block ='BLJjnzaPtSsxykZ9pLTFLSfsKuiN3z7SjSPDPWwbE4Q68u5EpBw';
99
+ console.log(validateBlock(block));
100
+ // output: 3 which is valid
101
+ ```
102
+
103
+ **Operation hash validation**
104
+
105
+ ```ts
106
+ import { validateOperation } from '@tezos-x/octez.js-utils';
107
+
108
+ const operation ='ood2Y1FLHH9izvYghVcDGGAkvJFo1CgSEjPfWvGsaz3qypCmeUj';
109
+ console.log(validateOperation(operation));
110
+ // output: 3 which is valid
111
+ ```
112
+
113
+ **Protocol hash validation**
114
+
115
+ ```ts
116
+ import { validateProtocol } from '@tezos-x/octez.js-utils';
117
+
118
+ //valid
119
+ const protocol ='PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx';
120
+ console.log(validateProtocol(protocol));
121
+ // output: 3 which is valid
122
+ ```
123
+
124
+ ### Verification of a signature
125
+
126
+ The function takes a message, a public key, and a signature as parameters and returns a boolean indicating if the signature matches.
127
+
128
+ ```ts
129
+ import { verifySignature } from '@tezos-x/octez.js-utils';
130
+
131
+ const message = '03d0c10e3ed11d7c6e3357f6ef335bab9e8f2bd54d0ce20c482e241191a6e4b8ce6c01be917311d9ac46959750e405d57e268e2ed9e174a80794fbd504e12a4a000141eb3781afed2f69679ff2bbe1c5375950b0e40d00ff000000005e05050505050507070100000024747a32526773486e74516b72794670707352466261313652546656503539684b72654a4d07070100000024747a315a6672455263414c42776d4171776f6e525859565142445439426a4e6a42484a750001';
132
+ const pk = 'sppk7c7hkPj47yjYFEHX85q46sFJGw6RBrqoVSHwAJAT4e14KJwzoey';
133
+ const sig = 'spsig1cdLkp1RLgUHAp13aRFkZ6MQDPp7xCnjAExGL3MBSdMDmT6JgQSX8cufyDgJRM3sinFtiCzLbsyP6d365EHoNevxhT47nx'
134
+
135
+ const isValid = verifySignature(message, pk, sig);
136
+ console.log(isValid);
137
+ // output: true
138
+ ```
139
+
140
+ ### Utility functions
141
+
142
+ **Conversion between hexadecimal and ASCII strings**
143
+ ```ts
144
+ import { stringToBytes, bytesToString } from '@tezos-x/octez.js-utils';
145
+
146
+ const url = 'https://storage.googleapis.com/tzip-16/fa2-views.json';
147
+ const hex = '68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f747a69702d31362f6661322d76696577732e6a736f6e';
148
+
149
+ console.log(stringToBytes(url));
150
+ // output: 68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f747a69702d31362f6661322d76696577732e6a736f6e
151
+
152
+ console.log(bytesToString(hex));
153
+ // output: https://storage.googleapis.com/tzip-16/fa2-views.json
154
+ ```
155
+
156
+ **Conversion between buffer and hexadecimal strings**
157
+
158
+ ```ts
159
+ import { buf2hex, hex2buf } from '@tezos-x/octez.js-utils';
160
+
161
+ const buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
162
+ const hex = '627566666572'
163
+
164
+ console.log(buf2hex(buffer));
165
+ // output: 627566666572
166
+
167
+ console.log(hex2buf(hex));
168
+ // output: Uint8Array(6) [ 98, 117, 102, 102, 101, 114 ]
169
+ ```
170
+
171
+ **Merge 2 buffers together**
172
+
173
+ ```ts
174
+ import { mergebuf } from '@tezos-x/octez.js-utils';
175
+
176
+ const buff = new Uint8Array([1,2]);
177
+ const buff2 = new Uint8Array([3,4]);
178
+
179
+ console.log(mergebuf(buff, buff2));
180
+ // output: Uint8Array(4) [ 1, 2, 3, 4 ]
181
+ ```
182
+
183
+ **Base58 encode a key hash according to its prefix**
184
+
185
+ ```ts
186
+ import { encodeKeyHash } from '@tezos-x/octez.js-utils';
187
+
188
+ console.log(encodeKeyHash('01106d79a502c4135b10e61e92f4c5a72ca740fb87'));
189
+ // output: tz29p6csejX9FcHXgQERr5sXsAinLvxmVerM
190
+ ```
191
+
192
+ **Base58 encode a public key according to its prefix**
193
+
194
+ ```ts
195
+ import { encodeKey } from '@tezos-x/octez.js-utils';
196
+
197
+ console.log(encodeKey('0060842d4ba23a9940ef5dcf4404fdaa430cfaaccb5029fad06cb5ea894e4562ae'));
198
+ // output: edpkuNjKKT48xBoT5asPrWdmuM1Yw8D93MwgFgVvtca8jb5pstzaCh
199
+ ```
200
+
201
+ **Base58 encode an address using a predefined prefix**
202
+ ```ts
203
+ import { encodeAddress } from '@tezos-x/octez.js-utils';
204
+
205
+ console.log(encodeAddress('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f'));
206
+ // output: tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM
207
+
208
+ console.log(encodeAddress('01f9b689a478253793bd92357c5e08e5ebcd8db47600'));
209
+ // output: KT1XM8VUFBiM9AC5czWU15fEeE9nmuEYWt3Y
210
+ ```
211
+
212
+ **Base58 decode a address with a predefined prefix**
213
+
214
+ ```ts
215
+ import { b58DecodeAddress } from '@tezos-x/octez.js-utils';
216
+
217
+ console.log(b58DecodeAddress('tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'));
218
+ // output: 0000e96b9f8b19af9c7ffa0c0480e1977b295850961f
219
+ ```
220
+
221
+ **Base58 decode a string and remove the prefix from it**
222
+
223
+ ```ts
224
+ import { b58DecodeAndCheckPrefix, PrefixV2 } from '@tezos-x/octez.js-utils';
225
+
226
+ console.log(b58DecodeAndCheckPrefix('tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM', [PrefixV2.Ed25519PublicKeyHash], true));
227
+ // output: <Buffer e9 6b 9f 8b 19 af 9c 7f fa 0c 04 80 e1 97 7b 29 58 50 96 1f>
228
+ ```
229
+
230
+ **Base58 encode a string or a Uint8Array and append a prefix to it**
231
+
232
+ ```ts
233
+ import { b58Encode } from '@tezos-x/octez.js-utils';
234
+
235
+ console.log(b58Encode('e96b9f8b19af9c7ffa0c0480e1977b295850961f', PrefixV2.Ed25519PublicKeyHash));
236
+ // output: tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM
237
+ ```
238
+
239
+ **Return the operation hash of a signed operation**
240
+
241
+ ```ts
242
+ import { encodeOpHash } from '@tezos-x/octez.js-utils';
243
+
244
+ const opBytesSigned = '0f185d8a30061e8134c162dbb7a6c3ab8f5fdb153363ccd6149b49a33481156a6c00b2e19a9e74440d86c59f13dab8a18ff873e889eaa304ab05da13000001f1585a7384f36e45fb43dc37e8ce172bced3e05700ff0000000002002110c033f3a990c2e46a3d6054ecc2f74072aae7a34b5ac4d9ce9edc11c2410a97695682108951786f05b361da03b97245dc9897e1955e08b5b8d9e153b0bdeb0d';
245
+ console.log(encodeOpHash(opBytesSigned));
246
+ // output: opapqvVXmebRTCFd2GQFydr4tJj3V5QocQuTmuhbatcHm4Seo2t
247
+ ```
248
+
249
+ **Generate expression hash**
250
+
251
+ Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and append the prefix 'expr' to it.
252
+
253
+ ```ts
254
+ import { encodeExpr } from '@tezos-x/octez.js-utils';
255
+
256
+ console.log(encodeExpr('050a000000160000b2e19a9e74440d86c59f13dab8a18ff873e889ea'));
257
+
258
+ // output: exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN
259
+ ```
260
+
261
+ **Obtain the public key hash given a public key**
262
+
263
+ ```ts
264
+ import { getPkhfromPk } from '@tezos-x/octez.js-utils';
265
+
266
+ const publicKey = 'sppk7czKu6So3zDWjhBPBv9wgCrBAfbEFoKYzEaKUsjhNr5Ug6E4Sn1';
267
+ console.log(getPkhfromPk(publicKey));
268
+ // output: 'tz2Gsf1Q857wUzkNGzHsJNC98z881UutMwjg
269
+ ```
270
+
271
+ ## Additional info
272
+
273
+ See the top-level [https://github.com/trilitech/octez.js](https://github.com/trilitech/octez.js) file for details on reporting issues, contributing, and versioning.
274
+
275
+ ## Disclaimer
276
+
277
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ // ref https://gitlab.com/tezos/tezos/-/blob/master/src/lib_crypto/base58.ml
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.payloadLength = exports.prefixV2 = exports.PrefixV2 = void 0;
5
+ /**
6
+ * @description base58 name to prefix mapping
7
+ */
8
+ var PrefixV2;
9
+ (function (PrefixV2) {
10
+ PrefixV2["BlockHash"] = "B";
11
+ PrefixV2["OperationHash"] = "o";
12
+ PrefixV2["OperationListHash"] = "Lo";
13
+ PrefixV2["OperationListListHash"] = "LLo";
14
+ PrefixV2["ProtocolHash"] = "P";
15
+ PrefixV2["ContextHash"] = "Co";
16
+ PrefixV2["BlockMetadataHash"] = "bm";
17
+ PrefixV2["OperationMetadataHash"] = "r";
18
+ PrefixV2["OperationMetadataListHash"] = "Lr";
19
+ PrefixV2["OperationMetadataListListHash"] = "LLr";
20
+ PrefixV2["Ed25519PublicKeyHash"] = "tz1";
21
+ PrefixV2["Secp256k1PublicKeyHash"] = "tz2";
22
+ PrefixV2["P256PublicKeyHash"] = "tz3";
23
+ PrefixV2["ContractHash"] = "KT1";
24
+ PrefixV2["BlindedPublicKeyHash"] = "btz1";
25
+ PrefixV2["BLS12_381PublicKeyHash"] = "tz4";
26
+ PrefixV2["TXRollupAddress"] = "txr1";
27
+ PrefixV2["ZkRollupHash"] = "epx1";
28
+ PrefixV2["ScRollupHash"] = "scr1";
29
+ PrefixV2["SmartRollupHash"] = "sr1";
30
+ PrefixV2["CryptoboxPublicKeyHash"] = "id";
31
+ PrefixV2["Ed25519Seed"] = "edsk";
32
+ PrefixV2["Ed25519PublicKey"] = "edpk";
33
+ PrefixV2["Secp256k1SecretKey"] = "spsk";
34
+ PrefixV2["P256SecretKey"] = "p2sk";
35
+ PrefixV2["BLS12_381SecretKey"] = "BLsk";
36
+ PrefixV2["ValueHash"] = "vh";
37
+ PrefixV2["CycleNonce"] = "nce";
38
+ PrefixV2["ScriptExpr"] = "expr";
39
+ PrefixV2["InboxHash"] = "txi";
40
+ PrefixV2["MessageHash"] = "txm";
41
+ PrefixV2["CommitmentHash"] = "txc";
42
+ PrefixV2["MessageResultHash"] = "txmr";
43
+ PrefixV2["MessageResultListHash"] = "txM";
44
+ PrefixV2["WithdrawListHash"] = "txw";
45
+ PrefixV2["ScRollupStateHash"] = "scs1";
46
+ PrefixV2["ScRollupCommitmentHash"] = "scc1";
47
+ PrefixV2["SmartRollupStateHash"] = "srs1";
48
+ PrefixV2["SmartRollupCommitmentHash"] = "src1";
49
+ PrefixV2["Ed25519EncryptedSeed"] = "edesk";
50
+ PrefixV2["Secp256k1EncryptedSecretKey"] = "spesk";
51
+ PrefixV2["P256EncryptedSecretKey"] = "p2esk";
52
+ PrefixV2["BLS12_381EncryptedSecretKey"] = "BLesk";
53
+ PrefixV2["Secp256k1EncryptedScalar"] = "seesk";
54
+ PrefixV2["Secp256k1PublicKey"] = "sppk";
55
+ PrefixV2["P256PublicKey"] = "p2pk";
56
+ PrefixV2["Secp256k1Scalar"] = "SSp";
57
+ PrefixV2["Secp256k1Element"] = "GSp";
58
+ PrefixV2["Ed25519SecretKey"] = "_edsk";
59
+ PrefixV2["Ed25519Signature"] = "edsig";
60
+ PrefixV2["Secp256k1Signature"] = "spsig1";
61
+ PrefixV2["P256Signature"] = "p2sig";
62
+ PrefixV2["GenericSignature"] = "sig";
63
+ PrefixV2["ChainID"] = "Net";
64
+ PrefixV2["SaplingSpendingKey"] = "sask";
65
+ PrefixV2["EncryptedSaplingSpendingKey"] = "_sask";
66
+ PrefixV2["SaplingAddress"] = "zet1";
67
+ PrefixV2["GenericAggregateSignature"] = "asig";
68
+ PrefixV2["BLS12_381Signature"] = "BLsig";
69
+ PrefixV2["BLS12_381PublicKey"] = "BLpk";
70
+ PrefixV2["SlotHeader"] = "sh";
71
+ })(PrefixV2 || (exports.PrefixV2 = PrefixV2 = {}));
72
+ /**
73
+ * @description base58 prefix to bytes mapping
74
+ */
75
+ exports.prefixV2 = {
76
+ [PrefixV2.BlockHash]: new Uint8Array([1, 52]),
77
+ [PrefixV2.OperationHash]: new Uint8Array([5, 116]),
78
+ [PrefixV2.OperationListHash]: new Uint8Array([133, 233]),
79
+ [PrefixV2.OperationListListHash]: new Uint8Array([29, 159, 109]),
80
+ [PrefixV2.ProtocolHash]: new Uint8Array([2, 170]),
81
+ [PrefixV2.ContextHash]: new Uint8Array([79, 199]),
82
+ [PrefixV2.BlockMetadataHash]: new Uint8Array([234, 249]),
83
+ [PrefixV2.OperationMetadataHash]: new Uint8Array([5, 183]),
84
+ [PrefixV2.OperationMetadataListHash]: new Uint8Array([134, 39]),
85
+ [PrefixV2.OperationMetadataListListHash]: new Uint8Array([29, 159, 182]),
86
+ [PrefixV2.Ed25519PublicKeyHash]: new Uint8Array([6, 161, 159]),
87
+ [PrefixV2.Secp256k1PublicKeyHash]: new Uint8Array([6, 161, 161]),
88
+ [PrefixV2.P256PublicKeyHash]: new Uint8Array([6, 161, 164]),
89
+ [PrefixV2.ContractHash]: new Uint8Array([2, 90, 121]),
90
+ [PrefixV2.BlindedPublicKeyHash]: new Uint8Array([1, 2, 49, 223]),
91
+ [PrefixV2.BLS12_381PublicKeyHash]: new Uint8Array([6, 161, 166]),
92
+ [PrefixV2.TXRollupAddress]: new Uint8Array([1, 128, 120, 31]),
93
+ [PrefixV2.ZkRollupHash]: new Uint8Array([1, 23, 224, 125]),
94
+ [PrefixV2.ScRollupHash]: new Uint8Array([1, 118, 132, 217]),
95
+ [PrefixV2.SmartRollupHash]: new Uint8Array([6, 124, 117]),
96
+ [PrefixV2.CryptoboxPublicKeyHash]: new Uint8Array([153, 103]),
97
+ [PrefixV2.Ed25519Seed]: new Uint8Array([13, 15, 58, 7]),
98
+ [PrefixV2.Ed25519PublicKey]: new Uint8Array([13, 15, 37, 217]),
99
+ [PrefixV2.Secp256k1SecretKey]: new Uint8Array([17, 162, 224, 201]),
100
+ [PrefixV2.P256SecretKey]: new Uint8Array([16, 81, 238, 189]),
101
+ [PrefixV2.BLS12_381SecretKey]: new Uint8Array([3, 150, 192, 40]),
102
+ [PrefixV2.ValueHash]: new Uint8Array([1, 106, 242]),
103
+ [PrefixV2.CycleNonce]: new Uint8Array([69, 220, 169]),
104
+ [PrefixV2.ScriptExpr]: new Uint8Array([13, 44, 64, 27]),
105
+ [PrefixV2.InboxHash]: new Uint8Array([79, 148, 196]),
106
+ [PrefixV2.MessageHash]: new Uint8Array([79, 149, 30]),
107
+ [PrefixV2.CommitmentHash]: new Uint8Array([79, 148, 17]),
108
+ [PrefixV2.MessageResultHash]: new Uint8Array([18, 7, 206, 87]),
109
+ [PrefixV2.MessageResultListHash]: new Uint8Array([79, 146, 82]),
110
+ [PrefixV2.WithdrawListHash]: new Uint8Array([79, 150, 72]),
111
+ [PrefixV2.ScRollupStateHash]: new Uint8Array([17, 144, 122, 202]),
112
+ [PrefixV2.ScRollupCommitmentHash]: new Uint8Array([17, 144, 21, 100]),
113
+ [PrefixV2.SmartRollupStateHash]: new Uint8Array([17, 165, 235, 240]),
114
+ [PrefixV2.SmartRollupCommitmentHash]: new Uint8Array([17, 165, 134, 138]),
115
+ [PrefixV2.Ed25519EncryptedSeed]: new Uint8Array([7, 90, 60, 179, 41]),
116
+ [PrefixV2.Secp256k1EncryptedSecretKey]: new Uint8Array([9, 237, 241, 174, 150]),
117
+ [PrefixV2.P256EncryptedSecretKey]: new Uint8Array([9, 48, 57, 115, 171]),
118
+ [PrefixV2.BLS12_381EncryptedSecretKey]: new Uint8Array([2, 5, 30, 53, 25]),
119
+ [PrefixV2.Secp256k1EncryptedScalar]: new Uint8Array([1, 131, 36, 86, 248]),
120
+ [PrefixV2.Secp256k1PublicKey]: new Uint8Array([3, 254, 226, 86]),
121
+ [PrefixV2.P256PublicKey]: new Uint8Array([3, 178, 139, 127]),
122
+ [PrefixV2.Secp256k1Scalar]: new Uint8Array([38, 248, 136]),
123
+ [PrefixV2.Secp256k1Element]: new Uint8Array([5, 92, 0]),
124
+ [PrefixV2.Ed25519SecretKey]: new Uint8Array([43, 246, 78, 7]),
125
+ [PrefixV2.Ed25519Signature]: new Uint8Array([9, 245, 205, 134, 18]),
126
+ [PrefixV2.Secp256k1Signature]: new Uint8Array([13, 115, 101, 19, 63]),
127
+ [PrefixV2.P256Signature]: new Uint8Array([54, 240, 44, 52]),
128
+ [PrefixV2.GenericSignature]: new Uint8Array([4, 130, 43]),
129
+ [PrefixV2.ChainID]: new Uint8Array([87, 82, 0]),
130
+ [PrefixV2.SaplingSpendingKey]: new Uint8Array([11, 237, 20, 92]),
131
+ [PrefixV2.EncryptedSaplingSpendingKey]: new Uint8Array([11, 237, 20, 92]),
132
+ [PrefixV2.SaplingAddress]: new Uint8Array([18, 71, 40, 223]),
133
+ [PrefixV2.GenericAggregateSignature]: new Uint8Array([2, 75, 234, 101]),
134
+ [PrefixV2.BLS12_381Signature]: new Uint8Array([40, 171, 64, 207]),
135
+ [PrefixV2.BLS12_381PublicKey]: new Uint8Array([6, 149, 135, 204]),
136
+ [PrefixV2.SlotHeader]: new Uint8Array([2, 116, 180]),
137
+ };
138
+ /**
139
+ * @description base58 prefix to payload length mapping
140
+ */
141
+ exports.payloadLength = {
142
+ [PrefixV2.BlockHash]: 32,
143
+ [PrefixV2.OperationHash]: 32,
144
+ [PrefixV2.OperationListHash]: 32,
145
+ [PrefixV2.OperationListListHash]: 32,
146
+ [PrefixV2.ProtocolHash]: 32,
147
+ [PrefixV2.ContextHash]: 32,
148
+ [PrefixV2.BlockMetadataHash]: 32,
149
+ [PrefixV2.OperationMetadataHash]: 32,
150
+ [PrefixV2.OperationMetadataListHash]: 32,
151
+ [PrefixV2.OperationMetadataListListHash]: 32,
152
+ [PrefixV2.Ed25519PublicKeyHash]: 20,
153
+ [PrefixV2.Secp256k1PublicKeyHash]: 20,
154
+ [PrefixV2.P256PublicKeyHash]: 20,
155
+ [PrefixV2.ContractHash]: 20,
156
+ [PrefixV2.BlindedPublicKeyHash]: 20,
157
+ [PrefixV2.BLS12_381PublicKeyHash]: 20,
158
+ [PrefixV2.TXRollupAddress]: 20,
159
+ [PrefixV2.ZkRollupHash]: 20,
160
+ [PrefixV2.ScRollupHash]: 20,
161
+ [PrefixV2.SmartRollupHash]: 20,
162
+ [PrefixV2.CryptoboxPublicKeyHash]: 16,
163
+ [PrefixV2.Ed25519Seed]: 32,
164
+ [PrefixV2.Ed25519PublicKey]: 32,
165
+ [PrefixV2.Secp256k1SecretKey]: 32,
166
+ [PrefixV2.P256SecretKey]: 32,
167
+ [PrefixV2.BLS12_381SecretKey]: 32,
168
+ [PrefixV2.ValueHash]: 32,
169
+ [PrefixV2.CycleNonce]: 32,
170
+ [PrefixV2.ScriptExpr]: 32,
171
+ [PrefixV2.InboxHash]: 32,
172
+ [PrefixV2.MessageHash]: 32,
173
+ [PrefixV2.CommitmentHash]: 32,
174
+ [PrefixV2.MessageResultHash]: 32,
175
+ [PrefixV2.MessageResultListHash]: 32,
176
+ [PrefixV2.WithdrawListHash]: 32,
177
+ [PrefixV2.ScRollupStateHash]: 32,
178
+ [PrefixV2.ScRollupCommitmentHash]: 32,
179
+ [PrefixV2.SmartRollupStateHash]: 32,
180
+ [PrefixV2.SmartRollupCommitmentHash]: 32,
181
+ [PrefixV2.Ed25519EncryptedSeed]: 56,
182
+ [PrefixV2.Secp256k1EncryptedSecretKey]: 56,
183
+ [PrefixV2.P256EncryptedSecretKey]: 56,
184
+ [PrefixV2.BLS12_381EncryptedSecretKey]: 56,
185
+ [PrefixV2.Secp256k1EncryptedScalar]: 60,
186
+ [PrefixV2.Secp256k1PublicKey]: 33,
187
+ [PrefixV2.P256PublicKey]: 33,
188
+ [PrefixV2.Secp256k1Scalar]: 33,
189
+ [PrefixV2.Secp256k1Element]: 33,
190
+ [PrefixV2.Ed25519SecretKey]: 64,
191
+ [PrefixV2.Ed25519Signature]: 64,
192
+ [PrefixV2.Secp256k1Signature]: 64,
193
+ [PrefixV2.P256Signature]: 64,
194
+ [PrefixV2.GenericSignature]: 64,
195
+ [PrefixV2.ChainID]: 4,
196
+ [PrefixV2.SaplingSpendingKey]: 169,
197
+ [PrefixV2.EncryptedSaplingSpendingKey]: 193,
198
+ [PrefixV2.SaplingAddress]: 43,
199
+ [PrefixV2.GenericAggregateSignature]: 96,
200
+ [PrefixV2.BLS12_381Signature]: 96,
201
+ [PrefixV2.BLS12_381PublicKey]: 48,
202
+ [PrefixV2.SlotHeader]: 48,
203
+ };