@layerzerolabs/lz-foundation 3.0.14 → 3.0.16
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/CHANGELOG.md +18 -0
- package/README.md +106 -2
- package/dist/index.cjs +427 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +412 -12
- package/dist/index.d.ts +412 -12
- package/dist/index.mjs +421 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hash/index.ts","../src/sign/constant.ts","../src/sign/ed25519.ts","../src/sign/internal.ts","../src/sign/secp256k1.ts","../src/sign/index.ts","../src/signer.ts"],"names":["SignAlgorithm","getPublicKey","signHash"],"mappings":";;;;;;;AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU,eAAe;AAClC,SAAS,YAAY,iBAAiB;AAE/B,SAAS,WAAW,SAA0C;AACjE,SAAO,WAAW,OAAO;AAC7B;AAEO,SAAS,QAAQ,SAA0C;AAC9D,SAAO,SAAS,OAAO;AAC3B;AAEO,SAAS,SAAS,SAA0C;AAC/D,SAAO,UAAU,OAAO;AAC5B;AAEO,SAAS,SAAS,SAA0C;AAC/D,SAAO,QAAQ,OAAO;AAC1B;;;AClBO,IAAK,gBAAL,kBAAKA,mBAAL;AACH,EAAAA,8BAAA;AACA,EAAAA,8BAAA;AACA,EAAAA,8BAAA;AAHQ,SAAAA;AAAA,GAAA;;;ACAZ;AAAA;AAAA,sBAAAC;AAAA,EAAA;AAAA;AAAA,YAAY,aAAa;;;ACMlB,SAAS,oBAAoB,YAA+D;AAC/F,MAAI,OAAO,eAAe,UAAU;AAChC,WAAO,WAAW,QAAQ,OAAO,EAAE;AAAA,EACvC,WAAW,OAAO,eAAe,UAAU;AACvC,WAAO,WAAW,SAAS,EAAE,EAAE,SAAS,IAAI,GAAG;AAAA,EACnD,OAAO;AACH,WAAO;A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A,WACmB;AACnB,MAAI,KAAK,WAAW,IAAI;AACpB,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAChD;AAIA,QAAM,UACF,OAAO,eAAe,WAAW,WAAW,QAAQ,OAAO,EAAE,IAAI,OAAO,KAAK,UAAU,EAAE,SAAS,KAAK;AAC3G,UAAQ,WAAW;AAAA,IACf;AACI,aAAiBA,UAAS,MAAM,OAAO;AACvC;AAAA,IACJ;AACI,aAAe,SAAS,MAAM,OAAO;AACrC;AAAA,IACJ;AACI,YAAM,IAAI,MAAM,0BAA0B,SAAS,EAAE;AAAA,EAC7D;AACJ;;;ACZO,IAAM,kBAAN,MAAM,iBAAsC;AAAA,EACvC,YAA6B,YAAwB;AAAxB;AAAA,EAAyB;AAAA,EAE9D,OAAO,KAAK,YAAyC;AACjD,WAAO,IAAI,iBAAgB,UAAU;AAAA,EACzC;AAAA,EAEA,MAAM,eAAoC;AACtC,WAAO,kBAAU,aAAa,KAAK,UAAU;AAAA,EACjD;AAAA,EAEA,MAAM,SAAS,MAAuC;AAClD,WAAO,kBAAU,SAAS,MAAM,KAAK,UAAU;AAAA,EACnD;AACJ;AAEO,IAAM,gBAAN,MAAM,eAAoC;AAAA,EACrC,YAA6B,YAAwB;AAAxB;AAAA,EAAyB;AAAA,EAE9D,OAAO,KAAK,YAAuC;AAC/C,WAAO,IAAI,eAAc,UAAU;AAAA,EACvC;AAAA,EAEA,MAAM,SAAS,MAAuC;AAClD,WAAO,gBAAQ,SAAS,MAAM,KAAK,UAAU;AAAA,EACjD;AAAA,EAEA,MAAM,eAAoC;AACtC,WAAO,gBAAQ,aAAa,KAAK,UAAU;AAAA,EAC/C;AACJ","sourcesContent":["import { blake2b as _blake2b } from '@noble/hashes/blake2b'\nimport { sha256 as _sha256 } from '@noble/hashes/sha256'\nimport { sha3_256 as _sha3_256 } from '@noble/hashes/sha3'\n\nexport function keccak_256(message: Uint8Array | string): Uint8Array {\n return keccak_256(message)\n}\n\nexport function blake2b(message: Uint8Array | string): Uint8Array {\n return _blake2b(message)\n}\n\nexport function sha3_256(message: Uint8Array | string): Uint8Array {\n return _sha3_256(message)\n}\n\nexport function sha2_256(message: Uint8Array | string): Uint8Array {\n return _sha256(message)\n}\n","export enum SignAlgorithm {\n NATIVE,\n SECP256K1,\n ED25519,\n}\n","import * as ed25519 from '@noble/ed25519'\n\nimport { normalizePrivateKey } from './internal'\n\n/**\n * Sign a hash using ed25519\n * @param hash - 32 bytes long\n * @param privateKey - private key in hex format\n * @returns\n */\nexport async function signHash(hash: Uint8Array, privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n privateKey = normalizePrivateKey(privateKey)\n const pubKey = await ed25519.getPublicKey(privateKey)\n const signature = await ed25519.sign(hash, privateKey)\n const isValid = await ed25519.verify(signature, hash, pubKey)\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return signature\n}\n\nexport async function getPublicKey(privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n privateKey = normalizePrivateKey(privateKey)\n return ed25519.getPublicKey(privateKey)\n}\n","/**\n * Normalize the private key to a string or Uint8Array\n * - getPublicKey accepts bigint but sign does not, in ed25519\n * - a string privateKey should not have a 0x prefix, in ed25519\n * @param privateKey\n */\nexport function normalizePrivateKey(privateKey: string | Uint8Array | bigint): string | Uint8Array {\n if (typeof privateKey === 'string') {\n return privateKey.replace(/^0x/, '')\n } else if (typeof privateKey === 'bigint') {\n return privateKey.toString(16).padStart(64, '0') // the private key is 32 bytes for ed25519 and secp256k1\n } else {\n return privateKey\n }\n}\n","import * as secp256k1 from '@noble/secp256k1'\n\nimport { normalizePrivateKey } from './internal'\n\n/**\n * Sign a hash using secp256k1\n * @param hash - 32 bytes long\n * @param privateKey - private key in hex format\n * @returns\n */\nexport async function signHash(hash: Uint8Array, privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n privateKey = normalizePrivateKey(privateKey)\n const pubKey = secp256k1.getPublicKey(privateKey, false)\n\n // refer to: https://github.com/paulmillr/noble-secp256k1/tree/1.7.1#signmsghash-privatekey\n const [signature, recoveryId] = await secp256k1.sign(hash, privateKey, {\n // recovered - true indicates the recovered bit should be included in the result\n recovered: true,\n // canonical - true makes signatures compatible with libsecp256k1, false makes signatures compatible with openssl\n canonical: true,\n // der - whether the returned signature should be in DER format. If false, it would be in Compact format (32-byte r + 32-byte s)\n der: false,\n // extraEntropy - When true, it would automatically be filled with 32 bytes of cryptographically secure entropy. Strongly recommended to pass true to improve security:\n extraEntropy: undefined,\n })\n\n const isValid = secp256k1.verify(signature, hash, pubKey, { strict: true })\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return Uint8Array.from([...signature, recoveryId])\n}\n\nexport async function getPublicKey(privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n privateKey = normalizePrivateKey(privateKey)\n return Promise.resolve(secp256k1.getPublicKey(privateKey, false))\n}\n","import { SignAlgorithm } from './constant'\nexport * from './keypair'\nexport * from './constant'\nimport * as ed25519 from './ed25519'\nimport * as secp256k1 from './secp256k1'\n\nexport async function signHash(\n hash: Uint8Array,\n privateKey: string | Uint8Array,\n algorithm: SignAlgorithm\n): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n // privKey should be a hex string without 0x prefix\n // refer to: https://github.com/paulmillr/noble-secp256k1/blob/5ed251242bf065aeb22a54bb42eee1f67e7c77ce/index.ts#L130\n const privKey =\n typeof privateKey === 'string' ? privateKey.replace(/^0x/, '') : Buffer.from(privateKey).toString('hex')\n switch (algorithm) {\n case SignAlgorithm.SECP256K1:\n return secp256k1.signHash(hash, privKey)\n break\n case SignAlgorithm.ED25519:\n return ed25519.signHash(hash, privKey)\n break\n default:\n throw new Error(`Unsupported algorithm: ${algorithm}`)\n }\n}\n\nexport { secp256k1, ed25519 }\n","import { ed25519, secp256k1 } from './sign'\n/**\n * Interface for signing a hash.\n */\nexport interface HashSigner {\n /**\n * signHash signs a hash\n * @param hash - 32 bytes long\n */\n signHash(hash: Uint8Array): Promise<Uint8Array>\n\n /**\n * publicKey returns the public key of the signer\n */\n getPublicKey(): Promise<Uint8Array>\n}\n\nexport class Secp256k1Signer implements HashSigner {\n private constructor(private readonly privateKey: Uint8Array) {}\n\n static from(privatekey: Uint8Array): Secp256k1Signer {\n return new Secp256k1Signer(privatekey)\n }\n\n async getPublicKey(): Promise<Uint8Array> {\n return secp256k1.getPublicKey(this.privateKey)\n }\n\n async signHash(hash: Uint8Array): Promise<Uint8Array> {\n return secp256k1.signHash(hash, this.privateKey)\n }\n}\n\nexport class Ed25519Signer implements HashSigner {\n private constructor(private readonly privateKey: Uint8Array) {}\n\n static from(privateKey: Uint8Array): Ed25519Signer {\n return new Ed25519Signer(privateKey)\n }\n\n async signHash(hash: Uint8Array): Promise<Uint8Array> {\n return ed25519.signHash(hash, this.privateKey)\n }\n\n async getPublicKey(): Promise<Uint8Array> {\n return ed25519.getPublicKey(this.privateKey)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/hash/index.ts","../src/sign/constant.ts","../src/sign/ed25519.ts","../src/sign/internal.ts","../src/sign/secp256k1.ts","../src/sign/index.ts","../src/signer.ts","../src/base/base58.ts","../src/base/base58check.ts","../src/base/base64.ts","../src/address/aptos.ts","../src/address/evm.ts","../src/address/solana.ts","../src/address/tron.ts","../src/address/utils.ts","../src/address/address.ts"],"names":["SignAlgorithm","getPublicKey","signHash","decode","encode","arrayify","Address","hexlify","isHex"],"mappings":";;;;;;;AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU,eAAe;AAClC,SAAS,cAAc,aAAa,YAAY,iBAAiB;AAS1D,SAAS,WAAW,SAA0C;AACjE,SAAO,YAAY,OAAO;AAC9B;AASO,SAAS,QAAQ,SAA0C;AAC9D,SAAO,SAAS,OAAO;AAC3B;AAQO,SAAS,SAAS,SAA0C;AAC/D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AA;AAAA;AAAA;AAAA,EAMA,MAAkB;AACd,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAa;AACT,WAAO,oBAAY,OAAO,KAAK,IAAI;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAW;AACP,WAAOE,SAAQ,KAAK,IAAI;AAAA,EAC5B;AACJ;;;AC3FA,SAAS,OAAO,WAAW,wBAAwB;AAQ5C,IAAMD,WAAU;AAAA,EACnB,MAAM,CAAC,SAA8B,UAAmC;AACpE,UAAM,YAAY,iBAAiB,KAAK;AACxC,YAAQ,WAAW;AAAA,MACf,KAAK,UAAU;AACX,YAAI,UAAU,MAAM,MAAM;AACtB,iBAAYA,SAAQ,KAAK,OAAO;AAAA,QACpC;AACA,eAAWA,SAAQ,KAAK,OAAO;AAAA,MACnC,KAAK,UAAU;AACX,eAAa,QAAQ,KAAK,OAAO;AAAA,MACrC,KAAK,UAAU;AACX,eAAcA,SAAQ,KAAK,OAAO;AAAA,MACtC;AACI,cAAM,IAAI,MAAM,2BAA2B,SAAS,EAAE;AAAA,IAC9D;AAAA,EACJ;AACJ;;;ACtBA,IAAMA,WAAUA","sourcesContent":["import { blake2b as _blake2b } from '@noble/hashes/blake2b'\nimport { sha256 as _sha256 } from '@noble/hashes/sha256'\nimport { keccak_256 as _keccak_256, sha3_256 as _sha3_256 } from '@noble/hashes/sha3'\n\n/**\n * Computes the Keccak-256 hash of the given message.\n * introduction: https://wiki.rugdoc.io/docs/introduction-to-ethereums-keccak-256-algorithm/\n *\n * @param {Uint8Array | string} message - The input message to hash.\n * @returns {Uint8Array} The Keccak-256 hash of the input message.\n */\nexport function keccak_256(message: Uint8Array | string): Uint8Array {\n return _keccak_256(message)\n}\n\n/**\n * Computes the BLAKE2b hash of the given message.\n * introduction: https://en.wikipedia.org/wiki/BLAKE_(hash_function)\n *\n * @param {Uint8Array | string} message - The input message to hash.\n * @returns {Uint8Array} The BLAKE2b hash of the input message.\n */\nexport function blake2b(message: Uint8Array | string): Uint8Array {\n return _blake2b(message)\n}\n\n/**\n * Computes the SHA3-256 hash of the given message.\n *\n * @param {Uint8Array | string} message - The input message to hash.\n * @returns {Uint8Array} The SHA3-256 hash of the input message.\n */\nexport function sha3_256(message: Uint8Array | string): Uint8Array {\n return _sha3_256(message)\n}\n\n/**\n * Computes the SHA-256 hash of the given message.\n *\n * @param {Uint8Array | string} message - The input message to hash.\n * @returns {Uint8Array} The SHA-256 hash of the input message.\n */\nexport function sha2_256(message: Uint8Array | string): Uint8Array {\n return _sha256(message)\n}\n","/**\n * Enum representing different signing algorithms.\n */\nexport enum SignAlgorithm {\n /**\n * Native signing algorithm.\n */\n NATIVE,\n\n /**\n * SECP256K1 signing algorithm.\n * introduction: https://en.bitcoin.it/wiki/Secp256k1\n */\n SECP256K1,\n\n /**\n * ED25519 signing algorithm.\n * introduction: https://ed25519.cr.yp.to/\n */\n ED25519,\n}\n","import * as ed25519 from '@noble/ed25519'\n\nimport { normalizePrivateKey } from './internal'\n\n/**\n * Signs a hash using the ed25519 algorithm.\n *\n * @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.\n * @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signature.\n * @throws {Error} If the hash is not 32 bytes long or the signature is invalid.\n */\nexport async function signHash(hash: Uint8Array, privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n privateKey = normalizePrivateKey(privateKey)\n const pubKey = await ed25519.getPublicKey(privateKey)\n const signature = await ed25519.sign(hash, privateKey)\n const isValid = await ed25519.verify(signature, hash, pubKey)\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return signature\n}\n\n/**\n * Gets the public key corresponding to the given private key using the ed25519 algorithm.\n *\n * @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.\n * @returns {Promise<Uint8Array>} A promise that resolves to the public key.\n */\nexport async function getPublicKey(privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n privateKey = normalizePrivateKey(privateKey)\n return ed25519.getPublicKey(privateKey)\n}\n","/**\n * Normalizes the private key to a string or Uint8Array.\n * - `getPublicKey` accepts bigint but `sign` does not, in ed25519.\n * - A string privateKey should not have a 0x prefix, in ed25519.\n *\n * @param {string | Uint8Array | bigint} privateKey - The private key to normalize.\n * @returns {string | Uint8Array} The normalized private key.\n */\nexport function normalizePrivateKey(privateKey: string | Uint8Array | bigint): string | Uint8Array {\n if (typeof privateKey === 'string') {\n return privateKey.replace(/^0x/, '')\n } else if (typeof privateKey === 'bigint') {\n return privateKey.toString(16).padStart(64, '0') // the private key is 32 bytes for ed25519 and secp256k1\n } else {\n return privateKey\n }\n}\n","import * as secp256k1 from '@noble/secp256k1'\n\nimport { normalizePrivateKey } from './internal'\n\n/**\n * Signs a hash using the secp256k1 algorithm.\n *\n * @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.\n * @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signature.\n * @throws {Error} If the hash is not 32 bytes long or the signature is invalid.\n */\nexport async function signHash(hash: Uint8Array, privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n privateKey = normalizePrivateKey(privateKey)\n const pubKey = secp256k1.getPublicKey(privateKey, false)\n\n // refer to: https://github.com/paulmillr/noble-secp256k1/tree/1.7.1#signmsghash-privatekey\n const [signature, recoveryId] = await secp256k1.sign(hash, privateKey, {\n // recovered - true indicates the recovered bit should be included in the result\n recovered: true,\n // canonical - true makes signatures compatible with libsecp256k1, false makes signatures compatible with openssl\n canonical: true,\n // der - whether the returned signature should be in DER format. If false, it would be in Compact format (32-byte r + 32-byte s)\n der: false,\n // extraEntropy - When true, it would automatically be filled with 32 bytes of cryptographically secure entropy. Strongly recommended to pass true to improve security:\n extraEntropy: undefined,\n })\n\n const isValid = secp256k1.verify(signature, hash, pubKey, { strict: true })\n if (!isValid) {\n throw new Error('Invalid signature')\n }\n\n return Uint8Array.from([...signature, recoveryId])\n}\n\n/**\n * Gets the public key corresponding to the given private key using the secp256k1 algorithm.\n *\n * @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.\n * @returns {Promise<Uint8Array>} A promise that resolves to the public key.\n */\nexport async function getPublicKey(privateKey: string | Uint8Array | bigint): Promise<Uint8Array> {\n privateKey = normalizePrivateKey(privateKey)\n return Promise.resolve(secp256k1.getPublicKey(privateKey, false))\n}\n","import { SignAlgorithm } from './constant'\nexport * from './keypair'\nexport * from './constant'\nimport * as ed25519 from './ed25519'\nimport * as secp256k1 from './secp256k1'\n\n/**\n * Signs a hash using the specified signing algorithm.\n *\n * @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.\n * @param {string | Uint8Array} privateKey - The private key in hex format or Uint8Array.\n * @param {SignAlgorithm} algorithm - The signing algorithm to use.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signature.\n * @throws {Error} If the hash is not 32 bytes long or the algorithm is unsupported.\n */\nexport async function signHash(\n hash: Uint8Array,\n privateKey: string | Uint8Array,\n algorithm: SignAlgorithm\n): Promise<Uint8Array> {\n if (hash.length !== 32) {\n throw new Error('Hash must be 32 bytes long')\n }\n\n // privKey should be a hex string without 0x prefix\n // refer to: https://github.com/paulmillr/noble-secp256k1/blob/5ed251242bf065aeb22a54bb42eee1f67e7c77ce/index.ts#L130\n const privKey =\n typeof privateKey === 'string' ? privateKey.replace(/^0x/, '') : Buffer.from(privateKey).toString('hex')\n switch (algorithm) {\n case SignAlgorithm.SECP256K1:\n return secp256k1.signHash(hash, privKey)\n break\n case SignAlgorithm.ED25519:\n return ed25519.signHash(hash, privKey)\n break\n default:\n throw new Error(`Unsupported algorithm: ${algorithm}`)\n }\n}\n\nexport { secp256k1, ed25519 }\n","import { ed25519, secp256k1 } from './sign'\n/**\n * Interface for signing a hash.\n */\nexport interface HashSigner {\n /**\n * Signs a hash.\n * @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signature.\n */\n signHash(hash: Uint8Array): Promise<Uint8Array>\n\n /**\n * Returns the public key of the signer.\n * @returns {Promise<Uint8Array>} A promise that resolves to the public key.\n */\n getPublicKey(): Promise<Uint8Array>\n}\n\n/**\n * Class for signing hashes using the secp256k1 algorithm.\n */\nexport class Secp256k1Signer implements HashSigner {\n private constructor(private readonly privateKey: Uint8Array) {}\n\n /**\n * Creates an instance of Secp256k1Signer from a private key.\n * @param {Uint8Array} privateKey - The private key.\n * @returns {Secp256k1Signer} The created Secp256k1Signer instance.\n */\n static from(privatekey: Uint8Array): Secp256k1Signer {\n return new Secp256k1Signer(privatekey)\n }\n\n /**\n * Returns the public key of the signer.\n * @returns {Promise<Uint8Array>} A promise that resolves to the public key.\n */\n async getPublicKey(): Promise<Uint8Array> {\n return secp256k1.getPublicKey(this.privateKey)\n }\n\n /**\n * Signs a hash.\n * @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signature.\n */\n async signHash(hash: Uint8Array): Promise<Uint8Array> {\n return secp256k1.signHash(hash, this.privateKey)\n }\n}\n\n/**\n * Class for signing hashes using the ed25519 algorithm.\n */\nexport class Ed25519Signer implements HashSigner {\n private constructor(private readonly privateKey: Uint8Array) {}\n\n /**\n * Creates an instance of Ed25519Signer from a private key.\n * @param {Uint8Array} privateKey - The private key.\n * @returns {Ed25519Signer} The created Ed25519Signer instance.\n */\n static from(privateKey: Uint8Array): Ed25519Signer {\n return new Ed25519Signer(privateKey)\n }\n\n /**\n * Signs a hash.\n * @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signature.\n */\n async signHash(hash: Uint8Array): Promise<Uint8Array> {\n return ed25519.signHash(hash, this.privateKey)\n }\n\n /**\n * Returns the public key of the signer.\n * @returns {Promise<Uint8Array>} A promise that resolves to the public key.\n */\n async getPublicKey(): Promise<Uint8Array> {\n return ed25519.getPublicKey(this.privateKey)\n }\n}\n","import { base58 } from '@scure/base'\n\nimport { arrayify } from '@layerzerolabs/lz-utilities'\n\n/**\n * Encodes a string or Uint8Array to a base58 string.\n *\n * @param {string | Uint8Array} value - The value to encode.\n * @returns {string} The base58 encoded string.\n */\nexport function encode(value: string | Uint8Array): string {\n if (typeof value === 'string') {\n return base58.encode(arrayify(value))\n } else {\n return base58.encode(value)\n }\n}\n\n/**\n * Decodes a base58 string to a Uint8Array.\n *\n * @param {string} value - The base58 string to decode.\n * @returns {Uint8Array} The decoded Uint8Array.\n */\nexport function decode(value: string): Uint8Array {\n return base58.decode(value)\n}\n","import { sha256 } from '@noble/hashes/sha256'\nimport { createBase58check } from '@scure/base'\n\nimport { arrayify } from '@layerzerolabs/lz-utilities'\n\n/**\n * Encodes a string or Uint8Array to a base58check string.\n *\n * @param {string | Uint8Array} value - The value to encode.\n * @returns {string} The base58check encoded string.\n */\nexport function encode(value: string | Uint8Array): string {\n const base58check = createBase58check(sha256)\n if (typeof value === 'string') {\n return base58check.encode(arrayify(value))\n } else {\n return base58check.encode(value)\n }\n}\n\n/**\n * Decodes a base58check string to a Uint8Array.\n *\n * @param {string} value - The base58check string to decode.\n * @returns {Uint8Array} The decoded Uint8Array.\n */\nexport function decode(value: string): Uint8Array {\n const base58check = createBase58check(sha256)\n return base58check.decode(value)\n}\n","import { base64 } from '@scure/base'\n\nimport { arrayify } from '@layerzerolabs/lz-utilities'\n\n/**\n * Encodes a string or Uint8Array to a base64 string.\n *\n * @param {string | Uint8Array} value - The value to encode.\n * @returns {string} The base64 encoded string.\n */\nexport function encode(value: string | Uint8Array): string {\n if (typeof value === 'string') {\n return base64.encode(arrayify(value))\n } else {\n return base64.encode(value)\n }\n}\n\n/**\n * Decodes a base64 string to a Uint8Array.\n *\n * @param {string} value - The base64 string to decode.\n * @returns {Uint8Array} The decoded Uint8Array.\n */\nexport function decode(value: string): Uint8Array {\n return base64.decode(value)\n}\n","import { Hex, arrayify, hexlify, isHex } from '@layerzerolabs/lz-utilities'\n\nimport { Address as AddressInterface } from './address'\n\n/**\n * Represents an Aptos address.\n * @see {@link AddressInterface}\n */\nexport class Address implements AddressInterface {\n /**\n * The raw address data.\n */\n private data: Uint8Array\n\n /**\n * Creates an instance of Address.\n * @param {Uint8Array | string} value - The address value.\n * @throws {Error} If the address is invalid.\n */\n constructor(value: Uint8Array | string) {\n let data: Uint8Array | undefined = undefined\n\n if (value instanceof Uint8Array) {\n data = value\n } else if (typeof value === 'string') {\n if (isHex(value)) {\n data = arrayify(value)\n }\n }\n if (data === undefined) {\n throw new Error('Invalid address')\n }\n\n if (data.length > 32) {\n throw new Error('Invalid address length. Expected less or equal than 32 bytes.')\n }\n\n this.data = data\n }\n\n /**\n * Creates an Address instance from a value.\n * @param {Uint8Array | string} value - The address value.\n * @returns {Address} The Address instance.\n */\n static from(value: Uint8Array | string): Address {\n return new Address(value)\n }\n\n /**\n * Inspects the address.\n * @returns {string} The address as a string.\n */\n inspect(): string {\n return this.toString()\n }\n\n /**\n * Converts the address to a string.\n * @returns {string} The address as a string.\n */\n toString(): string {\n return this.hr()\n }\n\n /**\n * Gets the raw address data.\n * @returns {Uint8Array} The raw address data.\n */\n raw(): Uint8Array {\n return this.data\n }\n\n /**\n * Gets the human-readable address.\n * @returns {string} The human-readable address.\n */\n hr(): string {\n return hexlify(this.data)\n }\n\n /**\n * Gets the address as a hexadecimal string.\n * @returns {Hex} The address as a hexadecimal string.\n */\n hex(): Hex {\n return hexlify(this.data)\n }\n}\n","import { Hex, arrayify, hexlify, isHex, padify } from '@layerzerolabs/lz-utilities'\n\nimport { Address as AddressInterface } from './address'\nimport { keccak_256 } from '../hash'\n\n/**\n * Represents an EVM address.\n * @see {@link AddressInterface}\n */\nexport class Address implements AddressInterface {\n /**\n * The raw address data.\n */\n private data: Uint8Array\n\n /**\n * Creates an instance of Address.\n * @param {Uint8Array | string} value - The address value.\n * @throws {Error} If the address is invalid.\n */\n constructor(value: Uint8Array | string) {\n let data: Uint8Array | undefined = undefined\n if (value instanceof Uint8Array) {\n data = value\n } else if (typeof value === 'string' && isHex(value)) {\n data = arrayify(value)\n }\n\n if (data === undefined) {\n throw new Error('Invalid address')\n }\n\n if (data.length > 20) {\n const prefix = data.slice(0, data.length - 20)\n const isAllZero = prefix.every((byte) => byte === 0)\n if (!isAllZero) {\n throw new Error('Invalid address length. Expected less or equal than 20 bytes.')\n }\n }\n\n this.data = data\n }\n\n /**\n * Creates an Address instance from a value.\n * @param {Uint8Array | string} value - The address value.\n * @returns {Address} The Address instance.\n */\n static from(value: Uint8Array | string): Address {\n return new Address(value)\n }\n\n /**\n * Inspects the address.\n * @returns {string} The address as a string.\n */\n inspect(): string {\n return this.toString()\n }\n\n /**\n * Converts the address to a string.\n * @returns {string} The address as a string.\n */\n toString(): string {\n return this.hr()\n }\n\n /**\n * Gets the raw address data.\n * @returns {Uint8Array} The raw address data.\n */\n raw(): Uint8Array {\n return this.data\n }\n\n /**\n * Gets the human-readable address.\n * @returns {string} The human-readable address.\n */\n hr(): string {\n const value = hexlify(padify(this.data, { size: 20 }))\n return toChecksumAddress(value)\n }\n\n /**\n * Gets the address as a hexadecimal string.\n * @returns {Hex} The address as a hexadecimal string.\n */\n hex(): Hex {\n return hexlify(padify(this.data, { size: 20 }))\n }\n}\n\n/**\n * Converts an address to its checksum format.\n * @param {string} address - The address to convert.\n * @returns {string} The checksummed address.\n */\nexport function toChecksumAddress(address: string): string {\n // https://eips.ethereum.org/EIPS/eip-55\n const lowercasedAddress = address.toLowerCase().replace('0x', '')\n\n const hash = Buffer.from(keccak_256(lowercasedAddress)).toString('hex')\n\n let checksumAddress = '0x'\n for (let i = 0; i < lowercasedAddress.length; i++) {\n if (parseInt(hash[i], 16) > 7) {\n checksumAddress += lowercasedAddress[i].toUpperCase()\n } else {\n checksumAddress += lowercasedAddress[i]\n }\n }\n\n return checksumAddress\n}\n","import { Hex, arrayify, hexlify, isHex } from '@layerzerolabs/lz-utilities'\n\nimport { Address as AddressInterface } from './address'\nimport { base58 } from '../base'\n\n/**\n * Represents a Solana address.\n * @see {@link AddressInterface}\n */\nexport class Address implements AddressInterface {\n /**\n * The raw address data.\n */\n private data: Uint8Array\n\n /**\n * Creates an instance of Address.\n * @param {Uint8Array | string} value - The address value.\n * @throws {Error} If the address is invalid.\n */\n constructor(value: Uint8Array | string) {\n let data: Uint8Array | undefined = undefined\n if (value instanceof Uint8Array) {\n data = value\n } else if (typeof value === 'string') {\n if (isHex(value)) {\n data = arrayify(value)\n } else {\n data = base58.decode(value)\n }\n }\n\n if (data === undefined) {\n throw new Error('Invalid address')\n }\n\n if (data.length > 32) {\n throw new Error('Invalid address length. Expected less or equal than 32 bytes.')\n }\n\n this.data = data\n }\n\n /**\n * Creates an Address instance from a value.\n * @param {Uint8Array | string} value - The address value.\n * @returns {Address} The Address instance.\n */\n static from(value: Uint8Array | string): Address {\n return new Address(value)\n }\n\n /**\n * Inspects the address.\n * @returns {string} The address as a string.\n */\n inspect(): string {\n return this.toString()\n }\n\n /**\n * Converts the address to a string.\n * @returns {string} The address as a string.\n */\n toString(): string {\n return this.hr()\n }\n\n /**\n * Gets the raw address data.\n * @returns {Uint8Array} The raw address data.\n */\n raw(): Uint8Array {\n return this.data\n }\n\n /**\n * Gets the human-readable address.\n * @returns {string} The human-readable address.\n */\n hr(): string {\n return base58.encode(this.data)\n }\n\n /**\n * Gets the address as a hexadecimal string.\n * @returns {Hex} The address as a hexadecimal string.\n */\n hex(): Hex {\n return hexlify(this.data)\n }\n}\n","import { Hex, arrayify, hexlify, isHex } from '@layerzerolabs/lz-utilities'\n\nimport { Address as AddressInterface } from './address'\nimport { base58check } from '../base'\n\n/**\n * Represents a Tron address.\n * @see {@link AddressInterface}\n */\nexport class Address implements AddressInterface {\n /**\n * The raw address data.\n */\n private data: Uint8Array\n\n /**\n * Creates an instance of Address.\n * @param {Uint8Array | string} value - The address value.\n * @throws {Error} If the address is invalid.\n */\n constructor(value: Uint8Array | string) {\n let data: Uint8Array | undefined = undefined\n if (value instanceof Uint8Array) {\n data = value\n } else if (typeof value === 'string') {\n if (isHex(value)) {\n data = arrayify(value)\n } else {\n data = base58check.decode(value)\n }\n }\n\n if (data === undefined) {\n throw new Error('Invalid address')\n }\n\n if (data.length != 21) {\n throw new Error('Invalid address length. Expected 21 bytes.')\n }\n\n this.data = data\n }\n\n /**\n * Creates an Address instance from a value.\n * @param {Uint8Array | string} value - The address value.\n * @returns {Address} The Address instance.\n */\n static from(value: Uint8Array | string): Address {\n return new Address(value)\n }\n\n /**\n * Inspects the address.\n * @returns {string} The address as a string.\n */\n inspect(): string {\n return this.toString()\n }\n\n /**\n * Converts the address to a string.\n * @returns {string} The address as a string.\n */\n toString(): string {\n return this.hr()\n }\n\n /**\n * Gets the raw address data.\n * @returns {Uint8Array} The raw address data.\n */\n raw(): Uint8Array {\n return this.data\n }\n\n /**\n * Gets the human-readable address.\n * @returns {string} The human-readable address.\n */\n hr(): string {\n return base58check.encode(this.data)\n }\n\n /**\n * Gets the address as a hexadecimal string.\n * @returns {Hex} The address as a hexadecimal string.\n */\n hex(): Hex {\n return hexlify(this.data)\n }\n}\n","import { Chain, ChainType, chainToChainType } from '@layerzerolabs/lz-definitions'\n\nimport { Address as AddressInterface } from './address'\nimport * as aptos from './aptos'\nimport * as evm from './evm'\nimport * as solana from './solana'\nimport * as tron from './tron'\n\nexport const Address = {\n from: (address: string | Uint8Array, chain: Chain): AddressInterface => {\n const chainType = chainToChainType(chain)\n switch (chainType) {\n case ChainType.EVM:\n if (chain === Chain.TRON) {\n return tron.Address.from(address)\n }\n return evm.Address.from(address)\n case ChainType.APTOS:\n return aptos.Address.from(address)\n case ChainType.SOLANA:\n return solana.Address.from(address)\n default:\n throw new Error(`Unsupported chain type: ${chainType}`)\n }\n },\n}\n","import { Address as AddressInterface } from './types'\nimport { Address as AddressObject } from './utils'\n\nconst Address = AddressObject\ntype Address = AddressInterface\n\nexport { Address }\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,26 +1,86 @@
|
|
|
1
|
+
import { Hex } from '@layerzerolabs/lz-utilities';
|
|
2
|
+
import * as _layerzerolabs_lz_definitions from '@layerzerolabs/lz-definitions';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Computes the Keccak-256 hash of the given message.
|
|
6
|
+
* introduction: https://wiki.rugdoc.io/docs/introduction-to-ethereums-keccak-256-algorithm/
|
|
7
|
+
*
|
|
8
|
+
* @param {Uint8Array | string} message - The input message to hash.
|
|
9
|
+
* @returns {Uint8Array} The Keccak-256 hash of the input message.
|
|
10
|
+
*/
|
|
1
11
|
declare function keccak_256(message: Uint8Array | string): Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* Computes the BLAKE2b hash of the given message.
|
|
14
|
+
* introduction: https://en.wikipedia.org/wiki/BLAKE_(hash_function)
|
|
15
|
+
*
|
|
16
|
+
* @param {Uint8Array | string} message - The input message to hash.
|
|
17
|
+
* @returns {Uint8Array} The BLAKE2b hash of the input message.
|
|
18
|
+
*/
|
|
2
19
|
declare function blake2b(message: Uint8Array | string): Uint8Array;
|
|
20
|
+
/**
|
|
21
|
+
* Computes the SHA3-256 hash of the given message.
|
|
22
|
+
*
|
|
23
|
+
* @param {Uint8Array | string} message - The input message to hash.
|
|
24
|
+
* @returns {Uint8Array} The SHA3-256 hash of the input message.
|
|
25
|
+
*/
|
|
3
26
|
declare function sha3_256(message: Uint8Array | string): Uint8Array;
|
|
27
|
+
/**
|
|
28
|
+
* Computes the SHA-256 hash of the given message.
|
|
29
|
+
*
|
|
30
|
+
* @param {Uint8Array | string} message - The input message to hash.
|
|
31
|
+
* @returns {Uint8Array} The SHA-256 hash of the input message.
|
|
32
|
+
*/
|
|
4
33
|
declare function sha2_256(message: Uint8Array | string): Uint8Array;
|
|
5
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Enum representing different signing algorithms.
|
|
37
|
+
*/
|
|
6
38
|
declare enum SignAlgorithm {
|
|
39
|
+
/**
|
|
40
|
+
* Native signing algorithm.
|
|
41
|
+
*/
|
|
7
42
|
NATIVE = 0,
|
|
43
|
+
/**
|
|
44
|
+
* SECP256K1 signing algorithm.
|
|
45
|
+
* introduction: https://en.bitcoin.it/wiki/Secp256k1
|
|
46
|
+
*/
|
|
8
47
|
SECP256K1 = 1,
|
|
48
|
+
/**
|
|
49
|
+
* ED25519 signing algorithm.
|
|
50
|
+
* introduction: https://ed25519.cr.yp.to/
|
|
51
|
+
*/
|
|
9
52
|
ED25519 = 2
|
|
10
53
|
}
|
|
11
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Interface representing a key pair consisting of a private key and a public key.
|
|
57
|
+
*/
|
|
12
58
|
interface KeyPair {
|
|
59
|
+
/**
|
|
60
|
+
* The private key as a Uint8Array.
|
|
61
|
+
*/
|
|
13
62
|
privateKey: Uint8Array;
|
|
63
|
+
/**
|
|
64
|
+
* The public key as a Uint8Array.
|
|
65
|
+
*/
|
|
14
66
|
publicKey: Uint8Array;
|
|
15
67
|
}
|
|
16
68
|
|
|
17
69
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
21
|
-
* @
|
|
70
|
+
* Signs a hash using the ed25519 algorithm.
|
|
71
|
+
*
|
|
72
|
+
* @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.
|
|
73
|
+
* @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.
|
|
74
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the signature.
|
|
75
|
+
* @throws {Error} If the hash is not 32 bytes long or the signature is invalid.
|
|
22
76
|
*/
|
|
23
77
|
declare function signHash$2(hash: Uint8Array, privateKey: string | Uint8Array | bigint): Promise<Uint8Array>;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the public key corresponding to the given private key using the ed25519 algorithm.
|
|
80
|
+
*
|
|
81
|
+
* @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.
|
|
82
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the public key.
|
|
83
|
+
*/
|
|
24
84
|
declare function getPublicKey$1(privateKey: string | Uint8Array | bigint): Promise<Uint8Array>;
|
|
25
85
|
|
|
26
86
|
declare namespace ed25519 {
|
|
@@ -28,12 +88,20 @@ declare namespace ed25519 {
|
|
|
28
88
|
}
|
|
29
89
|
|
|
30
90
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @param
|
|
34
|
-
* @
|
|
91
|
+
* Signs a hash using the secp256k1 algorithm.
|
|
92
|
+
*
|
|
93
|
+
* @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.
|
|
94
|
+
* @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.
|
|
95
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the signature.
|
|
96
|
+
* @throws {Error} If the hash is not 32 bytes long or the signature is invalid.
|
|
35
97
|
*/
|
|
36
98
|
declare function signHash$1(hash: Uint8Array, privateKey: string | Uint8Array | bigint): Promise<Uint8Array>;
|
|
99
|
+
/**
|
|
100
|
+
* Gets the public key corresponding to the given private key using the secp256k1 algorithm.
|
|
101
|
+
*
|
|
102
|
+
* @param {string | Uint8Array | bigint} privateKey - The private key in hex format, Uint8Array, or bigint.
|
|
103
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the public key.
|
|
104
|
+
*/
|
|
37
105
|
declare function getPublicKey(privateKey: string | Uint8Array | bigint): Promise<Uint8Array>;
|
|
38
106
|
|
|
39
107
|
declare const secp256k1_getPublicKey: typeof getPublicKey;
|
|
@@ -41,6 +109,15 @@ declare namespace secp256k1 {
|
|
|
41
109
|
export { secp256k1_getPublicKey as getPublicKey, signHash$1 as signHash };
|
|
42
110
|
}
|
|
43
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Signs a hash using the specified signing algorithm.
|
|
114
|
+
*
|
|
115
|
+
* @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.
|
|
116
|
+
* @param {string | Uint8Array} privateKey - The private key in hex format or Uint8Array.
|
|
117
|
+
* @param {SignAlgorithm} algorithm - The signing algorithm to use.
|
|
118
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the signature.
|
|
119
|
+
* @throws {Error} If the hash is not 32 bytes long or the algorithm is unsupported.
|
|
120
|
+
*/
|
|
44
121
|
declare function signHash(hash: Uint8Array, privateKey: string | Uint8Array, algorithm: SignAlgorithm): Promise<Uint8Array>;
|
|
45
122
|
|
|
46
123
|
/**
|
|
@@ -48,28 +125,351 @@ declare function signHash(hash: Uint8Array, privateKey: string | Uint8Array, alg
|
|
|
48
125
|
*/
|
|
49
126
|
interface HashSigner {
|
|
50
127
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param hash - 32 bytes long
|
|
128
|
+
* Signs a hash.
|
|
129
|
+
* @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.
|
|
130
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the signature.
|
|
53
131
|
*/
|
|
54
132
|
signHash(hash: Uint8Array): Promise<Uint8Array>;
|
|
55
133
|
/**
|
|
56
|
-
*
|
|
134
|
+
* Returns the public key of the signer.
|
|
135
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the public key.
|
|
57
136
|
*/
|
|
58
137
|
getPublicKey(): Promise<Uint8Array>;
|
|
59
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Class for signing hashes using the secp256k1 algorithm.
|
|
141
|
+
*/
|
|
60
142
|
declare class Secp256k1Signer implements HashSigner {
|
|
61
143
|
private readonly privateKey;
|
|
62
144
|
private constructor();
|
|
145
|
+
/**
|
|
146
|
+
* Creates an instance of Secp256k1Signer from a private key.
|
|
147
|
+
* @param {Uint8Array} privateKey - The private key.
|
|
148
|
+
* @returns {Secp256k1Signer} The created Secp256k1Signer instance.
|
|
149
|
+
*/
|
|
63
150
|
static from(privatekey: Uint8Array): Secp256k1Signer;
|
|
151
|
+
/**
|
|
152
|
+
* Returns the public key of the signer.
|
|
153
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the public key.
|
|
154
|
+
*/
|
|
64
155
|
getPublicKey(): Promise<Uint8Array>;
|
|
156
|
+
/**
|
|
157
|
+
* Signs a hash.
|
|
158
|
+
* @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.
|
|
159
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the signature.
|
|
160
|
+
*/
|
|
65
161
|
signHash(hash: Uint8Array): Promise<Uint8Array>;
|
|
66
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Class for signing hashes using the ed25519 algorithm.
|
|
165
|
+
*/
|
|
67
166
|
declare class Ed25519Signer implements HashSigner {
|
|
68
167
|
private readonly privateKey;
|
|
69
168
|
private constructor();
|
|
169
|
+
/**
|
|
170
|
+
* Creates an instance of Ed25519Signer from a private key.
|
|
171
|
+
* @param {Uint8Array} privateKey - The private key.
|
|
172
|
+
* @returns {Ed25519Signer} The created Ed25519Signer instance.
|
|
173
|
+
*/
|
|
70
174
|
static from(privateKey: Uint8Array): Ed25519Signer;
|
|
175
|
+
/**
|
|
176
|
+
* Signs a hash.
|
|
177
|
+
* @param {Uint8Array} hash - The hash to sign, must be 32 bytes long.
|
|
178
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the signature.
|
|
179
|
+
*/
|
|
71
180
|
signHash(hash: Uint8Array): Promise<Uint8Array>;
|
|
181
|
+
/**
|
|
182
|
+
* Returns the public key of the signer.
|
|
183
|
+
* @returns {Promise<Uint8Array>} A promise that resolves to the public key.
|
|
184
|
+
*/
|
|
72
185
|
getPublicKey(): Promise<Uint8Array>;
|
|
73
186
|
}
|
|
74
187
|
|
|
75
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Encodes a string or Uint8Array to a base58 string.
|
|
190
|
+
*
|
|
191
|
+
* @param {string | Uint8Array} value - The value to encode.
|
|
192
|
+
* @returns {string} The base58 encoded string.
|
|
193
|
+
*/
|
|
194
|
+
declare function encode$2(value: string | Uint8Array): string;
|
|
195
|
+
/**
|
|
196
|
+
* Decodes a base58 string to a Uint8Array.
|
|
197
|
+
*
|
|
198
|
+
* @param {string} value - The base58 string to decode.
|
|
199
|
+
* @returns {Uint8Array} The decoded Uint8Array.
|
|
200
|
+
*/
|
|
201
|
+
declare function decode$2(value: string): Uint8Array;
|
|
202
|
+
|
|
203
|
+
declare namespace base58 {
|
|
204
|
+
export { decode$2 as decode, encode$2 as encode };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Encodes a string or Uint8Array to a base58check string.
|
|
209
|
+
*
|
|
210
|
+
* @param {string | Uint8Array} value - The value to encode.
|
|
211
|
+
* @returns {string} The base58check encoded string.
|
|
212
|
+
*/
|
|
213
|
+
declare function encode$1(value: string | Uint8Array): string;
|
|
214
|
+
/**
|
|
215
|
+
* Decodes a base58check string to a Uint8Array.
|
|
216
|
+
*
|
|
217
|
+
* @param {string} value - The base58check string to decode.
|
|
218
|
+
* @returns {Uint8Array} The decoded Uint8Array.
|
|
219
|
+
*/
|
|
220
|
+
declare function decode$1(value: string): Uint8Array;
|
|
221
|
+
|
|
222
|
+
declare namespace base58check {
|
|
223
|
+
export { decode$1 as decode, encode$1 as encode };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Encodes a string or Uint8Array to a base64 string.
|
|
228
|
+
*
|
|
229
|
+
* @param {string | Uint8Array} value - The value to encode.
|
|
230
|
+
* @returns {string} The base64 encoded string.
|
|
231
|
+
*/
|
|
232
|
+
declare function encode(value: string | Uint8Array): string;
|
|
233
|
+
/**
|
|
234
|
+
* Decodes a base64 string to a Uint8Array.
|
|
235
|
+
*
|
|
236
|
+
* @param {string} value - The base64 string to decode.
|
|
237
|
+
* @returns {Uint8Array} The decoded Uint8Array.
|
|
238
|
+
*/
|
|
239
|
+
declare function decode(value: string): Uint8Array;
|
|
240
|
+
|
|
241
|
+
declare const base64_decode: typeof decode;
|
|
242
|
+
declare const base64_encode: typeof encode;
|
|
243
|
+
declare namespace base64 {
|
|
244
|
+
export { base64_decode as decode, base64_encode as encode };
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface Address$5 {
|
|
248
|
+
raw(): Uint8Array;
|
|
249
|
+
hr(): string;
|
|
250
|
+
hex(): Hex;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
declare const Address$4: {
|
|
254
|
+
from: (address: string | Uint8Array, chain: _layerzerolabs_lz_definitions.Chain) => Address$5;
|
|
255
|
+
};
|
|
256
|
+
type Address$4 = Address$5;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Represents an Aptos address.
|
|
260
|
+
* @see {@link AddressInterface}
|
|
261
|
+
*/
|
|
262
|
+
declare class Address$3 implements Address$4 {
|
|
263
|
+
/**
|
|
264
|
+
* The raw address data.
|
|
265
|
+
*/
|
|
266
|
+
private data;
|
|
267
|
+
/**
|
|
268
|
+
* Creates an instance of Address.
|
|
269
|
+
* @param {Uint8Array | string} value - The address value.
|
|
270
|
+
* @throws {Error} If the address is invalid.
|
|
271
|
+
*/
|
|
272
|
+
constructor(value: Uint8Array | string);
|
|
273
|
+
/**
|
|
274
|
+
* Creates an Address instance from a value.
|
|
275
|
+
* @param {Uint8Array | string} value - The address value.
|
|
276
|
+
* @returns {Address} The Address instance.
|
|
277
|
+
*/
|
|
278
|
+
static from(value: Uint8Array | string): Address$3;
|
|
279
|
+
/**
|
|
280
|
+
* Inspects the address.
|
|
281
|
+
* @returns {string} The address as a string.
|
|
282
|
+
*/
|
|
283
|
+
inspect(): string;
|
|
284
|
+
/**
|
|
285
|
+
* Converts the address to a string.
|
|
286
|
+
* @returns {string} The address as a string.
|
|
287
|
+
*/
|
|
288
|
+
toString(): string;
|
|
289
|
+
/**
|
|
290
|
+
* Gets the raw address data.
|
|
291
|
+
* @returns {Uint8Array} The raw address data.
|
|
292
|
+
*/
|
|
293
|
+
raw(): Uint8Array;
|
|
294
|
+
/**
|
|
295
|
+
* Gets the human-readable address.
|
|
296
|
+
* @returns {string} The human-readable address.
|
|
297
|
+
*/
|
|
298
|
+
hr(): string;
|
|
299
|
+
/**
|
|
300
|
+
* Gets the address as a hexadecimal string.
|
|
301
|
+
* @returns {Hex} The address as a hexadecimal string.
|
|
302
|
+
*/
|
|
303
|
+
hex(): Hex;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
declare namespace aptos {
|
|
307
|
+
export { Address$3 as Address };
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Represents an EVM address.
|
|
312
|
+
* @see {@link AddressInterface}
|
|
313
|
+
*/
|
|
314
|
+
declare class Address$2 implements Address$4 {
|
|
315
|
+
/**
|
|
316
|
+
* The raw address data.
|
|
317
|
+
*/
|
|
318
|
+
private data;
|
|
319
|
+
/**
|
|
320
|
+
* Creates an instance of Address.
|
|
321
|
+
* @param {Uint8Array | string} value - The address value.
|
|
322
|
+
* @throws {Error} If the address is invalid.
|
|
323
|
+
*/
|
|
324
|
+
constructor(value: Uint8Array | string);
|
|
325
|
+
/**
|
|
326
|
+
* Creates an Address instance from a value.
|
|
327
|
+
* @param {Uint8Array | string} value - The address value.
|
|
328
|
+
* @returns {Address} The Address instance.
|
|
329
|
+
*/
|
|
330
|
+
static from(value: Uint8Array | string): Address$2;
|
|
331
|
+
/**
|
|
332
|
+
* Inspects the address.
|
|
333
|
+
* @returns {string} The address as a string.
|
|
334
|
+
*/
|
|
335
|
+
inspect(): string;
|
|
336
|
+
/**
|
|
337
|
+
* Converts the address to a string.
|
|
338
|
+
* @returns {string} The address as a string.
|
|
339
|
+
*/
|
|
340
|
+
toString(): string;
|
|
341
|
+
/**
|
|
342
|
+
* Gets the raw address data.
|
|
343
|
+
* @returns {Uint8Array} The raw address data.
|
|
344
|
+
*/
|
|
345
|
+
raw(): Uint8Array;
|
|
346
|
+
/**
|
|
347
|
+
* Gets the human-readable address.
|
|
348
|
+
* @returns {string} The human-readable address.
|
|
349
|
+
*/
|
|
350
|
+
hr(): string;
|
|
351
|
+
/**
|
|
352
|
+
* Gets the address as a hexadecimal string.
|
|
353
|
+
* @returns {Hex} The address as a hexadecimal string.
|
|
354
|
+
*/
|
|
355
|
+
hex(): Hex;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Converts an address to its checksum format.
|
|
359
|
+
* @param {string} address - The address to convert.
|
|
360
|
+
* @returns {string} The checksummed address.
|
|
361
|
+
*/
|
|
362
|
+
declare function toChecksumAddress(address: string): string;
|
|
363
|
+
|
|
364
|
+
declare const evm_toChecksumAddress: typeof toChecksumAddress;
|
|
365
|
+
declare namespace evm {
|
|
366
|
+
export { Address$2 as Address, evm_toChecksumAddress as toChecksumAddress };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Represents a Solana address.
|
|
371
|
+
* @see {@link AddressInterface}
|
|
372
|
+
*/
|
|
373
|
+
declare class Address$1 implements Address$4 {
|
|
374
|
+
/**
|
|
375
|
+
* The raw address data.
|
|
376
|
+
*/
|
|
377
|
+
private data;
|
|
378
|
+
/**
|
|
379
|
+
* Creates an instance of Address.
|
|
380
|
+
* @param {Uint8Array | string} value - The address value.
|
|
381
|
+
* @throws {Error} If the address is invalid.
|
|
382
|
+
*/
|
|
383
|
+
constructor(value: Uint8Array | string);
|
|
384
|
+
/**
|
|
385
|
+
* Creates an Address instance from a value.
|
|
386
|
+
* @param {Uint8Array | string} value - The address value.
|
|
387
|
+
* @returns {Address} The Address instance.
|
|
388
|
+
*/
|
|
389
|
+
static from(value: Uint8Array | string): Address$1;
|
|
390
|
+
/**
|
|
391
|
+
* Inspects the address.
|
|
392
|
+
* @returns {string} The address as a string.
|
|
393
|
+
*/
|
|
394
|
+
inspect(): string;
|
|
395
|
+
/**
|
|
396
|
+
* Converts the address to a string.
|
|
397
|
+
* @returns {string} The address as a string.
|
|
398
|
+
*/
|
|
399
|
+
toString(): string;
|
|
400
|
+
/**
|
|
401
|
+
* Gets the raw address data.
|
|
402
|
+
* @returns {Uint8Array} The raw address data.
|
|
403
|
+
*/
|
|
404
|
+
raw(): Uint8Array;
|
|
405
|
+
/**
|
|
406
|
+
* Gets the human-readable address.
|
|
407
|
+
* @returns {string} The human-readable address.
|
|
408
|
+
*/
|
|
409
|
+
hr(): string;
|
|
410
|
+
/**
|
|
411
|
+
* Gets the address as a hexadecimal string.
|
|
412
|
+
* @returns {Hex} The address as a hexadecimal string.
|
|
413
|
+
*/
|
|
414
|
+
hex(): Hex;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
declare namespace solana {
|
|
418
|
+
export { Address$1 as Address };
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Represents a Tron address.
|
|
423
|
+
* @see {@link AddressInterface}
|
|
424
|
+
*/
|
|
425
|
+
declare class Address implements Address$4 {
|
|
426
|
+
/**
|
|
427
|
+
* The raw address data.
|
|
428
|
+
*/
|
|
429
|
+
private data;
|
|
430
|
+
/**
|
|
431
|
+
* Creates an instance of Address.
|
|
432
|
+
* @param {Uint8Array | string} value - The address value.
|
|
433
|
+
* @throws {Error} If the address is invalid.
|
|
434
|
+
*/
|
|
435
|
+
constructor(value: Uint8Array | string);
|
|
436
|
+
/**
|
|
437
|
+
* Creates an Address instance from a value.
|
|
438
|
+
* @param {Uint8Array | string} value - The address value.
|
|
439
|
+
* @returns {Address} The Address instance.
|
|
440
|
+
*/
|
|
441
|
+
static from(value: Uint8Array | string): Address;
|
|
442
|
+
/**
|
|
443
|
+
* Inspects the address.
|
|
444
|
+
* @returns {string} The address as a string.
|
|
445
|
+
*/
|
|
446
|
+
inspect(): string;
|
|
447
|
+
/**
|
|
448
|
+
* Converts the address to a string.
|
|
449
|
+
* @returns {string} The address as a string.
|
|
450
|
+
*/
|
|
451
|
+
toString(): string;
|
|
452
|
+
/**
|
|
453
|
+
* Gets the raw address data.
|
|
454
|
+
* @returns {Uint8Array} The raw address data.
|
|
455
|
+
*/
|
|
456
|
+
raw(): Uint8Array;
|
|
457
|
+
/**
|
|
458
|
+
* Gets the human-readable address.
|
|
459
|
+
* @returns {string} The human-readable address.
|
|
460
|
+
*/
|
|
461
|
+
hr(): string;
|
|
462
|
+
/**
|
|
463
|
+
* Gets the address as a hexadecimal string.
|
|
464
|
+
* @returns {Hex} The address as a hexadecimal string.
|
|
465
|
+
*/
|
|
466
|
+
hex(): Hex;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
type tron_Address = Address;
|
|
470
|
+
declare const tron_Address: typeof Address;
|
|
471
|
+
declare namespace tron {
|
|
472
|
+
export { tron_Address as Address };
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export { Address$4 as Address, Ed25519Signer, type HashSigner, type KeyPair, Secp256k1Signer, SignAlgorithm, aptos, base58, base58check, base64, blake2b, ed25519, evm, keccak_256, secp256k1, sha2_256, sha3_256, signHash, solana, tron };
|