UNPKG

tiny-crypto-suite

Version:

Tiny tools, big crypto — seamless encryption and certificate handling for modern web and Node apps.

98 lines 3.66 kB
export default TinySecp256k1Mock; /** * TinySecp256k1Mock is a mock implementation of the TinySecp256k1 class, * intended for testing and development environments where full cryptographic * functionality is not required. * * This mock class provides stubbed methods for key and signature operations, * returning empty or constant values to simulate the behavior of real cryptographic * routines without performing actual computations. It allows predefined public keys * and addresses to be injected for deterministic behavior in tests. * * Usage is ideal in unit tests, validation checks, or environments where * cryptographic performance or security is not critical. * * @class */ declare class TinySecp256k1Mock extends TinySecp256k1 { /** @typedef {import('./index.mjs').ValidationResult} ValidationResult */ /** * Creates a new mock instance of TinySecp256k1 for testing purposes. * @param {Object} [options] - Optional parameters for the instance. * @param {string|null} [options.preAddress=''] - Pre-defined mock address. * @param {string|null} [options.preHex=''] - Pre-defined mock public key in hex format. * @param {string|null} [options.prefix=''] - Crypto prefix used during message verification. * @param {string} [options.type='empty'] - The type of mock address to simulate. */ constructor({ type, prefix, preAddress, preHex }?: { preAddress?: string | null | undefined; preHex?: string | null | undefined; prefix?: string | null | undefined; type?: string | undefined; }); preAddress: string; preHex: string; /** * Gets the predefined address with strict string validation. * @returns {string} */ getPreAddress(): string; /** * Gets the predefined public key hex with strict string validation. * @returns {string} */ getPreHex(): string; /** * Signs a message using ECDSA. (Mocked) * @returns {Buffer} A buffer representing the signature. */ signECDSA(): Buffer; /** * Verifies a message signature using ECDSA. (Mocked) * @returns {boolean} Always returns true as a mock. */ verifyECDSA(): boolean; /** * Returns a vanilla-format public address. (Mocked) * @returns {Buffer} An empty buffer as a mock result. */ getPubVanillaAddress(): Buffer; /** * Returns the public key in buffer format. (Mocked) * @returns {Buffer} An empty buffer as a mock result. */ getPublicKeyBuffer(): Buffer; /** * Returns the public key in hexadecimal format. * @returns {string} The predefined public key hex. */ getPublicKeyHex(): string; /** * Returns the public address. * @returns {string} The predefined mock address. */ getAddress(): string; /** * Converts an address to vanilla format. (Mocked) * @returns {Buffer} An empty buffer as mock result. */ addressToVanilla(): Buffer; /** * Validates the current address. (Mocked) * @returns {ValidationResult} Validation result object with mock values. */ validateAddress(): import("./index.mjs").ValidationResult; /** * Recovers the message from a signed hash. (Mocked) * @returns {string|null} An empty string as mock recovery. */ recoverMessage(): string | null; /** * Signs a plain message using the mock instance. (Mocked) * @returns {Buffer} A mock signature as an empty buffer. */ signMessage(): Buffer; } import TinySecp256k1 from './index.mjs'; import { Buffer } from 'buffer'; //# sourceMappingURL=TinySecp256k1Mock.d.mts.map