UNPKG

@taquito/utils

Version:

Encoding, crypto, and utility helpers for Taquito.

204 lines (203 loc) 9.56 kB
"use strict"; // ref https://gitlab.com/tezos/tezos/-/blob/master/src/lib_crypto/base58.ml Object.defineProperty(exports, "__esModule", { value: true }); exports.payloadLength = exports.prefixV2 = exports.PrefixV2 = void 0; /** * base58 name to prefix mapping */ var PrefixV2; (function (PrefixV2) { PrefixV2["BlockHash"] = "B"; PrefixV2["OperationHash"] = "o"; PrefixV2["OperationListHash"] = "Lo"; PrefixV2["OperationListListHash"] = "LLo"; PrefixV2["ProtocolHash"] = "P"; PrefixV2["ContextHash"] = "Co"; PrefixV2["BlockMetadataHash"] = "bm"; PrefixV2["OperationMetadataHash"] = "r"; PrefixV2["OperationMetadataListHash"] = "Lr"; PrefixV2["OperationMetadataListListHash"] = "LLr"; PrefixV2["Ed25519PublicKeyHash"] = "tz1"; PrefixV2["Secp256k1PublicKeyHash"] = "tz2"; PrefixV2["P256PublicKeyHash"] = "tz3"; PrefixV2["ContractHash"] = "KT1"; PrefixV2["BlindedPublicKeyHash"] = "btz1"; PrefixV2["BLS12_381PublicKeyHash"] = "tz4"; PrefixV2["TXRollupAddress"] = "txr1"; PrefixV2["ZkRollupHash"] = "epx1"; PrefixV2["ScRollupHash"] = "scr1"; PrefixV2["SmartRollupHash"] = "sr1"; PrefixV2["CryptoboxPublicKeyHash"] = "id"; PrefixV2["Ed25519Seed"] = "edsk"; PrefixV2["Ed25519PublicKey"] = "edpk"; PrefixV2["Secp256k1SecretKey"] = "spsk"; PrefixV2["P256SecretKey"] = "p2sk"; PrefixV2["BLS12_381SecretKey"] = "BLsk"; PrefixV2["ValueHash"] = "vh"; PrefixV2["CycleNonce"] = "nce"; PrefixV2["ScriptExpr"] = "expr"; PrefixV2["InboxHash"] = "txi"; PrefixV2["MessageHash"] = "txm"; PrefixV2["CommitmentHash"] = "txc"; PrefixV2["MessageResultHash"] = "txmr"; PrefixV2["MessageResultListHash"] = "txM"; PrefixV2["WithdrawListHash"] = "txw"; PrefixV2["ScRollupStateHash"] = "scs1"; PrefixV2["ScRollupCommitmentHash"] = "scc1"; PrefixV2["SmartRollupStateHash"] = "srs1"; PrefixV2["SmartRollupCommitmentHash"] = "src1"; PrefixV2["Ed25519EncryptedSeed"] = "edesk"; PrefixV2["Secp256k1EncryptedSecretKey"] = "spesk"; PrefixV2["P256EncryptedSecretKey"] = "p2esk"; PrefixV2["BLS12_381EncryptedSecretKey"] = "BLesk"; PrefixV2["Secp256k1EncryptedScalar"] = "seesk"; PrefixV2["Secp256k1PublicKey"] = "sppk"; PrefixV2["P256PublicKey"] = "p2pk"; PrefixV2["Secp256k1Scalar"] = "SSp"; PrefixV2["Secp256k1Element"] = "GSp"; PrefixV2["Ed25519SecretKey"] = "_edsk"; PrefixV2["Ed25519Signature"] = "edsig"; PrefixV2["Secp256k1Signature"] = "spsig1"; PrefixV2["P256Signature"] = "p2sig"; PrefixV2["GenericSignature"] = "sig"; PrefixV2["ChainID"] = "Net"; PrefixV2["SaplingSpendingKey"] = "sask"; PrefixV2["EncryptedSaplingSpendingKey"] = "_sask"; PrefixV2["SaplingAddress"] = "zet1"; PrefixV2["GenericAggregateSignature"] = "asig"; PrefixV2["BLS12_381Signature"] = "BLsig"; PrefixV2["BLS12_381PublicKey"] = "BLpk"; PrefixV2["SlotHeader"] = "sh"; })(PrefixV2 || (exports.PrefixV2 = PrefixV2 = {})); /** * base58 prefix to bytes mapping */ exports.prefixV2 = { [PrefixV2.BlockHash]: new Uint8Array([1, 52]), [PrefixV2.OperationHash]: new Uint8Array([5, 116]), [PrefixV2.OperationListHash]: new Uint8Array([133, 233]), [PrefixV2.OperationListListHash]: new Uint8Array([29, 159, 109]), [PrefixV2.ProtocolHash]: new Uint8Array([2, 170]), [PrefixV2.ContextHash]: new Uint8Array([79, 199]), [PrefixV2.BlockMetadataHash]: new Uint8Array([234, 249]), [PrefixV2.OperationMetadataHash]: new Uint8Array([5, 183]), [PrefixV2.OperationMetadataListHash]: new Uint8Array([134, 39]), [PrefixV2.OperationMetadataListListHash]: new Uint8Array([29, 159, 182]), [PrefixV2.Ed25519PublicKeyHash]: new Uint8Array([6, 161, 159]), [PrefixV2.Secp256k1PublicKeyHash]: new Uint8Array([6, 161, 161]), [PrefixV2.P256PublicKeyHash]: new Uint8Array([6, 161, 164]), [PrefixV2.ContractHash]: new Uint8Array([2, 90, 121]), [PrefixV2.BlindedPublicKeyHash]: new Uint8Array([1, 2, 49, 223]), [PrefixV2.BLS12_381PublicKeyHash]: new Uint8Array([6, 161, 166]), [PrefixV2.TXRollupAddress]: new Uint8Array([1, 128, 120, 31]), [PrefixV2.ZkRollupHash]: new Uint8Array([1, 23, 224, 125]), [PrefixV2.ScRollupHash]: new Uint8Array([1, 118, 132, 217]), [PrefixV2.SmartRollupHash]: new Uint8Array([6, 124, 117]), [PrefixV2.CryptoboxPublicKeyHash]: new Uint8Array([153, 103]), [PrefixV2.Ed25519Seed]: new Uint8Array([13, 15, 58, 7]), [PrefixV2.Ed25519PublicKey]: new Uint8Array([13, 15, 37, 217]), [PrefixV2.Secp256k1SecretKey]: new Uint8Array([17, 162, 224, 201]), [PrefixV2.P256SecretKey]: new Uint8Array([16, 81, 238, 189]), [PrefixV2.BLS12_381SecretKey]: new Uint8Array([3, 150, 192, 40]), [PrefixV2.ValueHash]: new Uint8Array([1, 106, 242]), [PrefixV2.CycleNonce]: new Uint8Array([69, 220, 169]), [PrefixV2.ScriptExpr]: new Uint8Array([13, 44, 64, 27]), [PrefixV2.InboxHash]: new Uint8Array([79, 148, 196]), [PrefixV2.MessageHash]: new Uint8Array([79, 149, 30]), [PrefixV2.CommitmentHash]: new Uint8Array([79, 148, 17]), [PrefixV2.MessageResultHash]: new Uint8Array([18, 7, 206, 87]), [PrefixV2.MessageResultListHash]: new Uint8Array([79, 146, 82]), [PrefixV2.WithdrawListHash]: new Uint8Array([79, 150, 72]), [PrefixV2.ScRollupStateHash]: new Uint8Array([17, 144, 122, 202]), [PrefixV2.ScRollupCommitmentHash]: new Uint8Array([17, 144, 21, 100]), [PrefixV2.SmartRollupStateHash]: new Uint8Array([17, 165, 235, 240]), [PrefixV2.SmartRollupCommitmentHash]: new Uint8Array([17, 165, 134, 138]), [PrefixV2.Ed25519EncryptedSeed]: new Uint8Array([7, 90, 60, 179, 41]), [PrefixV2.Secp256k1EncryptedSecretKey]: new Uint8Array([9, 237, 241, 174, 150]), [PrefixV2.P256EncryptedSecretKey]: new Uint8Array([9, 48, 57, 115, 171]), [PrefixV2.BLS12_381EncryptedSecretKey]: new Uint8Array([2, 5, 30, 53, 25]), [PrefixV2.Secp256k1EncryptedScalar]: new Uint8Array([1, 131, 36, 86, 248]), [PrefixV2.Secp256k1PublicKey]: new Uint8Array([3, 254, 226, 86]), [PrefixV2.P256PublicKey]: new Uint8Array([3, 178, 139, 127]), [PrefixV2.Secp256k1Scalar]: new Uint8Array([38, 248, 136]), [PrefixV2.Secp256k1Element]: new Uint8Array([5, 92, 0]), [PrefixV2.Ed25519SecretKey]: new Uint8Array([43, 246, 78, 7]), [PrefixV2.Ed25519Signature]: new Uint8Array([9, 245, 205, 134, 18]), [PrefixV2.Secp256k1Signature]: new Uint8Array([13, 115, 101, 19, 63]), [PrefixV2.P256Signature]: new Uint8Array([54, 240, 44, 52]), [PrefixV2.GenericSignature]: new Uint8Array([4, 130, 43]), [PrefixV2.ChainID]: new Uint8Array([87, 82, 0]), [PrefixV2.SaplingSpendingKey]: new Uint8Array([11, 237, 20, 92]), [PrefixV2.EncryptedSaplingSpendingKey]: new Uint8Array([11, 237, 20, 92]), [PrefixV2.SaplingAddress]: new Uint8Array([18, 71, 40, 223]), [PrefixV2.GenericAggregateSignature]: new Uint8Array([2, 75, 234, 101]), [PrefixV2.BLS12_381Signature]: new Uint8Array([40, 171, 64, 207]), [PrefixV2.BLS12_381PublicKey]: new Uint8Array([6, 149, 135, 204]), [PrefixV2.SlotHeader]: new Uint8Array([2, 116, 180]), }; /** * base58 prefix to payload length mapping */ exports.payloadLength = { [PrefixV2.BlockHash]: 32, [PrefixV2.OperationHash]: 32, [PrefixV2.OperationListHash]: 32, [PrefixV2.OperationListListHash]: 32, [PrefixV2.ProtocolHash]: 32, [PrefixV2.ContextHash]: 32, [PrefixV2.BlockMetadataHash]: 32, [PrefixV2.OperationMetadataHash]: 32, [PrefixV2.OperationMetadataListHash]: 32, [PrefixV2.OperationMetadataListListHash]: 32, [PrefixV2.Ed25519PublicKeyHash]: 20, [PrefixV2.Secp256k1PublicKeyHash]: 20, [PrefixV2.P256PublicKeyHash]: 20, [PrefixV2.ContractHash]: 20, [PrefixV2.BlindedPublicKeyHash]: 20, [PrefixV2.BLS12_381PublicKeyHash]: 20, [PrefixV2.TXRollupAddress]: 20, [PrefixV2.ZkRollupHash]: 20, [PrefixV2.ScRollupHash]: 20, [PrefixV2.SmartRollupHash]: 20, [PrefixV2.CryptoboxPublicKeyHash]: 16, [PrefixV2.Ed25519Seed]: 32, [PrefixV2.Ed25519PublicKey]: 32, [PrefixV2.Secp256k1SecretKey]: 32, [PrefixV2.P256SecretKey]: 32, [PrefixV2.BLS12_381SecretKey]: 32, [PrefixV2.ValueHash]: 32, [PrefixV2.CycleNonce]: 32, [PrefixV2.ScriptExpr]: 32, [PrefixV2.InboxHash]: 32, [PrefixV2.MessageHash]: 32, [PrefixV2.CommitmentHash]: 32, [PrefixV2.MessageResultHash]: 32, [PrefixV2.MessageResultListHash]: 32, [PrefixV2.WithdrawListHash]: 32, [PrefixV2.ScRollupStateHash]: 32, [PrefixV2.ScRollupCommitmentHash]: 32, [PrefixV2.SmartRollupStateHash]: 32, [PrefixV2.SmartRollupCommitmentHash]: 32, [PrefixV2.Ed25519EncryptedSeed]: 56, [PrefixV2.Secp256k1EncryptedSecretKey]: 56, [PrefixV2.P256EncryptedSecretKey]: 56, [PrefixV2.BLS12_381EncryptedSecretKey]: 56, [PrefixV2.Secp256k1EncryptedScalar]: 60, [PrefixV2.Secp256k1PublicKey]: 33, [PrefixV2.P256PublicKey]: 33, [PrefixV2.Secp256k1Scalar]: 33, [PrefixV2.Secp256k1Element]: 33, [PrefixV2.Ed25519SecretKey]: 64, [PrefixV2.Ed25519Signature]: 64, [PrefixV2.Secp256k1Signature]: 64, [PrefixV2.P256Signature]: 64, [PrefixV2.GenericSignature]: 64, [PrefixV2.ChainID]: 4, [PrefixV2.SaplingSpendingKey]: 169, [PrefixV2.EncryptedSaplingSpendingKey]: 193, [PrefixV2.SaplingAddress]: 43, [PrefixV2.GenericAggregateSignature]: 96, [PrefixV2.BLS12_381Signature]: 96, [PrefixV2.BLS12_381PublicKey]: 48, [PrefixV2.SlotHeader]: 48, };