@waku/rln 0.0.12 → 0.0.13-d77370f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,7 @@ Browser library providing the cryptographic functions for Waku RLN Relay
4
4
  https://rfc.vac.dev/spec/17/
5
5
 
6
6
  ### Install
7
+
7
8
  ```
8
9
  npm install @waku/rln
9
10
 
@@ -13,6 +14,7 @@ yarn add @waku/rln
13
14
  ```
14
15
 
15
16
  ### Running example app
17
+
16
18
  ```
17
19
  git clone https://github.com/waku-org/js-rln
18
20
 
@@ -26,10 +28,10 @@ npm start
26
28
 
27
29
  Browse http://localhost:8080 and open the dev tools console to see the proof being generated and its verification
28
30
 
29
-
30
31
  ### Usage
31
32
 
32
33
  #### Initializing the library
34
+
33
35
  ```js
34
36
  import * as rln from "@waku/rln";
35
37
 
@@ -37,45 +39,60 @@ const rlnInstance = wait rln.create();
37
39
  ```
38
40
 
39
41
  #### Generating RLN membership keypair
42
+
40
43
  ```js
41
44
  let memKeys = rlnInstance.generateMembershipKey();
42
45
  ```
43
46
 
47
+ #### Generating RLN membership keypair using a seed
48
+
49
+ ```js
50
+ let memKeys = rlnInstance.generateSeededMembershipKey(seed);
51
+ ```
44
52
 
45
53
  #### Adding membership keys into merkle tree
54
+
46
55
  ```js
47
56
  rlnInstance.insertMember(memKeys.IDCommitment);
48
57
  ```
49
58
 
50
59
  #### Generating a proof
60
+
51
61
  ```js
52
62
  // prepare the message
53
- const uint8Msg = Uint8Array.from("Hello World".split("").map(x => x.charCodeAt()));
63
+ const uint8Msg = Uint8Array.from(
64
+ "Hello World".split("").map((x) => x.charCodeAt())
65
+ );
54
66
 
55
67
  // setting up the epoch (With 0s for the test)
56
68
  const epoch = new Uint8Array(32);
57
69
 
58
70
  // generating a proof
59
- const proof = await rlnInstance.generateProof(uint8Msg, index, epoch, memKeys.IDKey)
71
+ const proof = await rlnInstance.generateProof(
72
+ uint8Msg,
73
+ index,
74
+ epoch,
75
+ memKeys.IDKey
76
+ );
60
77
  ```
61
78
 
62
79
  #### Verifying a proof
80
+
63
81
  ```js
64
82
  try {
65
- // verify the proof
66
- const verificationResult = rlnInstance.verifyProof(proof);
67
- console.log("Is proof verified?", verificationResult ? "yes" : "no");
83
+ // verify the proof
84
+ const verificationResult = rlnInstance.verifyProof(proof);
85
+ console.log("Is proof verified?", verificationResult ? "yes" : "no");
68
86
  } catch (err) {
69
- console.log("Invalid proof")
87
+ console.log("Invalid proof");
70
88
  }
71
89
  ```
72
90
 
73
-
74
-
75
91
  ### Updating circuit, verification key and zkey
92
+
76
93
  The RLN specs defines the defaults. These values are fixed and should not
77
94
  change. Currently, these [resources](https://github.com/vacp2p/zerokit/tree/master/rln/resources/tree_height_20) are being used.
78
- If they change, this file needs to be updated in `resources.ts` which
95
+ If they change, this file needs to be updated in `resources.ts` which
79
96
  contains these values encoded in base64 in this format:
80
97
 
81
98
  ```
@@ -85,37 +102,41 @@ const zkey = "...";
85
102
  export {verification_key, circuit, zkey};
86
103
  ```
87
104
 
88
- A tool like GNU's `base64` could be used to encode this data.
105
+ A tool like GNU's `base64` could be used to encode this data.
89
106
 
90
107
  ### Updating zerokit
108
+
91
109
  1. Make sure you have nodejs installed and a C compiler
92
110
  2. Install wasm-pack
111
+
93
112
  ```
94
113
  curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
95
114
  ```
115
+
96
116
  3. Compile RLN for wasm
117
+
97
118
  ```
98
119
  git clone https://github.com/vacp2p/zerokit
99
120
  cd zerokit/rln-wasm
100
121
  wasm-pack build --release
101
122
  ```
102
- 4. Copy `pkg/rln*` into `src/zerokit`
103
123
 
124
+ 4. Copy `pkg/rln*` into `src/zerokit`
104
125
 
105
126
  ## Bugs, Questions & Features
106
127
 
107
128
  If you encounter any bug or would like to propose new features, feel free to [open an issue](https://github.com/waku-org/js-rln/issues/new/).
108
129
 
109
- For more general discussion, help and latest news, join [Vac Discord](https://discord.gg/PQFdubGt6d) or [Telegram](https://t.me/vacp2p).
110
-
130
+ For more general discussion, help and latest news, join [Vac Discord](https://discord.gg/PQFdubGt6d) or [Telegram](https://t.me/vacp2p).
111
131
 
112
132
  ## License
133
+
113
134
  Licensed and distributed under either of
114
135
 
115
- * MIT license: [LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT
136
+ - MIT license: [LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT
116
137
 
117
138
  or
118
139
 
119
- * Apache License, Version 2.0, ([LICENSE-APACHEv2](LICENSE-APACHEv2) or http://www.apache.org/licenses/LICENSE-2.0)
140
+ - Apache License, Version 2.0, ([LICENSE-APACHEv2](LICENSE-APACHEv2) or http://www.apache.org/licenses/LICENSE-2.0)
120
141
 
121
142
  at your option. These files may not be copied, modified, or distributed except according to those terms.