mirror of
https://github.com/logos-messaging/js-rln.git
synced 2026-01-02 21:53:08 +00:00
16 lines
595 B
TypeScript
16 lines
595 B
TypeScript
import * as zerokitRLN from "@waku/zerokit-rln-wasm";
|
|
|
|
import { concatenate, writeUIntLE } from "./bytes.js";
|
|
|
|
export function poseidonHash(...input: Array<Uint8Array>): Uint8Array {
|
|
const inputLen = writeUIntLE(new Uint8Array(8), input.length, 0, 8);
|
|
const lenPrefixedData = concatenate(inputLen, ...input);
|
|
return zerokitRLN.poseidonHash(lenPrefixedData);
|
|
}
|
|
|
|
export function sha256(input: Uint8Array): Uint8Array {
|
|
const inputLen = writeUIntLE(new Uint8Array(8), input.length, 0, 8);
|
|
const lenPrefixedData = concatenate(inputLen, input);
|
|
return zerokitRLN.hash(lenPrefixedData);
|
|
}
|