import { Blake2b } from "@iota/crypto.js" ; import type { IPowProvider } from "../models/IPowProvider" ; import { PowHelper } from "../utils/powHelper" ; /**
 * Local POW Provider.
 * WARNING - This is really slow.
 */ export class LocalPowProvider implements IPowProvider { param message param targetScore returns public async pow ( message , targetScore ) { const powRelevantData = message . slice ( 0 , - 8 ) ; const powDigest = Blake2b . sum256 ( powRelevantData ) ; const targetZeros = PowHelper . calculateTargetZeros ( message , targetScore ) ; return PowHelper . performPow ( powDigest , targetZeros , "0" ) . toString ( ) ; } }