@sei-js/cosmjs
Version:
TypeScript library for CosmJS interactions on the Sei blockchain
62 lines (61 loc) • 3 kB
TypeScript
import { ec as EllipticCurve } from 'elliptic';
/**
* Derives and returns the address from a given private key.
* @param privateKeyHex A hex (0x) string of the private key of an account.
* @returns The corresponding address for the given private key.
* @category Utils
*/
export declare const deriveAddressesFromPrivateKey: (privateKeyHex: string) => string;
/**
* Creates a hex encoded ECC KeyPair given a public key.
* @param pubKey A byte array representing a public key.
* @returns A hex encoded ECC KeyPair.
* @category Utils
*/
export declare const pubKeyToKeyPair: (pubKey: Uint8Array) => EllipticCurve.KeyPair;
/**
* Converts the given public key to a bytestring
* @param pubKey The public key to convert.
* @param uncompressed Whether the public key has already been compressed.
* @returns A byte array representing the converted public key.
* @category Utils
*/
export declare const pubKeyToBytes: (pubKey: Uint8Array, uncompressed?: boolean) => Uint8Array;
/**
* Gets the corresponding address from a byte array representing a compressed public key.
* @param publicKey A byte array representing a compressed public key.
* @returns The corresponding address to the given compressed public key.
* @category Utils
*/
export declare const compressedPubKeyToAddress: (publicKey: Uint8Array) => string;
/**
* Gets the corresponding sha256 hashed address to a given compressed public key.
* @param compressedPublicKey A byte array representing a compressed public key.
* @returns A sha256 hashed address that corresponds to the given public key.
* @category Utils
*/
export declare const getAddressHashFromPubKey: (compressedPublicKey: Uint8Array) => Uint8Array;
/**
* Verifies a digest signed with a private key using the corresponding public key.
* @param digest A byte array representing the digest we wish to verify.
* @param signature A byte array representing the digital signature.
* @param pubKey A byte array representing the public key of the signer.
* @returns True if the digest is verified to have been signed using the private key complementing the given public key.
* @category Utils
*/
export declare const verifyDigest32: (digest: Uint8Array, signature: Uint8Array, pubKey: Uint8Array) => boolean;
/**
* Returns a boolean representing if the given string is a valid Sei address.
* @param address The string we wish to verify.
* @returns True if a string is a valid Sei address
* @category Utils
*/
export declare const isValidSeiCosmosAddress: (address: string) => boolean | "";
/**
* Shortens a sei address to display it in the format sei...xxxxx where xxxxx is the last five characters of the address.
* Used to display sei address in an easily identifiable way.
* @param address The address to truncate
* @returns A shortened version of the address in the format sei...xxxxx. Returns the input address if it is not a valid sei address.
* @category Utils
*/
export declare const truncateSeiAddress: (address: string) => string;