@waku/rln 0.1.6-b7e9b08.0 → 0.1.6-f7778a9.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 (71) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/index.js +2 -1
  4. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/_sha2.js +1 -1
  5. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/hmac.js +1 -1
  6. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/pbkdf2.js +1 -1
  7. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/scrypt.js +1 -1
  8. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha256.js +1 -1
  9. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha512.js +1 -1
  10. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/utils.js +1 -1
  11. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  12. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  13. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +1 -1
  14. package/bundle/node_modules/{@ethersproject/keccak256/node_modules/js-sha3 → js-sha3}/src/sha3.js +2 -2
  15. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +0 -3
  16. package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +3 -3
  17. package/bundle/packages/core/dist/lib/filter/filter.js +0 -3
  18. package/bundle/packages/core/dist/lib/light_push/light_push.js +0 -3
  19. package/bundle/packages/core/dist/lib/message/version_0.js +1 -4
  20. package/bundle/packages/core/dist/lib/metadata/metadata.js +0 -3
  21. package/bundle/packages/core/dist/lib/store/store.js +3 -3
  22. package/bundle/packages/rln/dist/codec.js +3 -3
  23. package/bundle/packages/rln/dist/contract/constants.js +8 -1
  24. package/bundle/packages/rln/dist/contract/rln_base_contract.js +138 -75
  25. package/bundle/packages/rln/dist/contract/rln_contract.js +3 -3
  26. package/bundle/packages/rln/dist/credentials_manager.js +15 -10
  27. package/bundle/packages/rln/dist/keystore/keystore.js +4 -4
  28. package/bundle/packages/rln/dist/message.js +11 -0
  29. package/bundle/packages/rln/dist/rln.js +3 -3
  30. package/bundle/packages/rln/dist/utils/epoch.js +3 -3
  31. package/bundle/packages/utils/dist/common/sharding/index.js +4 -4
  32. package/dist/.tsbuildinfo +1 -1
  33. package/dist/contract/constants.d.ts +6 -0
  34. package/dist/contract/constants.js +6 -0
  35. package/dist/contract/constants.js.map +1 -1
  36. package/dist/contract/index.d.ts +1 -0
  37. package/dist/contract/index.js +1 -0
  38. package/dist/contract/index.js.map +1 -1
  39. package/dist/contract/rln_base_contract.d.ts +37 -22
  40. package/dist/contract/rln_base_contract.js +135 -72
  41. package/dist/contract/rln_base_contract.js.map +1 -1
  42. package/dist/contract/types.d.ts +5 -0
  43. package/dist/contract/types.js.map +1 -1
  44. package/dist/credentials_manager.js +12 -7
  45. package/dist/credentials_manager.js.map +1 -1
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +1 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/keystore/keystore.js.map +1 -1
  50. package/dist/keystore/types.d.ts +2 -2
  51. package/dist/message.d.ts +5 -4
  52. package/dist/message.js +2 -0
  53. package/dist/message.js.map +1 -1
  54. package/package.json +1 -1
  55. package/src/contract/constants.ts +9 -0
  56. package/src/contract/index.ts +1 -0
  57. package/src/contract/rln_base_contract.ts +181 -103
  58. package/src/contract/types.ts +5 -0
  59. package/src/credentials_manager.ts +20 -7
  60. package/src/index.ts +3 -1
  61. package/src/keystore/keystore.ts +4 -2
  62. package/src/keystore/types.ts +2 -2
  63. package/src/message.ts +7 -4
  64. package/bundle/packages/utils/node_modules/@waku/interfaces/dist/connection_manager.js +0 -19
  65. package/bundle/packages/utils/node_modules/@waku/interfaces/dist/health_indicator.js +0 -12
  66. package/bundle/packages/utils/node_modules/@waku/interfaces/dist/protocols.js +0 -92
  67. /package/bundle/packages/{utils/node_modules/@waku/interfaces → interfaces}/dist/constants.js +0 -0
  68. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/native.js +0 -0
  69. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/rng.js +0 -0
  70. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/stringify.js +0 -0
  71. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/v4.js +0 -0
@@ -1,8 +1,8 @@
1
1
  import { hmac } from '../../../node_modules/@noble/hashes/esm/hmac.js';
