@waku/rln 0.0.1 → 0.0.2-09108d9.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 (392) hide show
  1. package/README.md +12 -108
  2. package/bundle/_virtual/__node-resolve_empty.js +6 -0
  3. package/bundle/_virtual/_assert.js +3 -0
  4. package/bundle/_virtual/_commonjs-dynamic-modules.js +5 -0
  5. package/bundle/_virtual/_commonjsHelpers.js +32 -0
  6. package/bundle/_virtual/_node-resolve_empty.js +3 -0
  7. package/bundle/_virtual/_sha2.js +3 -0
  8. package/bundle/_virtual/_u64.js +3 -0
  9. package/bundle/_virtual/aes.js +3 -0
  10. package/bundle/_virtual/bn.js +3 -0
  11. package/bundle/_virtual/browser.js +3 -0
  12. package/bundle/_virtual/checksum.js +3 -0
  13. package/bundle/_virtual/cipher.js +3 -0
  14. package/bundle/_virtual/class.js +3 -0
  15. package/bundle/_virtual/common.js +3 -0
  16. package/bundle/_virtual/common2.js +3 -0
  17. package/bundle/_virtual/cryptoBrowser.js +3 -0
  18. package/bundle/_virtual/functional.js +3 -0
  19. package/bundle/_virtual/hash.js +3 -0
  20. package/bundle/_virtual/hmac.js +3 -0
  21. package/bundle/_virtual/index.js +3 -0
  22. package/bundle/_virtual/index2.js +6 -0
  23. package/bundle/_virtual/inherits_browser.js +3 -0
  24. package/bundle/_virtual/kdf.js +3 -0
  25. package/bundle/_virtual/lodash.js +3 -0
  26. package/bundle/_virtual/password.js +3 -0
  27. package/bundle/_virtual/pbkdf2.js +3 -0
  28. package/bundle/_virtual/pbkdf22.js +3 -0
  29. package/bundle/_virtual/random.js +3 -0
  30. package/bundle/_virtual/ripemd.js +3 -0
  31. package/bundle/_virtual/schema-validation-generated.js +3 -0
  32. package/bundle/_virtual/schema-validation.js +3 -0
  33. package/bundle/_virtual/scrypt.js +3 -0
  34. package/bundle/_virtual/scrypt2.js +3 -0
  35. package/bundle/_virtual/sha.js +3 -0
  36. package/bundle/_virtual/sha256.js +3 -0
  37. package/bundle/_virtual/sha2562.js +3 -0
  38. package/bundle/_virtual/sha3.js +3 -0
  39. package/bundle/_virtual/sha512.js +3 -0
  40. package/bundle/_virtual/types.js +3 -0
  41. package/bundle/_virtual/utils.js +3 -0
  42. package/bundle/_virtual/utils2.js +3 -0
  43. package/bundle/_virtual/utils3.js +3 -0
  44. package/bundle/index.js +11 -10
  45. package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +3 -0
  46. package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +96 -0
  47. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +148 -0
  48. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +26 -0
  49. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +20 -0
  50. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +210 -0
  51. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +18 -0
  52. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +30 -0
  53. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +26 -0
  54. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +22 -0
  55. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +43 -0
  56. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +19 -0
  57. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +58 -0
  58. package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +854 -0
  59. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +609 -0
  60. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +3 -0
  61. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +66 -0
  62. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +3 -0
  63. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +302 -0
  64. package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +3 -0
  65. package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +110 -0
  66. package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +20 -0
  67. package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +120 -0
  68. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +3 -0
  69. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +287 -0
  70. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +3 -0
  71. package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +402 -0
  72. package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +3 -0
  73. package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +8 -0
  74. package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +3 -0
  75. package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +3 -0
  76. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +893 -0
  77. package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +3 -0
  78. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +256 -0
  79. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +36 -0
  80. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +135 -0
  81. package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +8 -0
  82. package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +64 -0
  83. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +443 -0
  84. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +8 -0
  85. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +660 -0
  86. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +3 -0
  87. package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +352 -0
  88. package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +3 -0
  89. package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +248 -0
  90. package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +3 -0
  91. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +127 -0
  92. package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +3 -0
  93. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +2007 -0
  94. package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +422 -0
  95. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +674 -0
  96. package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +132 -0
  97. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +3 -0
  98. package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +120 -0
  99. package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +8 -0
  100. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +3 -0
  101. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +2430 -0
  102. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +76 -0
  103. package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +3 -0
  104. package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +219 -0
  105. package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +3 -0
  106. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +279 -0
  107. package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +3 -0
  108. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +69 -0
  109. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +404 -0
  110. package/bundle/node_modules/@multiformats/multiaddr/dist/src/convert.js +15 -0
  111. package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +20 -0
  112. package/bundle/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js +92 -0
  113. package/bundle/node_modules/@noble/hashes/esm/_assert.js +37 -0
  114. package/bundle/node_modules/@noble/hashes/esm/_md.js +132 -0
  115. package/bundle/node_modules/@noble/hashes/esm/_u64.js +29 -0
  116. package/bundle/node_modules/@noble/hashes/esm/sha256.js +113 -0
  117. package/bundle/node_modules/@noble/hashes/esm/sha3.js +210 -0
  118. package/bundle/node_modules/@noble/hashes/esm/utils.js +144 -0
  119. package/bundle/node_modules/@waku/zerokit-rln-wasm/rln_wasm.js +756 -0
  120. package/bundle/node_modules/bech32/index.js +187 -0
  121. package/bundle/node_modules/bn.js/lib/bn.js +3361 -0
  122. package/bundle/node_modules/debug/src/browser.js +283 -0
  123. package/bundle/node_modules/debug/src/common.js +295 -0
  124. package/bundle/node_modules/ethereum-cryptography/esm/keccak.js +10 -0
  125. package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +6 -0
  126. package/bundle/node_modules/ethereum-cryptography/esm/utils.js +24 -0
  127. package/bundle/node_modules/hash.js/lib/hash/common.js +97 -0
  128. package/bundle/node_modules/hash.js/lib/hash/hmac.js +51 -0
  129. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +152 -0
  130. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +81 -0
  131. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +33 -0
  132. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +113 -0
  133. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +39 -0
  134. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +336 -0
  135. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +53 -0
  136. package/bundle/node_modules/hash.js/lib/hash/sha.js +14 -0
  137. package/bundle/node_modules/hash.js/lib/hash/utils.js +282 -0
  138. package/bundle/node_modules/hash.js/lib/hash.js +33 -0
  139. package/bundle/node_modules/inherits/inherits_browser.js +33 -0
  140. package/bundle/node_modules/it-length-prefixed/dist/src/decode.js +6 -0
  141. package/bundle/node_modules/lodash/lodash.js +17207 -0
  142. package/bundle/node_modules/minimalistic-assert/index.js +13 -0
  143. package/bundle/node_modules/ms/index.js +172 -0
  144. package/bundle/node_modules/multiformats/dist/src/bases/base.js +205 -0
  145. package/bundle/node_modules/multiformats/dist/src/bases/base10.js +9 -0
  146. package/bundle/node_modules/multiformats/dist/src/bases/base16.js +16 -0
  147. package/bundle/node_modules/multiformats/dist/src/bases/base2.js +10 -0
  148. package/bundle/node_modules/multiformats/dist/src/bases/base256emoji.js +41 -0
  149. package/bundle/node_modules/multiformats/dist/src/bases/base32.js +58 -0
  150. package/bundle/node_modules/multiformats/dist/src/bases/base36.js +14 -0
  151. package/bundle/node_modules/multiformats/dist/src/bases/base58.js +14 -0
  152. package/bundle/node_modules/multiformats/dist/src/bases/base64.js +28 -0
  153. package/bundle/node_modules/multiformats/dist/src/bases/base8.js +10 -0
  154. package/bundle/node_modules/multiformats/dist/src/bases/identity.js +11 -0
  155. package/bundle/node_modules/multiformats/dist/src/basics.js +15 -0
  156. package/bundle/node_modules/multiformats/dist/src/bytes.js +18 -0
  157. package/bundle/node_modules/multiformats/dist/src/codecs/json.js +2 -0
  158. package/bundle/node_modules/multiformats/dist/src/vendor/base-x.js +170 -0
  159. package/bundle/node_modules/protons-runtime/dist/src/codec.js +20 -0
  160. package/bundle/node_modules/protons-runtime/dist/src/codecs/enum.js +24 -0
  161. package/bundle/node_modules/protons-runtime/dist/src/codecs/message.js +7 -0
  162. package/bundle/node_modules/protons-runtime/dist/src/decode.js +8 -0
  163. package/bundle/node_modules/protons-runtime/dist/src/encode.js +11 -0
  164. package/bundle/node_modules/protons-runtime/dist/src/index.js +30 -0
  165. package/bundle/node_modules/protons-runtime/dist/src/utils/float.js +54 -0
  166. package/bundle/node_modules/protons-runtime/dist/src/utils/longbits.js +175 -0
  167. package/bundle/node_modules/protons-runtime/dist/src/utils/pool.js +28 -0
  168. package/bundle/node_modules/protons-runtime/dist/src/utils/reader.js +367 -0
  169. package/bundle/node_modules/protons-runtime/dist/src/utils/utf8.js +99 -0
  170. package/bundle/node_modules/protons-runtime/dist/src/utils/writer.js +438 -0
  171. package/bundle/node_modules/uint8-varint/dist/src/index.js +124 -0
  172. package/bundle/node_modules/uint8arrays/dist/src/alloc.js +17 -0
  173. package/bundle/node_modules/uint8arrays/dist/src/from-string.js +19 -0
  174. package/bundle/node_modules/uint8arrays/dist/src/util/bases.js +49 -0
  175. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +21 -0
  176. package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +18 -0
  177. package/bundle/packages/core/dist/lib/filter/filter.js +27 -0
  178. package/bundle/packages/core/dist/lib/light_push/light_push.js +27 -0
  179. package/bundle/packages/core/dist/lib/message/version_0.js +154 -0
  180. package/bundle/packages/core/dist/lib/metadata/metadata.js +27 -0
  181. package/bundle/packages/core/dist/lib/store/store.js +27 -0
  182. package/bundle/packages/interfaces/dist/connection_manager.js +19 -0
  183. package/bundle/packages/interfaces/dist/constants.js +6 -0
  184. package/bundle/packages/interfaces/dist/health_indicator.js +12 -0
  185. package/bundle/packages/interfaces/dist/protocols.js +92 -0
  186. package/bundle/packages/proto/dist/generated/filter.js +445 -0
  187. package/bundle/packages/proto/dist/generated/filter_v2.js +424 -0
  188. package/bundle/packages/proto/dist/generated/light_push.js +389 -0
  189. package/bundle/packages/proto/dist/generated/message.js +213 -0
  190. package/bundle/packages/proto/dist/generated/metadata.js +130 -0
  191. package/bundle/packages/proto/dist/generated/peer_exchange.js +209 -0
  192. package/bundle/packages/proto/dist/generated/sds_message.js +105 -0
  193. package/bundle/packages/proto/dist/generated/store_v3.js +490 -0
  194. package/bundle/packages/proto/dist/generated/topic_only_message.js +61 -0
  195. package/bundle/packages/rln/dist/codec.js +93 -0
  196. package/bundle/packages/rln/dist/contract/constants.js +68 -0
  197. package/bundle/packages/rln/dist/contract/rln_contract.js +218 -0
  198. package/bundle/packages/rln/dist/create.js +9 -0
  199. package/bundle/packages/rln/dist/identity.js +30 -0
  200. package/bundle/packages/rln/dist/keystore/cipher.js +31 -0
  201. package/bundle/packages/rln/dist/keystore/credential_validation_generated.js +119 -0
  202. package/bundle/packages/rln/dist/keystore/keystore.js +223 -0
  203. package/bundle/packages/rln/dist/keystore/keystore_validation_generated.js +74 -0
  204. package/bundle/packages/rln/dist/keystore/schema_validator.js +20 -0
  205. package/bundle/packages/rln/dist/message.js +51 -0
  206. package/bundle/packages/rln/dist/proof.js +54 -0
  207. package/bundle/packages/rln/dist/resources/verification_key.js +112 -0
  208. package/bundle/packages/rln/dist/resources/witness_calculator.js +330 -0
  209. package/bundle/packages/rln/dist/rln.js +206 -0
  210. package/bundle/packages/rln/dist/root_tracker.js +76 -0
  211. package/bundle/packages/rln/dist/utils/bytes.js +65 -0
  212. package/bundle/packages/rln/dist/utils/epoch.js +39 -0
  213. package/bundle/packages/rln/dist/utils/hash.js +10 -0
  214. package/bundle/packages/rln/dist/utils/metamask.js +14 -0
  215. package/bundle/packages/rln/dist/zerokit.js +108 -0
  216. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +52 -0
  217. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +65 -0
  218. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +99 -0
  219. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +103 -0
  220. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/index.js +28 -0
  221. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +78 -0
  222. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +17 -0
  223. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1253 -0
  224. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +40 -0
  225. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/types.js +5 -0
  226. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +103 -0
  227. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +41 -0
  228. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +17 -0
  229. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +23 -0
  230. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +12 -0
  231. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +77 -0
  232. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +9 -0
  233. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +215 -0
  234. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +3 -0
  235. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +35 -0
  236. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +3 -0
  237. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +21 -0
  238. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
  239. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
  240. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +96 -0
  241. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +6 -0
  242. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +66 -0
  243. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +24 -0
  244. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +6 -0
  245. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +7 -0
  246. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +11 -0
  247. package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +52 -0
  248. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +124 -0
  249. package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +71 -0
  250. package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +10 -0
  251. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +88 -0
  252. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +99 -0
  253. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +233 -0
  254. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +133 -0
  255. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +243 -0
  256. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +167 -0
  257. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/native.js +4 -0
  258. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/rng.js +13 -0
  259. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/stringify.js +28 -0
  260. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/v4.js +19 -0
  261. package/bundle/packages/utils/dist/bytes/index.js +44 -0
  262. package/bundle/packages/utils/dist/common/sharding/index.js +91 -0
  263. package/bundle/packages/utils/dist/logger/index.js +31 -0
  264. package/bundle/resources/rln.wasm +0 -0
  265. package/bundle/resources/rln_final.zkey +0 -0
  266. package/bundle/resources/verification_key.d.ts +13 -0
  267. package/bundle/resources/verification_key.js +112 -0
  268. package/bundle/resources/witness_calculator.d.ts +11 -0
  269. package/bundle/resources/witness_calculator.js +328 -0
  270. package/dist/.tsbuildinfo +1 -1
  271. package/dist/codec.d.ts +39 -0
  272. package/dist/codec.js +77 -0
  273. package/dist/codec.js.map +1 -0
  274. package/dist/contract/constants.d.ts +7 -0
  275. package/dist/contract/constants.js +67 -0
  276. package/dist/contract/constants.js.map +1 -0
  277. package/dist/contract/index.d.ts +2 -0
  278. package/dist/contract/index.js +3 -0
  279. package/dist/contract/index.js.map +1 -0
  280. package/dist/contract/rln_contract.d.ts +46 -0
  281. package/dist/contract/rln_contract.js +211 -0
  282. package/dist/contract/rln_contract.js.map +1 -0
  283. package/dist/create.d.ts +2 -0
  284. package/dist/create.js +8 -0
  285. package/dist/create.js.map +1 -0
  286. package/dist/identity.d.ts +9 -0
  287. package/dist/identity.js +27 -0
  288. package/dist/identity.js.map +1 -0
  289. package/dist/index.d.ts +11 -2
  290. package/dist/index.js +11 -8
  291. package/dist/index.js.map +1 -1
  292. package/dist/keystore/cipher.d.ts +4 -0
  293. package/dist/keystore/cipher.js +28 -0
  294. package/dist/keystore/cipher.js.map +1 -0
  295. package/dist/keystore/credential_validation_generated.d.ts +8 -0
  296. package/dist/keystore/credential_validation_generated.js +121 -0
  297. package/dist/keystore/credential_validation_generated.js.map +1 -0
  298. package/dist/keystore/index.d.ts +4 -0
  299. package/dist/keystore/index.js +3 -0
  300. package/dist/keystore/index.js.map +1 -0
  301. package/dist/keystore/keystore.d.ts +50 -0
  302. package/dist/keystore/keystore.js +205 -0
  303. package/dist/keystore/keystore.js.map +1 -0
  304. package/dist/keystore/keystore_validation_generated.d.ts +8 -0
  305. package/dist/keystore/keystore_validation_generated.js +75 -0
  306. package/dist/keystore/keystore_validation_generated.js.map +1 -0
  307. package/dist/keystore/schema_validator.d.ts +2 -0
  308. package/dist/keystore/schema_validator.js +18 -0
  309. package/dist/keystore/schema_validator.js.map +1 -0
  310. package/dist/keystore/types.d.ts +29 -0
  311. package/dist/keystore/types.js +2 -0
  312. package/dist/keystore/types.js.map +1 -0
  313. package/dist/message.d.ts +18 -0
  314. package/dist/message.js +49 -0
  315. package/dist/message.js.map +1 -0
  316. package/dist/proof.d.ts +21 -0
  317. package/dist/proof.js +50 -0
  318. package/dist/proof.js.map +1 -0
  319. package/dist/resources/rln.wasm +0 -0
  320. package/dist/resources/rln_final.zkey +0 -0
  321. package/dist/resources/verification_key.d.ts +13 -0
  322. package/dist/resources/verification_key.js +112 -0
  323. package/dist/resources/witness_calculator.d.ts +11 -0
  324. package/dist/resources/witness_calculator.js +328 -0
  325. package/dist/rln.d.ts +55 -13
  326. package/dist/rln.js +164 -79
  327. package/dist/rln.js.map +1 -1
  328. package/dist/root_tracker.d.ts +10 -0
  329. package/dist/root_tracker.js +75 -0
  330. package/dist/root_tracker.js.map +1 -0
  331. package/dist/utils/bytes.d.ts +20 -0
  332. package/dist/utils/bytes.js +64 -0
  333. package/dist/utils/bytes.js.map +1 -0
  334. package/dist/utils/epoch.d.ts +3 -0
  335. package/dist/utils/epoch.js +23 -0
  336. package/dist/utils/epoch.js.map +1 -0
  337. package/dist/utils/hash.d.ts +2 -0
  338. package/dist/utils/hash.js +13 -0
  339. package/dist/utils/hash.js.map +1 -0
  340. package/dist/utils/index.d.ts +4 -0
  341. package/dist/utils/index.js +5 -0
  342. package/dist/utils/index.js.map +1 -0
  343. package/dist/utils/metamask.d.ts +2 -0
  344. package/dist/utils/metamask.js +12 -0
  345. package/dist/utils/metamask.js.map +1 -0
  346. package/dist/zerokit.d.ts +19 -0
  347. package/dist/zerokit.js +105 -0
  348. package/dist/zerokit.js.map +1 -0
  349. package/package.json +1 -126
  350. package/src/codec.ts +134 -0
  351. package/src/contract/constants.ts +68 -0
  352. package/src/contract/index.ts +2 -0
  353. package/src/contract/rln_contract.ts +353 -0
  354. package/src/create.ts +9 -0
  355. package/src/identity.ts +31 -0
  356. package/src/index.ts +29 -10
  357. package/src/keystore/cipher.ts +54 -0
  358. package/src/keystore/credential_validation_generated.ts +7 -0
  359. package/src/keystore/index.ts +5 -0
  360. package/src/keystore/keystore.ts +330 -0
  361. package/src/keystore/keystore_validation_generated.ts +7 -0
  362. package/src/keystore/schema_validator.ts +34 -0
  363. package/src/keystore/types.ts +36 -0
  364. package/src/message.ts +70 -0
  365. package/src/proof.ts +69 -0
  366. package/src/resources/verification_key.d.ts +13 -0
  367. package/src/resources/witness_calculator.d.ts +11 -0
  368. package/src/rln.ts +266 -104
  369. package/src/root_tracker.ts +92 -0
  370. package/src/utils/bytes.ts +84 -0
  371. package/src/utils/epoch.ts +30 -0
  372. package/src/utils/hash.ts +15 -0
  373. package/src/utils/index.ts +9 -0
  374. package/src/utils/metamask.ts +17 -0
  375. package/src/zerokit.ts +184 -0
  376. package/bundle/02bce7e5f3bcf834.wasm +0 -0
  377. package/bundle/rln-f87f6dbe.js +0 -563
  378. package/dist/resources.d.ts +0 -4
  379. package/dist/resources.js +0 -5
  380. package/dist/resources.js.map +0 -1
  381. package/dist/witness_calculator.d.ts +0 -16
  382. package/dist/witness_calculator.js +0 -291
  383. package/dist/witness_calculator.js.map +0 -1
  384. package/dist/zerokit/rln_wasm.d.ts +0 -1
  385. package/dist/zerokit/rln_wasm.js +0 -2
  386. package/dist/zerokit/rln_wasm.js.map +0 -1
  387. package/dist/zerokit/rln_wasm_bg.d.ts +0 -108
  388. package/dist/zerokit/rln_wasm_bg.js +0 -592
  389. package/dist/zerokit/rln_wasm_bg.js.map +0 -1
  390. package/dist/zerokit/rln_wasm_bg.wasm +0 -0
  391. package/src/resources.ts +0 -10
  392. package/src/witness_calculator.d.ts +0 -4
