Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
instrument('keccak_256', (): void => {
const data = heap.get(dataPtr, dataLen);
const hash = keccakAsU8a(data);
l.debug((): any[] => ['keccak_256', [dataPtr, dataLen, outPtr], '<-', u8aToHex(data), '->', u8aToHex(hash)]);
heap.set(outPtr, hash);
}),
// eslint-disable-next-line @typescript-eslint/camelcase
function hash (x) {
return Buffer.from(keccakAsU8a(x))
}
export function hash(value: bytes): bytes32 {
return Buffer.from(keccakAsU8a(value));
}
export function hashMessage (message: string): Buffer {
const expanded = stringToU8a(`\x19Ethereum Signed Message:\n${message.length.toString()}${message}`);
const hashed = keccakAsU8a(expanded);
return u8aToBuffer(hashed);
}