merkle-tree-lib
Version:
Merkle Tree implementation with BIP340 tagged hash support.
50 lines (49 loc) • 1.4 kB
TypeScript
/**
* HashStrategy - Interface for hash algorithm implementations
* This allows for different hashing strategies to be used interchangeably
*/
export interface HashStrategy {
/**
* Calculate a hash for the input data
*
* @param data - The data to hash (Buffer or string)
* @returns The computed hash as a Buffer
*/
hash(data: Buffer | string): Buffer;
/**
* Get the name of the hashing algorithm
*
* @returns The algorithm name as a string
*/
getAlgorithmName(): string;
}
/**
* SHA-256 hash strategy implementation
*/
export declare class SHA256Strategy implements HashStrategy {
readonly name = "sha256";
hash(data: Buffer | string): Buffer;
getAlgorithmName(): string;
}
/**
* SHA-512 hash strategy implementation
*/
export declare class SHA512Strategy implements HashStrategy {
readonly name = "sha512";
hash(data: Buffer | string): Buffer;
getAlgorithmName(): string;
}
/**
* Keccak-256 hash strategy implementation (used in Ethereum)
*/
export declare class Keccak256Strategy implements HashStrategy {
readonly name = "keccak256";
hash(data: Buffer | string): Buffer;
getAlgorithmName(): string;
}
/**
* Factory to create hash strategy instances
*/
export declare class HashStrategyFactory {
static createStrategy(algorithm: 'sha256' | 'sha512' | 'keccak256'): HashStrategy;
}