2
2
  import { sha256 } from '../../../node_modules/@noble/hashes/esm/sha256.js';
3
- import '../../utils/node_modules/@waku/interfaces/dist/protocols.js';
4
- import '../../utils/node_modules/@waku/interfaces/dist/connection_manager.js';
5
- import '../../utils/node_modules/@waku/interfaces/dist/health_indicator.js';
3
+ import '../../interfaces/dist/protocols.js';
4
+ import '../../interfaces/dist/connection_manager.js';
5
+ import '../../interfaces/dist/health_indicator.js';
6
6
  import '../../../node_modules/multiformats/dist/src/bases/base10.js';
7
7
  import '../../../node_modules/multiformats/dist/src/bases/base16.js';
8
8
  import '../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -64,7 +64,7 @@ class RLNCredentialsManager {
64
64
  }
65
65
  this.credentials = credentials;
66
66
  this.signer = signer;
67
- this.contract = new RLNBaseContract({
67
+ this.contract = await RLNBaseContract.create({
68
68
  address: address,
69
69
  signer: signer,
70
70
  rateLimit: rateLimit ?? this.zerokit?.rateLimit
@@ -95,7 +95,7 @@ class RLNCredentialsManager {
95
95
  }
96
96
  else {
97
97
  log.info("Using local implementation to generate identity");
98
- identity = this.generateSeededIdentityCredential(options.signature);
98
+ identity = await this.generateSeededIdentityCredential(options.signature);
99
99
  }
100
100
  }
101
101
  if (!identity) {
@@ -191,7 +191,7 @@ class RLNCredentialsManager {
191
191
  * @param seed A string seed to generate the identity from
192
192
  * @returns IdentityCredential
193
193
  */
194
- generateSeededIdentityCredential(seed) {
194
+ async generateSeededIdentityCredential(seed) {
195
195
  log.info("Generating seeded identity credential");
196
196
  // Convert the seed to bytes
197
197
  const encoder = new TextEncoder();
@@ -200,13 +200,18 @@ class RLNCredentialsManager {
200
200
  // We use different context strings for each component to ensure they're different
201
201
  const idTrapdoor = hmac(sha256, seedBytes, encoder.encode("IDTrapdoor"));
202
202
  const idNullifier = hmac(sha256, seedBytes, encoder.encode("IDNullifier"));
203
- // Generate IDSecretHash as a hash of IDTrapdoor and IDNullifier
204
203
  const combinedBytes = new Uint8Array([...idTrapdoor, ...idNullifier]);
205
204
  const idSecretHash = sha256(combinedBytes);
206
- // Generate IDCommitment as a hash of IDSecretHash
207
205
  const idCommitment = sha256(idSecretHash);
208
- // Convert IDCommitment to BigInt
209
- const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
206
+ let idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
207
+ if (!this.contract) {
208
+ throw Error("RLN contract is not initialized");
209
+ }
210
+ const idCommitmentBigIntLimit = this.contract.idCommitmentBigIntLimit;
211
+ if (idCommitmentBigInt >= idCommitmentBigIntLimit) {
212
+ log.warn(`ID commitment is greater than Q, reducing it by Q(idCommitmentBigIntLimit): ${idCommitmentBigInt} % ${idCommitmentBigIntLimit}`);
213
+ idCommitmentBigInt = idCommitmentBigInt % idCommitmentBigIntLimit;
214
+ }
210
215
  log.info("Successfully generated identity credential");
211
216
  return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment, idCommitmentBigInt);
212
217
  }
@@ -1,7 +1,7 @@
1
1
  import '../../../../node_modules/@chainsafe/bls-keystore/lib/index.js';
2
- import '../../../utils/node_modules/@waku/interfaces/dist/protocols.js';
3
- import '../../../utils/node_modules/@waku/interfaces/dist/connection_manager.js';
4
- import '../../../utils/node_modules/@waku/interfaces/dist/health_indicator.js';
2
+ import '../../../interfaces/dist/protocols.js';
3
+ import '../../../interfaces/dist/connection_manager.js';
4
+ import '../../../interfaces/dist/health_indicator.js';
5
5
  import '../../../../node_modules/multiformats/dist/src/bases/base10.js';
6
6
  import '../../../../node_modules/multiformats/dist/src/bases/base16.js';
7
7
  import '../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -21,7 +21,7 @@ import { buildBigIntFromUint8Array } from '../utils/bytes.js';
21
21
  import { keccak256Checksum, decryptEipKeystore } from './cipher.js';
22
22
  import { isKeystoreValid, isCredentialValid } from './schema_validator.js';
23
23
  import { __exports as lib } from '../../../../_virtual/index.js';
24
- import v4 from '../../../../node_modules/uuid/dist/esm-browser/v4.js';
24
+ import v4 from '../../node_modules/uuid/dist/esm-browser/v4.js';
25
25
  import { bytesToHex, utf8ToBytes } from '../../../../node_modules/@noble/hashes/esm/utils.js';
26
26
 
27
27
  const log = new Logger("waku:rln:keystore");
@@ -1,4 +1,14 @@
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/store/store.js';
5
+ import '../../core/dist/lib/connection_manager/connection_manager.js';
6
+ import '../../interfaces/dist/protocols.js';
7
+ import '../../interfaces/dist/connection_manager.js';
8
+ import '../../interfaces/dist/health_indicator.js';
1
9
  import { utf8ToBytes } from '../../utils/dist/bytes/index.js';
10
+ import '../../../node_modules/debug/src/browser.js';
11
+ import '../../core/dist/lib/metadata/metadata.js';
2
12
  import { epochBytesToInt } from './utils/epoch.js';
3
13
 
4
14
  function toRLNSignal(contentTopic, msg) {
@@ -10,6 +20,7 @@ class RlnMessage {
10
20
  msg;
11
21
  rateLimitProof;
12
22
  pubsubTopic = "";
23
+ version = Version;
13
24
  constructor(rlnInstance, msg, rateLimitProof) {
14
25
  this.rlnInstance = rlnInstance;
15
26
  this.msg = msg;
@@ -3,9 +3,9 @@ import '../../core/dist/lib/filter/filter.js';
3
3
  import '../../core/dist/lib/light_push/light_push.js';
4
4
  import '../../core/dist/lib/store/store.js';
5
5
  import '../../core/dist/lib/connection_manager/connection_manager.js';
6
- import '../../utils/node_modules/@waku/interfaces/dist/protocols.js';
7
- import '../../utils/node_modules/@waku/interfaces/dist/connection_manager.js';
8
- import '../../utils/node_modules/@waku/interfaces/dist/health_indicator.js';
6
+ import '../../interfaces/dist/protocols.js';
7
+ import '../../interfaces/dist/connection_manager.js';
8
+ import '../../interfaces/dist/health_indicator.js';
9
9
  import '../../../node_modules/multiformats/dist/src/bases/base10.js';
10
10
  import '../../../node_modules/multiformats/dist/src/bases/base16.js';
11
11
  import '../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
- import '../../../utils/node_modules/@waku/interfaces/dist/protocols.js';
2
- import '../../../utils/node_modules/@waku/interfaces/dist/connection_manager.js';
3
- import '../../../utils/node_modules/@waku/interfaces/dist/health_indicator.js';
1
+ import '../../../interfaces/dist/protocols.js';
2
+ import '../../../interfaces/dist/connection_manager.js';
3
+ import '../../../interfaces/dist/health_indicator.js';
4
4
  import '../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,8 +1,8 @@
1
1
  import { sha256 } from '../../../../../node_modules/@noble/hashes/esm/sha256.js';
2
- import '../../../node_modules/@waku/interfaces/dist/protocols.js';
3
- import '../../../node_modules/@waku/interfaces/dist/connection_manager.js';
4
- import { DEFAULT_CLUSTER_ID } from '../../../node_modules/@waku/interfaces/dist/constants.js';
5
- import '../../../node_modules/@waku/interfaces/dist/health_indicator.js';
2
+ import '../../../../interfaces/dist/protocols.js';
3
+ import '../../../../interfaces/dist/connection_manager.js';
4
+ import { DEFAULT_CLUSTER_ID } from '../../../../interfaces/dist/constants.js';
5
+ import '../../../../interfaces/dist/health_indicator.js';
6
6
  import { concat, utf8ToBytes } from '../../bytes/index.js';
7
7
 
8
8
  const singleShardInfoToPubsubTopic = (shardInfo) => {