@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,96 @@
1
+ // Adapted from Chris Veness' SHA1 code at
2
+ // http://www.movable-type.co.uk/scripts/sha1.html
3
+ function f(s, x, y, z) {
4
+ switch (s) {
5
+ case 0:
6
+ return x & y ^ ~x & z;
7
+
8
+ case 1:
9
+ return x ^ y ^ z;
10
+
11
+ case 2:
12
+ return x & y ^ x & z ^ y & z;
13
+
14
+ case 3:
15
+ return x ^ y ^ z;
16
+ }
17
+ }
18
+
19
+ function ROTL(x, n) {
20
+ return x << n | x >>> 32 - n;
21
+ }
22
+
23
+ function sha1(bytes) {
24
+ var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
25
+ var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
26
+
27
+ if (typeof bytes === 'string') {
28
+ var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
29
+
30
+ bytes = [];
31
+
32
+ for (var i = 0; i < msg.length; ++i) {
33
+ bytes.push(msg.charCodeAt(i));
34
+ }
35
+ } else if (!Array.isArray(bytes)) {
36
+ // Convert Array-like to Array
37
+ bytes = Array.prototype.slice.call(bytes);
38
+ }
39
+
40
+ bytes.push(0x80);
41
+ var l = bytes.length / 4 + 2;
42
+ var N = Math.ceil(l / 16);
43
+ var M = new Array(N);
44
+
45
+ for (var _i = 0; _i < N; ++_i) {
46
+ var arr = new Uint32Array(16);
47
+
48
+ for (var j = 0; j < 16; ++j) {
49
+ arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
50
+ }
51
+
52
+ M[_i] = arr;
53
+ }
54
+
55
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
56
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
57
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
58
+
59
+ for (var _i2 = 0; _i2 < N; ++_i2) {
60
+ var W = new Uint32Array(80);
61
+
62
+ for (var t = 0; t < 16; ++t) {
63
+ W[t] = M[_i2][t];
64
+ }
65
+
66
+ for (var _t = 16; _t < 80; ++_t) {
67
+ W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
68
+ }
69
+
70
+ var a = H[0];
71
+ var b = H[1];
72
+ var c = H[2];
73
+ var d = H[3];
74
+ var e = H[4];
75
+
76
+ for (var _t2 = 0; _t2 < 80; ++_t2) {
77
+ var s = Math.floor(_t2 / 20);
78
+ var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
79
+ e = d;
80
+ d = c;
81
+ c = ROTL(b, 30) >>> 0;
82
+ b = a;
83
+ a = T;
84
+ }
85
+
86
+ H[0] = H[0] + a >>> 0;
87
+ H[1] = H[1] + b >>> 0;
88
+ H[2] = H[2] + c >>> 0;
89
+ H[3] = H[3] + d >>> 0;
90
+ H[4] = H[4] + e >>> 0;
91
+ }
92
+
93
+ return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
94
+ }
95
+
96
+ export { sha1 as default };
@@ -0,0 +1,31 @@
1
+ import validate from './validate.js';
2
+
3
+ /**
4
+ * Convert array of 16 byte values to UUID string format of the form:
5
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6
+ */
7
+
8
+ var byteToHex = [];
9
+
10
+ for (var i = 0; i < 256; ++i) {
11
+ byteToHex.push((i + 0x100).toString(16).substr(1));
12
+ }
13
+
14
+ function stringify(arr) {
15
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
16
+ // Note: Be careful editing this code! It's been tuned for performance
17
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
18
+ var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
19
+ // of the following:
20
+ // - One or more input array values don't map to a hex octet (leading to
21
+ // "undefined" in the uuid)
22
+ // - Invalid input values for the RFC `version` or `variant` fields
23
+
24
+ if (!validate(uuid)) {
25
+ throw TypeError('Stringified UUID is invalid');
26
+ }
27
+
28
+ return uuid;
29
+ }
30
+
31
+ export { stringify as default };
@@ -0,0 +1,96 @@
1
+ import rng from './rng.js';
2
+ import stringify from './stringify.js';
3
+
4
+ //
5
+ // Inspired by https://github.com/LiosK/UUID.js
6
+ // and http://docs.python.org/library/uuid.html
7
+
8
+ var _nodeId;
9
+
10
+ var _clockseq; // Previous uuid creation time
11
+
12
+
13
+ var _lastMSecs = 0;
14
+ var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
15
+
16
+ function v1(options, buf, offset) {
17
+ var i = buf && offset || 0;
18
+ var b = buf || new Array(16);
19
+ options = options || {};
20
+ var node = options.node || _nodeId;
21
+ var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
22
+ // specified. We do this lazily to minimize issues related to insufficient
23
+ // system entropy. See #189
24
+
25
+ if (node == null || clockseq == null) {
26
+ var seedBytes = options.random || (options.rng || rng)();
27
+
28
+ if (node == null) {
29
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
30
+ node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
31
+ }
32
+
33
+ if (clockseq == null) {
34
+ // Per 4.2.2, randomize (14 bit) clockseq
35
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
36
+ }
37
+ } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
38
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
39
+ // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
40
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
41
+
42
+
43
+ var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
44
+ // cycle to simulate higher resolution clock
45
+
46
+ var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
47
+
48
+ var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
49
+
50
+ if (dt < 0 && options.clockseq === undefined) {
51
+ clockseq = clockseq + 1 & 0x3fff;
52
+ } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
53
+ // time interval
54
+
55
+
56
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
57
+ nsecs = 0;
58
+ } // Per 4.2.1.2 Throw error if too many uuids are requested
59
+
60
+
61
+ if (nsecs >= 10000) {
62
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
63
+ }
64
+
65
+ _lastMSecs = msecs;
66
+ _lastNSecs = nsecs;
67
+ _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
68
+
69
+ msecs += 12219292800000; // `time_low`
70
+
71
+ var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
72
+ b[i++] = tl >>> 24 & 0xff;
73
+ b[i++] = tl >>> 16 & 0xff;
74
+ b[i++] = tl >>> 8 & 0xff;
75
+ b[i++] = tl & 0xff; // `time_mid`
76
+
77
+ var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
78
+ b[i++] = tmh >>> 8 & 0xff;
79
+ b[i++] = tmh & 0xff; // `time_high_and_version`
80
+
81
+ b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
82
+
83
+ b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
84
+
85
+ b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
86
+
87
+ b[i++] = clockseq & 0xff; // `node`
88
+
89
+ for (var n = 0; n < 6; ++n) {
90
+ b[i + n] = node[n];
91
+ }
92
+
93
+ return buf || stringify(b);
94
+ }
95
+
96
+ export { v1 as default };
@@ -0,0 +1,6 @@
1
+ import v35 from './v35.js';
2
+ import md5 from './md5.js';
3
+
4
+ var v3 = v35('v3', 0x30, md5);
5
+
6
+ export { v3 as default };
@@ -0,0 +1,66 @@
1
+ import stringify from './stringify.js';
2
+ import parse from './parse.js';
3
+
4
+ function stringToBytes(str) {
5
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
6
+
7
+ var bytes = [];
8
+
9
+ for (var i = 0; i < str.length; ++i) {
10
+ bytes.push(str.charCodeAt(i));
11
+ }
12
+
13
+ return bytes;
14
+ }
15
+
16
+ var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
17
+ var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
18
+ function v35 (name, version, hashfunc) {
19
+ function generateUUID(value, namespace, buf, offset) {
20
+ if (typeof value === 'string') {
21
+ value = stringToBytes(value);
22
+ }
23
+
24
+ if (typeof namespace === 'string') {
25
+ namespace = parse(namespace);
26
+ }
27
+
28
+ if (namespace.length !== 16) {
29
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
30
+ } // Compute hash of namespace and value, Per 4.3
31
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
32
+ // hashfunc([...namespace, ... value])`
33
+
34
+
35
+ var bytes = new Uint8Array(16 + value.length);
36
+ bytes.set(namespace);
37
+ bytes.set(value, namespace.length);
38
+ bytes = hashfunc(bytes);
39
+ bytes[6] = bytes[6] & 0x0f | version;
40
+ bytes[8] = bytes[8] & 0x3f | 0x80;
41
+
42
+ if (buf) {
43
+ offset = offset || 0;
44
+
45
+ for (var i = 0; i < 16; ++i) {
46
+ buf[offset + i] = bytes[i];
47
+ }
48
+
49
+ return buf;
50
+ }
51
+
52
+ return stringify(bytes);
53
+ } // Function#name is not settable on some platforms (#270)
54
+
55
+
56
+ try {
57
+ generateUUID.name = name; // eslint-disable-next-line no-empty
58
+ } catch (err) {} // For CommonJS default export support
59
+
60
+
61
+ generateUUID.DNS = DNS;
62
+ generateUUID.URL = URL;
63
+ return generateUUID;
64
+ }
65
+
66
+ export { DNS, URL, v35 as default };
@@ -0,0 +1,24 @@
1
+ import rng from './rng.js';
2
+ import stringify from './stringify.js';
3
+
4
+ function v4(options, buf, offset) {
5
+ options = options || {};
6
+ var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
7
+
8
+ rnds[6] = rnds[6] & 0x0f | 0x40;
9
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
10
+
11
+ if (buf) {
12
+ offset = offset || 0;
13
+
14
+ for (var i = 0; i < 16; ++i) {
15
+ buf[offset + i] = rnds[i];
16
+ }
17
+
18
+ return buf;
19
+ }
20
+
21
+ return stringify(rnds);
22
+ }
23
+
24
+ export { v4 as default };
@@ -0,0 +1,6 @@
1
+ import v35 from './v35.js';
2
+ import sha1 from './sha1.js';
3
+
4
+ var v5 = v35('v5', 0x50, sha1);
5
+
6
+ export { v5 as default };
@@ -0,0 +1,7 @@
1
+ import REGEX from './regex.js';
2
+
3
+ function validate(uuid) {
4
+ return typeof uuid === 'string' && REGEX.test(uuid);
5
+ }
6
+
7
+ export { validate as default };
@@ -0,0 +1,11 @@
1
+ import validate from './validate.js';
2
+
3
+ function version(uuid) {
4
+ if (!validate(uuid)) {
5
+ throw TypeError('Invalid UUID');
6
+ }
7
+
8
+ return parseInt(uuid.substr(14, 1), 16);
9
+ }
10
+
11
+ export { version as default };
@@ -0,0 +1,52 @@
1
+ import { __exports as _assert } from '../../../../../_virtual/_assert.js';
2
+
3
+ Object.defineProperty(_assert, "__esModule", { value: true });
4
+ _assert.output = _assert.exists = _assert.hash = _assert.bytes = _assert.bool = _assert.number = undefined;
5
+ function number(n) {
6
+ if (!Number.isSafeInteger(n) || n < 0)
7
+ throw new Error(`Wrong positive integer: ${n}`);
8
+ }
9
+ _assert.number = number;
10
+ function bool(b) {
11
+ if (typeof b !== 'boolean')
12
+ throw new Error(`Expected boolean, not ${b}`);
13
+ }
14
+ _assert.bool = bool;
15
+ function bytes(b, ...lengths) {
16
+ if (!(b instanceof Uint8Array))
17
+ throw new TypeError('Expected Uint8Array');
18
+ if (lengths.length > 0 && !lengths.includes(b.length))
19
+ throw new TypeError(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
20
+ }
21
+ _assert.bytes = bytes;
22
+ function hash(hash) {
23
+ if (typeof hash !== 'function' || typeof hash.create !== 'function')
24
+ throw new Error('Hash should be wrapped by utils.wrapConstructor');
25
+ number(hash.outputLen);
26
+ number(hash.blockLen);
27
+ }
28
+ _assert.hash = hash;
29
+ function exists(instance, checkFinished = true) {
30
+ if (instance.destroyed)
31
+ throw new Error('Hash instance has been destroyed');
32
+ if (checkFinished && instance.finished)
33
+ throw new Error('Hash#digest() has already been called');
34
+ }
35
+ _assert.exists = exists;
36
+ function output(out, instance) {
37
+ bytes(out);
38
+ const min = instance.outputLen;
39
+ if (out.length < min) {
40
+ throw new Error(`digestInto() expects output buffer of length at least ${min}`);
41
+ }
42
+ }
43
+ _assert.output = output;
44
+ const assert = {
45
+ number,
46
+ bool,
47
+ bytes,
48
+ hash,
49
+ exists,
50
+ output,
51
+ };
52
+ _assert.default = assert;
@@ -0,0 +1,124 @@
1
+ import { __exports as _sha2 } from '../../../../../_virtual/_sha2.js';
2
+ import './_assert.js';
3
+ import './utils.js';
4
+ import { __exports as _assert } from '../../../../../_virtual/_assert.js';
5
+ import { __exports as utils } from '../../../../../_virtual/utils.js';
6
+
7
+ Object.defineProperty(_sha2, "__esModule", { value: true });
8
+ _sha2.SHA2 = undefined;
9
+ const _assert_js_1 = _assert;
10
+ const utils_js_1 = utils;
11
+ // Polyfill for Safari 14
12
+ function setBigUint64(view, byteOffset, value, isLE) {
13
+ if (typeof view.setBigUint64 === 'function')
14
+ return view.setBigUint64(byteOffset, value, isLE);
15
+ const _32n = BigInt(32);
16
+ const _u32_max = BigInt(0xffffffff);
17
+ const wh = Number((value >> _32n) & _u32_max);
18
+ const wl = Number(value & _u32_max);
19
+ const h = isLE ? 4 : 0;
20
+ const l = isLE ? 0 : 4;
21
+ view.setUint32(byteOffset + h, wh, isLE);
22
+ view.setUint32(byteOffset + l, wl, isLE);
23
+ }
24
+ // Base SHA2 class (RFC 6234)
25
+ class SHA2 extends utils_js_1.Hash {
26
+ constructor(blockLen, outputLen, padOffset, isLE) {
27
+ super();
28
+ this.blockLen = blockLen;
29
+ this.outputLen = outputLen;
30
+ this.padOffset = padOffset;
31
+ this.isLE = isLE;
32
+ this.finished = false;
33
+ this.length = 0;
34
+ this.pos = 0;
35
+ this.destroyed = false;
36
+ this.buffer = new Uint8Array(blockLen);
37
+ this.view = (0, utils_js_1.createView)(this.buffer);
38
+ }
39
+ update(data) {
40
+ _assert_js_1.default.exists(this);
41
+ const { view, buffer, blockLen } = this;
42
+ data = (0, utils_js_1.toBytes)(data);
43
+ const len = data.length;
44
+ for (let pos = 0; pos < len;) {
45
+ const take = Math.min(blockLen - this.pos, len - pos);
46
+ // Fast path: we have at least one block in input, cast it to view and process
47
+ if (take === blockLen) {
48
+ const dataView = (0, utils_js_1.createView)(data);
49
+ for (; blockLen <= len - pos; pos += blockLen)
50
+ this.process(dataView, pos);
51
+ continue;
52
+ }
53
+ buffer.set(data.subarray(pos, pos + take), this.pos);
54
+ this.pos += take;
55
+ pos += take;
56
+ if (this.pos === blockLen) {
57
+ this.process(view, 0);
58
+ this.pos = 0;
59
+ }
60
+ }
61
+ this.length += data.length;
62
+ this.roundClean();
63
+ return this;
64
+ }
65
+ digestInto(out) {
66
+ _assert_js_1.default.exists(this);
67
+ _assert_js_1.default.output(out, this);
68
+ this.finished = true;
69
+ // Padding
70
+ // We can avoid allocation of buffer for padding completely if it
71
+ // was previously not allocated here. But it won't change performance.
72
+ const { buffer, view, blockLen, isLE } = this;
73
+ let { pos } = this;
74
+ // append the bit '1' to the message
75
+ buffer[pos++] = 0b10000000;
76
+ this.buffer.subarray(pos).fill(0);
77
+ // we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again
78
+ if (this.padOffset > blockLen - pos) {
79
+ this.process(view, 0);
80
+ pos = 0;
81
+ }
82
+ // Pad until full block byte with zeros
83
+ for (let i = pos; i < blockLen; i++)
84
+ buffer[i] = 0;
85
+ // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
86
+ // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
87
+ // So we just write lowest 64 bits of that value.
88
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
89
+ this.process(view, 0);
90
+ const oview = (0, utils_js_1.createView)(out);
91
+ const len = this.outputLen;
92
+ // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
93
+ if (len % 4)
94
+ throw new Error('_sha2: outputLen should be aligned to 32bit');
95
+ const outLen = len / 4;
96
+ const state = this.get();
97
+ if (outLen > state.length)
98
+ throw new Error('_sha2: outputLen bigger than state');
99
+ for (let i = 0; i < outLen; i++)
100
+ oview.setUint32(4 * i, state[i], isLE);
101
+ }
102
+ digest() {
103
+ const { buffer, outputLen } = this;
104
+ this.digestInto(buffer);
105
+ const res = buffer.slice(0, outputLen);
106
+ this.destroy();
107
+ return res;
108
+ }
109
+ _cloneInto(to) {
110
+ to || (to = new this.constructor());
111
+ to.set(...this.get());
112
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
113
+ to.length = length;
114
+ to.pos = pos;
115
+ to.finished = finished;
116
+ to.destroyed = destroyed;
117
+ if (length % blockLen)
118
+ to.buffer.set(buffer);
119
+ return to;
120
+ }
121
+ }
122
+ _sha2.SHA2 = SHA2;
123
+
124
+ export { _sha2 as default };
@@ -0,0 +1,71 @@
1
+ import { __exports as _u64 } from '../../../../../_virtual/_u64.js';
2
+
3
+ (function (exports) {
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.add = exports.toBig = exports.split = exports.fromBig = undefined;
6
+ const U32_MASK64 = BigInt(2 ** 32 - 1);
7
+ const _32n = BigInt(32);
8
+ // We are not using BigUint64Array, because they are extremely slow as per 2022
9
+ function fromBig(n, le = false) {
10
+ if (le)
11
+ return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
12
+ return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
13
+ }
14
+ exports.fromBig = fromBig;
15
+ function split(lst, le = false) {
16
+ let Ah = new Uint32Array(lst.length);
17
+ let Al = new Uint32Array(lst.length);
18
+ for (let i = 0; i < lst.length; i++) {
19
+ const { h, l } = fromBig(lst[i], le);
20
+ [Ah[i], Al[i]] = [h, l];
21
+ }
22
+ return [Ah, Al];
23
+ }
24
+ exports.split = split;
25
+ const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
26
+ exports.toBig = toBig;
27
+ // for Shift in [0, 32)
28
+ const shrSH = (h, l, s) => h >>> s;
29
+ const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
30
+ // Right rotate for Shift in [1, 32)
31
+ const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
32
+ const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
33
+ // Right rotate for Shift in (32, 64), NOTE: 32 is special case.
34
+ const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
35
+ const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
36
+ // Right rotate for shift===32 (just swaps l&h)
37
+ const rotr32H = (h, l) => l;
38
+ const rotr32L = (h, l) => h;
39
+ // Left rotate for Shift in [1, 32)
40
+ const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
41
+ const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
42
+ // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
43
+ const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
44
+ const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
45
+ // JS uses 32-bit signed integers for bitwise operations which means we cannot
46
+ // simple take carry out of low bit sum by shift, we need to use division.
47
+ // Removing "export" has 5% perf penalty -_-
48
+ function add(Ah, Al, Bh, Bl) {
49
+ const l = (Al >>> 0) + (Bl >>> 0);
50
+ return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
51
+ }
52
+ exports.add = add;
53
+ // Addition with more than 2 elements
54
+ const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
55
+ const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
56
+ const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
57
+ const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
58
+ const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
59
+ const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
60
+ // prettier-ignore
61
+ const u64 = {
62
+ fromBig, split, toBig: exports.toBig,
63
+ shrSH, shrSL,
64
+ rotrSH, rotrSL, rotrBH, rotrBL,
65
+ rotr32H, rotr32L,
66
+ rotlSH, rotlSL, rotlBH, rotlBL,
67
+ add, add3L, add3H, add4L, add4H, add5H, add5L,
68
+ };
69
+ exports.default = u64;
70
+
71
+ } (_u64));
@@ -0,0 +1,10 @@
1
+ import { __exports as cryptoBrowser } from '../../../../../_virtual/cryptoBrowser.js';
2
+
3
+ Object.defineProperty(cryptoBrowser, "__esModule", { value: true });
4
+ cryptoBrowser.crypto = undefined;
5
+ cryptoBrowser.crypto = {
6
+ node: undefined,
7
+ web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,
8
+ };
9
+
10
+ export { cryptoBrowser as default };