UNPKG

@waku/rln

Version:

RLN (Rate Limiting Nullifier) implementation for Waku

40 lines (39 loc) 1.72 kB
import type { IDecodedMessage, IDecoder, IEncoder, IMessage, IProtoMessage } from "@waku/interfaces"; import type { IdentityCredential } from "./identity.js"; import { RlnMessage } from "./message.js"; import { RLNInstance } from "./rln.js"; export declare class RLNEncoder implements IEncoder { private readonly encoder; private readonly rlnInstance; private readonly index; private readonly idSecretHash; constructor(encoder: IEncoder, rlnInstance: RLNInstance, index: number, identityCredential: IdentityCredential); toWire(message: IMessage): Promise<Uint8Array | undefined>; toProtoObj(message: IMessage): Promise<IProtoMessage | undefined>; private generateProof; get pubsubTopic(): string; get contentTopic(): string; get ephemeral(): boolean; } type RLNEncoderOptions = { encoder: IEncoder; rlnInstance: RLNInstance; index: number; credential: IdentityCredential; }; export declare const createRLNEncoder: (options: RLNEncoderOptions) => RLNEncoder; export declare class RLNDecoder<T extends IDecodedMessage> implements IDecoder<RlnMessage<T>> { private readonly rlnInstance; private readonly decoder; constructor(rlnInstance: RLNInstance, decoder: IDecoder<T>); get pubsubTopic(): string; get contentTopic(): string; fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined>; fromProtoObj(pubsubTopic: string, proto: IProtoMessage): Promise<RlnMessage<T> | undefined>; } type RLNDecoderOptions<T extends IDecodedMessage> = { decoder: IDecoder<T>; rlnInstance: RLNInstance; }; export declare const createRLNDecoder: <T extends IDecodedMessage>(options: RLNDecoderOptions<T>) => RLNDecoder<T>; export {};