@waku/rln 0.1.4-d27db21.0 → 0.1.5-053bb95.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 (138) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +5 -0
  3. package/bundle/_virtual/utils.js +2 -2
  4. package/bundle/_virtual/utils2.js +2 -2
  5. package/bundle/index.js +3 -1
  6. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +1 -1
  7. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +1 -1
  8. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +1 -1
  9. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +11 -11
  10. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +1 -1
  11. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +7 -7
  12. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +2 -2
  13. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +2 -2
  14. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +1 -1
  15. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +1 -1
  16. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +1 -1
  17. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +44 -44
  18. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +8 -8
  19. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +1 -1
  20. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +1 -1
  21. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +1 -1
  22. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +2 -2
  23. package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +1 -0
  24. package/bundle/node_modules/@noble/hashes/esm/sha3.js +1 -1
  25. package/bundle/node_modules/bn.js/lib/bn.js +1 -1
  26. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +6 -6
  27. package/bundle/packages/rln/dist/contract/abi.js +502 -248
  28. package/bundle/packages/rln/dist/contract/constants.js +5 -9
  29. package/bundle/packages/rln/dist/contract/errors.js +62 -0
  30. package/bundle/packages/rln/dist/contract/rln_base_contract.js +347 -0
  31. package/bundle/packages/rln/dist/contract/rln_contract.js +81 -392
  32. package/bundle/packages/rln/dist/contract/types.js +9 -0
  33. package/bundle/packages/rln/dist/create.js +1 -1
  34. package/bundle/packages/rln/dist/credentials_manager.js +215 -0
  35. package/bundle/packages/rln/dist/identity.js +8 -0
  36. package/bundle/packages/rln/dist/keystore/keystore.js +20 -28
  37. package/bundle/packages/rln/dist/rln.js +56 -166
  38. package/bundle/packages/rln/dist/zerokit.js +5 -5
  39. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +2 -2
  40. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +3 -3
  41. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +4 -4
  42. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +4 -4
  43. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +4 -4
  44. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +1 -1
  45. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1 -1
  46. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +1 -1
  47. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +1 -1
  48. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +1 -1
  49. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +2 -2
  50. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +1 -1
  51. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +1 -1
  52. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +3 -3
  53. package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +1 -1
  54. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +2 -2
  55. package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +1 -1
  56. package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +1 -1
  57. package/bundle/packages/rln/node_modules/@noble/hashes/esm/_assert.js +43 -0
  58. package/bundle/packages/rln/node_modules/@noble/hashes/esm/_sha2.js +116 -0
  59. package/bundle/packages/rln/node_modules/@noble/hashes/esm/hmac.js +79 -0
  60. package/bundle/packages/rln/node_modules/@noble/hashes/esm/sha256.js +126 -0
  61. package/bundle/packages/rln/node_modules/@noble/hashes/esm/utils.js +43 -0
  62. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +2 -2
  63. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +2 -2
  64. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +3 -3
  65. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +2 -2
  66. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +3 -3
  67. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +2 -2
  68. package/dist/.tsbuildinfo +1 -1
  69. package/dist/codec.test-utils.d.ts +36 -0
  70. package/dist/codec.test-utils.js +56 -0
  71. package/dist/codec.test-utils.js.map +1 -0
  72. package/dist/contract/abi.d.ts +21 -17
  73. package/dist/contract/abi.js +502 -248
  74. package/dist/contract/abi.js.map +1 -1
  75. package/dist/contract/constants.d.ts +23 -19
  76. package/dist/contract/constants.js +3 -3
  77. package/dist/contract/constants.js.map +1 -1
  78. package/dist/contract/errors.d.ts +30 -0
  79. package/dist/contract/errors.js +61 -0
  80. package/dist/contract/errors.js.map +1 -0
  81. package/dist/contract/rln_base_contract.d.ts +88 -0
  82. package/dist/contract/rln_base_contract.js +330 -0
  83. package/dist/contract/rln_base_contract.js.map +1 -0
  84. package/dist/contract/rln_contract.d.ts +19 -109
  85. package/dist/contract/rln_contract.js +80 -390
  86. package/dist/contract/rln_contract.js.map +1 -1
  87. package/dist/contract/test-setup.d.ts +26 -0
  88. package/dist/contract/test-setup.js +56 -0
  89. package/dist/contract/test-setup.js.map +1 -0
  90. package/dist/contract/test-utils.d.ts +39 -0
  91. package/dist/contract/test-utils.js +118 -0
  92. package/dist/contract/test-utils.js.map +1 -0
  93. package/dist/contract/types.d.ts +40 -0
  94. package/dist/contract/types.js +8 -0
  95. package/dist/contract/types.js.map +1 -0
  96. package/dist/create.js +1 -1
  97. package/dist/create.js.map +1 -1
  98. package/dist/credentials_manager.d.ts +44 -0
  99. package/dist/credentials_manager.js +197 -0
  100. package/dist/credentials_manager.js.map +1 -0
  101. package/dist/identity.d.ts +1 -0
  102. package/dist/identity.js +8 -0
  103. package/dist/identity.js.map +1 -1
  104. package/dist/index.d.ts +5 -2
  105. package/dist/index.js +4 -2
  106. package/dist/index.js.map +1 -1
  107. package/dist/keystore/keystore.d.ts +0 -1
  108. package/dist/keystore/keystore.js +20 -28
  109. package/dist/keystore/keystore.js.map +1 -1
  110. package/dist/keystore/types.d.ts +2 -1
  111. package/dist/rln.d.ts +9 -52
  112. package/dist/rln.js +54 -163
  113. package/dist/rln.js.map +1 -1
  114. package/dist/types.d.ts +27 -0
  115. package/dist/types.js +2 -0
  116. package/dist/types.js.map +1 -0
  117. package/dist/zerokit.d.ts +3 -3
  118. package/dist/zerokit.js +5 -5
  119. package/dist/zerokit.js.map +1 -1
  120. package/package.json +1 -1
  121. package/src/codec.test-utils.ts +80 -0
  122. package/src/contract/abi.ts +502 -248
  123. package/src/contract/constants.ts +3 -3
  124. package/src/contract/errors.ts +75 -0
  125. package/src/contract/rln_base_contract.ts +500 -0
  126. package/src/contract/rln_contract.ts +102 -619
  127. package/src/contract/test-setup.ts +86 -0
  128. package/src/contract/test-utils.ts +179 -0
  129. package/src/contract/types.ts +48 -0
  130. package/src/create.ts +1 -1
  131. package/src/credentials_manager.ts +282 -0
  132. package/src/identity.ts +9 -0
  133. package/src/index.ts +17 -2
  134. package/src/keystore/keystore.ts +32 -46
  135. package/src/keystore/types.ts +2 -1
  136. package/src/rln.ts +67 -258
  137. package/src/types.ts +31 -0
  138. package/src/zerokit.ts +3 -3
