mirror of
https://github.com/logos-messaging/logos-delivery-js.git
synced 2026-03-13 05:03:40 +00:00
19 lines
497 B
TypeScript
19 lines
497 B
TypeScript
import { hash, poseidonHash as poseidon } from "@waku/zerokit-rln-wasm-utils";
|
|
|
|
import { BytesUtils } from "./bytes.js";
|
|
|
|
export function poseidonHash(...input: Array<Uint8Array>): Uint8Array {
|
|
const inputLen = BytesUtils.writeUIntLE(
|
|
new Uint8Array(8),
|
|
input.length,
|
|
0,
|
|
8
|
|
);
|
|
const lenPrefixedData = BytesUtils.concatenate(inputLen, ...input);
|
|
return poseidon(lenPrefixedData, true);
|
|
}
|
|
|
|
export function sha256(input: Uint8Array): Uint8Array {
|
|
return hash(input, true);
|
|
}
|