UNPKG

@ellcrys/spell

Version:

The official JavaScript library for Ellcrys

212 lines (211 loc) 5.15 kB
/// <reference types="node" /> export declare const AddressVersion: Buffer; export declare const PublicKeyVersion: Buffer; export declare const PrivateKeyVersion: Buffer; /** * PrivateKey represents an Ed25519 * key use for constructing an Ellcrys * address, signing and verifying a * signed messages. * * @export * @class PrivateKey */ export declare class PrivateKey { /** * The ED25519 key material * * @private * @type {ed25519.CurveKeyPair} * @memberof PrivateKey */ private keypair; /** * Creates an instance of PrivateKey. * @param {Buffer} seed Random seed used ro create the key * @memberof PrivateKey */ constructor(seed?: Buffer); /** * Sign a message * * @param {Buffer} data The message * @returns {Buffer} * @memberof PrivateKey */ sign(data: Buffer): Buffer; /** * Returns an address derived from * the private key * * @returns {Address} * @memberof PrivateKey */ toAddress(): Address; /** * Returns the public key. * * @returns {PublicKey} * @memberof PrivateKey */ publicKey(): PublicKey; /** * Returns base58 encode string of the private key * * @returns {string} * @memberof PrivateKey */ toBase58(): string; /** * Returns the private key as a buffer. * The base58 version is added as the 0th * byte in the returned buffer * * @returns {Buffer} * @memberof PrivateKey */ toBuffer(): Buffer; /** * Instantiate a PrivateKey from a base58 * encoded private key string * * @static * @param {string} str The base58 encoded private keys * @returns {PrivateKey} * @throws InvalidPrivateKeyChecksum|InvalidPrivateKeyVersion|InvalidPrivateKeySize * @memberof PrivateKey */ static from(str: string): PrivateKey; /** * Instantiate a PrivateKey from a buffer. * The buffer's 0th index must contain the * private key version. * * @static * @param {Buffer} buf * @returns {PrivateKey} * @memberof PrivateKey */ static fromBuffer(buf: Buffer): PrivateKey; } /** * PublicKey represents an ED25519 * public key * * @export * @class PublicKey */ export declare class PublicKey { private pk; /** * Returns base58 encode string of the public key * * @returns {string} * @memberof PublicKey */ toBase58(): string; /** * Returns the public key as a buffer. * The public key version is added as the 0th * byte in the returned buffer * * @returns {Buffer} * @memberof PublicKey */ toBuffer(): Buffer; /** * Returns an address derived from * the public key * * @returns {Address} * @memberof PublicKey */ toAddress(): Address; /** * Verify a signature * * @param {Buffer} msg The message that was signed * @param {Buffer} sig The message's signature * @returns {boolean} * @memberof PublicKey */ verify(msg: Buffer, sig: Buffer): boolean; /** * Instantiate a PublicKey from a buffer. * The buffer's 0th index must contain the * public key version. * * @static * @param {Buffer} buf * @returns {PublicKey} * @memberof PublicKey */ static fromBuffer(buf: Buffer): PublicKey; /** * Instantiate a PublicKey from a base58 * encoded public key string * * @static * @param {string} str * @returns {PublicKey} * @throws InvalidPublicKeyChecksum|InvalidPublicKeyVersion|InvalidPublicKeySize * @memberof PublicKey */ static from(str: string): PublicKey; } /** * Address represents a compressed * equivalent of a public key used * as an address for transacting. * * @class Address */ export declare class Address { /** * The loaded address * * @private * @type {string} * @memberof Address */ private address; /** * Check whether an address is valid * * @static * @param {string} address The address to check * @returns {boolean} * @memberof Address */ static isValid(address: string): boolean; /** * Check whether a given address is valid. * If not valid, the specific validation error * is returned. It returns null if the address * is valid. * * @static * @param {string} address The address to check * @returns {(null | Error)} InvalidAddressVersion | * InvalidAddressSize }| InvalidAddressFormat * @memberof Address */ static getValidationError(address: string): null | Error; /** * Instantiate an Address instance from * a given address string * * @static * @param {string} address * @returns {Address} * @throws InvalidAddress * @memberof Address */ static from(address: string): Address; /** * Return a string format of the address * * @memberof Address */ toString: () => string; }