Merge 732b2af45af4f8e569b634cef4ec306cc1c3fcfd into f6d5deb8cb51602b2b544de5de5b88de96e11aef

This commit is contained in:
Ya-wen, Jeng 2024-07-17 17:37:10 +00:00 committed by GitHub
commit 08c5afb8d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View File

@ -86,7 +86,7 @@ await rlnInstance.start(); // will use default Sepolia contract
#### Generating RLN Membership Credentials
```js
let credentials = rlnInstance.generateIdentityCredentials();
let credentials = rlnInstance.zerokit.generateIdentityCredentials();
```
### 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).
```js
let credentials = rlnInstance.generateSeededIdentityCredentials(seed);
let credentials = rlnInstance.zerokit.generateSeededIdentityCredential(seed);
```
### Adding Membership Keys Into Merkle Tree
```js
rlnInstance.insertMember(credentials.IDCommitment);
rlnInstance.zerokit.insertMember(credentials.IDCommitment);
```
### Registering Membership on a contract
@ -126,7 +126,7 @@ const uint8Msg = Uint8Array.from(
const epoch = new Uint8Array(32);
// generating a proof
const proof = await rlnInstance.generateProof(
const proof = await rlnInstance.zerokit.generateRLNProof(
uint8Msg,
index,
epoch,
@ -139,7 +139,7 @@ const proof = await rlnInstance.generateProof(
```js
try {
// verify the proof
const verificationResult = rlnInstance.verifyProof(proof, uint8Msg);
const verificationResult = rlnInstance.zerokit.verifyRLNProof(proof, uint8Msg);
console.log("Is proof verified?", verificationResult ? "yes" : "no");
} catch (err) {
console.log("Invalid proof");

View File

@ -1,7 +1,7 @@
import * as rln from "@waku/rln";
rln.create().then(async (rlnInstance) => {
const credentials = rlnInstance.generateIdentityCredentials();
rln.createRLN().then(async (rlnInstance) => {
const credentials = rlnInstance.zerokit.generateIdentityCredentials();
//peer's index in the Merkle Tree
const index = 5;
@ -10,11 +10,11 @@ rln.create().then(async (rlnInstance) => {
for (let i = 0; i < 10; i++) {
if (i == index) {
// insert the current peer's pk
rlnInstance.insertMember(credentials.IDCommitment);
rlnInstance.zerokit.insertMember(credentials.IDCommitment);
} else {
// create a new key pair
const credentials = rlnInstance.generateIdentityCredentials(); // TODO: handle error
rlnInstance.insertMember(credentials.IDCommitment);
const credentials = rlnInstance.zerokit.generateIdentityCredentials(); // TODO: handle error
rlnInstance.zerokit.insertMember(credentials.IDCommitment);
}
}
@ -28,7 +28,7 @@ rln.create().then(async (rlnInstance) => {
console.log("Generating proof...");
console.time("proof_gen_timer");
let proof = await rlnInstance.generateRLNProof(
let proof = await rlnInstance.zerokit.generateRLNProof(
uint8Msg,
index,
epoch,
@ -39,7 +39,7 @@ rln.create().then(async (rlnInstance) => {
try {
// verify the proof
let verifResult = rlnInstance.verifyRLNProof(proof, uint8Msg);
let verifResult = rlnInstance.zerokit.verifyRLNProof(proof, uint8Msg);
console.log("Is proof verified?", verifResult ? "yes" : "no");
} catch (err) {
console.log("Invalid proof");