@@ -0,0 +1,105 @@
1
+ import * as zerokitRLN from "@waku/zerokit-rln-wasm";
2
+ import { IdentityCredential } from "./identity.js";
3
+ import { Proof, proofToBytes } from "./proof.js";
4
+ import { concatenate, dateToEpoch, epochIntToBytes, writeUIntLE } from "./utils/index.js";
5
+ export class Zerokit {
6
+ zkRLN;
7
+ witnessCalculator;
8
+ constructor(zkRLN, witnessCalculator) {
9
+ this.zkRLN = zkRLN;
10
+ this.witnessCalculator = witnessCalculator;
11
+ }
12
+ generateIdentityCredentials() {
13
+ const memKeys = zerokitRLN.generateExtendedMembershipKey(this.zkRLN); // TODO: rename this function in zerokit rln-wasm
14
+ return IdentityCredential.fromBytes(memKeys);
15
+ }
16
+ generateSeededIdentityCredential(seed) {
17
+ const stringEncoder = new TextEncoder();
18
+ const seedBytes = stringEncoder.encode(seed);
19
+ // TODO: rename this function in zerokit rln-wasm
20
+ const memKeys = zerokitRLN.generateSeededExtendedMembershipKey(this.zkRLN, seedBytes);
21
+ return IdentityCredential.fromBytes(memKeys);
22
+ }
23
+ insertMember(idCommitment) {
24
+ zerokitRLN.insertMember(this.zkRLN, idCommitment);
25
+ }
26
+ insertMembers(index, ...idCommitments) {
27
+ // serializes a seq of IDCommitments to a byte seq
28
+ // the order of serialization is |id_commitment_len<8>|id_commitment<var>|
29
+ const idCommitmentLen = writeUIntLE(new Uint8Array(8), idCommitments.length, 0, 8);
30
+ const idCommitmentBytes = concatenate(idCommitmentLen, ...idCommitments);
31
+ zerokitRLN.setLeavesFrom(this.zkRLN, index, idCommitmentBytes);
32
+ }
33
+ deleteMember(index) {
34
+ zerokitRLN.deleteLeaf(this.zkRLN, index);
35
+ }
36
+ getMerkleRoot() {
37
+ return zerokitRLN.getRoot(this.zkRLN);
38
+ }
39
+ serializeMessage(uint8Msg, memIndex, epoch, idKey) {
40
+ // calculate message length
41
+ const msgLen = writeUIntLE(new Uint8Array(8), uint8Msg.length, 0, 8);
42
+ // Converting index to LE bytes
43
+ const memIndexBytes = writeUIntLE(new Uint8Array(8), memIndex, 0, 8);
44
+ // [ id_key<32> | id_index<8> | epoch<32> | signal_len<8> | signal<var> ]
45
+ return concatenate(idKey, memIndexBytes, epoch, msgLen, uint8Msg);
46
+ }
47
+ async generateRLNProof(msg, index, epoch, idSecretHash) {
48
+ if (epoch === undefined) {
49
+ epoch = epochIntToBytes(dateToEpoch(new Date()));
50
+ }
51
+ else if (epoch instanceof Date) {
52
+ epoch = epochIntToBytes(dateToEpoch(epoch));
53
+ }
54
+ if (epoch.length !== 32)
55
+ throw new Error("invalid epoch");
56
+ if (idSecretHash.length !== 32)
57
+ throw new Error("invalid id secret hash");
58
+ if (index < 0)
59
+ throw new Error("index must be >= 0");
60
+ const serialized_msg = this.serializeMessage(msg, index, epoch, idSecretHash);
61
+ const rlnWitness = zerokitRLN.getSerializedRLNWitness(this.zkRLN, serialized_msg);
62
+ const inputs = zerokitRLN.RLNWitnessToJson(this.zkRLN, rlnWitness);
63
+ const calculatedWitness = await this.witnessCalculator.calculateWitness(inputs, false); // no sanity check being used in zerokit
64
+ const proofBytes = zerokitRLN.generate_rln_proof_with_witness(this.zkRLN, calculatedWitness, rlnWitness);
65
+ return new Proof(proofBytes);
66
+ }
67
+ verifyRLNProof(proof, msg) {
68
+ let pBytes;
69
+ if (proof instanceof Uint8Array) {
70
+ pBytes = proof;
71
+ }
72
+ else {
73
+ pBytes = proofToBytes(proof);
74
+ }
75
+ // calculate message length
76
+ const msgLen = writeUIntLE(new Uint8Array(8), msg.length, 0, 8);
77
+ return zerokitRLN.verifyRLNProof(this.zkRLN, concatenate(pBytes, msgLen, msg));
78
+ }
79
+ verifyWithRoots(proof, msg, ...roots) {
80
+ let pBytes;
81
+ if (proof instanceof Uint8Array) {
82
+ pBytes = proof;
83
+ }
84
+ else {
85
+ pBytes = proofToBytes(proof);
86
+ }
87
+ // calculate message length
88
+ const msgLen = writeUIntLE(new Uint8Array(8), msg.length, 0, 8);
89
+ const rootsBytes = concatenate(...roots);
90
+ return zerokitRLN.verifyWithRoots(this.zkRLN, concatenate(pBytes, msgLen, msg), rootsBytes);
91
+ }
92
+ verifyWithNoRoot(proof, msg) {
93
+ let pBytes;
94
+ if (proof instanceof Uint8Array) {
95
+ pBytes = proof;
96
+ }
97
+ else {
98
+ pBytes = proofToBytes(proof);
99
+ }
100
+ // calculate message length
101
+ const msgLen = writeUIntLE(new Uint8Array(8), msg.length, 0, 8);
102
+ return zerokitRLN.verifyWithRoots(this.zkRLN, concatenate(pBytes, msgLen, msg), new Uint8Array());
103
+ }
104
+ }
105
+ //# sourceMappingURL=zerokit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zerokit.js","sourceRoot":"","sources":["../src/zerokit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EACL,WAAW,EACX,WAAW,EACX,eAAe,EACf,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,OAAO;IAEC;IACA;IAFnB,YACmB,KAAa,EACb,iBAAoC;QADpC,UAAK,GAAL,KAAK,CAAQ;QACb,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEG,2BAA2B;QAChC,MAAM,OAAO,GAAG,UAAU,CAAC,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,iDAAiD;QACvH,OAAO,kBAAkB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEM,gCAAgC,CAAC,IAAY;QAClD,MAAM,aAAa,GAAG,IAAI,WAAW,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7C,iDAAiD;QACjD,MAAM,OAAO,GAAG,UAAU,CAAC,mCAAmC,CAC5D,IAAI,CAAC,KAAK,EACV,SAAS,CACV,CAAC;QACF,OAAO,kBAAkB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEM,YAAY,CAAC,YAAwB;QAC1C,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC;IAEM,aAAa,CAClB,KAAa,EACb,GAAG,aAAgC;QAEnC,kDAAkD;QAClD,0EAA0E;QAC1E,MAAM,eAAe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C;CACF"}
package/package.json CHANGED
@@ -1,126 +1 @@
1
- {
2
- "name": "@waku/rln",
3
- "version": "0.0.1",
4
- "description": "Rate Limit Nullifier for js-waku",
5
- "types": "./dist/index.d.ts",
6
- "module": "./dist/index.js",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js"
11
- }
12
- },
13
- "type": "module",
14
- "repository": "https://github.com/waku-org/js-rln",
15
- "license": "MIT OR Apache-2.0",
16
- "keywords": [
17
- "waku",
18
- "decentralised",
19
- "communication",
20
- "web3",
21
- "ethereum",
22
- "dapps"
23
- ],
24
- "scripts": {
25
- "prepare": "husky install",
26
- "build": "run-s build:**",
27
- "build:tsc": "tsc",
28
- "build:bundle": "rollup --config rollup.config.js",
29
- "size": "npm run build && size-limit",
30
- "fix": "run-s fix:*",
31
- "fix:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.*js\" \".github/**/*.yml\" --write",
32
- "fix:lint": "eslint src --ext .ts --ext .cjs --fix",
33
- "test": "run-s test:*",
34
- "test:lint": "eslint src --ext .ts",
35
- "test:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.*js\" \".github/**/*.yml\" --list-different",
36
- "test:spelling": "cspell \"{*.md,.github/*.md,src/**/*.ts}\"",
37
- "test:tsc": "tsc -p tsconfig.dev.json",
38
- "test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
39
- "test:browser": "karma start karma.conf.cjs",
40
- "watch:build": "tsc -p tsconfig.json -w",
41
- "watch:test": "mocha --watch",
42
- "prepublish": "npm run build",
43
- "reset-hard": "git clean -dfx && git reset --hard && npm i && npm run build"
44
- },
45
- "browser": {
46
- "crypto": false
47
- },
48
- "engines": {
49
- "node": ">=16"
50
- },
51
- "publishConfig": {
52
- "access": "public",
53
- "registry": "https://registry.npmjs.org/"
54
- },
55
- "devDependencies": {
56
- "@rollup/plugin-commonjs": "^22.0.2",
57
- "@rollup/plugin-json": "^4.1.0",
58
- "@rollup/plugin-node-resolve": "^13.3.0",
59
- "@rollup/plugin-wasm": "^5.2.0",
60
- "@size-limit/preset-big-lib": "^8.0.0",
61
- "@types/app-root-path": "^1.2.4",
62
- "@types/chai": "^4.2.15",
63
- "@types/debug": "^4.1.7",
64
- "@types/mocha": "^9.1.0",
65
- "@types/node": "^17.0.6",
66
- "@types/tail": "^2.0.0",
67
- "@types/uuid": "^8.3.0",
68
- "@typescript-eslint/eslint-plugin": "^5.8.1",
69
- "@typescript-eslint/parser": "^5.8.1",
70
- "app-root-path": "^3.0.0",
71
- "chai": "^4.3.4",
72
- "cspell": "^5.14.0",
73
- "eslint": "^8.6.0",
74
- "eslint-config-prettier": "^8.3.0",
75
- "eslint-plugin-eslint-comments": "^3.2.0",
76
- "eslint-plugin-functional": "^4.0.2",
77
- "eslint-plugin-import": "^2.25.3",
78
- "eslint-plugin-prettier": "^4.0.0",
79
- "fast-check": "^2.14.0",
80
- "gh-pages": "^3.2.3",
81
- "husky": "^7.0.4",
82
- "ignore-loader": "^0.1.2",
83
- "isomorphic-fetch": "^3.0.0",
84
- "jsdom": "^19.0.0",
85
- "jsdom-global": "^3.0.2",
86
- "karma": "^6.3.12",
87
- "karma-chrome-launcher": "^3.1.0",
88
- "karma-mocha": "^2.0.1",
89
- "karma-webpack": "^5.0.0",
90
- "lint-staged": "^13.0.3",
91
- "mocha": "^9.1.3",
92
- "npm-run-all": "^4.1.5",
93
- "p-timeout": "^4.1.0",
94
- "prettier": "^2.1.1",
95
- "process": "^0.11.10",
96
- "puppeteer": "^13.0.1",
97
- "rollup": "^2.75.0",
98
- "rollup-plugin-copy": "^3.4.0",
99
- "size-limit": "^8.0.0",
100
- "tail": "^2.2.0",
101
- "ts-loader": "^9.3.1",
102
- "ts-node": "^10.9.1",
103
- "typedoc": "^0.23.10",
104
- "typescript": "^4.5.5"
105
- },
106
- "files": [
107
- "dist",
108
- "bundle",
109
- "src/*.ts",
110
- "src/lib/**/*.ts",
111
- "src/proto/**/*.ts",
112
- "!**/*.spec.*",
113
- "!**/*.json",
114
- "CHANGELOG.md",
115
- "LICENSE",
116
- "README.md"
117
- ],
118
- "lint-staged": {
119
- "*.ts": [
120
- "eslint --fix"
121
- ],
122
- "*.{ts,md,json,conf*.*js}": [
123
- "prettier --write"
124
- ]
125
- }
126
- }
1
+ {"name":"@waku/rln","version":"0.0.2-09108d9.0","description":"RLN (Rate Limiting Nullifier) implementation for Waku","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/rln#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","rln","rate-limiting","privacy","web3"],"scripts":{"build":"run-s build:**","build:copy":"mkdir -p dist/resources && cp -r src/resources/* dist/resources/","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint \"src/!(resources)/**/*.{ts,js}\" *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"NODE_ENV=test run-s test:*","test:browser":"karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=20"},"devDependencies":{"@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^5.0.1","@types/chai-spies":"^1.0.6","@types/deep-equal-in-any-order":"^1.0.4","@types/lodash":"^4.17.15","@waku/build-utils":"^1.0.0","@waku/message-encryption":"0.0.32-09108d9.0","chai":"^5.1.2","chai-as-promised":"^8.0.1","chai-spies":"^1.1.0","chai-subset":"^1.6.0","deep-equal-in-any-order":"^2.0.6","fast-check":"^3.23.2","rollup-plugin-copy":"^3.5.0"},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"],"dependencies":{"@chainsafe/bls-keystore":"3.0.0","@waku/core":"0.0.34-09108d9.0","@waku/utils":"0.0.22-09108d9.0","@waku/zerokit-rln-wasm":"^0.0.13","ethereum-cryptography":"^3.1.0","ethers":"^5.7.2","lodash":"^4.17.21","uuid":"^11.0.5"}}
package/src/codec.ts ADDED
@@ -0,0 +1,134 @@
1
+ import type {
2
+ IDecodedMessage,
3
+ IDecoder,
4
+ IEncoder,
5
+ IMessage,
6
+ IProtoMessage,
7
+ IRateLimitProof
8
+ } from "@waku/interfaces";
9
+ import { Logger } from "@waku/utils";
10
+
11
+ import type { IdentityCredential } from "./identity.js";
12
+ import { RlnMessage, toRLNSignal } from "./message.js";
13
+ import { RLNInstance } from "./rln.js";
14
+
15
+ const log = new Logger("waku:rln:encoder");
16
+
17
+ export class RLNEncoder implements IEncoder {
18
+ private readonly idSecretHash: Uint8Array;
19
+
20
+ public constructor(
21
+ private readonly encoder: IEncoder,
22
+ private readonly rlnInstance: RLNInstance,
23
+ private readonly index: number,
24
+ identityCredential: IdentityCredential
25
+ ) {
26
+ if (index < 0) throw new Error("Invalid membership index");
27
+ this.idSecretHash = identityCredential.IDSecretHash;
28
+ }
29
+
30
+ public async toWire(message: IMessage): Promise<Uint8Array | undefined> {
31
+ message.rateLimitProof = await this.generateProof(message);
32
+ log.info("Proof generated", message.rateLimitProof);
33
+ return this.encoder.toWire(message);
34
+ }
35
+
36
+ public async toProtoObj(
37
+ message: IMessage
38
+ ): Promise<IProtoMessage | undefined> {
39
+ const protoMessage = await this.encoder.toProtoObj(message);
40
+ if (!protoMessage) return;
41
+
42
+ protoMessage.contentTopic = this.contentTopic;
43
+ protoMessage.rateLimitProof = await this.generateProof(message);
44
+ log.info("Proof generated", protoMessage.rateLimitProof);
45
+ return protoMessage;
46
+ }
47
+
48
+ private async generateProof(message: IMessage): Promise<IRateLimitProof> {
49
+ const signal = toRLNSignal(this.contentTopic, message);
50
+ const proof = await this.rlnInstance.zerokit.generateRLNProof(
51
+ signal,
52
+ this.index,
53
+ message.timestamp,
54
+ this.idSecretHash
55
+ );
56
+ return proof;
57
+ }
58
+
59
+ public get pubsubTopic(): string {
60
+ return this.encoder.pubsubTopic;
61
+ }
62
+
63
+ public get contentTopic(): string {
64
+ return this.encoder.contentTopic;
65
+ }
66
+
67
+ public get ephemeral(): boolean {
68
+ return this.encoder.ephemeral;
69
+ }
70
+ }
71
+
72
+ type RLNEncoderOptions = {
73
+ encoder: IEncoder;
74
+ rlnInstance: RLNInstance;
75
+ index: number;
76
+ credential: IdentityCredential;
77
+ };
78
+
79
+ export const createRLNEncoder = (options: RLNEncoderOptions): RLNEncoder => {
80
+ return new RLNEncoder(
81
+ options.encoder,
82
+ options.rlnInstance,
83
+ options.index,
84
+ options.credential
85
+ );
86
+ };
87
+
88
+ export class RLNDecoder<T extends IDecodedMessage>
89
+ implements IDecoder<RlnMessage<T>>
90
+ {
91
+ public constructor(
92
+ private readonly rlnInstance: RLNInstance,
93
+ private readonly decoder: IDecoder<T>
94
+ ) {}
95
+
96
+ public get pubsubTopic(): string {
97
+ return this.decoder.pubsubTopic;
98
+ }
99
+
100
+ public get contentTopic(): string {
101
+ return this.decoder.contentTopic;
102
+ }
103
+
104
+ public fromWireToProtoObj(
105
+ bytes: Uint8Array
106
+ ): Promise<IProtoMessage | undefined> {
107
+ const protoMessage = this.decoder.fromWireToProtoObj(bytes);
108
+ log.info("Message decoded", protoMessage);
109
+ return Promise.resolve(protoMessage);
110
+ }
111
+
112
+ public async fromProtoObj(
113
+ pubsubTopic: string,
114
+ proto: IProtoMessage
115
+ ): Promise<RlnMessage<T> | undefined> {
116
+ const msg: T | undefined = await this.decoder.fromProtoObj(
117
+ pubsubTopic,
118
+ proto
119
+ );
120
+ if (!msg) return;
121
+ return new RlnMessage(this.rlnInstance, msg, proto.rateLimitProof);
122
+ }
123
+ }
124
+
125
+ type RLNDecoderOptions<T extends IDecodedMessage> = {
126
+ decoder: IDecoder<T>;
127
+ rlnInstance: RLNInstance;
128
+ };
129
+
130
+ export const createRLNDecoder = <T extends IDecodedMessage>(
131
+ options: RLNDecoderOptions<T>
132
+ ): RLNDecoder<T> => {
133
+ return new RLNDecoder(options.rlnInstance, options.decoder);
134
+ };
@@ -0,0 +1,68 @@
1
+ // ref https://github.com/waku-org/waku-rln-contract/blob/19fded82bca07e7b535b429dc507cfb83f10dfcf/deployments/sepolia/WakuRlnRegistry_Implementation.json#L3
2
+ export const RLN_REGISTRY_ABI = [
3
+ "error IncompatibleStorage()",
4
+ "error IncompatibleStorageIndex()",
5
+ "error NoStorageContractAvailable()",
6
+ "error StorageAlreadyExists(address storageAddress)",
7
+ "event AdminChanged(address previousAdmin, address newAdmin)",
8
+ "event BeaconUpgraded(address indexed beacon)",
9
+ "event Initialized(uint8 version)",
10
+ "event NewStorageContract(uint16 index, address storageAddress)",
11
+ "event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
12
+ "event Upgraded(address indexed implementation)",
13
+ "function forceProgress()",
14
+ "function initialize(address _poseidonHasher)",
15
+ "function newStorage()",
16
+ "function nextStorageIndex() view returns (uint16)",
17
+ "function owner() view returns (address)",
18
+ "function poseidonHasher() view returns (address)",
19
+ "function proxiableUUID() view returns (bytes32)",
20
+ "function register(uint16 storageIndex, uint256 commitment)",
21
+ "function register(uint256[] commitments)",
22
+ "function register(uint16 storageIndex, uint256[] commitments)",
23
+ "function registerStorage(address storageAddress)",
24
+ "function renounceOwnership()",
25
+ "function storages(uint16) view returns (address)",
26
+ "function transferOwnership(address newOwner)",
27
+ "function upgradeTo(address newImplementation)",
28
+ "function upgradeToAndCall(address newImplementation, bytes data) payable",
29
+ "function usingStorageIndex() view returns (uint16)"
30
+ ];
31
+
32
+ // ref https://github.com/waku-org/waku-rln-contract/blob/19fded82bca07e7b535b429dc507cfb83f10dfcf/deployments/sepolia/WakuRlnStorage_0.json#L3
33
+ export const RLN_STORAGE_ABI = [
34
+ "constructor(address _poseidonHasher, uint16 _contractIndex)",
35
+ "error DuplicateIdCommitment()",
36
+ "error FullTree()",
37
+ "error InvalidIdCommitment(uint256 idCommitment)",
38
+ "error NotImplemented()",
39
+ "event MemberRegistered(uint256 idCommitment, uint256 index)",
40
+ "event MemberWithdrawn(uint256 idCommitment, uint256 index)",
41
+ "event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
42
+ "function DEPTH() view returns (uint256)",
43
+ "function MEMBERSHIP_DEPOSIT() view returns (uint256)",
44
+ "function SET_SIZE() view returns (uint256)",
45
+ "function contractIndex() view returns (uint16)",
46
+ "function deployedBlockNumber() view returns (uint32)",
47
+ "function idCommitmentIndex() view returns (uint256)",
48
+ "function isValidCommitment(uint256 idCommitment) view returns (bool)",
49
+ "function memberExists(uint256) view returns (bool)",
50
+ "function members(uint256) view returns (uint256)",
51
+ "function owner() view returns (address)",
52
+ "function poseidonHasher() view returns (address)",
53
+ "function register(uint256[] idCommitments)",
54
+ "function register(uint256 idCommitment) payable",
55
+ "function renounceOwnership()",
56
+ "function slash(uint256 idCommitment, address receiver, uint256[8] proof) pure",
57
+ "function stakedAmounts(uint256) view returns (uint256)",
58
+ "function transferOwnership(address newOwner)",
59
+ "function verifier() view returns (address)",
60
+ "function withdraw() pure",
61
+ "function withdrawalBalance(address) view returns (uint256)"
62
+ ];
63
+
64
+ export const SEPOLIA_CONTRACT = {
65
+ chainId: 11155111,
66
+ address: "0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4",
67
+ abi: RLN_REGISTRY_ABI
68
+ };
@@ -0,0 +1,2 @@
1
+ export { RLNContract } from "./rln_contract.js";
2
+ export * from "./constants.js";