@waku/rln 0.1.3-f6d5deb → 0.1.4-d27db21.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,283 @@
1
+ import { getDefaultExportFromCjs } from '../../../_virtual/_commonjsHelpers.js';
2
+ import { __module as browser } from '../../../_virtual/browser.js';
3
+ import { c as common } from './common.js';
4
+
5
+ /* eslint-env browser */
6
+
7
+ (function (module, exports) {
8
+ /**
9
+ * This is the web browser implementation of `debug()`.
10
+ */
11
+
12
+ exports.formatArgs = formatArgs;
13
+ exports.save = save;
14
+ exports.load = load;
15
+ exports.useColors = useColors;
16
+ exports.storage = localstorage();
17
+ exports.destroy = (() => {
18
+ let warned = false;
19
+
20
+ return () => {
21
+ if (!warned) {
22
+ warned = true;
23
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
24
+ }
25
+ };
26
+ })();
27
+
28
+ /**
29
+ * Colors.
30
+ */
31
+
32
+ exports.colors = [
33
+ '#0000CC',
34
+ '#0000FF',
35
+ '#0033CC',
36
+ '#0033FF',
37
+ '#0066CC',
38
+ '#0066FF',
39
+ '#0099CC',
40
+ '#0099FF',
41
+ '#00CC00',
42
+ '#00CC33',
43
+ '#00CC66',
44
+ '#00CC99',
45
+ '#00CCCC',
46
+ '#00CCFF',
47
+ '#3300CC',
48
+ '#3300FF',
49
+ '#3333CC',
50
+ '#3333FF',
51
+ '#3366CC',
52
+ '#3366FF',
53
+ '#3399CC',
54
+ '#3399FF',
55
+ '#33CC00',
56
+ '#33CC33',
57
+ '#33CC66',
58
+ '#33CC99',
59
+ '#33CCCC',
60
+ '#33CCFF',
61
+ '#6600CC',
62
+ '#6600FF',
63
+ '#6633CC',
64
+ '#6633FF',
65
+ '#66CC00',
66
+ '#66CC33',
67
+ '#9900CC',
68
+ '#9900FF',
69
+ '#9933CC',
70
+ '#9933FF',
71
+ '#99CC00',
72
+ '#99CC33',
73
+ '#CC0000',
74
+ '#CC0033',
75
+ '#CC0066',
76
+ '#CC0099',
77
+ '#CC00CC',
78
+ '#CC00FF',
79
+ '#CC3300',
80
+ '#CC3333',
81
+ '#CC3366',
82
+ '#CC3399',
83
+ '#CC33CC',
84
+ '#CC33FF',
85
+ '#CC6600',
86
+ '#CC6633',
87
+ '#CC9900',
88
+ '#CC9933',
89
+ '#CCCC00',
90
+ '#CCCC33',
91
+ '#FF0000',
92
+ '#FF0033',
93
+ '#FF0066',
94
+ '#FF0099',
95
+ '#FF00CC',
96
+ '#FF00FF',
97
+ '#FF3300',
98
+ '#FF3333',
99
+ '#FF3366',
100
+ '#FF3399',
101
+ '#FF33CC',
102
+ '#FF33FF',
103
+ '#FF6600',
104
+ '#FF6633',
105
+ '#FF9900',
106
+ '#FF9933',
107
+ '#FFCC00',
108
+ '#FFCC33'
109
+ ];
110
+
111
+ /**
112
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
113
+ * and the Firebug extension (any Firefox version) are known
114
+ * to support "%c" CSS customizations.
115
+ *
116
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
117
+ */
118
+
119
+ // eslint-disable-next-line complexity
120
+ function useColors() {
121
+ // NB: In an Electron preload script, document will be defined but not fully
122
+ // initialized. Since we know we're in Chrome, we'll just detect this case
123
+ // explicitly
124
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
125
+ return true;
126
+ }
127
+
128
+ // Internet Explorer and Edge do not support colors.
129
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
130
+ return false;
131
+ }
132
+
133
+ let m;
134
+
135
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
136
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
137
+ // eslint-disable-next-line no-return-assign
138
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
139
+ // Is firebug? http://stackoverflow.com/a/398120/376773
140
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
141
+ // Is firefox >= v31?
142
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
143
+ (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
144
+ // Double check webkit in userAgent just in case we are in a worker
145
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
146
+ }
147
+
148
+ /**
149
+ * Colorize log arguments if enabled.
150
+ *
151
+ * @api public
152
+ */
153
+
154
+ function formatArgs(args) {
155
+ args[0] = (this.useColors ? '%c' : '') +
156
+ this.namespace +
157
+ (this.useColors ? ' %c' : ' ') +
158
+ args[0] +
159
+ (this.useColors ? '%c ' : ' ') +
160
+ '+' + module.exports.humanize(this.diff);
161
+
162
+ if (!this.useColors) {
163
+ return;
164
+ }
165
+
166
+ const c = 'color: ' + this.color;
167
+ args.splice(1, 0, c, 'color: inherit');
168
+
169
+ // The final "%c" is somewhat tricky, because there could be other
170
+ // arguments passed either before or after the %c, so we need to
171
+ // figure out the correct index to insert the CSS into
172
+ let index = 0;
173
+ let lastC = 0;
174
+ args[0].replace(/%[a-zA-Z%]/g, match => {
175
+ if (match === '%%') {
176
+ return;
177
+ }
178
+ index++;
179
+ if (match === '%c') {
180
+ // We only are interested in the *last* %c
181
+ // (the user may have provided their own)
182
+ lastC = index;
183
+ }
184
+ });
185
+
186
+ args.splice(lastC, 0, c);
187
+ }
188
+
189
+ /**
190
+ * Invokes `console.debug()` when available.
191
+ * No-op when `console.debug` is not a "function".
192
+ * If `console.debug` is not available, falls back
193
+ * to `console.log`.
194
+ *
195
+ * @api public
196
+ */
197
+ exports.log = console.debug || console.log || (() => {});
198
+
199
+ /**
200
+ * Save `namespaces`.
201
+ *
202
+ * @param {String} namespaces
203
+ * @api private
204
+ */
205
+ function save(namespaces) {
206
+ try {
207
+ if (namespaces) {
208
+ exports.storage.setItem('debug', namespaces);
209
+ } else {
210
+ exports.storage.removeItem('debug');
211
+ }
212
+ } catch (error) {
213
+ // Swallow
214
+ // XXX (@Qix-) should we be logging these?
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Load `namespaces`.
220
+ *
221
+ * @return {String} returns the previously persisted debug modes
222
+ * @api private
223
+ */
224
+ function load() {
225
+ let r;
226
+ try {
227
+ r = exports.storage.getItem('debug');
228
+ } catch (error) {
229
+ // Swallow
230
+ // XXX (@Qix-) should we be logging these?
231
+ }
232
+
233
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
234
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
235
+ r = process.env.DEBUG;
236
+ }
237
+
238
+ return r;
239
+ }
240
+
241
+ /**
242
+ * Localstorage attempts to return the localstorage.
243
+ *
244
+ * This is necessary because safari throws
245
+ * when a user disables cookies/localstorage
246
+ * and you attempt to access it.
247
+ *
248
+ * @return {LocalStorage}
249
+ * @api private
250
+ */
251
+
252
+ function localstorage() {
253
+ try {
254
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
255
+ // The Browser also has localStorage in the global context.
256
+ return localStorage;
257
+ } catch (error) {
258
+ // Swallow
259
+ // XXX (@Qix-) should we be logging these?
260
+ }
261
+ }
262
+
263
+ module.exports = common(exports);
264
+
265
+ const {formatters} = module.exports;
266
+
267
+ /**
268
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
269
+ */
270
+
271
+ formatters.j = function (v) {
272
+ try {
273
+ return JSON.stringify(v);
274
+ } catch (error) {
275
+ return '[UnexpectedJSONParseError]: ' + error.message;
276
+ }
277
+ };
278
+ } (browser, browser.exports));
279
+
280
+ var browserExports = browser.exports;
281
+ var debug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
282
+
283
+ export { debug as default };
@@ -0,0 +1,295 @@
1
+ import { __require as requireMs } from '../../ms/index.js';
2
+
3
+ /**
4
+ * This is the common logic for both the Node.js and web browser
5
+ * implementations of `debug()`.
6
+ */
7
+
8
+ function setup(env) {
9
+ createDebug.debug = createDebug;
10
+ createDebug.default = createDebug;
11
+ createDebug.coerce = coerce;
12
+ createDebug.disable = disable;
13
+ createDebug.enable = enable;
14
+ createDebug.enabled = enabled;
15
+ createDebug.humanize = requireMs();
16
+ createDebug.destroy = destroy;
17
+
18
+ Object.keys(env).forEach(key => {
19
+ createDebug[key] = env[key];
20
+ });
21
+
22
+ /**
23
+ * The currently active debug mode names, and names to skip.
24
+ */
25
+
26
+ createDebug.names = [];
27
+ createDebug.skips = [];
28
+
29
+ /**
30
+ * Map of special "%n" handling functions, for the debug "format" argument.
31
+ *
32
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
33
+ */
34
+ createDebug.formatters = {};
35
+
36
+ /**
37
+ * Selects a color for a debug namespace
38
+ * @param {String} namespace The namespace string for the debug instance to be colored
39
+ * @return {Number|String} An ANSI color code for the given namespace
40
+ * @api private
41
+ */
42
+ function selectColor(namespace) {
43
+ let hash = 0;
44
+
45
+ for (let i = 0; i < namespace.length; i++) {
46
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
47
+ hash |= 0; // Convert to 32bit integer
48
+ }
49
+
50
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
51
+ }
52
+ createDebug.selectColor = selectColor;
53
+
54
+ /**
55
+ * Create a debugger with the given `namespace`.
56
+ *
57
+ * @param {String} namespace
58
+ * @return {Function}
59
+ * @api public
60
+ */
61
+ function createDebug(namespace) {
62
+ let prevTime;
63
+ let enableOverride = null;
64
+ let namespacesCache;
65
+ let enabledCache;
66
+
67
+ function debug(...args) {
68
+ // Disabled?
69
+ if (!debug.enabled) {
70
+ return;
71
+ }
72
+
73
+ const self = debug;
74
+
75
+ // Set `diff` timestamp
76
+ const curr = Number(new Date());
77
+ const ms = curr - (prevTime || curr);
78
+ self.diff = ms;
79
+ self.prev = prevTime;
80
+ self.curr = curr;
81
+ prevTime = curr;
82
+
83
+ args[0] = createDebug.coerce(args[0]);
84
+
85
+ if (typeof args[0] !== 'string') {
86
+ // Anything else let's inspect with %O
87
+ args.unshift('%O');
88
+ }
89
+
90
+ // Apply any `formatters` transformations
91
+ let index = 0;
92
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
93
+ // If we encounter an escaped % then don't increase the array index
94
+ if (match === '%%') {
95
+ return '%';
96
+ }
97
+ index++;
98
+ const formatter = createDebug.formatters[format];
99
+ if (typeof formatter === 'function') {
100
+ const val = args[index];
101
+ match = formatter.call(self, val);
102
+
103
+ // Now we need to remove `args[index]` since it's inlined in the `format`
104
+ args.splice(index, 1);
105
+ index--;
106
+ }
107
+ return match;
108
+ });
109
+
110
+ // Apply env-specific formatting (colors, etc.)
111
+ createDebug.formatArgs.call(self, args);
112
+
113
+ const logFn = self.log || createDebug.log;
114
+ logFn.apply(self, args);
115
+ }
116
+
117
+ debug.namespace = namespace;
118
+ debug.useColors = createDebug.useColors();
119
+ debug.color = createDebug.selectColor(namespace);
120
+ debug.extend = extend;
121
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
122
+
123
+ Object.defineProperty(debug, 'enabled', {
124
+ enumerable: true,
125
+ configurable: false,
126
+ get: () => {
127
+ if (enableOverride !== null) {
128
+ return enableOverride;
129
+ }
130
+ if (namespacesCache !== createDebug.namespaces) {
131
+ namespacesCache = createDebug.namespaces;
132
+ enabledCache = createDebug.enabled(namespace);
133
+ }
134
+
135
+ return enabledCache;
136
+ },
137
+ set: v => {
138
+ enableOverride = v;
139
+ }
140
+ });
141
+
142
+ // Env-specific initialization logic for debug instances
143
+ if (typeof createDebug.init === 'function') {
144
+ createDebug.init(debug);
145
+ }
146
+
147
+ return debug;
148
+ }
149
+
150
+ function extend(namespace, delimiter) {
151
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
152
+ newDebug.log = this.log;
153
+ return newDebug;
154
+ }
155
+
156
+ /**
157
+ * Enables a debug mode by namespaces. This can include modes
158
+ * separated by a colon and wildcards.
159
+ *
160
+ * @param {String} namespaces
161
+ * @api public
162
+ */
163
+ function enable(namespaces) {
164
+ createDebug.save(namespaces);
165
+ createDebug.namespaces = namespaces;
166
+
167
+ createDebug.names = [];
168
+ createDebug.skips = [];
169
+
170
+ const split = (typeof namespaces === 'string' ? namespaces : '')
171
+ .trim()
172
+ .replace(' ', ',')
173
+ .split(',')
174
+ .filter(Boolean);
175
+
176
+ for (const ns of split) {
177
+ if (ns[0] === '-') {
178
+ createDebug.skips.push(ns.slice(1));
179
+ } else {
180
+ createDebug.names.push(ns);
181
+ }
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Checks if the given string matches a namespace template, honoring
187
+ * asterisks as wildcards.
188
+ *
189
+ * @param {String} search
190
+ * @param {String} template
191
+ * @return {Boolean}
192
+ */
193
+ function matchesTemplate(search, template) {
194
+ let searchIndex = 0;
195
+ let templateIndex = 0;
196
+ let starIndex = -1;
197
+ let matchIndex = 0;
198
+
199
+ while (searchIndex < search.length) {
200
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
201
+ // Match character or proceed with wildcard
202
+ if (template[templateIndex] === '*') {
203
+ starIndex = templateIndex;
204
+ matchIndex = searchIndex;
205
+ templateIndex++; // Skip the '*'
206
+ } else {
207
+ searchIndex++;
208
+ templateIndex++;
209
+ }
210
+ } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
211
+ // Backtrack to the last '*' and try to match more characters
212
+ templateIndex = starIndex + 1;
213
+ matchIndex++;
214
+ searchIndex = matchIndex;
215
+ } else {
216
+ return false; // No match
217
+ }
218
+ }
219
+
220
+ // Handle trailing '*' in template
221
+ while (templateIndex < template.length && template[templateIndex] === '*') {
222
+ templateIndex++;
223
+ }
224
+
225
+ return templateIndex === template.length;
226
+ }
227
+
228
+ /**
229
+ * Disable debug output.
230
+ *
231
+ * @return {String} namespaces
232
+ * @api public
233
+ */
234
+ function disable() {
235
+ const namespaces = [
236
+ ...createDebug.names,
237
+ ...createDebug.skips.map(namespace => '-' + namespace)
238
+ ].join(',');
239
+ createDebug.enable('');
240
+ return namespaces;
241
+ }
242
+
243
+ /**
244
+ * Returns true if the given mode name is enabled, false otherwise.
245
+ *
246
+ * @param {String} name
247
+ * @return {Boolean}
248
+ * @api public
249
+ */
250
+ function enabled(name) {
251
+ for (const skip of createDebug.skips) {
252
+ if (matchesTemplate(name, skip)) {
253
+ return false;
254
+ }
255
+ }
256
+
257
+ for (const ns of createDebug.names) {
258
+ if (matchesTemplate(name, ns)) {
259
+ return true;
260
+ }
261
+ }
262
+
263
+ return false;
264
+ }
265
+
266
+ /**
267
+ * Coerce `val`.
268
+ *
269
+ * @param {Mixed} val
270
+ * @return {Mixed}
271
+ * @api private
272
+ */
273
+ function coerce(val) {
274
+ if (val instanceof Error) {
275
+ return val.stack || val.message;
276
+ }
277
+ return val;
278
+ }
279
+
280
+ /**
281
+ * XXX DO NOT USE. This is a temporary stub function.
282
+ * XXX It WILL be removed in the next major release.
283
+ */
284
+ function destroy() {
285
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
286
+ }
287
+
288
+ createDebug.enable(createDebug.load());
289
+
290
+ return createDebug;
291
+ }
292
+
293
+ var common = setup;
294
+
295
+ export { common as c };
@@ -0,0 +1,10 @@
1
+ import { keccak_256 } from '../../@noble/hashes/esm/sha3.js';
2
+ import { wrapHash } from './utils.js';
3
+
4
+ const keccak256 = (() => {
5
+ const k = wrapHash(keccak_256);
6
+ k.create = keccak_256.create;
7
+ return k;
8
+ })();
9
+
10
+ export { keccak256 };
@@ -0,0 +1,6 @@
1
+ import { sha256 as sha256$1 } from '../../@noble/hashes/esm/sha256.js';
2
+ import { wrapHash } from './utils.js';
3
+
4
+ const sha256 = wrapHash(sha256$1);
5
+
6
+ export { sha256 };
@@ -0,0 +1,24 @@
1
+ import { abytes } from '../../@noble/hashes/esm/_assert.js';
2
+ import { hexToBytes as hexToBytes$1 } from '../../@noble/hashes/esm/utils.js';
3
+ export { bytesToHex, concatBytes, createView, bytesToHex as toHex, utf8ToBytes } from '../../@noble/hashes/esm/utils.js';
4
+
5
+ // buf.toString('utf8') -> bytesToUtf8(buf)
6
+ function bytesToUtf8(data) {
7
+ if (!(data instanceof Uint8Array)) {
8
+ throw new TypeError(`bytesToUtf8 expected Uint8Array, got ${typeof data}`);
9
+ }
10
+ return new TextDecoder().decode(data);
11
+ }
12
+ function hexToBytes(data) {
13
+ const sliced = data.startsWith("0x") ? data.substring(2) : data;
14
+ return hexToBytes$1(sliced);
15
+ }
16
+ // Internal utils
17
+ function wrapHash(hash) {
18
+ return (msg) => {
19
+ abytes(msg);
20
+ return hash(msg);
21
+ };
22
+ }
23
+
24
+ export { abytes as assertBytes, bytesToUtf8, hexToBytes, wrapHash };
@@ -0,0 +1,97 @@
1
+ import { __exports as common } from '../../../../_virtual/common.js';
2
+ import './utils.js';
3
+ import { m as minimalisticAssert } from '../../../minimalistic-assert/index.js';
4
+ import { __exports as utils$1 } from '../../../../_virtual/utils3.js';
5
+
6
+ var utils = utils$1;
7
+ var assert = minimalisticAssert;
8
+
9
+ function BlockHash() {
10
+ this.pending = null;
11
+ this.pendingTotal = 0;
12
+ this.blockSize = this.constructor.blockSize;
13
+ this.outSize = this.constructor.outSize;
14
+ this.hmacStrength = this.constructor.hmacStrength;
15
+ this.padLength = this.constructor.padLength / 8;
16
+ this.endian = 'big';
17
+
18
+ this._delta8 = this.blockSize / 8;
19
+ this._delta32 = this.blockSize / 32;
20
+ }
21
+ common.BlockHash = BlockHash;
22
+
23
+ BlockHash.prototype.update = function update(msg, enc) {
24
+ // Convert message to array, pad it, and join into 32bit blocks
25
+ msg = utils.toArray(msg, enc);
26
+ if (!this.pending)
27
+ this.pending = msg;
28
+ else
29
+ this.pending = this.pending.concat(msg);
30
+ this.pendingTotal += msg.length;
31
+
32
+ // Enough data, try updating
33
+ if (this.pending.length >= this._delta8) {
34
+ msg = this.pending;
35
+
36
+ // Process pending data in blocks
37
+ var r = msg.length % this._delta8;
38
+ this.pending = msg.slice(msg.length - r, msg.length);
39
+ if (this.pending.length === 0)
40
+ this.pending = null;
41
+
42
+ msg = utils.join32(msg, 0, msg.length - r, this.endian);
43
+ for (var i = 0; i < msg.length; i += this._delta32)
44
+ this._update(msg, i, i + this._delta32);
45
+ }
46
+
47
+ return this;
48
+ };
49
+
50
+ BlockHash.prototype.digest = function digest(enc) {
51
+ this.update(this._pad());
52
+ assert(this.pending === null);
53
+
54
+ return this._digest(enc);
55
+ };
56
+
57
+ BlockHash.prototype._pad = function pad() {
58
+ var len = this.pendingTotal;
59
+ var bytes = this._delta8;
60
+ var k = bytes - ((len + this.padLength) % bytes);
61
+ var res = new Array(k + this.padLength);
62
+ res[0] = 0x80;
63
+ for (var i = 1; i < k; i++)
64
+ res[i] = 0;
65
+
66
+ // Append length
67
+ len <<= 3;
68
+ if (this.endian === 'big') {
69
+ for (var t = 8; t < this.padLength; t++)
70
+ res[i++] = 0;
71
+
72
+ res[i++] = 0;
73
+ res[i++] = 0;
74
+ res[i++] = 0;
75
+ res[i++] = 0;
76
+ res[i++] = (len >>> 24) & 0xff;
77
+ res[i++] = (len >>> 16) & 0xff;
78
+ res[i++] = (len >>> 8) & 0xff;
79
+ res[i++] = len & 0xff;
80
+ } else {
81
+ res[i++] = len & 0xff;
82
+ res[i++] = (len >>> 8) & 0xff;
83
+ res[i++] = (len >>> 16) & 0xff;
84
+ res[i++] = (len >>> 24) & 0xff;
85
+ res[i++] = 0;
86
+ res[i++] = 0;
87
+ res[i++] = 0;
88
+ res[i++] = 0;
89
+
90
+ for (t = 8; t < this.padLength; t++)
91
+ res[i++] = 0;
92
+ }
93
+
94
+ return res;
95
+ };
96
+
97
+ export { common as default };