mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-14 22:13:09 +00:00
36 lines
1012 B
TypeScript
36 lines
1012 B
TypeScript
import * as zerokitRLN from "@waku/zerokit-rln-wasm";
|
|
|
|
import { DEFAULT_RATE_LIMIT } from "./contract/constants.js";
|
|
import { IdentityCredential } from "./identity.js";
|
|
import { WitnessCalculator } from "./resources/witness_calculator";
|
|
|
|
export class Zerokit {
|
|
public constructor(
|
|
private readonly zkRLN: number,
|
|
private readonly witnessCalculator: WitnessCalculator,
|
|
private readonly _rateLimit: number = DEFAULT_RATE_LIMIT
|
|
) {}
|
|
|
|
public get getZkRLN(): number {
|
|
return this.zkRLN;
|
|
}
|
|
|
|
public get getWitnessCalculator(): WitnessCalculator {
|
|
return this.witnessCalculator;
|
|
}
|
|
|
|
public get rateLimit(): number {
|
|
return this._rateLimit;
|
|
}
|
|
|
|
public generateSeededIdentityCredential(seed: string): IdentityCredential {
|
|
const stringEncoder = new TextEncoder();
|
|
const seedBytes = stringEncoder.encode(seed);
|
|
const memKeys = zerokitRLN.generateSeededExtendedMembershipKey(
|
|
this.zkRLN,
|
|
seedBytes
|
|
);
|
|
return IdentityCredential.fromBytes(memKeys);
|
|
}
|
|
}
|