@waku/rln 0.1.6-10590da.0 → 0.1.6-3730abc.0

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.
Files changed (47) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/_sha2.js +1 -1
  4. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/hmac.js +1 -1
  5. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/pbkdf2.js +1 -1
  6. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/scrypt.js +1 -1
  7. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha256.js +1 -1
  8. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha512.js +1 -1
  9. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/utils.js +1 -1
  10. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  11. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  12. package/bundle/packages/core/dist/lib/filter/filter.js +2 -0
  13. package/bundle/packages/core/dist/lib/light_push/light_push.js +2 -0
  14. package/bundle/packages/core/dist/lib/light_push/light_push_v3.js +30 -0
  15. package/bundle/packages/core/dist/lib/light_push/status_codes.js +25 -0
  16. package/bundle/packages/core/dist/lib/light_push/status_codes_v3.js +31 -0
  17. package/bundle/packages/core/dist/lib/message/version_0.js +3 -4
  18. package/bundle/packages/core/dist/lib/metadata/metadata.js +2 -0
  19. package/bundle/packages/core/dist/lib/store/store.js +2 -0
  20. package/bundle/packages/proto/dist/generated/light_push.js +28 -22
  21. package/bundle/packages/proto/dist/generated/light_push_v2.js +389 -0
  22. package/bundle/packages/proto/dist/generated/light_push_v3.js +348 -0
  23. package/bundle/packages/rln/dist/contract/rln_base_contract.js +2 -2
  24. package/bundle/packages/rln/dist/credentials_manager.js +1 -6
  25. package/bundle/packages/rln/dist/identity.js +1 -1
  26. package/bundle/packages/rln/dist/message.js +25 -0
  27. package/bundle/packages/rln/dist/rln.js +14 -0
  28. package/bundle/packages/rln/dist/utils/bytes.js +2 -6
  29. package/dist/.tsbuildinfo +1 -1
  30. package/dist/contract/rln_base_contract.d.ts +1 -1
  31. package/dist/contract/rln_base_contract.js +2 -2
  32. package/dist/contract/rln_base_contract.js.map +1 -1
  33. package/dist/credentials_manager.js +1 -6
  34. package/dist/credentials_manager.js.map +1 -1
  35. package/dist/identity.js +1 -1
  36. package/dist/identity.js.map +1 -1
  37. package/dist/message.d.ts +5 -4
  38. package/dist/message.js +2 -0
  39. package/dist/message.js.map +1 -1
  40. package/dist/utils/bytes.js +2 -6
  41. package/dist/utils/bytes.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/contract/rln_base_contract.ts +2 -2
  44. package/src/credentials_manager.ts +1 -8
  45. package/src/identity.ts +1 -1
  46. package/src/message.ts +7 -4
  47. package/src/utils/bytes.ts +2 -6