@@ -0,0 +1,56 @@
1
+ import { expect } from "chai";
2
+ import { createRLN } from "./create.js";
3
+ export const TEST_CONSTANTS = {
4
+ contentTopic: "/test/1/waku-message/utf8",
5
+ emptyPubsubTopic: "",
6
+ defaultIndex: 0,
7
+ defaultPayload: new Uint8Array([1, 2, 3, 4, 5])
8
+ };
9
+ export const EMPTY_PROTO_MESSAGE = {
10
+ timestamp: undefined,
11
+ contentTopic: "",
12
+ ephemeral: undefined,
13
+ meta: undefined,
14
+ rateLimitProof: undefined,
15
+ version: undefined
16
+ };
17
+ /**
18
+ * Creates a basic RLN setup for codec tests
19
+ */
20
+ export async function createTestRLNCodecSetup() {
21
+ const rlnInstance = await createRLN();
22
+ const credential = rlnInstance.zerokit.generateIdentityCredentials();
23
+ rlnInstance.zerokit.insertMember(credential.IDCommitment);
24
+ return {
25
+ rlnInstance,
26
+ credential,
27
+ index: TEST_CONSTANTS.defaultIndex,
28
+ payload: TEST_CONSTANTS.defaultPayload
29
+ };
30
+ }
31
+ /**
32
+ * Creates a meta setter function for testing
33
+ */
34
+ export function createTestMetaSetter() {
35
+ return (msg) => {
36
+ const buffer = new ArrayBuffer(4);
37
+ const view = new DataView(buffer);
38
+ view.setUint32(0, msg.payload.length, false);
39
+ return new Uint8Array(buffer);
40
+ };
41
+ }
42
+ /**
43
+ * Verifies common RLN message properties
44
+ */
45
+ export function verifyRLNMessage(msg, payload, contentTopic, version, rlnInstance) {
46
+ expect(msg.rateLimitProof).to.not.be.undefined;
47
+ expect(msg.verify([rlnInstance.zerokit.getMerkleRoot()])).to.be.true;
48
+ expect(msg.verifyNoRoot()).to.be.true;
49
+ expect(msg.epoch).to.not.be.undefined;
50
+ expect(msg.epoch).to.be.gt(0);
51
+ expect(msg.contentTopic).to.eq(contentTopic);
52
+ expect(msg.msg.version).to.eq(version);
53
+ expect(msg.payload).to.deep.eq(payload);
54
+ expect(msg.timestamp).to.not.be.undefined;
55
+ }
56
+ //# sourceMappingURL=codec.test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.test-utils.js","sourceRoot":"","sources":["../src/codec.test-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,2BAA2B;IACzC,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,CAAC;IACf,cAAc,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CACvC,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,SAAS,EAAE,SAAS;IACpB,YAAY,EAAE,EAAE;IAChB,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,SAAS;IACf,cAAc,EAAE,SAAS;IACzB,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,MAAM,WAAW,GAAG,MAAM,SAAS,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC;IACrE,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE1D,OAAO;QACL,WAAW;QACX,UAAU;QACV,KAAK,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CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;AAC5C,CAAC"}
@@ -1,42 +1,46 @@
1
1
  export declare const RLN_ABI: ({
2
- type: string;
3
2
  inputs: never[];
4
3
  stateMutability: string;
4
+ type: string;
5
5
  name?: undefined;
6
- outputs?: undefined;
7
6
  anonymous?: undefined;
7
+ outputs?: undefined;
8
8
  } | {
9
- type: string;
10
- name: string;
11
9
  inputs: {
10
+ internalType: string;
12
11
  name: string;
13
12
  type: string;
14
13
  }[];
14
+ name: string;
15
+ type: string;
15
16
  stateMutability?: undefined;
16
- outputs?: undefined;
17
17
  anonymous?: undefined;
18
+ outputs?: undefined;
18
19
  } | {
19
- type: string;
20
- name: string;
20
+ anonymous: boolean;
21
21
  inputs: {
22
+ indexed: boolean;
23
+ internalType: string;
22
24
  name: string;
23
25
  type: string;
24
26
  }[];
25
- outputs: {
27
+ name: string;
28
+ type: string;
29
+ stateMutability?: undefined;
30
+ outputs?: undefined;
31
+ } | {
32
+ inputs: {
33
+ internalType: string;
26
34
  name: string;
27
35
  type: string;
28
36
  }[];
29
- stateMutability: string;
30
- anonymous?: undefined;
31
- } | {
32
- type: string;
33
37
  name: string;
34
- inputs: {
38
+ outputs: {
39
+ internalType: string;
35
40
  name: string;
36
41
  type: string;
37
- indexed: boolean;
38
42
  }[];
39
- anonymous: boolean;
40
- stateMutability?: undefined;
41
- outputs?: undefined;
43
+ stateMutability: string;
44
+ type: string;
45
+ anonymous?: undefined;
42
46
  })[];