RLN (Rate-Limiting Nullifier) is a zk-gadget/protocol that enables spam prevention mechanism for anonymous environments. The core of the RLN is in the circuit logic. RLN also provides Javascript Library for easy management of the registry and proof creation.
git clone https://github.com/Rate-Limiting-Nullifier/rlnjs.git
And install the dependencies:
cd rlnjs && npm i
// generate default RLN registry
const registry = new RLNRegistry()
// generate RLN registry that contains slashed registry
const registry = new RLNRegistry(
20,
BigInt(0),
true
)
const identity = new ZkIdentity()
const identityCommitment = identity.genIdentityCommitment()
registry.addMember(identityCommitment)
registry.removeMember(identityCommitment)
const secretHash = identity.getSecretHash()
const leaves = Object.assign([], identityCommitments)
leaves.push(identityCommitment)
const signal = "signal"
const epoch = genExternalNullifier("test-epoch")
const rlnIdentifier = RLN.genIdentifier()
const merkleProof = await generateMerkleProof(15, BigInt(0), leaves, identityCommitment)
const witness = RLN.genWitness(secretHash, merkleProof, epoch, signal, rlnIdentifier)
const fullProof = await RLN.genProof(witness, wasmFilePath, finalZkeyPath)
const proofResult = await RLN.verifyProof(vKey, fullProof)
npm test
RLNjs is released under the MIT license.