mirror of
https://github.com/logos-messaging/js-rln.git
synced 2026-01-07 16:13:07 +00:00
Merge 732b2af45af4f8e569b634cef4ec306cc1c3fcfd into f6d5deb8cb51602b2b544de5de5b88de96e11aef
This commit is contained in:
commit
08c5afb8d4
10
README.md
10
README.md
@ -86,7 +86,7 @@ await rlnInstance.start(); // will use default Sepolia contract
|
|||||||
#### Generating RLN Membership Credentials
|
#### Generating RLN Membership Credentials
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let credentials = rlnInstance.generateIdentityCredentials();
|
let credentials = rlnInstance.zerokit.generateIdentityCredentials();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Generating RLN Membership Keypair Using a Seed
|
### Generating RLN Membership Keypair Using a Seed
|
||||||
@ -94,13 +94,13 @@ let credentials = rlnInstance.generateIdentityCredentials();
|
|||||||
This can be used to generate credentials from a signature hash (e.g. signed by an Ethereum account).
|
This can be used to generate credentials from a signature hash (e.g. signed by an Ethereum account).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let credentials = rlnInstance.generateSeededIdentityCredentials(seed);
|
let credentials = rlnInstance.zerokit.generateSeededIdentityCredential(seed);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Adding Membership Keys Into Merkle Tree
|
### Adding Membership Keys Into Merkle Tree
|
||||||
|
|
||||||
```js
|
```js
|
||||||
rlnInstance.insertMember(credentials.IDCommitment);
|
rlnInstance.zerokit.insertMember(credentials.IDCommitment);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Registering Membership on a contract
|
### Registering Membership on a contract
|
||||||
@ -126,7 +126,7 @@ const uint8Msg = Uint8Array.from(
|
|||||||
const epoch = new Uint8Array(32);
|
const epoch = new Uint8Array(32);
|
||||||
|
|
||||||
// generating a proof
|
// generating a proof
|
||||||
const proof = await rlnInstance.generateProof(
|
const proof = await rlnInstance.zerokit.generateRLNProof(
|
||||||
uint8Msg,
|
uint8Msg,
|
||||||
index,
|
index,
|
||||||
epoch,
|
epoch,
|
||||||
@ -139,7 +139,7 @@ const proof = await rlnInstance.generateProof(
|
|||||||
```js
|
```js
|
||||||
try {
|
try {
|
||||||
// verify the proof
|
// verify the proof
|
||||||
const verificationResult = rlnInstance.verifyProof(proof, uint8Msg);
|
const verificationResult = rlnInstance.zerokit.verifyRLNProof(proof, uint8Msg);
|
||||||
console.log("Is proof verified?", verificationResult ? "yes" : "no");
|
console.log("Is proof verified?", verificationResult ? "yes" : "no");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Invalid proof");
|
console.log("Invalid proof");
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as rln from "@waku/rln";
|
import * as rln from "@waku/rln";
|
||||||
|
|
||||||
rln.create().then(async (rlnInstance) => {
|
rln.createRLN().then(async (rlnInstance) => {
|
||||||
const credentials = rlnInstance.generateIdentityCredentials();
|
const credentials = rlnInstance.zerokit.generateIdentityCredentials();
|
||||||
|
|
||||||
//peer's index in the Merkle Tree
|
//peer's index in the Merkle Tree
|
||||||
const index = 5;
|
const index = 5;
|
||||||
@ -10,11 +10,11 @@ rln.create().then(async (rlnInstance) => {
|
|||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
if (i == index) {
|
if (i == index) {
|
||||||
// insert the current peer's pk
|
// insert the current peer's pk
|
||||||
rlnInstance.insertMember(credentials.IDCommitment);
|
rlnInstance.zerokit.insertMember(credentials.IDCommitment);
|
||||||
} else {
|
} else {
|
||||||
// create a new key pair
|
// create a new key pair
|
||||||
const credentials = rlnInstance.generateIdentityCredentials(); // TODO: handle error
|
const credentials = rlnInstance.zerokit.generateIdentityCredentials(); // TODO: handle error
|
||||||
rlnInstance.insertMember(credentials.IDCommitment);
|
rlnInstance.zerokit.insertMember(credentials.IDCommitment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ rln.create().then(async (rlnInstance) => {
|
|||||||
|
|
||||||
console.log("Generating proof...");
|
console.log("Generating proof...");
|
||||||
console.time("proof_gen_timer");
|
console.time("proof_gen_timer");
|
||||||
let proof = await rlnInstance.generateRLNProof(
|
let proof = await rlnInstance.zerokit.generateRLNProof(
|
||||||
uint8Msg,
|
uint8Msg,
|
||||||
index,
|
index,
|
||||||
epoch,
|
epoch,
|
||||||
@ -39,7 +39,7 @@ rln.create().then(async (rlnInstance) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// verify the proof
|
// verify the proof
|
||||||
let verifResult = rlnInstance.verifyRLNProof(proof, uint8Msg);
|
let verifResult = rlnInstance.zerokit.verifyRLNProof(proof, uint8Msg);
|
||||||
console.log("Is proof verified?", verifResult ? "yes" : "no");
|
console.log("Is proof verified?", verifResult ? "yes" : "no");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Invalid proof");
|
console.log("Invalid proof");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user