0.1.3 • Published 1 month ago

@waku/rln v0.1.3

Weekly downloads
-
License
MIT OR Apache-2.0
Repository
github
Last release
1 month ago

js-rln

Browser library providing the cryptographic functions for Waku RLN Relay https://rfc.vac.dev/spec/17/

Install

npm install @waku/rln

# or with yarn

yarn add @waku/rln

Running example app

git clone https://github.com/waku-org/js-rln

cd js-rln/example

npm install  # or yarn

npm start

Browse http://localhost:8080 and open the dev tools console to see the proof being generated and its verification

Usage

Initializing the library

import * as rln from "@waku/rln";

const rlnInstance = wait rln.create();

Generating RLN membership keypair

let memKeys = rlnInstance.generateMembershipKey();

Adding membership keys into merkle tree

rlnInstance.insertMember(memKeys.IDCommitment);

Generating a proof

// prepare the message
const uint8Msg = Uint8Array.from("Hello World".split("").map(x => x.charCodeAt()));

// setting up the epoch (With 0s for the test)
const epoch = new Uint8Array(32);

// generating a proof
const proof = await rlnInstance.generateProof(uint8Msg, index, epoch, memKeys.IDKey)

Verifying a proof

try {
    // verify the proof
    const verificationResult = rlnInstance.verifyProof(proof);
    console.log("Is proof verified?", verificationResult ? "yes" : "no");
} catch (err) {
    console.log("Invalid proof")
}

Updating circuit, verification key and zkey

The RLN specs defines the defaults. These values are fixed and should not change. Currently, these resources are being used. If they change, this file needs to be updated in resources.ts which contains these values encoded in base64 in this format:

const verification_key = "...";
const circuit = "..."; // wasm file generated by circom
const zkey = "...";
export {verification_key, circuit, zkey};

A tool like GNU's base64 could be used to encode this data.

Updating zerokit

  1. Make sure you have nodejs installed and a C compiler
  2. Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
  1. Compile RLN for wasm
git clone https://github.com/vacp2p/zerokit
cd zerokit/rln-wasm
wasm-pack build --release
  1. Copy pkg/rln* into src/zerokit

Bugs, Questions & Features

If you encounter any bug or would like to propose new features, feel free to open an issue.

For more general discussion, help and latest news, join Vac Discord or Telegram.

License

Licensed and distributed under either of

or

at your option. These files may not be copied, modified, or distributed except according to those terms.

0.1.3

1 month ago

0.1.3-f6d5deb

1 month ago

0.1.2-126bce3

2 months ago

0.1.2-3dc5908

2 months ago

0.1.2-6454446

2 months ago

0.1.2

3 months ago

0.1.1-ac12f68

3 months ago

0.1.2-86d4f56

3 months ago

0.1.2-e1679b6

3 months ago

0.1.1-77ba0a6

3 months ago

0.1.1-bafbe01

4 months ago

0.1.1-18ce994

4 months ago

0.1.1-530034b

6 months ago

0.1.1-5d7f77f

10 months ago

0.1.1-891ee34

7 months ago

0.1.1-5b9414a

7 months ago

0.1.1-60a5070

6 months ago

0.1.1-fa49e29

7 months ago

0.1.1-0c98a26

5 months ago

0.1.1-0fbf6be

6 months ago

0.1.1-8928376

7 months ago

0.1.1-9b1e818

5 months ago

0.1.1-7e8cb89

7 months ago

0.1.1-7e93896

12 months ago

0.1.1

12 months ago

0.1.1-b429b05

12 months ago

0.1.0-e52107d

1 year ago

0.0.14-7e0966a

1 year ago

0.0.14

1 year ago

0.0.13-fae4bea

1 year ago

0.0.14-360dc82

1 year ago

0.1.0

1 year ago

0.1.0-b7cb3f9

1 year ago

0.0.14-88a28a1

1 year ago

0.0.13-d77370f

1 year ago

0.0.13-fa70837

1 year ago

0.0.12-58d19b1

2 years ago

0.0.11-a15afc3

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

1 year ago

0.0.12-6ecdc59

2 years ago

0.0.12-f312f3d

1 year ago

0.0.12-6875952

2 years ago

0.0.12-ccac829

2 years ago

0.0.10-b40b4d6

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8-378ad04

2 years ago

0.0.8-b5f0cbb

2 years ago

0.0.8-964df01

2 years ago

0.0.8-4f8118e

2 years ago

0.0.8-38fdb53

2 years ago

0.0.8-3d977ba

2 years ago

0.0.8-4b656ce

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2-webpack.1

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago