@waku/rln 0.1.3-f6d5deb → 0.1.4-29a4c3f.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 (341) hide show
  1. package/README.md +10 -186
  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 +12 -74804
  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/abi.js +394 -0
  197. package/bundle/packages/rln/dist/contract/constants.js +27 -0
  198. package/bundle/packages/rln/dist/contract/rln_contract.js +438 -0
  199. package/bundle/packages/rln/dist/create.js +9 -0
  200. package/bundle/packages/rln/dist/identity.js +30 -0
  201. package/bundle/packages/rln/dist/keystore/cipher.js +31 -0
  202. package/bundle/packages/rln/dist/keystore/credential_validation_generated.js +119 -0
  203. package/bundle/packages/rln/dist/keystore/keystore.js +223 -0
  204. package/bundle/packages/rln/dist/keystore/keystore_validation_generated.js +74 -0
  205. package/bundle/packages/rln/dist/keystore/schema_validator.js +20 -0
  206. package/bundle/packages/rln/dist/message.js +51 -0
  207. package/bundle/packages/rln/dist/proof.js +54 -0
  208. package/bundle/packages/rln/dist/resources/verification_key.js +112 -0
  209. package/bundle/packages/rln/dist/resources/witness_calculator.js +330 -0
  210. package/bundle/packages/rln/dist/rln.js +220 -0
  211. package/bundle/packages/rln/dist/root_tracker.js +76 -0
  212. package/bundle/packages/rln/dist/utils/bytes.js +65 -0
  213. package/bundle/packages/rln/dist/utils/epoch.js +39 -0
  214. package/bundle/packages/rln/dist/utils/hash.js +10 -0
  215. package/bundle/packages/rln/dist/utils/metamask.js +14 -0
  216. package/bundle/packages/rln/dist/zerokit.js +128 -0
  217. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +52 -0
  218. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +65 -0
  219. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +99 -0
  220. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +103 -0
  221. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/index.js +28 -0
  222. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +78 -0
  223. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +17 -0
  224. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1253 -0
  225. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +40 -0
  226. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/types.js +5 -0
  227. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +103 -0
  228. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +41 -0
  229. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +17 -0
  230. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +23 -0
  231. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +12 -0
  232. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +77 -0
  233. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +9 -0
  234. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +215 -0
  235. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +3 -0
  236. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +35 -0
  237. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +3 -0
  238. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +21 -0
  239. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
  240. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
  241. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +96 -0
  242. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +6 -0
  243. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +66 -0
  244. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +24 -0
  245. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +6 -0
  246. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +7 -0
  247. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +11 -0
  248. package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +52 -0
  249. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +124 -0
  250. package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +71 -0
  251. package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +10 -0
  252. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +88 -0
  253. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +99 -0
  254. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +233 -0
  255. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +133 -0
  256. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +243 -0
  257. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +167 -0
  258. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/native.js +4 -0
  259. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/rng.js +13 -0
  260. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/stringify.js +28 -0
  261. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/v4.js +19 -0
  262. package/bundle/packages/utils/dist/bytes/index.js +44 -0
  263. package/bundle/packages/utils/dist/common/sharding/index.js +91 -0
  264. package/bundle/packages/utils/dist/logger/index.js +31 -0
  265. package/bundle/resources/verification_key.d.ts +13 -0
  266. package/bundle/resources/verification_key.js +112 -0
  267. package/bundle/resources/witness_calculator.d.ts +11 -0
  268. package/bundle/resources/witness_calculator.js +328 -0
  269. package/dist/.tsbuildinfo +1 -0
  270. package/dist/codec.d.ts +5 -5
  271. package/dist/codec.js +6 -6
  272. package/dist/codec.js.map +1 -1
  273. package/dist/contract/abi.d.ts +42 -0
  274. package/dist/contract/abi.js +393 -0
  275. package/dist/contract/abi.js.map +1 -0
  276. package/dist/contract/constants.d.ts +59 -3
  277. package/dist/contract/constants.js +21 -63
  278. package/dist/contract/constants.js.map +1 -1
  279. package/dist/contract/rln_contract.d.ts +98 -17
  280. package/dist/contract/rln_contract.js +292 -71
  281. package/dist/contract/rln_contract.js.map +1 -1
  282. package/dist/identity.js +5 -2
  283. package/dist/identity.js.map +1 -1
  284. package/dist/index.d.ts +3 -3
  285. package/dist/index.js +3 -3
  286. package/dist/index.js.map +1 -1
  287. package/dist/keystore/cipher.js +3 -3
  288. package/dist/keystore/cipher.js.map +1 -1
  289. package/dist/keystore/credential_validation_generated.js.map +1 -1
  290. package/dist/keystore/keystore.js +4 -4
  291. package/dist/keystore/keystore.js.map +1 -1
  292. package/dist/keystore/keystore_validation_generated.js.map +1 -1
  293. package/dist/message.js +3 -3
  294. package/dist/message.js.map +1 -1
  295. package/dist/proof.js +3 -2
  296. package/dist/proof.js.map +1 -1
  297. package/dist/resources/verification_key.d.ts +12 -11
  298. package/dist/resources/verification_key.js +103 -103
  299. package/dist/resources/witness_calculator.d.ts +10 -15
  300. package/dist/resources/witness_calculator.js +302 -265
  301. package/dist/rln.d.ts +5 -1
  302. package/dist/rln.js +56 -28
  303. package/dist/rln.js.map +1 -1
  304. package/dist/root_tracker.js.map +1 -1
  305. package/dist/utils/epoch.js +5 -5
  306. package/dist/utils/epoch.js.map +1 -1
  307. package/dist/zerokit.d.ts +13 -9
  308. package/dist/zerokit.js +40 -20
  309. package/dist/zerokit.js.map +1 -1
  310. package/package.json +1 -146
  311. package/src/codec.ts +26 -22
  312. package/src/contract/abi.ts +392 -0
  313. package/src/contract/constants.ts +28 -0
  314. package/src/contract/index.ts +2 -0
  315. package/src/contract/rln_contract.ts +686 -0
  316. package/src/identity.ts +8 -4
  317. package/src/index.ts +4 -9
  318. package/src/keystore/cipher.ts +54 -0
  319. package/src/keystore/credential_validation_generated.ts +7 -0
  320. package/src/keystore/index.ts +5 -0
  321. package/src/keystore/keystore.ts +330 -0
  322. package/src/keystore/keystore_validation_generated.ts +7 -0
  323. package/src/keystore/schema_validator.ts +34 -0
  324. package/src/keystore/types.ts +36 -0
  325. package/src/message.ts +10 -10
  326. package/src/proof.ts +13 -11
  327. package/src/resources/verification_key.d.ts +13 -0
  328. package/src/resources/witness_calculator.d.ts +11 -0
  329. package/src/rln.ts +76 -31
  330. package/src/root_tracker.ts +7 -6
  331. package/src/utils/bytes.ts +84 -0
  332. package/src/utils/epoch.ts +30 -0
  333. package/src/utils/hash.ts +15 -0
  334. package/src/utils/index.ts +9 -0
  335. package/src/utils/metamask.ts +17 -0
  336. package/src/zerokit.ts +95 -33
  337. package/bundle/assets/rln_wasm_bg-a503e304.wasm +0 -0
  338. package/dist/resources/verification_key.js.map +0 -1
  339. package/dist/resources/witness_calculator.js.map +0 -1
  340. /package/bundle/{assets/rln-6ded2896.wasm → resources/rln.wasm} +0 -0
  341. /package/bundle/{assets/rln_final-8b299152.zkey → resources/rln_final.zkey} +0 -0
