import { crc32c } from "@node-lightning/checksum" ; /**
 * CRC32C checksum for the provided value
 */ export class Checksum { public static fromBuffer ( buf ) { return new Checksum ( crc32c ( buf ) ) ; } public static empty ( ) { return new Checksum ( 0 ) ; } private _checksum : number ; private constructor ( checksum ) { this . _checksum = checksum ; } public equals ( other ) { return this . _checksum === other . _checksum ; } public toNumber ( ) { return this . _checksum ; } public toBuffer ( ) { const buf = Buffer . alloc ( 4 ) ; buf . writeUInt32BE ( this . _checksum , 0 ) ; return buf ; } public toString ( ) { return this . _checksum . toString ( 16 ) ; } }