mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-16 04:33:12 +00:00
* chore: idCommitmentBigInt validates against contract Q * chore: fix linting * chore: add log * chore: rename Q and make sync * fix: test * chore: remove stubbed contract test * chore: hardcode default constant for Q * use non deprecated sha256 * chore: use full 32 bytes for bigint * chore: all storage in LE, but smart contract interactions in BE * chore: remove references to idCOmmitmentBigInt in Identity * chore: don't fetch Q from contract * chore: ByteUtils as a class * chore: store Identity in BE, convert during Keystore * chore: add IDCommitmentBigInt part of Identity * chore: minor improvements * chore: switch idTrapdoor to LE * chore: add logs * chore: rename `DEFAULT_Q` to `RLN_Q` * chore: rm spec test * chore: improve modulo logging * fix(tests): add IDCommitmentBigInt
26 lines
665 B
TypeScript
26 lines
665 B
TypeScript
import * as zerokitRLN from "@waku/zerokit-rln-wasm";
|
|
|
|
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 zerokitRLN.poseidonHash(lenPrefixedData);
|
|
}
|
|
|
|
export function sha256(input: Uint8Array): Uint8Array {
|
|
const inputLen = BytesUtils.writeUIntLE(
|
|
new Uint8Array(8),
|
|
input.length,
|
|
0,
|
|
8
|
|
);
|
|
const lenPrefixedData = BytesUtils.concatenate(inputLen, input);
|
|
return zerokitRLN.hash(lenPrefixedData);
|
|
}
|