@@ -0,0 +1,348 @@
1
+ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src/decode.js';
2
+ import { encodeMessage } from '../../../../node_modules/protons-runtime/dist/src/encode.js';
3
+ import '../../../../node_modules/protons-runtime/dist/src/codec.js';
4
+ import { message } from '../../../../node_modules/protons-runtime/dist/src/codecs/message.js';
5
+ import { alloc } from '../../../../node_modules/uint8arrays/dist/src/alloc.js';
6
+ import '../../../../node_modules/protons-runtime/dist/src/utils/float.js';
7
+ import '../../../../node_modules/protons-runtime/dist/src/utils/longbits.js';
8
+ import '../../../../node_modules/protons-runtime/dist/src/utils/writer.js';
9
+
10
+ /* eslint-disable import/export */
11
+ /* eslint-disable complexity */
12
+ /* eslint-disable @typescript-eslint/no-namespace */
13
+ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
14
+ /* eslint-disable @typescript-eslint/no-empty-interface */
15
+ var LightpushRequest;
16
+ (function (LightpushRequest) {
17
+ let _codec;
18
+ LightpushRequest.codec = () => {
19
+ if (_codec == null) {
20
+ _codec = message((obj, w, opts = {}) => {
21
+ if (opts.lengthDelimited !== false) {
22
+ w.fork();
23
+ }
24
+ if ((obj.requestId != null && obj.requestId !== '')) {
25
+ w.uint32(10);
26
+ w.string(obj.requestId);
27
+ }
28
+ if (obj.pubsubTopic != null) {
29
+ w.uint32(162);
30
+ w.string(obj.pubsubTopic);
31
+ }
32
+ if (obj.message != null) {
33
+ w.uint32(170);
34
+ WakuMessage.codec().encode(obj.message, w);
35
+ }
36
+ if (opts.lengthDelimited !== false) {
37
+ w.ldelim();
38
+ }
39
+ }, (reader, length, opts = {}) => {
40
+ const obj = {
41
+ requestId: ''
42
+ };
43
+ const end = length == null ? reader.len : reader.pos + length;
44
+ while (reader.pos < end) {
45
+ const tag = reader.uint32();
46
+ switch (tag >>> 3) {
47
+ case 1: {
48
+ obj.requestId = reader.string();
49
+ break;
50
+ }
51
+ case 20: {
52
+ obj.pubsubTopic = reader.string();
53
+ break;
54
+ }
55
+ case 21: {
56
+ obj.message = WakuMessage.codec().decode(reader, reader.uint32(), {
57
+ limits: opts.limits?.message
58
+ });
59
+ break;
60
+ }
61
+ default: {
62
+ reader.skipType(tag & 7);
63
+ break;
64
+ }
65
+ }
66
+ }
67
+ return obj;
68
+ });
69
+ }
70
+ return _codec;
71
+ };
72
+ LightpushRequest.encode = (obj) => {
73
+ return encodeMessage(obj, LightpushRequest.codec());
74
+ };
75
+ LightpushRequest.decode = (buf, opts) => {
76
+ return decodeMessage(buf, LightpushRequest.codec(), opts);
77
+ };
78
+ })(LightpushRequest || (LightpushRequest = {}));
79
+ var LightpushResponse;
80
+ (function (LightpushResponse) {
81
+ let _codec;
82
+ LightpushResponse.codec = () => {
83
+ if (_codec == null) {
84
+ _codec = message((obj, w, opts = {}) => {
85
+ if (opts.lengthDelimited !== false) {
86
+ w.fork();
87
+ }
88
+ if ((obj.requestId != null && obj.requestId !== '')) {
89
+ w.uint32(10);
90
+ w.string(obj.requestId);
91
+ }
92
+ if ((obj.statusCode != null && obj.statusCode !== 0)) {
93
+ w.uint32(80);
94
+ w.uint32(obj.statusCode);
95
+ }
96
+ if (obj.statusDesc != null) {
97
+ w.uint32(90);
98
+ w.string(obj.statusDesc);
99
+ }
100
+ if (obj.relayPeerCount != null) {
101
+ w.uint32(96);
102
+ w.uint32(obj.relayPeerCount);
103
+ }
104
+ if (opts.lengthDelimited !== false) {
105
+ w.ldelim();
106
+ }
107
+ }, (reader, length, opts = {}) => {
108
+ const obj = {
109
+ requestId: '',
110
+ statusCode: 0
111
+ };
112
+ const end = length == null ? reader.len : reader.pos + length;
113
+ while (reader.pos < end) {
114
+ const tag = reader.uint32();
115
+ switch (tag >>> 3) {
116
+ case 1: {
117
+ obj.requestId = reader.string();
118
+ break;
119
+ }
120
+ case 10: {
121
+ obj.statusCode = reader.uint32();
122
+ break;
123
+ }
124
+ case 11: {
125
+ obj.statusDesc = reader.string();
126
+ break;
127
+ }
128
+ case 12: {
129
+ obj.relayPeerCount = reader.uint32();
130
+ break;
131
+ }
132
+ default: {
133
+ reader.skipType(tag & 7);
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ return obj;
139
+ });
140
+ }
141
+ return _codec;
142
+ };
143
+ LightpushResponse.encode = (obj) => {
144
+ return encodeMessage(obj, LightpushResponse.codec());
145
+ };
146
+ LightpushResponse.decode = (buf, opts) => {
147
+ return decodeMessage(buf, LightpushResponse.codec(), opts);
148
+ };
149
+ })(LightpushResponse || (LightpushResponse = {}));
150
+ var RateLimitProof;
151
+ (function (RateLimitProof) {
152
+ let _codec;
153
+ RateLimitProof.codec = () => {
154
+ if (_codec == null) {
155
+ _codec = message((obj, w, opts = {}) => {
156
+ if (opts.lengthDelimited !== false) {
157
+ w.fork();
158
+ }
159
+ if ((obj.proof != null && obj.proof.byteLength > 0)) {
160
+ w.uint32(10);
161
+ w.bytes(obj.proof);
162
+ }
163
+ if ((obj.merkleRoot != null && obj.merkleRoot.byteLength > 0)) {
164
+ w.uint32(18);
165
+ w.bytes(obj.merkleRoot);
166
+ }
167
+ if ((obj.epoch != null && obj.epoch.byteLength > 0)) {
168
+ w.uint32(26);
169
+ w.bytes(obj.epoch);
170
+ }
171
+ if ((obj.shareX != null && obj.shareX.byteLength > 0)) {
172
+ w.uint32(34);
173
+ w.bytes(obj.shareX);
174
+ }
175
+ if ((obj.shareY != null && obj.shareY.byteLength > 0)) {
176
+ w.uint32(42);
177
+ w.bytes(obj.shareY);
178
+ }
179
+ if ((obj.nullifier != null && obj.nullifier.byteLength > 0)) {
180
+ w.uint32(50);
181
+ w.bytes(obj.nullifier);
182
+ }
183
+ if ((obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0)) {
184
+ w.uint32(58);
185
+ w.bytes(obj.rlnIdentifier);
186
+ }
187
+ if (opts.lengthDelimited !== false) {
188
+ w.ldelim();
189
+ }
190
+ }, (reader, length, opts = {}) => {
191
+ const obj = {
192
+ proof: alloc(0),
193
+ merkleRoot: alloc(0),
194
+ epoch: alloc(0),
195
+ shareX: alloc(0),
196
+ shareY: alloc(0),
197
+ nullifier: alloc(0),
198
+ rlnIdentifier: alloc(0)
199
+ };
200
+ const end = length == null ? reader.len : reader.pos + length;
201
+ while (reader.pos < end) {
202
+ const tag = reader.uint32();
203
+ switch (tag >>> 3) {
204
+ case 1: {
205
+ obj.proof = reader.bytes();
206
+ break;
207
+ }
208
+ case 2: {
209
+ obj.merkleRoot = reader.bytes();
210
+ break;
211
+ }
212
+ case 3: {
213
+ obj.epoch = reader.bytes();
214
+ break;
215
+ }
216
+ case 4: {
217
+ obj.shareX = reader.bytes();
218
+ break;
219
+ }
220
+ case 5: {
221
+ obj.shareY = reader.bytes();
222
+ break;
223
+ }
224
+ case 6: {
225
+ obj.nullifier = reader.bytes();
226
+ break;
227
+ }
228
+ case 7: {
229
+ obj.rlnIdentifier = reader.bytes();
230
+ break;
231
+ }
232
+ default: {
233
+ reader.skipType(tag & 7);
234
+ break;
235
+ }
236
+ }
237
+ }
238
+ return obj;
239
+ });
240
+ }
241
+ return _codec;
242
+ };
243
+ RateLimitProof.encode = (obj) => {
244
+ return encodeMessage(obj, RateLimitProof.codec());
245
+ };
246
+ RateLimitProof.decode = (buf, opts) => {
247
+ return decodeMessage(buf, RateLimitProof.codec(), opts);
248
+ };
249
+ })(RateLimitProof || (RateLimitProof = {}));
250
+ var WakuMessage;
251
+ (function (WakuMessage) {
252
+ let _codec;
253
+ WakuMessage.codec = () => {
254
+ if (_codec == null) {
255
+ _codec = message((obj, w, opts = {}) => {
256
+ if (opts.lengthDelimited !== false) {
257
+ w.fork();
258
+ }
259
+ if ((obj.payload != null && obj.payload.byteLength > 0)) {
260
+ w.uint32(10);
261
+ w.bytes(obj.payload);
262
+ }
263
+ if ((obj.contentTopic != null && obj.contentTopic !== '')) {
264
+ w.uint32(18);
265
+ w.string(obj.contentTopic);
266
+ }
267
+ if (obj.version != null) {
268
+ w.uint32(24);
269
+ w.uint32(obj.version);
270
+ }
271
+ if (obj.timestamp != null) {
272
+ w.uint32(80);
273
+ w.sint64(obj.timestamp);
274
+ }
275
+ if (obj.meta != null) {
276
+ w.uint32(90);
277
+ w.bytes(obj.meta);
278
+ }
279
+ if (obj.rateLimitProof != null) {
280
+ w.uint32(170);
281
+ RateLimitProof.codec().encode(obj.rateLimitProof, w);
282
+ }
283
+ if (obj.ephemeral != null) {
284
+ w.uint32(248);
285
+ w.bool(obj.ephemeral);
286
+ }
287
+ if (opts.lengthDelimited !== false) {
288
+ w.ldelim();
289
+ }
290
+ }, (reader, length, opts = {}) => {
291
+ const obj = {
292
+ payload: alloc(0),
293
+ contentTopic: ''
294
+ };
295
+ const end = length == null ? reader.len : reader.pos + length;
296
+ while (reader.pos < end) {
297
+ const tag = reader.uint32();
298
+ switch (tag >>> 3) {
299
+ case 1: {
300
+ obj.payload = reader.bytes();
301
+ break;
302
+ }
303
+ case 2: {
304
+ obj.contentTopic = reader.string();
305
+ break;
306
+ }
307
+ case 3: {
308
+ obj.version = reader.uint32();
309
+ break;
310
+ }
311
+ case 10: {
312
+ obj.timestamp = reader.sint64();
313
+ break;
314
+ }
315
+ case 11: {
316
+ obj.meta = reader.bytes();
317
+ break;
318
+ }
319
+ case 21: {
320
+ obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {
321
+ limits: opts.limits?.rateLimitProof
322
+ });
323
+ break;
324
+ }
325
+ case 31: {
326
+ obj.ephemeral = reader.bool();
327
+ break;
328
+ }
329
+ default: {
330
+ reader.skipType(tag & 7);
331
+ break;
332
+ }
333
+ }
334
+ }
335
+ return obj;
336
+ });
337
+ }
338
+ return _codec;
339
+ };
340
+ WakuMessage.encode = (obj) => {
341
+ return encodeMessage(obj, WakuMessage.codec());
342
+ };
343
+ WakuMessage.decode = (buf, opts) => {
344
+ return decodeMessage(buf, WakuMessage.codec(), opts);
345
+ };
346
+ })(WakuMessage || (WakuMessage = {}));
347
+
348
+ export { LightpushRequest, LightpushResponse, RateLimitProof, WakuMessage };
@@ -328,9 +328,9 @@ class RLNBaseContract {
328
328
  }
329
329
  return this.contract.register(idCommitmentBigInt, rateLimit, []);
330
330
  }
331
- async withdraw(token, from) {
331
+ async withdraw(token, walletAddress) {
332
332
  try {
333
- const tx = await this.contract.withdraw(token, from);
333
+ const tx = await this.contract.withdraw(token, walletAddress);
334
334
  await tx.wait();
335
335
  }
336
336
  catch (error) {
@@ -206,12 +206,7 @@ class RLNCredentialsManager {
206
206
  // Generate IDCommitment as a hash of IDSecretHash
207
207
  const idCommitment = sha256(idSecretHash);
208
208
  // Convert IDCommitment to BigInt
209
- let idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
210
- const Q = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
211
- if (idCommitmentBigInt >= Q) {
212
- log.warn("IDCommitment is greater than Q, truncating");
213
- idCommitmentBigInt = idCommitmentBigInt % Q;
214
- }
209
+ const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
215
210
  log.info("Successfully generated identity credential");
216
211
  return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment, idCommitmentBigInt);
217
212
  }
@@ -22,7 +22,7 @@ class IdentityCredential {
22
22
  const idNullifier = memKeys.subarray(32, 64);
23
23
  const idSecretHash = memKeys.subarray(64, 96);
24
24
  const idCommitment = memKeys.subarray(96, 128);
25
- const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
25
+ const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment, 32);
26
26
  return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment, idCommitmentBigInt);
27
27
  }
28
28
  }
@@ -1,4 +1,28 @@
1
+ import { Version } from '../../core/dist/lib/message/version_0.js';
2
+ import '../../core/dist/lib/filter/filter.js';
3
+ import '../../core/dist/lib/light_push/light_push.js';
4
+ import '../../core/dist/lib/light_push/light_push_v3.js';
5
+ import '../../proto/dist/generated/message.js';
6
+ import '../../proto/dist/generated/filter.js';
7
+ import '../../proto/dist/generated/topic_only_message.js';
8
+ import '../../proto/dist/generated/filter_v2.js';
9
+ import '../../proto/dist/generated/light_push.js';
10
+ import '../../proto/dist/generated/light_push_v2.js';
11
+ import '../../proto/dist/generated/light_push_v3.js';
12
+ import '../../proto/dist/generated/store_v3.js';
13
+ import '../../proto/dist/generated/peer_exchange.js';
14
+ import '../../proto/dist/generated/metadata.js';
15
+ import '../../proto/dist/generated/sds_message.js';
16
+ import '../../core/dist/lib/light_push/status_codes_v3.js';
17
+ import '../../core/dist/lib/light_push/status_codes.js';
18
+ import '../../core/dist/lib/store/store.js';
19
+ import '../../core/dist/lib/connection_manager/connection_manager.js';
20
+ import '../../interfaces/dist/protocols.js';
21
+ import '../../interfaces/dist/connection_manager.js';
22
+ import '../../interfaces/dist/health_indicator.js';
1
23
  import { utf8ToBytes } from '../../utils/dist/bytes/index.js';
