@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,211 @@
1
+ import { Logger } from "@waku/utils";
2
+ import { hexToBytes } from "@waku/utils/bytes";
3
+ import { ethers } from "ethers";
4
+ import { MerkleRootTracker } from "../root_tracker.js";
5
+ import { zeroPadLE } from "../utils/index.js";
6
+ import { RLN_REGISTRY_ABI, RLN_STORAGE_ABI } from "./constants.js";
7
+ const log = new Logger("waku:rln:contract");
8
+ export class RLNContract {
9
+ registryContract;
10
+ merkleRootTracker;
11
+ deployBlock;
12
+ storageIndex;
13
+ storageContract;
14
+ _membersFilter;
15
+ _members = new Map();
16
+ static async init(rlnInstance, options) {
17
+ const rlnContract = new RLNContract(rlnInstance, options);
18
+ await rlnContract.initStorageContract(options.signer);
19
+ await rlnContract.fetchMembers(rlnInstance);
20
+ rlnContract.subscribeToMembers(rlnInstance);
21
+ return rlnContract;
22
+ }
23
+ constructor(rlnInstance, { registryAddress, signer }) {
24
+ const initialRoot = rlnInstance.zerokit.getMerkleRoot();
25
+ this.registryContract = new ethers.Contract(registryAddress, RLN_REGISTRY_ABI, signer);
26
+ this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
27
+ }
28
+ async initStorageContract(signer, options = {}) {
29
+ const storageIndex = options?.storageIndex
30
+ ? options.storageIndex
31
+ : await this.registryContract.usingStorageIndex();
32
+ const storageAddress = await this.registryContract.storages(storageIndex);
33
+ if (!storageAddress || storageAddress === ethers.constants.AddressZero) {
34
+ throw Error("No RLN Storage initialized on registry contract.");
35
+ }
36
+ this.storageIndex = storageIndex;
37
+ this.storageContract = new ethers.Contract(storageAddress, RLN_STORAGE_ABI, signer);
38
+ this._membersFilter = this.storageContract.filters.MemberRegistered();
39
+ this.deployBlock = await this.storageContract.deployedBlockNumber();
40
+ }
41
+ get registry() {
42
+ if (!this.registryContract) {
43
+ throw Error("Registry contract was not initialized");
44
+ }
45
+ return this.registryContract;
46
+ }
47
+ get contract() {
48
+ if (!this.storageContract) {
49
+ throw Error("Storage contract was not initialized");
50
+ }
51
+ return this.storageContract;
52
+ }
53
+ get members() {
54
+ const sortedMembers = Array.from(this._members.values()).sort((left, right) => left.index.toNumber() - right.index.toNumber());
55
+ return sortedMembers;
56
+ }
57
+ get membersFilter() {
58
+ if (!this._membersFilter) {
59
+ throw Error("Members filter was not initialized.");
60
+ }
61
+ return this._membersFilter;
62
+ }
63
+ async fetchMembers(rlnInstance, options = {}) {
64
+ const registeredMemberEvents = await queryFilter(this.contract, {
65
+ fromBlock: this.deployBlock,
66
+ ...options,
67
+ membersFilter: this.membersFilter
68
+ });
69
+ this.processEvents(rlnInstance, registeredMemberEvents);
70
+ }
71
+ processEvents(rlnInstance, events) {
72
+ const toRemoveTable = new Map();
73
+ const toInsertTable = new Map();
74
+ events.forEach((evt) => {
75
+ if (!evt.args) {
76
+ return;
77
+ }
78
+ if (evt.removed) {
79
+ const index = evt.args.index;
80
+ const toRemoveVal = toRemoveTable.get(evt.blockNumber);
81
+ if (toRemoveVal != undefined) {
82
+ toRemoveVal.push(index.toNumber());
83
+ toRemoveTable.set(evt.blockNumber, toRemoveVal);
84
+ }
85
+ else {
86
+ toRemoveTable.set(evt.blockNumber, [index.toNumber()]);
87
+ }
88
+ }
89
+ else {
90
+ let eventsPerBlock = toInsertTable.get(evt.blockNumber);
91
+ if (eventsPerBlock == undefined) {
92
+ eventsPerBlock = [];
93
+ }
94
+ eventsPerBlock.push(evt);
95
+ toInsertTable.set(evt.blockNumber, eventsPerBlock);
96
+ }
97
+ });
98
+ this.removeMembers(rlnInstance, toRemoveTable);
99
+ this.insertMembers(rlnInstance, toInsertTable);
100
+ }
101
+ insertMembers(rlnInstance, toInsert) {
102
+ toInsert.forEach((events, blockNumber) => {
103
+ events.forEach((evt) => {
104
+ const _idCommitment = evt?.args?.idCommitment;
105
+ const index = evt?.args?.index;
106
+ if (!_idCommitment || !index) {
107
+ return;
108
+ }
109
+ const idCommitment = zeroPadLE(hexToBytes(_idCommitment?._hex), 32);
110
+ rlnInstance.zerokit.insertMember(idCommitment);
111
+ this._members.set(index.toNumber(), {
112
+ index,
113
+ idCommitment: _idCommitment?._hex
114
+ });
115
+ });
116
+ const currentRoot = rlnInstance.zerokit.getMerkleRoot();
117
+ this.merkleRootTracker.pushRoot(blockNumber, currentRoot);
118
+ });
119
+ }
120
+ removeMembers(rlnInstance, toRemove) {
121
+ const removeDescending = new Map([...toRemove].sort().reverse());
122
+ removeDescending.forEach((indexes, blockNumber) => {
123
+ indexes.forEach((index) => {
124
+ if (this._members.has(index)) {
125
+ this._members.delete(index);
126
+ rlnInstance.zerokit.deleteMember(index);
127
+ }
128
+ });
129
+ this.merkleRootTracker.backFill(blockNumber);
130
+ });
131
+ }
132
+ subscribeToMembers(rlnInstance) {
133
+ this.contract.on(this.membersFilter, (_pubkey, _index, event) => this.processEvents(rlnInstance, [event]));
134
+ }
135
+ async registerWithIdentity(identity) {
136
+ if (this.storageIndex === undefined) {
137
+ throw Error("Cannot register credential, no storage contract index found.");
138
+ }
139
+ const txRegisterResponse = await this.registryContract["register(uint16,uint256)"](this.storageIndex, identity.IDCommitmentBigInt, { gasLimit: 100000 });
140
+ const txRegisterReceipt = await txRegisterResponse.wait();
141
+ // assumption: register(uint16,uint256) emits one event
142
+ const memberRegistered = txRegisterReceipt?.events?.[0];
143
+ if (!memberRegistered) {
144
+ return undefined;
145
+ }
146
+ const decodedData = this.contract.interface.decodeEventLog("MemberRegistered", memberRegistered.data);
147
+ const network = await this.registryContract.provider.getNetwork();
148
+ const address = this.registryContract.address;
149
+ const membershipId = decodedData.index.toNumber();
150
+ return {
151
+ identity,
152
+ membership: {
153
+ address,
154
+ treeIndex: membershipId,
155
+ chainId: network.chainId
156
+ }
157
+ };
158
+ }
159
+ roots() {
160
+ return this.merkleRootTracker.roots();
161
+ }
162
+ }
163
+ // these value should be tested on other networks
164
+ const FETCH_CHUNK = 5;
165
+ const BLOCK_RANGE = 3000;
166
+ async function queryFilter(contract, options) {
167
+ const { fromBlock, membersFilter, fetchRange = BLOCK_RANGE, fetchChunks = FETCH_CHUNK } = options;
168
+ if (!fromBlock) {
169
+ return contract.queryFilter(membersFilter);
170
+ }
171
+ if (!contract.signer.provider) {
172
+ throw Error("No provider found on the contract's signer.");
173
+ }
174
+ const toBlock = await contract.signer.provider.getBlockNumber();
175
+ if (toBlock - fromBlock < fetchRange) {
176
+ return contract.queryFilter(membersFilter);
177
+ }
178
+ const events = [];
179
+ const chunks = splitToChunks(fromBlock, toBlock, fetchRange);
180
+ for (const portion of takeN(chunks, fetchChunks)) {
181
+ const promises = portion.map(([left, right]) => ignoreErrors(contract.queryFilter(membersFilter, left, right), []));
182
+ const fetchedEvents = await Promise.all(promises);
183
+ events.push(fetchedEvents.flatMap((v) => v));
184
+ }
185
+ return events.flatMap((v) => v);
186
+ }
187
+ function splitToChunks(from, to, step) {
188
+ const chunks = [];
189
+ let left = from;
190
+ while (left < to) {
191
+ const right = left + step < to ? left + step : to;
192
+ chunks.push([left, right]);
193
+ left = right;
194
+ }
195
+ return chunks;
196
+ }
197
+ function* takeN(array, size) {
198
+ let start = 0;
199
+ while (start < array.length) {
200
+ const portion = array.slice(start, start + size);
201
+ yield portion;
202
+ start += size;
203
+ }
204
+ }
205
+ function ignoreErrors(promise, defaultValue) {
206
+ return promise.catch((err) => {
207
+ log.info(`Ignoring an error during query: ${err?.message}`);
208
+ return defaultValue;
209
+ });
210
+ }
211
+ //# sourceMappingURL=rln_contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rln_contract.js","sourceRoot":"","sources":["../../src/contract/rln_contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEnE,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;AA0B5C,MAAM,OAAO,WAAW;IACd,gBAAgB,CAAkB;IAClC,iBAAiB,CAAoB;IAErC,WAAW,CAAqB;IAChC,YAAY,CAAqB;IACjC,eAAe,CAA8B;IAC7C,cAAc,CAAiC;IAE/C,QAAQ,GAAwB,IAAI,GAAG,EAAE,CAAC;IAE3C,M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AM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;QAEjD,MAAM,OAAO,CAAC;QAEd,KAAK,IAAI,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAI,OAAmB,EAAE,YAAe;IAC3D,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAC3B,GAAG,CAAC,IAAI,CAAC,mCAAmC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QAC5D,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RLNInstance } from "./rln.js";
2
+ export declare function createRLN(): Promise<RLNInstance>;
package/dist/create.js ADDED
@@ -0,0 +1,8 @@
1
+ export async function createRLN() {
2
+ // A dependency graph that contains any wasm must all be imported
3
+ // asynchronously. This file does the single async import, so
4
+ // that no one else needs to worry about it again.
5
+ const rlnModule = await import("./rln.js");
6
+ return rlnModule.create();
7
+ }
8
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,iEAAiE;IACjE,6DAA6D;IAC7D,kDAAkD;IAClD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3C,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare class IdentityCredential {
2
+ readonly IDTrapdoor: Uint8Array;
3
+ readonly IDNullifier: Uint8Array;
4
+ readonly IDSecretHash: Uint8Array;
5
+ readonly IDCommitment: Uint8Array;
6
+ readonly IDCommitmentBigInt: bigint;
7
+ constructor(IDTrapdoor: Uint8Array, IDNullifier: Uint8Array, IDSecretHash: Uint8Array, IDCommitment: Uint8Array, IDCommitmentBigInt: bigint);
8
+ static fromBytes(memKeys: Uint8Array): IdentityCredential;
9
+ }
@@ -0,0 +1,27 @@
1
+ import { buildBigIntFromUint8Array } from "./utils/index.js";
2
+ export class IdentityCredential {
3
+ IDTrapdoor;
4
+ IDNullifier;
5
+ IDSecretHash;
6
+ IDCommitment;
7
+ IDCommitmentBigInt;
8
+ constructor(IDTrapdoor, IDNullifier, IDSecretHash, IDCommitment, IDCommitmentBigInt) {
9
+ this.IDTrapdoor = IDTrapdoor;
10
+ this.IDNullifier = IDNullifier;
11
+ this.IDSecretHash = IDSecretHash;
12
+ this.IDCommitment = IDCommitment;
13
+ this.IDCommitmentBigInt = IDCommitmentBigInt;
14
+ }
15
+ static fromBytes(memKeys) {
16
+ if (memKeys.length < 128) {
17
+ throw new Error("Invalid memKeys length - must be at least 128 bytes");
18
+ }
19
+ const idTrapdoor = memKeys.subarray(0, 32);
20
+ const idNullifier = memKeys.subarray(32, 64);
21
+ const idSecretHash = memKeys.subarray(64, 96);
22
+ const idCommitment = memKeys.subarray(96, 128);
23
+ const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment, 32);
24
+ return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment, idCommitmentBigInt);
25
+ }
26
+ }
27
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,OAAO,kBAAkB;IAEX;IACA;IACA;IACA;IACA;IALlB,YACkB,UAAsB,EACtB,WAAuB,EACvB,YAAwB,EACxB,YAAwB,EACxB,kBAA0B;QAJ1B,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAY;QACvB,iBAAY,GAAZ,YAAY,CAAY;QACxB,iBAAY,GAAZ,YAAY,CAAY;QACxB,uBAAkB,GAAlB,kBAAkB,CAAQ;IACzC,CAAC;IAEG,MAAM,CAAC,SAAS,CAAC,OAAmB;QACzC,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAC/C,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAEvE,OAAO,IAAI,kBAAkB,CAC3B,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,CACnB,CAAC;IACJ,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,11 @@
1
- import { RLNInstance } from "./rln";
2
- export declare function create(): Promise<RLNInstance>;
1
+ import { RLNDecoder, RLNEncoder } from "./codec.js";
2
+ import { RLN_REGISTRY_ABI, RLN_STORAGE_ABI, SEPOLIA_CONTRACT } from "./contract/index.js";
3
+ import { RLNContract } from "./contract/index.js";
4
+ import { createRLN } from "./create.js";
5
+ import { IdentityCredential } from "./identity.js";
6
+ import { Keystore } from "./keystore/index.js";
7
+ import { Proof } from "./proof.js";
8
+ import { RLNInstance } from "./rln.js";
9
+ import { MerkleRootTracker } from "./root_tracker.js";
10
+ import { extractMetaMaskSigner } from "./utils/index.js";
11
+ export { createRLN, Keystore, RLNInstance, IdentityCredential, Proof, RLNEncoder, RLNDecoder, MerkleRootTracker, RLNContract, RLN_STORAGE_ABI, RLN_REGISTRY_ABI, SEPOLIA_CONTRACT, extractMetaMaskSigner };
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
- // reexport the create function, dynamically imported from rln.ts
2
- export async function create() {
3
- // A dependency graph that contains any wasm must all be imported
4
- // asynchronously. This file does the single async import, so
5
- // that no one else needs to worry about it again.
6
- const rlnModule = await import("./rln");
7
- return await rlnModule.create();
8
- }
1
+ import { RLNDecoder, RLNEncoder } from "./codec.js";
2
+ import { RLN_REGISTRY_ABI, RLN_STORAGE_ABI, SEPOLIA_CONTRACT } from "./contract/index.js";
3
+ import { RLNContract } from "./contract/index.js";
4
+ import { createRLN } from "./create.js";
5
+ import { IdentityCredential } from "./identity.js";
6
+ import { Keystore } from "./keystore/index.js";
7
+ import { Proof } from "./proof.js";
8
+ import { RLNInstance } from "./rln.js";
9
+ import { MerkleRootTracker } from "./root_tracker.js";
10
+ import { extractMetaMaskSigner } from "./utils/index.js";
11
+ export { createRLN, Keystore, RLNInstance, IdentityCredential, Proof, RLNEncoder, RLNDecoder, MerkleRootTracker, RLNContract, RLN_STORAGE_ABI, RLN_REGISTRY_ABI, SEPOLIA_CONTRACT, extractMetaMaskSigner };
9
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,iEAAiE;IACjE,6DAA6D;IAC7D,kDAAkD;IAClD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO,MAAM,SAAS,CAAC,MAAM,EAAE,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,KAAK,EACL,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACtB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IKeystore as IEipKeystore } from "@chainsafe/bls-keystore";
2
+ import type { Keccak256Hash, Password } from "./types.js";
3
+ export declare const decryptEipKeystore: (password: Password, eipKeystore: IEipKeystore) => Promise<Uint8Array>;
4
+ export declare const keccak256Checksum: (password: Password, eipKeystore: IEipKeystore) => Promise<Keccak256Hash>;
@@ -0,0 +1,28 @@
1
+ import { cipherDecrypt } from "@chainsafe/bls-keystore/lib/cipher";
2
+ import { kdf } from "@chainsafe/bls-keystore/lib/kdf";
3
+ import { normalizePassword } from "@chainsafe/bls-keystore/lib/password";
4
+ import { keccak256 } from "ethereum-cryptography/keccak";
5
+ import { bytesToHex, concatBytes, hexToBytes } from "ethereum-cryptography/utils";
6
+ // eipKeystore supports only sha256 checksum so we just make an assumption it is keccak256
7
+ const validateChecksum = async (password, eipKeystore) => {
8
+ const computedChecksum = await keccak256Checksum(password, eipKeystore);
9
+ return computedChecksum === eipKeystore.crypto.checksum.message;
10
+ };
11
+ // decrypt from @chainsafe/bls-keystore supports only sha256
12
+ // but nwaku uses keccak256
13
+ // https://github.com/waku-org/nwaku/blob/25d6e52e3804d15f9b61bc4cc6dd448540c072a1/waku/waku_keystore/keyfile.nim#L367
14
+ export const decryptEipKeystore = async (password, eipKeystore) => {
15
+ const decryptionKey = await kdf(eipKeystore.crypto.kdf, normalizePassword(password));
16
+ const isChecksumValid = await validateChecksum(password, eipKeystore);
17
+ if (!isChecksumValid) {
18
+ throw Error("Password is invalid.");
19
+ }
20
+ return cipherDecrypt(eipKeystore.crypto.cipher, decryptionKey.slice(0, 16));
21
+ };
22
+ export const keccak256Checksum = async (password, eipKeystore) => {
23
+ const key = await kdf(eipKeystore.crypto.kdf, normalizePassword(password));
24
+ const payload = concatBytes(key.slice(16), hexToBytes(eipKeystore.crypto.cipher.message));
25
+ const ciphertext = keccak256(payload);
26
+ return bytesToHex(ciphertext);
27
+ };
28
+ //# sourceMappingURL=cipher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cipher.js","sourceRoot":"","sources":["../../src/keystore/cipher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACX,MAAM,6BAA6B,CAAC;AAIrC,0FAA0F;AAC1F,MAAM,gBAAgB,GAAG,KAAK,EAC5B,QAAkB,EAClB,WAAyB,EACP,EAAE;IACpB,MAAM,gBAAgB,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACxE,OAAO,gBAAgB,KAAK,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;AAClE,CAAC,CAAC;AAEF,4DAA4D;AAC5D,2BAA2B;AAC3B,sHAAsH;AACtH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,QAAkB,EAClB,WAAyB,EACJ,EAAE;IACvB,MAAM,aAAa,GAAG,MAAM,GAAG,CAC7B,WAAW,CAAC,MAAM,CAAC,GAAG,EACtB,iBAAiB,CAAC,QAAQ,CAAC,CAC5B,CAAC;IACF,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAEtE,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,QAAkB,EAClB,WAAyB,EACD,EAAE;IAC1B,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3E,MAAM,OAAO,GAAG,WAAW,CACzB,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EACb,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAC9C,CAAC;IACF,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const Credential: typeof validate11;
2
+ declare function validate11(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
3
+ instancePath?: string | undefined;
4
+ parentData: any;
5
+ parentDataProperty: any;
6
+ rootData?: any;
7
+ }): boolean;
8
+ export {};
@@ -0,0 +1,121 @@
1
+ /* eslint eslint-comments/no-unlimited-disable: "off" */
2
+ // This file was generated by /scripts/schema-validation-codegen.ts
3
+ // Do not modify this file by hand.
4
+ /* eslint-disable */
5
+ // @ts-ignore
6
+ "use strict";
7
+ export const Credential = validate11;
8
+ const schema12 = { "type": "object", "properties": { "crypto": { "type": "object", "properties": { "cipher": { "type": "string" }, "cipherparams": { "type": "object" }, "ciphertext": { "type": "string" }, "kdf": { "type": "string" }, "kdfparams": { "type": "object" }, "mac": { "type": "string" } }, "required": ["cipher", "cipherparams", "ciphertext", "kdf", "kdfparams", "mac"] } }, "required": ["crypto"] };
9
+ function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (errors === 0) {
10
+ if (data && typeof data == "object" && !Array.isArray(data)) {
11
+ let missing0;
12
+ if ((data.crypto === undefined) && (missing0 = "crypto")) {
13
+ validate11.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
14
+ return false;
15
+ }
16
+ else {
17
+ if (data.crypto !== undefined) {
18
+ let data0 = data.crypto;
19
+ const _errs1 = errors;
20
+ if (errors === _errs1) {
21
+ if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
22
+ let missing1;
23
+ if (((((((data0.cipher === undefined) && (missing1 = "cipher")) || ((data0.cipherparams === undefined) && (missing1 = "cipherparams"))) || ((data0.ciphertext === undefined) && (missing1 = "ciphertext"))) || ((data0.kdf === undefined) && (missing1 = "kdf"))) || ((data0.kdfparams === undefined) && (missing1 = "kdfparams"))) || ((data0.mac === undefined) && (missing1 = "mac"))) {
24
+ validate11.errors = [{ instancePath: instancePath + "/crypto", schemaPath: "#/properties/crypto/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
25
+ return false;
26
+ }
27
+ else {
28
+ if (data0.cipher !== undefined) {
29
+ const _errs3 = errors;
30
+ if (typeof data0.cipher !== "string") {
31
+ validate11.errors = [{ instancePath: instancePath + "/crypto/cipher", schemaPath: "#/properties/crypto/properties/cipher/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
32
+ return false;
33
+ }
34
+ var valid1 = _errs3 === errors;
35
+ }
36
+ else {
37
+ var valid1 = true;
38
+ }
39
+ if (valid1) {
40
+ if (data0.cipherparams !== undefined) {
41
+ let data2 = data0.cipherparams;
42
+ const _errs5 = errors;
43
+ if (!(data2 && typeof data2 == "object" && !Array.isArray(data2))) {
44
+ validate11.errors = [{ instancePath: instancePath + "/crypto/cipherparams", schemaPath: "#/properties/crypto/properties/cipherparams/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
45
+ return false;
46
+ }
47
+ var valid1 = _errs5 === errors;
48
+ }
49
+ else {
50
+ var valid1 = true;
51
+ }
52
+ if (valid1) {
53
+ if (data0.ciphertext !== undefined) {
54
+ const _errs7 = errors;
55
+ if (typeof data0.ciphertext !== "string") {
56
+ validate11.errors = [{ instancePath: instancePath + "/crypto/ciphertext", schemaPath: "#/properties/crypto/properties/ciphertext/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
57
+ return false;
58
+ }
59
+ var valid1 = _errs7 === errors;
60
+ }
61
+ else {
62
+ var valid1 = true;
63
+ }
64
+ if (valid1) {
65
+ if (data0.kdf !== undefined) {
66
+ const _errs9 = errors;
67
+ if (typeof data0.kdf !== "string") {
68
+ validate11.errors = [{ instancePath: instancePath + "/crypto/kdf", schemaPath: "#/properties/crypto/properties/kdf/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
69
+ return false;
70
+ }
71
+ var valid1 = _errs9 === errors;
72
+ }
73
+ else {
74
+ var valid1 = true;
75
+ }
76
+ if (valid1) {
77
+ if (data0.kdfparams !== undefined) {
78
+ let data5 = data0.kdfparams;
79
+ const _errs11 = errors;
80
+ if (!(data5 && typeof data5 == "object" && !Array.isArray(data5))) {
81
+ validate11.errors = [{ instancePath: instancePath + "/crypto/kdfparams", schemaPath: "#/properties/crypto/properties/kdfparams/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
82
+ return false;
83
+ }
84
+ var valid1 = _errs11 === errors;
85
+ }
86
+ else {
87
+ var valid1 = true;
88
+ }
89
+ if (valid1) {
90
+ if (data0.mac !== undefined) {
91
+ const _errs13 = errors;
92
+ if (typeof data0.mac !== "string") {
93
+ validate11.errors = [{ instancePath: instancePath + "/crypto/mac", schemaPath: "#/properties/crypto/properties/mac/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
94
+ return false;
95
+ }
96
+ var valid1 = _errs13 === errors;
97
+ }
98
+ else {
99
+ var valid1 = true;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ else {
109
+ validate11.errors = [{ instancePath: instancePath + "/crypto", schemaPath: "#/properties/crypto/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
110
+ return false;
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ else {
117
+ validate11.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
118
+ return false;
119
+ }
120
+ } validate11.errors = vErrors; return errors === 0; }
121
+ //# sourceMappingURL=credential_validation_generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential_validation_generated.js","sourceRoot":"","sources":["../../src/keystore/credential_validation_generated.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,mEAAmE;AACnE,mCAAmC;AAEnC,oBAAoB;AACpB,aAAa;AACb,YAAY,CAAC;AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAAA,MAAM,QAAQ,GAAG,EAAC,MAAM,EAAC,QAAQ,EAAC,YAAY,EAAC,EAAC,QAAQ,EAAC,EAAC,MAAM,EAAC,QAAQ,EAAC,YAAY,EAAC,EAAC,QAAQ,EAAC,EAAC,MAAM,EAAC,QAAQ,EAAC,EAAC,cAAc,EAAC,EAAC,MAAM,EAAC,QAAQ,EAAC,EAAC,YAAY,EAAC,EAAC,MAAM,EAAC,QAAQ,EAAC,EAAC,KAAK,EAAC,EAAC,MAAM,EAAC,QAA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,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAC,OAAO,EAAC,gBAAgB,EAAC,CAAC,CAAC;wBAAA,OAAO,KAAK,CAAC;oBAAA,CAAC;gBAAA,CAAC;YAAA,CAAC;QAAA,CAAC;IAAA,CAAC;SAAK,CAAC;QAAA,UAAU,CAAC,MAAM,GAAG,CAAC,EAAC,YAAY,EAAC,UAAU,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,EAAC,MAAM,EAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAC,OAAO,EAAC,gBAAgB,EAAC,CAAC,CAAC;QAAA,OAAO,KAAK,CAAC;IAAA,CAAC;AAAA,CAAC,CAAA,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,CAAA,OAAO,MAAM,KAAK,CAAC,CAAC,CAAA,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Keystore } from "./keystore.js";
2
+ import type { DecryptedCredentials, EncryptedCredentials } from "./types.js";
3
+ export { Keystore };
4
+ export type { EncryptedCredentials, DecryptedCredentials };
@@ -0,0 +1,3 @@
1
+ import { Keystore } from "./keystore.js";
2
+ export { Keystore };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/keystore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { ICipherModule, IPbkdf2KdfModule } from "@chainsafe/bls-keystore";
2
+ import type { KeystoreEntity, MembershipHash, Password, Sha256Hash } from "./types.js";
3
+ type NwakuCredential = {
4
+ crypto: {
5
+ cipher: ICipherModule["function"];
6
+ cipherparams: ICipherModule["params"];
7
+ ciphertext: ICipherModule["message"];
8
+ kdf: IPbkdf2KdfModule["function"];
9
+ kdfparams: IPbkdf2KdfModule["params"];
10
+ mac: Sha256Hash;
11
+ };
12
+ };
13
+ interface NwakuKeystore {
14
+ application: string;
15
+ version: string;
16
+ appIdentifier: string;
17
+ credentials: {
18
+ [key: MembershipHash]: NwakuCredential;
19
+ };
20
+ }
21
+ type KeystoreCreateOptions = {
22
+ application?: string;
23
+ version?: string;
24
+ appIdentifier?: string;
25
+ };
26
+ export declare class Keystore {
27
+ private data;
28
+ private constructor();
29
+ static create(options?: KeystoreCreateOptions): Keystore;
30
+ static fromString(str: string): undefined | Keystore;
31
+ static fromObject(obj: NwakuKeystore): Keystore;
32
+ addCredential(options: KeystoreEntity, password: Password): Promise<MembershipHash>;
33
+ readCredential(membershipHash: MembershipHash, password: Password): Promise<undefined | KeystoreEntity>;
34
+ removeCredential(hash: MembershipHash): void;
35
+ toString(): string;
36
+ toObject(): NwakuKeystore;
37
+ /**
38
+ * Read array of hashes of current credentials
39
+ * @returns array of keys of credentials in current Keystore
40
+ */
41
+ keys(): string[];
42
+ private static isValidNwakuStore;
43
+ private static fromCredentialToEip;
44
+ private static fromEipToCredential;
45
+ private static fromBytesToIdentity;
46
+ private static fromArraylikeToBytes;
47
+ private static computeMembershipHash;
48
+ private static fromIdentityToBytes;
49
+ }
50
+ export {};