@@ -0,0 +1,243 @@
1
+ import { __exports as sha512 } from '../../../../../_virtual/sha512.js';
2
+ import './_sha2.js';
3
+ import './_u64.js';
4
+ import './utils.js';
5
+ import { __exports as _sha2 } from '../../../../../_virtual/_sha2.js';
6
+ import { __exports as _u64 } from '../../../../../_virtual/_u64.js';
7
+ import { __exports as utils } from '../../../../../_virtual/utils.js';
8
+
9
+ Object.defineProperty(sha512, "__esModule", { value: true });
10
+ sha512.sha384 = sha512.sha512_256 = sha512.sha512_224 = sha512.sha512 = sha512.SHA512 = undefined;
11
+ const _sha2_js_1 = _sha2;
12
+ const _u64_js_1 = _u64;
13
+ const utils_js_1 = utils;
14
+ // Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):
15
+ // prettier-ignore
16
+ const [SHA512_Kh, SHA512_Kl] = _u64_js_1.default.split([
17
+ '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',
18
+ '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',
19
+ '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',
20
+ '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',
21
+ '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',
22
+ '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',
23
+ '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',
24
+ '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',
25
+ '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',
26
+ '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',
27
+ '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',
28
+ '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',
29
+ '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',
30
+ '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',
31
+ '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',
32
+ '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',
33
+ '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',
34
+ '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',
35
+ '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',
36
+ '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'
37
+ ].map(n => BigInt(n)));
38
+ // Temporary buffer, not used to store anything between runs
39
+ const SHA512_W_H = new Uint32Array(80);
40
+ const SHA512_W_L = new Uint32Array(80);
41
+ class SHA512 extends _sha2_js_1.SHA2 {
42
+ constructor() {
43
+ super(128, 64, 16, false);
44
+ // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
45
+ // Also looks cleaner and easier to verify with spec.
46
+ // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
47
+ // h -- high 32 bits, l -- low 32 bits
48
+ this.Ah = 0x6a09e667 | 0;
49
+ this.Al = 0xf3bcc908 | 0;
50
+ this.Bh = 0xbb67ae85 | 0;
51
+ this.Bl = 0x84caa73b | 0;
52
+ this.Ch = 0x3c6ef372 | 0;
53
+ this.Cl = 0xfe94f82b | 0;
54
+ this.Dh = 0xa54ff53a | 0;
55
+ this.Dl = 0x5f1d36f1 | 0;
56
+ this.Eh = 0x510e527f | 0;
57
+ this.El = 0xade682d1 | 0;
58
+ this.Fh = 0x9b05688c | 0;
59
+ this.Fl = 0x2b3e6c1f | 0;
60
+ this.Gh = 0x1f83d9ab | 0;
61
+ this.Gl = 0xfb41bd6b | 0;
62
+ this.Hh = 0x5be0cd19 | 0;
63
+ this.Hl = 0x137e2179 | 0;
64
+ }
65
+ // prettier-ignore
66
+ get() {
67
+ const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
68
+ return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
69
+ }
70
+ // prettier-ignore
71
+ set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
72
+ this.Ah = Ah | 0;
73
+ this.Al = Al | 0;
74
+ this.Bh = Bh | 0;
75
+ this.Bl = Bl | 0;
76
+ this.Ch = Ch | 0;
77
+ this.Cl = Cl | 0;
78
+ this.Dh = Dh | 0;
79
+ this.Dl = Dl | 0;
80
+ this.Eh = Eh | 0;
81
+ this.El = El | 0;
82
+ this.Fh = Fh | 0;
83
+ this.Fl = Fl | 0;
84
+ this.Gh = Gh | 0;
85
+ this.Gl = Gl | 0;
86
+ this.Hh = Hh | 0;
87
+ this.Hl = Hl | 0;
88
+ }
89
+ process(view, offset) {
90
+ // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array
91
+ for (let i = 0; i < 16; i++, offset += 4) {
92
+ SHA512_W_H[i] = view.getUint32(offset);
93
+ SHA512_W_L[i] = view.getUint32((offset += 4));
94
+ }
95
+ for (let i = 16; i < 80; i++) {
96
+ // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)
97
+ const W15h = SHA512_W_H[i - 15] | 0;
98
+ const W15l = SHA512_W_L[i - 15] | 0;
99
+ const s0h = _u64_js_1.default.rotrSH(W15h, W15l, 1) ^ _u64_js_1.default.rotrSH(W15h, W15l, 8) ^ _u64_js_1.default.shrSH(W15h, W15l, 7);
100
+ const s0l = _u64_js_1.default.rotrSL(W15h, W15l, 1) ^ _u64_js_1.default.rotrSL(W15h, W15l, 8) ^ _u64_js_1.default.shrSL(W15h, W15l, 7);
101
+ // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)
102
+ const W2h = SHA512_W_H[i - 2] | 0;
103
+ const W2l = SHA512_W_L[i - 2] | 0;
104
+ const s1h = _u64_js_1.default.rotrSH(W2h, W2l, 19) ^ _u64_js_1.default.rotrBH(W2h, W2l, 61) ^ _u64_js_1.default.shrSH(W2h, W2l, 6);
105
+ const s1l = _u64_js_1.default.rotrSL(W2h, W2l, 19) ^ _u64_js_1.default.rotrBL(W2h, W2l, 61) ^ _u64_js_1.default.shrSL(W2h, W2l, 6);
106
+ // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];
107
+ const SUMl = _u64_js_1.default.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
108
+ const SUMh = _u64_js_1.default.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
109
+ SHA512_W_H[i] = SUMh | 0;
110
+ SHA512_W_L[i] = SUMl | 0;
111
+ }
112
+ let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
113
+ // Compression function main loop, 80 rounds
114
+ for (let i = 0; i < 80; i++) {
115
+ // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)
116
+ const sigma1h = _u64_js_1.default.rotrSH(Eh, El, 14) ^ _u64_js_1.default.rotrSH(Eh, El, 18) ^ _u64_js_1.default.rotrBH(Eh, El, 41);
117
+ const sigma1l = _u64_js_1.default.rotrSL(Eh, El, 14) ^ _u64_js_1.default.rotrSL(Eh, El, 18) ^ _u64_js_1.default.rotrBL(Eh, El, 41);
118
+ //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
119
+ const CHIh = (Eh & Fh) ^ (~Eh & Gh);
120
+ const CHIl = (El & Fl) ^ (~El & Gl);
121
+ // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]
122
+ // prettier-ignore
123
+ const T1ll = _u64_js_1.default.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
124
+ const T1h = _u64_js_1.default.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
125
+ const T1l = T1ll | 0;
126
+ // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)
127
+ const sigma0h = _u64_js_1.default.rotrSH(Ah, Al, 28) ^ _u64_js_1.default.rotrBH(Ah, Al, 34) ^ _u64_js_1.default.rotrBH(Ah, Al, 39);
128
+ const sigma0l = _u64_js_1.default.rotrSL(Ah, Al, 28) ^ _u64_js_1.default.rotrBL(Ah, Al, 34) ^ _u64_js_1.default.rotrBL(Ah, Al, 39);
129
+ const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);
130
+ const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);
131
+ Hh = Gh | 0;
132
+ Hl = Gl | 0;
133
+ Gh = Fh | 0;
134
+ Gl = Fl | 0;
135
+ Fh = Eh | 0;
136
+ Fl = El | 0;
137
+ ({ h: Eh, l: El } = _u64_js_1.default.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
138
+ Dh = Ch | 0;
139
+ Dl = Cl | 0;
140
+ Ch = Bh | 0;
141
+ Cl = Bl | 0;
142
+ Bh = Ah | 0;
143
+ Bl = Al | 0;
144
+ const All = _u64_js_1.default.add3L(T1l, sigma0l, MAJl);
145
+ Ah = _u64_js_1.default.add3H(All, T1h, sigma0h, MAJh);
146
+ Al = All | 0;
147
+ }
148
+ // Add the compressed chunk to the current hash value
149
+ ({ h: Ah, l: Al } = _u64_js_1.default.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
150
+ ({ h: Bh, l: Bl } = _u64_js_1.default.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
151
+ ({ h: Ch, l: Cl } = _u64_js_1.default.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
152
+ ({ h: Dh, l: Dl } = _u64_js_1.default.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
153
+ ({ h: Eh, l: El } = _u64_js_1.default.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
154
+ ({ h: Fh, l: Fl } = _u64_js_1.default.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
155
+ ({ h: Gh, l: Gl } = _u64_js_1.default.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
156
+ ({ h: Hh, l: Hl } = _u64_js_1.default.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
157
+ this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
158
+ }
159
+ roundClean() {
160
+ SHA512_W_H.fill(0);
161
+ SHA512_W_L.fill(0);
162
+ }
163
+ destroy() {
164
+ this.buffer.fill(0);
165
+ this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
166
+ }
167
+ }
168
+ sha512.SHA512 = SHA512;
169
+ class SHA512_224 extends SHA512 {
170
+ constructor() {
171
+ super();
172
+ // h -- high 32 bits, l -- low 32 bits
173
+ this.Ah = 0x8c3d37c8 | 0;
174
+ this.Al = 0x19544da2 | 0;
175
+ this.Bh = 0x73e19966 | 0;
176
+ this.Bl = 0x89dcd4d6 | 0;
177
+ this.Ch = 0x1dfab7ae | 0;
178
+ this.Cl = 0x32ff9c82 | 0;
179
+ this.Dh = 0x679dd514 | 0;
180
+ this.Dl = 0x582f9fcf | 0;
181
+ this.Eh = 0x0f6d2b69 | 0;
182
+ this.El = 0x7bd44da8 | 0;
183
+ this.Fh = 0x77e36f73 | 0;
184
+ this.Fl = 0x04c48942 | 0;
185
+ this.Gh = 0x3f9d85a8 | 0;
186
+ this.Gl = 0x6a1d36c8 | 0;
187
+ this.Hh = 0x1112e6ad | 0;
188
+ this.Hl = 0x91d692a1 | 0;
189
+ this.outputLen = 28;
190
+ }
191
+ }
192
+ class SHA512_256 extends SHA512 {
193
+ constructor() {
194
+ super();
195
+ // h -- high 32 bits, l -- low 32 bits
196
+ this.Ah = 0x22312194 | 0;
197
+ this.Al = 0xfc2bf72c | 0;
198
+ this.Bh = 0x9f555fa3 | 0;
199
+ this.Bl = 0xc84c64c2 | 0;
200
+ this.Ch = 0x2393b86b | 0;
201
+ this.Cl = 0x6f53b151 | 0;
202
+ this.Dh = 0x96387719 | 0;
203
+ this.Dl = 0x5940eabd | 0;
204
+ this.Eh = 0x96283ee2 | 0;
205
+ this.El = 0xa88effe3 | 0;
206
+ this.Fh = 0xbe5e1e25 | 0;
207
+ this.Fl = 0x53863992 | 0;
208
+ this.Gh = 0x2b0199fc | 0;
209
+ this.Gl = 0x2c85b8aa | 0;
210
+ this.Hh = 0x0eb72ddc | 0;
211
+ this.Hl = 0x81c52ca2 | 0;
212
+ this.outputLen = 32;
213
+ }
214
+ }
215
+ class SHA384 extends SHA512 {
216
+ constructor() {
217
+ super();
218
+ // h -- high 32 bits, l -- low 32 bits
219
+ this.Ah = 0xcbbb9d5d | 0;
220
+ this.Al = 0xc1059ed8 | 0;
221
+ this.Bh = 0x629a292a | 0;
222
+ this.Bl = 0x367cd507 | 0;
223
+ this.Ch = 0x9159015a | 0;
224
+ this.Cl = 0x3070dd17 | 0;
225
+ this.Dh = 0x152fecd8 | 0;
226
+ this.Dl = 0xf70e5939 | 0;
227
+ this.Eh = 0x67332667 | 0;
228
+ this.El = 0xffc00b31 | 0;
229
+ this.Fh = 0x8eb44a87 | 0;
230
+ this.Fl = 0x68581511 | 0;
231
+ this.Gh = 0xdb0c2e0d | 0;
232
+ this.Gl = 0x64f98fa7 | 0;
233
+ this.Hh = 0x47b5481d | 0;
234
+ this.Hl = 0xbefa4fa4 | 0;
235
+ this.outputLen = 48;
236
+ }
237
+ }
238
+ sha512.sha512 = (0, utils_js_1.wrapConstructor)(() => new SHA512());
239
+ sha512.sha512_224 = (0, utils_js_1.wrapConstructor)(() => new SHA512_224());
240
+ sha512.sha512_256 = (0, utils_js_1.wrapConstructor)(() => new SHA512_256());
241
+ sha512.sha384 = (0, utils_js_1.wrapConstructor)(() => new SHA384());
242
+
243
+ export { sha512 as default };
@@ -0,0 +1,167 @@
1
+ import { __exports as utils } from '../../../../../_virtual/utils.js';
2
+ import './cryptoBrowser.js';
3
+ import { __exports as cryptoBrowser } from '../../../../../_virtual/cryptoBrowser.js';
4
+
5
+ (function (exports) {
6
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.randomBytes = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = undefined;
9
+ // The import here is via the package name. This is to ensure
10
+ // that exports mapping/resolution does fall into place.
11
+ const crypto_1 = cryptoBrowser;
12
+ // Cast array to different type
13
+ const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
14
+ exports.u8 = u8;
15
+ const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
16
+ exports.u32 = u32;
17
+ // Cast array to view
18
+ const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
19
+ exports.createView = createView;
20
+ // The rotate right (circular right shift) operation for uint32
21
+ const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
22
+ exports.rotr = rotr;
23
+ exports.isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
24
+ // There is almost no big endian hardware, but js typed arrays uses platform specific endianness.
25
+ // So, just to be sure not to corrupt anything.
26
+ if (!exports.isLE)
27
+ throw new Error('Non little-endian hardware is not supported');
28
+ const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
29
+ /**
30
+ * @example bytesToHex(Uint8Array.from([0xde, 0xad, 0xbe, 0xef]))
31
+ */
32
+ function bytesToHex(uint8a) {
33
+ // pre-caching improves the speed 6x
34
+ if (!(uint8a instanceof Uint8Array))
35
+ throw new Error('Uint8Array expected');
36
+ let hex = '';
37
+ for (let i = 0; i < uint8a.length; i++) {
38
+ hex += hexes[uint8a[i]];
39
+ }
40
+ return hex;
41
+ }
42
+ exports.bytesToHex = bytesToHex;
43
+ /**
44
+ * @example hexToBytes('deadbeef')
45
+ */
46
+ function hexToBytes(hex) {
47
+ if (typeof hex !== 'string') {
48
+ throw new TypeError('hexToBytes: expected string, got ' + typeof hex);
49
+ }
50
+ if (hex.length % 2)
51
+ throw new Error('hexToBytes: received invalid unpadded hex');
52
+ const array = new Uint8Array(hex.length / 2);
53
+ for (let i = 0; i < array.length; i++) {
54
+ const j = i * 2;
55
+ const hexByte = hex.slice(j, j + 2);
56
+ const byte = Number.parseInt(hexByte, 16);
57
+ if (Number.isNaN(byte) || byte < 0)
58
+ throw new Error('Invalid byte sequence');
59
+ array[i] = byte;
60
+ }
61
+ return array;
62
+ }
63
+ exports.hexToBytes = hexToBytes;
64
+ // There is no setImmediate in browser and setTimeout is slow. However, call to async function will return Promise
65
+ // which will be fullfiled only on next scheduler queue processing step and this is exactly what we need.
66
+ const nextTick = async () => { };
67
+ exports.nextTick = nextTick;
68
+ // Returns control to thread each 'tick' ms to avoid blocking
69
+ async function asyncLoop(iters, tick, cb) {
70
+ let ts = Date.now();
71
+ for (let i = 0; i < iters; i++) {
72
+ cb(i);
73
+ // Date.now() is not monotonic, so in case if clock goes backwards we return return control too
74
+ const diff = Date.now() - ts;
75
+ if (diff >= 0 && diff < tick)
76
+ continue;
77
+ await (0, exports.nextTick)();
78
+ ts += diff;
79
+ }
80
+ }
81
+ exports.asyncLoop = asyncLoop;
82
+ function utf8ToBytes(str) {
83
+ if (typeof str !== 'string') {
84
+ throw new TypeError(`utf8ToBytes expected string, got ${typeof str}`);
85
+ }
86
+ return new TextEncoder().encode(str);
87
+ }
88
+ exports.utf8ToBytes = utf8ToBytes;
89
+ function toBytes(data) {
90
+ if (typeof data === 'string')
91
+ data = utf8ToBytes(data);
92
+ if (!(data instanceof Uint8Array))
93
+ throw new TypeError(`Expected input type is Uint8Array (got ${typeof data})`);
94
+ return data;
95
+ }
96
+ exports.toBytes = toBytes;
97
+ /**
98
+ * Concats Uint8Array-s into one; like `Buffer.concat([buf1, buf2])`
99
+ * @example concatBytes(buf1, buf2)
100
+ */
101
+ function concatBytes(...arrays) {
102
+ if (!arrays.every((a) => a instanceof Uint8Array))
103
+ throw new Error('Uint8Array list expected');
104
+ if (arrays.length === 1)
105
+ return arrays[0];
106
+ const length = arrays.reduce((a, arr) => a + arr.length, 0);
107
+ const result = new Uint8Array(length);
108
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
109
+ const arr = arrays[i];
110
+ result.set(arr, pad);
111
+ pad += arr.length;
112
+ }
113
+ return result;
114
+ }
115
+ exports.concatBytes = concatBytes;
116
+ // For runtime check if class implements interface
117
+ class Hash {
118
+ // Safe version that clones internal state
119
+ clone() {
120
+ return this._cloneInto();
121
+ }
122
+ }
123
+ exports.Hash = Hash;
124
+ // Check if object doens't have custom constructor (like Uint8Array/Array)
125
+ const isPlainObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object;
126
+ function checkOpts(defaults, opts) {
127
+ if (opts !== undefined && (typeof opts !== 'object' || !isPlainObject(opts)))
128
+ throw new TypeError('Options should be object or undefined');
129
+ const merged = Object.assign(defaults, opts);
130
+ return merged;
131
+ }
132
+ exports.checkOpts = checkOpts;
133
+ function wrapConstructor(hashConstructor) {
134
+ const hashC = (message) => hashConstructor().update(toBytes(message)).digest();
135
+ const tmp = hashConstructor();
136
+ hashC.outputLen = tmp.outputLen;
137
+ hashC.blockLen = tmp.blockLen;
138
+ hashC.create = () => hashConstructor();
139
+ return hashC;
140
+ }
141
+ exports.wrapConstructor = wrapConstructor;
142
+ function wrapConstructorWithOpts(hashCons) {
143
+ const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
144
+ const tmp = hashCons({});
145
+ hashC.outputLen = tmp.outputLen;
146
+ hashC.blockLen = tmp.blockLen;
147
+ hashC.create = (opts) => hashCons(opts);
148
+ return hashC;
149
+ }
150
+ exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
151
+ /**
152
+ * Secure PRNG
153
+ */
154
+ function randomBytes(bytesLength = 32) {
155
+ if (crypto_1.crypto.web) {
156
+ return crypto_1.crypto.web.getRandomValues(new Uint8Array(bytesLength));
157
+ }
158
+ else if (crypto_1.crypto.node) {
159
+ return new Uint8Array(crypto_1.crypto.node.randomBytes(bytesLength).buffer);
160
+ }
161
+ else {
162
+ throw new Error("The environment doesn't have randomBytes function");
163
+ }
164
+ }
165
+ exports.randomBytes = randomBytes;
166
+
167
+ } (utils));
@@ -0,0 +1,4 @@
1
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2
+ var native = { randomUUID };
3
+
4
+ export { native as default };
@@ -0,0 +1,13 @@
1
+ let getRandomValues;
2
+ const rnds8 = new Uint8Array(16);
3
+ function rng() {
4
+ if (!getRandomValues) {
5
+ if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
6
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
7
+ }
8
+ getRandomValues = crypto.getRandomValues.bind(crypto);
9
+ }
10
+ return getRandomValues(rnds8);
11
+ }
12
+
13
+ export { rng as default };
@@ -0,0 +1,28 @@
1
+ const byteToHex = [];
2
+ for (let i = 0; i < 256; ++i) {
3
+ byteToHex.push((i + 0x100).toString(16).slice(1));
4
+ }
5
+ function unsafeStringify(arr, offset = 0) {
6
+ return (byteToHex[arr[offset + 0]] +
7
+ byteToHex[arr[offset + 1]] +
8
+ byteToHex[arr[offset + 2]] +
9
+ byteToHex[arr[offset + 3]] +
10
+ '-' +
11
+ byteToHex[arr[offset + 4]] +
12
+ byteToHex[arr[offset + 5]] +
13
+ '-' +
14
+ byteToHex[arr[offset + 6]] +
15
+ byteToHex[arr[offset + 7]] +
16
+ '-' +
17
+ byteToHex[arr[offset + 8]] +
18
+ byteToHex[arr[offset + 9]] +
19
+ '-' +
20
+ byteToHex[arr[offset + 10]] +
21
+ byteToHex[arr[offset + 11]] +
22
+ byteToHex[arr[offset + 12]] +
23
+ byteToHex[arr[offset + 13]] +
24
+ byteToHex[arr[offset + 14]] +
25
+ byteToHex[arr[offset + 15]]).toLowerCase();
26
+ }
27
+
28
+ export { unsafeStringify };
@@ -0,0 +1,19 @@
1
+ import native from './native.js';
2
+ import rng from './rng.js';
3
+ import { unsafeStringify } from './stringify.js';
4
+
5
+ function v4(options, buf, offset) {
6
+ if (native.randomUUID && true && !options) {
7
+ return native.randomUUID();
8
+ }
9
+ options = options || {};
10
+ const rnds = options.random ?? options.rng?.() ?? rng();
11
+ if (rnds.length < 16) {
12
+ throw new Error('Random bytes length must be >= 16');
13
+ }
14
+ rnds[6] = (rnds[6] & 0x0f) | 0x40;
15
+ rnds[8] = (rnds[8] & 0x3f) | 0x80;
16
+ return unsafeStringify(rnds);
17
+ }
18
+
19
+ export { v4 as default };
@@ -0,0 +1,44 @@
1
+ import { fromString } from '../../../../node_modules/uint8arrays/dist/src/from-string.js';
2
+ import '../../../../node_modules/multiformats/dist/src/bases/base10.js';
3
+ import '../../../../node_modules/multiformats/dist/src/bases/base16.js';
4
+ import '../../../../node_modules/multiformats/dist/src/bases/base2.js';
5
+ import '../../../../node_modules/multiformats/dist/src/bases/base256emoji.js';
6
+ import '../../../../node_modules/multiformats/dist/src/bases/base32.js';
7
+ import '../../../../node_modules/multiformats/dist/src/bases/base36.js';
8
+ import '../../../../node_modules/multiformats/dist/src/bases/base58.js';
9
+ import '../../../../node_modules/multiformats/dist/src/bases/base64.js';
10
+ import '../../../../node_modules/multiformats/dist/src/bases/base8.js';
11
+ import '../../../../node_modules/multiformats/dist/src/bases/identity.js';
12
+ import '../../../../node_modules/multiformats/dist/src/codecs/json.js';
13
+
14
+ /**
15
+ * Convert input to a byte array.
16
+ *
17
+ * Handles both `0x` prefixed and non-prefixed strings.
18
+ */
19
+ function hexToBytes(hex) {
20
+ if (typeof hex === "string") {
21
+ const _hex = hex.replace(/^0x/i, "");
22
+ return fromString(_hex.toLowerCase(), "base16");
23
+ }
24
+ return hex;
25
+ }
26
+ /**
27
+ * Encode utf-8 string to byte array.
28
+ */
29
+ const utf8ToBytes = (s) => fromString(s, "utf8");
30
+ /**
31
+ * Concatenate using Uint8Arrays as `Buffer` has a different behavior with `DataView`
32
+ */
33
+ function concat(byteArrays, totalLength) {
34
+ const len = byteArrays.reduce((acc, curr) => acc + curr.length, 0);
35
+ const res = new Uint8Array(len);
36
+ let offset = 0;
37
+ for (const bytes of byteArrays) {
38
+ res.set(bytes, offset);
39
+ offset += bytes.length;
40
+ }
41
+ return res;
42
+ }
43
+
44
+ export { concat, hexToBytes, utf8ToBytes };
@@ -0,0 +1,91 @@
1
+ import { sha256 } from '../../../../../node_modules/@noble/hashes/esm/sha256.js';
2
+ import '../../../../interfaces/dist/protocols.js';
3
+ import '../../../../interfaces/dist/connection_manager.js';
4
+ import { DEFAULT_CLUSTER_ID } from '../../../../interfaces/dist/constants.js';
5
+ import '../../../../interfaces/dist/health_indicator.js';
6
+ import { concat, utf8ToBytes } from '../../bytes/index.js';
7
+
8
+ const singleShardInfoToPubsubTopic = (shardInfo) => {
9
+ if (shardInfo.shard === undefined)
10
+ throw new Error("Invalid shard");
11
+ return `/waku/2/rs/${shardInfo.clusterId ?? DEFAULT_CLUSTER_ID}/${shardInfo.shard}`;
12
+ };
13
+ /**
14
+ * Given a string, will throw an error if it is not formatted as a valid content topic for autosharding based on https://rfc.vac.dev/spec/51/
15
+ * @param contentTopic String to validate
16
+ * @returns Object with each content topic field as an attribute
17
+ */
18
+ function ensureValidContentTopic(contentTopic) {
19
+ const parts = contentTopic.split("/");
20
+ if (parts.length < 5 || parts.length > 6) {
21
+ throw Error("Content topic format is invalid");
22
+ }
23
+ // Validate generation field if present
24
+ let generation = 0;
25
+ if (parts.length == 6) {
26
+ generation = parseInt(parts[1]);
27
+ if (isNaN(generation)) {
28
+ throw new Error("Invalid generation field in content topic");
29
+ }
30
+ if (generation > 0) {
31
+ throw new Error("Generation greater than 0 is not supported");
32
+ }
33
+ }
34
+ // Validate remaining fields
35
+ const fields = parts.splice(-4);
36
+ // Validate application field
37
+ if (fields[0].length == 0) {
38
+ throw new Error("Application field cannot be empty");
39
+ }
40
+ // Validate version field
41
+ if (fields[1].length == 0) {
42
+ throw new Error("Version field cannot be empty");
43
+ }
44
+ // Validate topic name field
45
+ if (fields[2].length == 0) {
46
+ throw new Error("Topic name field cannot be empty");
47
+ }
48
+ // Validate encoding field
49
+ if (fields[3].length == 0) {
50
+ throw new Error("Encoding field cannot be empty");
51
+ }
52
+ return {
53
+ generation,
54
+ application: fields[0],
55
+ version: fields[1],
56
+ topicName: fields[2],
57
+ encoding: fields[3]
58
+ };
59
+ }
60
+ /**
61
+ * Given a string, determines which autoshard index to use for its pubsub topic.
62
+ * Based on the algorithm described in the RFC: https://rfc.vac.dev/spec/51//#algorithm
63
+ */
64
+ function contentTopicToShardIndex(contentTopic, networkShards = 8) {
65
+ const { application, version } = ensureValidContentTopic(contentTopic);
66
+ const digest = sha256(concat([utf8ToBytes(application), utf8ToBytes(version)]));
67
+ const dataview = new DataView(digest.buffer.slice(-8));
68
+ return Number(dataview.getBigUint64(0, false) % BigInt(networkShards));
69
+ }
70
+ function contentTopicToPubsubTopic(contentTopic, clusterId = DEFAULT_CLUSTER_ID, networkShards = 8) {
71
+ if (!contentTopic) {
72
+ throw Error("Content topic must be specified");
73
+ }
74
+ const shardIndex = contentTopicToShardIndex(contentTopic, networkShards);
75
+ return `/waku/2/rs/${clusterId}/${shardIndex}`;
76
+ }
77
+ /**
78
+ * Used when creating encoders/decoders to determine which pubsub topic to use
79
+ */
80
+ function determinePubsubTopic(contentTopic,
81
+ // TODO: make it accept ShardInfo https://github.com/waku-org/js-waku/issues/2086
82
+ pubsubTopicShardInfo) {
83
+ if (typeof pubsubTopicShardInfo == "string") {
84
+ return pubsubTopicShardInfo;
85
+ }
86
+ return pubsubTopicShardInfo?.shard !== undefined
87
+ ? singleShardInfoToPubsubTopic(pubsubTopicShardInfo)
88
+ : contentTopicToPubsubTopic(contentTopic, pubsubTopicShardInfo?.clusterId ?? DEFAULT_CLUSTER_ID);
89
+ }
90
+
91
+ export { contentTopicToPubsubTopic, contentTopicToShardIndex, determinePubsubTopic, ensureValidContentTopic, singleShardInfoToPubsubTopic };
@@ -0,0 +1,31 @@
1
+ import debug from '../../../../node_modules/debug/src/browser.js';
2
+
3
+ const APP_NAME = "waku";
4
+ class Logger {
5
+ _info;
6
+ _warn;
7
+ _error;
8
+ static createDebugNamespace(level, prefix) {
9
+ return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;
10
+ }
11
+ constructor(prefix) {
12
+ this._info = debug(Logger.createDebugNamespace("info", prefix));
13
+ this._warn = debug(Logger.createDebugNamespace("warn", prefix));
14
+ this._error = debug(Logger.createDebugNamespace("error", prefix));
15
+ }
16
+ get info() {
17
+ return this._info;
18
+ }
19
+ get warn() {
20
+ return this._warn;
21
+ }
22
+ get error() {
23
+ return this._error;
24
+ }
25
+ log(level, ...args) {
26
+ const logger = this[level];
27
+ logger(...args);
28
+ }
29
+ }
30
+
31
+ export { Logger };
@@ -0,0 +1,13 @@
1
+ declare const verificationKey: {
2
+ protocol: string;
3
+ curve: string;
4
+ nPublic: number;
5
+ vk_alpha_1: string[];
6
+ vk_beta_2: string[][];
7
+ vk_gamma_2: string[][];
8
+ vk_delta_2: string[][];
9
+ vk_alphabeta_12: string[][][];
10
+ IC: string[][];
11
+ };
12
+
13
+ export default verificationKey;