24
+ import '../../../node_modules/debug/src/browser.js';
25
+ import '../../core/dist/lib/metadata/metadata.js';
2
26
  import { epochBytesToInt } from './utils/epoch.js';
3
27
 
4
28
  function toRLNSignal(contentTopic, msg) {
@@ -10,6 +34,7 @@ class RlnMessage {
10
34
  msg;
11
35
  rateLimitProof;
12
36
  pubsubTopic = "";
37
+ version = Version;
13
38
  constructor(rlnInstance, msg, rateLimitProof) {
14
39
  this.rlnInstance = rlnInstance;
15
40
  this.msg = msg;
@@ -1,6 +1,20 @@
1
1
  import { createEncoder, createDecoder } from '../../core/dist/lib/message/version_0.js';
2
2
  import '../../core/dist/lib/filter/filter.js';
3
3
  import '../../core/dist/lib/light_push/light_push.js';
4
+ import '../../core/dist/lib/light_push/light_push_v3.js';
5
+ import '../../proto/dist/generated/message.js';
6
+ import '../../proto/dist/generated/filter.js';
7
+ import '../../proto/dist/generated/topic_only_message.js';
8
+ import '../../proto/dist/generated/filter_v2.js';
9
+ import '../../proto/dist/generated/light_push.js';
10
+ import '../../proto/dist/generated/light_push_v2.js';
11
+ import '../../proto/dist/generated/light_push_v3.js';
12
+ import '../../proto/dist/generated/store_v3.js';
13
+ import '../../proto/dist/generated/peer_exchange.js';
14
+ import '../../proto/dist/generated/metadata.js';
15
+ import '../../proto/dist/generated/sds_message.js';
16
+ import '../../core/dist/lib/light_push/status_codes_v3.js';
17
+ import '../../core/dist/lib/light_push/status_codes.js';
4
18
  import '../../core/dist/lib/store/store.js';
5
19
  import '../../core/dist/lib/connection_manager/connection_manager.js';
6
20
  import '../../interfaces/dist/protocols.js';
@@ -45,12 +45,8 @@ function writeUIntLE(buf, value, offset, byteLength, noAssert) {
45
45
  * @returns BigInt
46
46
  */
47
47
  function buildBigIntFromUint8Array(array, byteOffset = 0) {
48
- // Use all bytes from byteOffset to the end, big-endian
49
- let hex = "";
50
- for (let i = byteOffset; i < array.length; i++) {
51
- hex += array[i].toString(16).padStart(2, "0");
52
- }
53
- return BigInt("0x" + hex);
48
+ const dataView = new DataView(array.buffer);
49
+ return dataView.getBigUint64(byteOffset, true);
54
50
  }
55
51
  /**
56
52
  * Fills with zeros to set length