mirror of
https://github.com/logos-messaging/js-rln.git
synced 2026-01-12 10:33:10 +00:00
* decouple utils, remove global variables * decouple hash utils * decouple proof related stuff * move to utils, move to resources * decouple zerokit * fix spelling * fix mock * remove auto prettier, typo * retur prettier * comma
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);
|
|
}
|