@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.
- package/README.md +10 -186
- package/bundle/_virtual/__node-resolve_empty.js +6 -0
- package/bundle/_virtual/_assert.js +3 -0
- package/bundle/_virtual/_commonjs-dynamic-modules.js +5 -0
- package/bundle/_virtual/_commonjsHelpers.js +32 -0
- package/bundle/_virtual/_node-resolve_empty.js +3 -0
- package/bundle/_virtual/_sha2.js +3 -0
- package/bundle/_virtual/_u64.js +3 -0
- package/bundle/_virtual/aes.js +3 -0
- package/bundle/_virtual/bn.js +3 -0
- package/bundle/_virtual/browser.js +3 -0
- package/bundle/_virtual/checksum.js +3 -0
- package/bundle/_virtual/cipher.js +3 -0
- package/bundle/_virtual/class.js +3 -0
- package/bundle/_virtual/common.js +3 -0
- package/bundle/_virtual/common2.js +3 -0
- package/bundle/_virtual/cryptoBrowser.js +3 -0
- package/bundle/_virtual/functional.js +3 -0
- package/bundle/_virtual/hash.js +3 -0
- package/bundle/_virtual/hmac.js +3 -0
- package/bundle/_virtual/index.js +3 -0
- package/bundle/_virtual/index2.js +6 -0
- package/bundle/_virtual/inherits_browser.js +3 -0
- package/bundle/_virtual/kdf.js +3 -0
- package/bundle/_virtual/lodash.js +3 -0
- package/bundle/_virtual/password.js +3 -0
- package/bundle/_virtual/pbkdf2.js +3 -0
- package/bundle/_virtual/pbkdf22.js +3 -0
- package/bundle/_virtual/random.js +3 -0
- package/bundle/_virtual/ripemd.js +3 -0
- package/bundle/_virtual/schema-validation-generated.js +3 -0
- package/bundle/_virtual/schema-validation.js +3 -0
- package/bundle/_virtual/scrypt.js +3 -0
- package/bundle/_virtual/scrypt2.js +3 -0
- package/bundle/_virtual/sha.js +3 -0
- package/bundle/_virtual/sha256.js +3 -0
- package/bundle/_virtual/sha2562.js +3 -0
- package/bundle/_virtual/sha3.js +3 -0
- package/bundle/_virtual/sha512.js +3 -0
- package/bundle/_virtual/types.js +3 -0
- package/bundle/_virtual/utils.js +3 -0
- package/bundle/_virtual/utils2.js +3 -0
- package/bundle/_virtual/utils3.js +3 -0
- package/bundle/index.js +12 -74804
- package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +96 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +148 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +26 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +20 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +210 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +18 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +30 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +26 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +22 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +43 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +19 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +58 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +854 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +609 -0
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +66 -0
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +302 -0
- package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +110 -0
- package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +20 -0
- package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +120 -0
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +287 -0
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +402 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +3 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +8 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +3 -0
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +893 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +256 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +36 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +135 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +8 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +64 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +443 -0
- package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +8 -0
- package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +660 -0
- package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +352 -0
- package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +248 -0
- package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +127 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +2007 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +422 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +674 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +132 -0
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +120 -0
- package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +8 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +2430 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +76 -0
- package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +219 -0
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +279 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +69 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +404 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/convert.js +15 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +20 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js +92 -0
- package/bundle/node_modules/@noble/hashes/esm/_assert.js +37 -0
- package/bundle/node_modules/@noble/hashes/esm/_md.js +132 -0
- package/bundle/node_modules/@noble/hashes/esm/_u64.js +29 -0
- package/bundle/node_modules/@noble/hashes/esm/sha256.js +113 -0
- package/bundle/node_modules/@noble/hashes/esm/sha3.js +210 -0
- package/bundle/node_modules/@noble/hashes/esm/utils.js +144 -0
- package/bundle/node_modules/@waku/zerokit-rln-wasm/rln_wasm.js +756 -0
- package/bundle/node_modules/bech32/index.js +187 -0
- package/bundle/node_modules/bn.js/lib/bn.js +3361 -0
- package/bundle/node_modules/debug/src/browser.js +283 -0
- package/bundle/node_modules/debug/src/common.js +295 -0
- package/bundle/node_modules/ethereum-cryptography/esm/keccak.js +10 -0
- package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +6 -0
- package/bundle/node_modules/ethereum-cryptography/esm/utils.js +24 -0
- package/bundle/node_modules/hash.js/lib/hash/common.js +97 -0
- package/bundle/node_modules/hash.js/lib/hash/hmac.js +51 -0
- package/bundle/node_modules/hash.js/lib/hash/ripemd.js +152 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/1.js +81 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/224.js +33 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/256.js +113 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/384.js +39 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/512.js +336 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/common.js +53 -0
- package/bundle/node_modules/hash.js/lib/hash/sha.js +14 -0
- package/bundle/node_modules/hash.js/lib/hash/utils.js +282 -0
- package/bundle/node_modules/hash.js/lib/hash.js +33 -0
- package/bundle/node_modules/inherits/inherits_browser.js +33 -0
- package/bundle/node_modules/it-length-prefixed/dist/src/decode.js +6 -0
- package/bundle/node_modules/lodash/lodash.js +17207 -0
- package/bundle/node_modules/minimalistic-assert/index.js +13 -0
- package/bundle/node_modules/ms/index.js +172 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base.js +205 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base10.js +9 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base16.js +16 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base2.js +10 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base256emoji.js +41 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base32.js +58 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base36.js +14 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base58.js +14 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base64.js +28 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base8.js +10 -0
- package/bundle/node_modules/multiformats/dist/src/bases/identity.js +11 -0
- package/bundle/node_modules/multiformats/dist/src/basics.js +15 -0
- package/bundle/node_modules/multiformats/dist/src/bytes.js +18 -0
- package/bundle/node_modules/multiformats/dist/src/codecs/json.js +2 -0
- package/bundle/node_modules/multiformats/dist/src/vendor/base-x.js +170 -0
- package/bundle/node_modules/protons-runtime/dist/src/codec.js +20 -0
- package/bundle/node_modules/protons-runtime/dist/src/codecs/enum.js +24 -0
- package/bundle/node_modules/protons-runtime/dist/src/codecs/message.js +7 -0
- package/bundle/node_modules/protons-runtime/dist/src/decode.js +8 -0
- package/bundle/node_modules/protons-runtime/dist/src/encode.js +11 -0
- package/bundle/node_modules/protons-runtime/dist/src/index.js +30 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/float.js +54 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/longbits.js +175 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/pool.js +28 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/reader.js +367 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/utf8.js +99 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/writer.js +438 -0
- package/bundle/node_modules/uint8-varint/dist/src/index.js +124 -0
- package/bundle/node_modules/uint8arrays/dist/src/alloc.js +17 -0
- package/bundle/node_modules/uint8arrays/dist/src/from-string.js +19 -0
- package/bundle/node_modules/uint8arrays/dist/src/util/bases.js +49 -0
- package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +21 -0
- package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +18 -0
- package/bundle/packages/core/dist/lib/filter/filter.js +27 -0
- package/bundle/packages/core/dist/lib/light_push/light_push.js +27 -0
- package/bundle/packages/core/dist/lib/message/version_0.js +154 -0
- package/bundle/packages/core/dist/lib/metadata/metadata.js +27 -0
- package/bundle/packages/core/dist/lib/store/store.js +27 -0
- package/bundle/packages/interfaces/dist/connection_manager.js +19 -0
- package/bundle/packages/interfaces/dist/constants.js +6 -0
- package/bundle/packages/interfaces/dist/health_indicator.js +12 -0
- package/bundle/packages/interfaces/dist/protocols.js +92 -0
- package/bundle/packages/proto/dist/generated/filter.js +445 -0
- package/bundle/packages/proto/dist/generated/filter_v2.js +424 -0
- package/bundle/packages/proto/dist/generated/light_push.js +389 -0
- package/bundle/packages/proto/dist/generated/message.js +213 -0
- package/bundle/packages/proto/dist/generated/metadata.js +130 -0
- package/bundle/packages/proto/dist/generated/peer_exchange.js +209 -0
- package/bundle/packages/proto/dist/generated/sds_message.js +105 -0
- package/bundle/packages/proto/dist/generated/store_v3.js +490 -0
- package/bundle/packages/proto/dist/generated/topic_only_message.js +61 -0
- package/bundle/packages/rln/dist/codec.js +93 -0
- package/bundle/packages/rln/dist/contract/abi.js +394 -0
- package/bundle/packages/rln/dist/contract/constants.js +27 -0
- package/bundle/packages/rln/dist/contract/rln_contract.js +438 -0
- package/bundle/packages/rln/dist/create.js +9 -0
- package/bundle/packages/rln/dist/identity.js +30 -0
- package/bundle/packages/rln/dist/keystore/cipher.js +31 -0
- package/bundle/packages/rln/dist/keystore/credential_validation_generated.js +119 -0
- package/bundle/packages/rln/dist/keystore/keystore.js +223 -0
- package/bundle/packages/rln/dist/keystore/keystore_validation_generated.js +74 -0
- package/bundle/packages/rln/dist/keystore/schema_validator.js +20 -0
- package/bundle/packages/rln/dist/message.js +51 -0
- package/bundle/packages/rln/dist/proof.js +54 -0
- package/bundle/packages/rln/dist/resources/verification_key.js +112 -0
- package/bundle/packages/rln/dist/resources/witness_calculator.js +330 -0
- package/bundle/packages/rln/dist/rln.js +220 -0
- package/bundle/packages/rln/dist/root_tracker.js +76 -0
- package/bundle/packages/rln/dist/utils/bytes.js +65 -0
- package/bundle/packages/rln/dist/utils/epoch.js +39 -0
- package/bundle/packages/rln/dist/utils/hash.js +10 -0
- package/bundle/packages/rln/dist/utils/metamask.js +14 -0
- package/bundle/packages/rln/dist/zerokit.js +128 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +52 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +65 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +99 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +103 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/index.js +28 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +78 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +17 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1253 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +40 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/types.js +5 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +103 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +41 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +17 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +23 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +12 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +77 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +9 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +215 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +3 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +35 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +3 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +21 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +96 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +6 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +66 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +24 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +6 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +7 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +11 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +52 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +124 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +71 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +10 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +88 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +99 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +233 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +133 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +243 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +167 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/native.js +4 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/rng.js +13 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/stringify.js +28 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/v4.js +19 -0
- package/bundle/packages/utils/dist/bytes/index.js +44 -0
- package/bundle/packages/utils/dist/common/sharding/index.js +91 -0
- package/bundle/packages/utils/dist/logger/index.js +31 -0
- package/bundle/resources/verification_key.d.ts +13 -0
- package/bundle/resources/verification_key.js +112 -0
- package/bundle/resources/witness_calculator.d.ts +11 -0
- package/bundle/resources/witness_calculator.js +328 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/codec.d.ts +5 -5
- package/dist/codec.js +6 -6
- package/dist/codec.js.map +1 -1
- package/dist/contract/abi.d.ts +42 -0
- package/dist/contract/abi.js +393 -0
- package/dist/contract/abi.js.map +1 -0
- package/dist/contract/constants.d.ts +59 -3
- package/dist/contract/constants.js +21 -63
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_contract.d.ts +98 -17
- package/dist/contract/rln_contract.js +292 -71
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/identity.js +5 -2
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/keystore/cipher.js +3 -3
- package/dist/keystore/cipher.js.map +1 -1
- package/dist/keystore/credential_validation_generated.js.map +1 -1
- package/dist/keystore/keystore.js +4 -4
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/keystore_validation_generated.js.map +1 -1
- package/dist/message.js +3 -3
- package/dist/message.js.map +1 -1
- package/dist/proof.js +3 -2
- package/dist/proof.js.map +1 -1
- package/dist/resources/verification_key.d.ts +12 -11
- package/dist/resources/verification_key.js +103 -103
- package/dist/resources/witness_calculator.d.ts +10 -15
- package/dist/resources/witness_calculator.js +302 -265
- package/dist/rln.d.ts +5 -1
- package/dist/rln.js +56 -28
- package/dist/rln.js.map +1 -1
- package/dist/root_tracker.js.map +1 -1
- package/dist/utils/epoch.js +5 -5
- package/dist/utils/epoch.js.map +1 -1
- package/dist/zerokit.d.ts +13 -9
- package/dist/zerokit.js +40 -20
- package/dist/zerokit.js.map +1 -1
- package/package.json +1 -146
- package/src/codec.ts +26 -22
- package/src/contract/abi.ts +392 -0
- package/src/contract/constants.ts +28 -0
- package/src/contract/index.ts +2 -0
- package/src/contract/rln_contract.ts +686 -0
- package/src/identity.ts +8 -4
- package/src/index.ts +4 -9
- package/src/keystore/cipher.ts +54 -0
- package/src/keystore/credential_validation_generated.ts +7 -0
- package/src/keystore/index.ts +5 -0
- package/src/keystore/keystore.ts +330 -0
- package/src/keystore/keystore_validation_generated.ts +7 -0
- package/src/keystore/schema_validator.ts +34 -0
- package/src/keystore/types.ts +36 -0
- package/src/message.ts +10 -10
- package/src/proof.ts +13 -11
- package/src/resources/verification_key.d.ts +13 -0
- package/src/resources/witness_calculator.d.ts +11 -0
- package/src/rln.ts +76 -31
- package/src/root_tracker.ts +7 -6
- package/src/utils/bytes.ts +84 -0
- package/src/utils/epoch.ts +30 -0
- package/src/utils/hash.ts +15 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/metamask.ts +17 -0
- package/src/zerokit.ts +95 -33
- package/bundle/assets/rln_wasm_bg-a503e304.wasm +0 -0
- package/dist/resources/verification_key.js.map +0 -1
- package/dist/resources/witness_calculator.js.map +0 -1
- /package/bundle/{assets/rln-6ded2896.wasm → resources/rln.wasm} +0 -0
- /package/bundle/{assets/rln_final-8b299152.zkey → resources/rln_final.zkey} +0 -0
@@ -0,0 +1,287 @@
|
|
1
|
+
import BN$1 from '../../../bn.js/lib/bn.js';
|
2
|
+
import { isBytes, hexlify, isHexString } from '../../bytes/lib.esm/index.js';
|
3
|
+
import { Logger } from '../../logger/lib.esm/index.js';
|
4
|
+
import { version } from './_version.js';
|
5
|
+
|
6
|
+
var BN = BN$1.BN;
|
7
|
+
const logger = new Logger(version);
|
8
|
+
const _constructorGuard = {};
|
9
|
+
const MAX_SAFE = 0x1fffffffffffff;
|
10
|
+
// Only warn about passing 10 into radix once
|
11
|
+
let _warnedToStringRadix = false;
|
12
|
+
class BigNumber {
|
13
|
+
constructor(constructorGuard, hex) {
|
14
|
+
if (constructorGuard !== _constructorGuard) {
|
15
|
+
logger.throwError("cannot call constructor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, {
|
16
|
+
operation: "new (BigNumber)"
|
17
|
+
});
|
18
|
+
}
|
19
|
+
this._hex = hex;
|
20
|
+
this._isBigNumber = true;
|
21
|
+
Object.freeze(this);
|
22
|
+
}
|
23
|
+
fromTwos(value) {
|
24
|
+
return toBigNumber(toBN(this).fromTwos(value));
|
25
|
+
}
|
26
|
+
toTwos(value) {
|
27
|
+
return toBigNumber(toBN(this).toTwos(value));
|
28
|
+
}
|
29
|
+
abs() {
|
30
|
+
if (this._hex[0] === "-") {
|
31
|
+
return BigNumber.from(this._hex.substring(1));
|
32
|
+
}
|
33
|
+
return this;
|
34
|
+
}
|
35
|
+
add(other) {
|
36
|
+
return toBigNumber(toBN(this).add(toBN(other)));
|
37
|
+
}
|
38
|
+
sub(other) {
|
39
|
+
return toBigNumber(toBN(this).sub(toBN(other)));
|
40
|
+
}
|
41
|
+
div(other) {
|
42
|
+
const o = BigNumber.from(other);
|
43
|
+
if (o.isZero()) {
|
44
|
+
throwFault("division-by-zero", "div");
|
45
|
+
}
|
46
|
+
return toBigNumber(toBN(this).div(toBN(other)));
|
47
|
+
}
|
48
|
+
mul(other) {
|
49
|
+
return toBigNumber(toBN(this).mul(toBN(other)));
|
50
|
+
}
|
51
|
+
mod(other) {
|
52
|
+
const value = toBN(other);
|
53
|
+
if (value.isNeg()) {
|
54
|
+
throwFault("division-by-zero", "mod");
|
55
|
+
}
|
56
|
+
return toBigNumber(toBN(this).umod(value));
|
57
|
+
}
|
58
|
+
pow(other) {
|
59
|
+
const value = toBN(other);
|
60
|
+
if (value.isNeg()) {
|
61
|
+
throwFault("negative-power", "pow");
|
62
|
+
}
|
63
|
+
return toBigNumber(toBN(this).pow(value));
|
64
|
+
}
|
65
|
+
and(other) {
|
66
|
+
const value = toBN(other);
|
67
|
+
if (this.isNegative() || value.isNeg()) {
|
68
|
+
throwFault("unbound-bitwise-result", "and");
|
69
|
+
}
|
70
|
+
return toBigNumber(toBN(this).and(value));
|
71
|
+
}
|
72
|
+
or(other) {
|
73
|
+
const value = toBN(other);
|
74
|
+
if (this.isNegative() || value.isNeg()) {
|
75
|
+
throwFault("unbound-bitwise-result", "or");
|
76
|
+
}
|
77
|
+
return toBigNumber(toBN(this).or(value));
|
78
|
+
}
|
79
|
+
xor(other) {
|
80
|
+
const value = toBN(other);
|
81
|
+
if (this.isNegative() || value.isNeg()) {
|
82
|
+
throwFault("unbound-bitwise-result", "xor");
|
83
|
+
}
|
84
|
+
return toBigNumber(toBN(this).xor(value));
|
85
|
+
}
|
86
|
+
mask(value) {
|
87
|
+
if (this.isNegative() || value < 0) {
|
88
|
+
throwFault("negative-width", "mask");
|
89
|
+
}
|
90
|
+
return toBigNumber(toBN(this).maskn(value));
|
91
|
+
}
|
92
|
+
shl(value) {
|
93
|
+
if (this.isNegative() || value < 0) {
|
94
|
+
throwFault("negative-width", "shl");
|
95
|
+
}
|
96
|
+
return toBigNumber(toBN(this).shln(value));
|
97
|
+
}
|
98
|
+
shr(value) {
|
99
|
+
if (this.isNegative() || value < 0) {
|
100
|
+
throwFault("negative-width", "shr");
|
101
|
+
}
|
102
|
+
return toBigNumber(toBN(this).shrn(value));
|
103
|
+
}
|
104
|
+
eq(other) {
|
105
|
+
return toBN(this).eq(toBN(other));
|
106
|
+
}
|
107
|
+
lt(other) {
|
108
|
+
return toBN(this).lt(toBN(other));
|
109
|
+
}
|
110
|
+
lte(other) {
|
111
|
+
return toBN(this).lte(toBN(other));
|
112
|
+
}
|
113
|
+
gt(other) {
|
114
|
+
return toBN(this).gt(toBN(other));
|
115
|
+
}
|
116
|
+
gte(other) {
|
117
|
+
return toBN(this).gte(toBN(other));
|
118
|
+
}
|
119
|
+
isNegative() {
|
120
|
+
return (this._hex[0] === "-");
|
121
|
+
}
|
122
|
+
isZero() {
|
123
|
+
return toBN(this).isZero();
|
124
|
+
}
|
125
|
+
toNumber() {
|
126
|
+
try {
|
127
|
+
return toBN(this).toNumber();
|
128
|
+
}
|
129
|
+
catch (error) {
|
130
|
+
throwFault("overflow", "toNumber", this.toString());
|
131
|
+
}
|
132
|
+
return null;
|
133
|
+
}
|
134
|
+
toBigInt() {
|
135
|
+
try {
|
136
|
+
return BigInt(this.toString());
|
137
|
+
}
|
138
|
+
catch (e) { }
|
139
|
+
return logger.throwError("this platform does not support BigInt", Logger.errors.UNSUPPORTED_OPERATION, {
|
140
|
+
value: this.toString()
|
141
|
+
});
|
142
|
+
}
|
143
|
+
toString() {
|
144
|
+
// Lots of people expect this, which we do not support, so check (See: #889)
|
145
|
+
if (arguments.length > 0) {
|
146
|
+
if (arguments[0] === 10) {
|
147
|
+
if (!_warnedToStringRadix) {
|
148
|
+
_warnedToStringRadix = true;
|
149
|
+
logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed");
|
150
|
+
}
|
151
|
+
}
|
152
|
+
else if (arguments[0] === 16) {
|
153
|
+
logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", Logger.errors.UNEXPECTED_ARGUMENT, {});
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
logger.throwError("BigNumber.toString does not accept parameters", Logger.errors.UNEXPECTED_ARGUMENT, {});
|
157
|
+
}
|
158
|
+
}
|
159
|
+
return toBN(this).toString(10);
|
160
|
+
}
|
161
|
+
toHexString() {
|
162
|
+
return this._hex;
|
163
|
+
}
|
164
|
+
toJSON(key) {
|
165
|
+
return { type: "BigNumber", hex: this.toHexString() };
|
166
|
+
}
|
167
|
+
static from(value) {
|
168
|
+
if (value instanceof BigNumber) {
|
169
|
+
return value;
|
170
|
+
}
|
171
|
+
if (typeof (value) === "string") {
|
172
|
+
if (value.match(/^-?0x[0-9a-f]+$/i)) {
|
173
|
+
return new BigNumber(_constructorGuard, toHex(value));
|
174
|
+
}
|
175
|
+
if (value.match(/^-?[0-9]+$/)) {
|
176
|
+
return new BigNumber(_constructorGuard, toHex(new BN(value)));
|
177
|
+
}
|
178
|
+
return logger.throwArgumentError("invalid BigNumber string", "value", value);
|
179
|
+
}
|
180
|
+
if (typeof (value) === "number") {
|
181
|
+
if (value % 1) {
|
182
|
+
throwFault("underflow", "BigNumber.from", value);
|
183
|
+
}
|
184
|
+
if (value >= MAX_SAFE || value <= -9007199254740991) {
|
185
|
+
throwFault("overflow", "BigNumber.from", value);
|
186
|
+
}
|
187
|
+
return BigNumber.from(String(value));
|
188
|
+
}
|
189
|
+
const anyValue = value;
|
190
|
+
if (typeof (anyValue) === "bigint") {
|
191
|
+
return BigNumber.from(anyValue.toString());
|
192
|
+
}
|
193
|
+
if (isBytes(anyValue)) {
|
194
|
+
return BigNumber.from(hexlify(anyValue));
|
195
|
+
}
|
196
|
+
if (anyValue) {
|
197
|
+
// Hexable interface (takes priority)
|
198
|
+
if (anyValue.toHexString) {
|
199
|
+
const hex = anyValue.toHexString();
|
200
|
+
if (typeof (hex) === "string") {
|
201
|
+
return BigNumber.from(hex);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
else {
|
205
|
+
// For now, handle legacy JSON-ified values (goes away in v6)
|
206
|
+
let hex = anyValue._hex;
|
207
|
+
// New-form JSON
|
208
|
+
if (hex == null && anyValue.type === "BigNumber") {
|
209
|
+
hex = anyValue.hex;
|
210
|
+
}
|
211
|
+
if (typeof (hex) === "string") {
|
212
|
+
if (isHexString(hex) || (hex[0] === "-" && isHexString(hex.substring(1)))) {
|
213
|
+
return BigNumber.from(hex);
|
214
|
+
}
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
return logger.throwArgumentError("invalid BigNumber value", "value", value);
|
219
|
+
}
|
220
|
+
static isBigNumber(value) {
|
221
|
+
return !!(value && value._isBigNumber);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
// Normalize the hex string
|
225
|
+
function toHex(value) {
|
226
|
+
// For BN, call on the hex string
|
227
|
+
if (typeof (value) !== "string") {
|
228
|
+
return toHex(value.toString(16));
|
229
|
+
}
|
230
|
+
// If negative, prepend the negative sign to the normalized positive value
|
231
|
+
if (value[0] === "-") {
|
232
|
+
// Strip off the negative sign
|
233
|
+
value = value.substring(1);
|
234
|
+
// Cannot have multiple negative signs (e.g. "--0x04")
|
235
|
+
if (value[0] === "-") {
|
236
|
+
logger.throwArgumentError("invalid hex", "value", value);
|
237
|
+
}
|
238
|
+
// Call toHex on the positive component
|
239
|
+
value = toHex(value);
|
240
|
+
// Do not allow "-0x00"
|
241
|
+
if (value === "0x00") {
|
242
|
+
return value;
|
243
|
+
}
|
244
|
+
// Negate the value
|
245
|
+
return "-" + value;
|
246
|
+
}
|
247
|
+
// Add a "0x" prefix if missing
|
248
|
+
if (value.substring(0, 2) !== "0x") {
|
249
|
+
value = "0x" + value;
|
250
|
+
}
|
251
|
+
// Normalize zero
|
252
|
+
if (value === "0x") {
|
253
|
+
return "0x00";
|
254
|
+
}
|
255
|
+
// Make the string even length
|
256
|
+
if (value.length % 2) {
|
257
|
+
value = "0x0" + value.substring(2);
|
258
|
+
}
|
259
|
+
// Trim to smallest even-length string
|
260
|
+
while (value.length > 4 && value.substring(0, 4) === "0x00") {
|
261
|
+
value = "0x" + value.substring(4);
|
262
|
+
}
|
263
|
+
return value;
|
264
|
+
}
|
265
|
+
function toBigNumber(value) {
|
266
|
+
return BigNumber.from(toHex(value));
|
267
|
+
}
|
268
|
+
function toBN(value) {
|
269
|
+
const hex = BigNumber.from(value).toHexString();
|
270
|
+
if (hex[0] === "-") {
|
271
|
+
return (new BN("-" + hex.substring(3), 16));
|
272
|
+
}
|
273
|
+
return new BN(hex.substring(2), 16);
|
274
|
+
}
|
275
|
+
function throwFault(fault, operation, value) {
|
276
|
+
const params = { fault: fault, operation: operation };
|
277
|
+
if (value != null) {
|
278
|
+
params.value = value;
|
279
|
+
}
|
280
|
+
return logger.throwError(fault, Logger.errors.NUMERIC_FAULT, params);
|
281
|
+
}
|
282
|
+
// value should have no prefix
|
283
|
+
function _base36To16(value) {
|
284
|
+
return (new BN(value, 36)).toString(16);
|
285
|
+
}
|
286
|
+
|
287
|
+
export { BigNumber, _base36To16 };
|
@@ -0,0 +1,402 @@
|
|
1
|
+
import { Logger } from '../../logger/lib.esm/index.js';
|
2
|
+
import { version } from './_version.js';
|
3
|
+
|
4
|
+
const logger = new Logger(version);
|
5
|
+
///////////////////////////////
|
6
|
+
function isHexable(value) {
|
7
|
+
return !!(value.toHexString);
|
8
|
+
}
|
9
|
+
function addSlice(array) {
|
10
|
+
if (array.slice) {
|
11
|
+
return array;
|
12
|
+
}
|
13
|
+
array.slice = function () {
|
14
|
+
const args = Array.prototype.slice.call(arguments);
|
15
|
+
return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
|
16
|
+
};
|
17
|
+
return array;
|
18
|
+
}
|
19
|
+
function isBytesLike(value) {
|
20
|
+
return ((isHexString(value) && !(value.length % 2)) || isBytes(value));
|
21
|
+
}
|
22
|
+
function isInteger(value) {
|
23
|
+
return (typeof (value) === "number" && value == value && (value % 1) === 0);
|
24
|
+
}
|
25
|
+
function isBytes(value) {
|
26
|
+
if (value == null) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
if (value.constructor === Uint8Array) {
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
if (typeof (value) === "string") {
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
if (!isInteger(value.length) || value.length < 0) {
|
36
|
+
return false;
|
37
|
+
}
|
38
|
+
for (let i = 0; i < value.length; i++) {
|
39
|
+
const v = value[i];
|
40
|
+
if (!isInteger(v) || v < 0 || v >= 256) {
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return true;
|
45
|
+
}
|
46
|
+
function arrayify(value, options) {
|
47
|
+
if (!options) {
|
48
|
+
options = {};
|
49
|
+
}
|
50
|
+
if (typeof (value) === "number") {
|
51
|
+
logger.checkSafeUint53(value, "invalid arrayify value");
|
52
|
+
const result = [];
|
53
|
+
while (value) {
|
54
|
+
result.unshift(value & 0xff);
|
55
|
+
value = parseInt(String(value / 256));
|
56
|
+
}
|
57
|
+
if (result.length === 0) {
|
58
|
+
result.push(0);
|
59
|
+
}
|
60
|
+
return addSlice(new Uint8Array(result));
|
61
|
+
}
|
62
|
+
if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
|
63
|
+
value = "0x" + value;
|
64
|
+
}
|
65
|
+
if (isHexable(value)) {
|
66
|
+
value = value.toHexString();
|
67
|
+
}
|
68
|
+
if (isHexString(value)) {
|
69
|
+
let hex = value.substring(2);
|
70
|
+
if (hex.length % 2) {
|
71
|
+
if (options.hexPad === "left") {
|
72
|
+
hex = "0" + hex;
|
73
|
+
}
|
74
|
+
else if (options.hexPad === "right") {
|
75
|
+
hex += "0";
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
logger.throwArgumentError("hex data is odd-length", "value", value);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
const result = [];
|
82
|
+
for (let i = 0; i < hex.length; i += 2) {
|
83
|
+
result.push(parseInt(hex.substring(i, i + 2), 16));
|
84
|
+
}
|
85
|
+
return addSlice(new Uint8Array(result));
|
86
|
+
}
|
87
|
+
if (isBytes(value)) {
|
88
|
+
return addSlice(new Uint8Array(value));
|
89
|
+
}
|
90
|
+
return logger.throwArgumentError("invalid arrayify value", "value", value);
|
91
|
+
}
|
92
|
+
function concat(items) {
|
93
|
+
const objects = items.map(item => arrayify(item));
|
94
|
+
const length = objects.reduce((accum, item) => (accum + item.length), 0);
|
95
|
+
const result = new Uint8Array(length);
|
96
|
+
objects.reduce((offset, object) => {
|
97
|
+
result.set(object, offset);
|
98
|
+
return offset + object.length;
|
99
|
+
}, 0);
|
100
|
+
return addSlice(result);
|
101
|
+
}
|
102
|
+
function stripZeros(value) {
|
103
|
+
let result = arrayify(value);
|
104
|
+
if (result.length === 0) {
|
105
|
+
return result;
|
106
|
+
}
|
107
|
+
// Find the first non-zero entry
|
108
|
+
let start = 0;
|
109
|
+
while (start < result.length && result[start] === 0) {
|
110
|
+
start++;
|
111
|
+
}
|
112
|
+
// If we started with zeros, strip them
|
113
|
+
if (start) {
|
114
|
+
result = result.slice(start);
|
115
|
+
}
|
116
|
+
return result;
|
117
|
+
}
|
118
|
+
function zeroPad(value, length) {
|
119
|
+
value = arrayify(value);
|
120
|
+
if (value.length > length) {
|
121
|
+
logger.throwArgumentError("value out of range", "value", arguments[0]);
|
122
|
+
}
|
123
|
+
const result = new Uint8Array(length);
|
124
|
+
result.set(value, length - value.length);
|
125
|
+
return addSlice(result);
|
126
|
+
}
|
127
|
+
function isHexString(value, length) {
|
128
|
+
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
129
|
+
return false;
|
130
|
+
}
|
131
|
+
if (length && value.length !== 2 + 2 * length) {
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
return true;
|
135
|
+
}
|
136
|
+
const HexCharacters = "0123456789abcdef";
|
137
|
+
function hexlify(value, options) {
|
138
|
+
if (!options) {
|
139
|
+
options = {};
|
140
|
+
}
|
141
|
+
if (typeof (value) === "number") {
|
142
|
+
logger.checkSafeUint53(value, "invalid hexlify value");
|
143
|
+
let hex = "";
|
144
|
+
while (value) {
|
145
|
+
hex = HexCharacters[value & 0xf] + hex;
|
146
|
+
value = Math.floor(value / 16);
|
147
|
+
}
|
148
|
+
if (hex.length) {
|
149
|
+
if (hex.length % 2) {
|
150
|
+
hex = "0" + hex;
|
151
|
+
}
|
152
|
+
return "0x" + hex;
|
153
|
+
}
|
154
|
+
return "0x00";
|
155
|
+
}
|
156
|
+
if (typeof (value) === "bigint") {
|
157
|
+
value = value.toString(16);
|
158
|
+
if (value.length % 2) {
|
159
|
+
return ("0x0" + value);
|
160
|
+
}
|
161
|
+
return "0x" + value;
|
162
|
+
}
|
163
|
+
if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
|
164
|
+
value = "0x" + value;
|
165
|
+
}
|
166
|
+
if (isHexable(value)) {
|
167
|
+
return value.toHexString();
|
168
|
+
}
|
169
|
+
if (isHexString(value)) {
|
170
|
+
if (value.length % 2) {
|
171
|
+
if (options.hexPad === "left") {
|
172
|
+
value = "0x0" + value.substring(2);
|
173
|
+
}
|
174
|
+
else if (options.hexPad === "right") {
|
175
|
+
value += "0";
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
logger.throwArgumentError("hex data is odd-length", "value", value);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
return value.toLowerCase();
|
182
|
+
}
|
183
|
+
if (isBytes(value)) {
|
184
|
+
let result = "0x";
|
185
|
+
for (let i = 0; i < value.length; i++) {
|
186
|
+
let v = value[i];
|
187
|
+
result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];
|
188
|
+
}
|
189
|
+
return result;
|
190
|
+
}
|
191
|
+
return logger.throwArgumentError("invalid hexlify value", "value", value);
|
192
|
+
}
|
193
|
+
/*
|
194
|
+
function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number {
|
195
|
+
if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") {
|
196
|
+
return "0x0" + value.substring(2);
|
197
|
+
}
|
198
|
+
return value;
|
199
|
+
}
|
200
|
+
*/
|
201
|
+
function hexDataLength(data) {
|
202
|
+
if (typeof (data) !== "string") {
|
203
|
+
data = hexlify(data);
|
204
|
+
}
|
205
|
+
else if (!isHexString(data) || (data.length % 2)) {
|
206
|
+
return null;
|
207
|
+
}
|
208
|
+
return (data.length - 2) / 2;
|
209
|
+
}
|
210
|
+
function hexDataSlice(data, offset, endOffset) {
|
211
|
+
if (typeof (data) !== "string") {
|
212
|
+
data = hexlify(data);
|
213
|
+
}
|
214
|
+
else if (!isHexString(data) || (data.length % 2)) {
|
215
|
+
logger.throwArgumentError("invalid hexData", "value", data);
|
216
|
+
}
|
217
|
+
offset = 2 + 2 * offset;
|
218
|
+
if (endOffset != null) {
|
219
|
+
return "0x" + data.substring(offset, 2 + 2 * endOffset);
|
220
|
+
}
|
221
|
+
return "0x" + data.substring(offset);
|
222
|
+
}
|
223
|
+
function hexConcat(items) {
|
224
|
+
let result = "0x";
|
225
|
+
items.forEach((item) => {
|
226
|
+
result += hexlify(item).substring(2);
|
227
|
+
});
|
228
|
+
return result;
|
229
|
+
}
|
230
|
+
function hexValue(value) {
|
231
|
+
const trimmed = hexStripZeros(hexlify(value, { hexPad: "left" }));
|
232
|
+
if (trimmed === "0x") {
|
233
|
+
return "0x0";
|
234
|
+
}
|
235
|
+
return trimmed;
|
236
|
+
}
|
237
|
+
function hexStripZeros(value) {
|
238
|
+
if (typeof (value) !== "string") {
|
239
|
+
value = hexlify(value);
|
240
|
+
}
|
241
|
+
if (!isHexString(value)) {
|
242
|
+
logger.throwArgumentError("invalid hex string", "value", value);
|
243
|
+
}
|
244
|
+
value = value.substring(2);
|
245
|
+
let offset = 0;
|
246
|
+
while (offset < value.length && value[offset] === "0") {
|
247
|
+
offset++;
|
248
|
+
}
|
249
|
+
return "0x" + value.substring(offset);
|
250
|
+
}
|
251
|
+
function hexZeroPad(value, length) {
|
252
|
+
if (typeof (value) !== "string") {
|
253
|
+
value = hexlify(value);
|
254
|
+
}
|
255
|
+
else if (!isHexString(value)) {
|
256
|
+
logger.throwArgumentError("invalid hex string", "value", value);
|
257
|
+
}
|
258
|
+
if (value.length > 2 * length + 2) {
|
259
|
+
logger.throwArgumentError("value out of range", "value", arguments[1]);
|
260
|
+
}
|
261
|
+
while (value.length < 2 * length + 2) {
|
262
|
+
value = "0x0" + value.substring(2);
|
263
|
+
}
|
264
|
+
return value;
|
265
|
+
}
|
266
|
+
function splitSignature(signature) {
|
267
|
+
const result = {
|
268
|
+
r: "0x",
|
269
|
+
s: "0x",
|
270
|
+
_vs: "0x",
|
271
|
+
recoveryParam: 0,
|
272
|
+
v: 0,
|
273
|
+
yParityAndS: "0x",
|
274
|
+
compact: "0x"
|
275
|
+
};
|
276
|
+
if (isBytesLike(signature)) {
|
277
|
+
let bytes = arrayify(signature);
|
278
|
+
// Get the r, s and v
|
279
|
+
if (bytes.length === 64) {
|
280
|
+
// EIP-2098; pull the v from the top bit of s and clear it
|
281
|
+
result.v = 27 + (bytes[32] >> 7);
|
282
|
+
bytes[32] &= 0x7f;
|
283
|
+
result.r = hexlify(bytes.slice(0, 32));
|
284
|
+
result.s = hexlify(bytes.slice(32, 64));
|
285
|
+
}
|
286
|
+
else if (bytes.length === 65) {
|
287
|
+
result.r = hexlify(bytes.slice(0, 32));
|
288
|
+
result.s = hexlify(bytes.slice(32, 64));
|
289
|
+
result.v = bytes[64];
|
290
|
+
}
|
291
|
+
else {
|
292
|
+
logger.throwArgumentError("invalid signature string", "signature", signature);
|
293
|
+
}
|
294
|
+
// Allow a recid to be used as the v
|
295
|
+
if (result.v < 27) {
|
296
|
+
if (result.v === 0 || result.v === 1) {
|
297
|
+
result.v += 27;
|
298
|
+
}
|
299
|
+
else {
|
300
|
+
logger.throwArgumentError("signature invalid v byte", "signature", signature);
|
301
|
+
}
|
302
|
+
}
|
303
|
+
// Compute recoveryParam from v
|
304
|
+
result.recoveryParam = 1 - (result.v % 2);
|
305
|
+
// Compute _vs from recoveryParam and s
|
306
|
+
if (result.recoveryParam) {
|
307
|
+
bytes[32] |= 0x80;
|
308
|
+
}
|
309
|
+
result._vs = hexlify(bytes.slice(32, 64));
|
310
|
+
}
|
311
|
+
else {
|
312
|
+
result.r = signature.r;
|
313
|
+
result.s = signature.s;
|
314
|
+
result.v = signature.v;
|
315
|
+
result.recoveryParam = signature.recoveryParam;
|
316
|
+
result._vs = signature._vs;
|
317
|
+
// If the _vs is available, use it to populate missing s, v and recoveryParam
|
318
|
+
// and verify non-missing s, v and recoveryParam
|
319
|
+
if (result._vs != null) {
|
320
|
+
const vs = zeroPad(arrayify(result._vs), 32);
|
321
|
+
result._vs = hexlify(vs);
|
322
|
+
// Set or check the recid
|
323
|
+
const recoveryParam = ((vs[0] >= 128) ? 1 : 0);
|
324
|
+
if (result.recoveryParam == null) {
|
325
|
+
result.recoveryParam = recoveryParam;
|
326
|
+
}
|
327
|
+
else if (result.recoveryParam !== recoveryParam) {
|
328
|
+
logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature);
|
329
|
+
}
|
330
|
+
// Set or check the s
|
331
|
+
vs[0] &= 0x7f;
|
332
|
+
const s = hexlify(vs);
|
333
|
+
if (result.s == null) {
|
334
|
+
result.s = s;
|
335
|
+
}
|
336
|
+
else if (result.s !== s) {
|
337
|
+
logger.throwArgumentError("signature v mismatch _vs", "signature", signature);
|
338
|
+
}
|
339
|
+
}
|
340
|
+
// Use recid and v to populate each other
|
341
|
+
if (result.recoveryParam == null) {
|
342
|
+
if (result.v == null) {
|
343
|
+
logger.throwArgumentError("signature missing v and recoveryParam", "signature", signature);
|
344
|
+
}
|
345
|
+
else if (result.v === 0 || result.v === 1) {
|
346
|
+
result.recoveryParam = result.v;
|
347
|
+
}
|
348
|
+
else {
|
349
|
+
result.recoveryParam = 1 - (result.v % 2);
|
350
|
+
}
|
351
|
+
}
|
352
|
+
else {
|
353
|
+
if (result.v == null) {
|
354
|
+
result.v = 27 + result.recoveryParam;
|
355
|
+
}
|
356
|
+
else {
|
357
|
+
const recId = (result.v === 0 || result.v === 1) ? result.v : (1 - (result.v % 2));
|
358
|
+
if (result.recoveryParam !== recId) {
|
359
|
+
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature);
|
360
|
+
}
|
361
|
+
}
|
362
|
+
}
|
363
|
+
if (result.r == null || !isHexString(result.r)) {
|
364
|
+
logger.throwArgumentError("signature missing or invalid r", "signature", signature);
|
365
|
+
}
|
366
|
+
else {
|
367
|
+
result.r = hexZeroPad(result.r, 32);
|
368
|
+
}
|
369
|
+
if (result.s == null || !isHexString(result.s)) {
|
370
|
+
logger.throwArgumentError("signature missing or invalid s", "signature", signature);
|
371
|
+
}
|
372
|
+
else {
|
373
|
+
result.s = hexZeroPad(result.s, 32);
|
374
|
+
}
|
375
|
+
const vs = arrayify(result.s);
|
376
|
+
if (vs[0] >= 128) {
|
377
|
+
logger.throwArgumentError("signature s out of range", "signature", signature);
|
378
|
+
}
|
379
|
+
if (result.recoveryParam) {
|
380
|
+
vs[0] |= 0x80;
|
381
|
+
}
|
382
|
+
const _vs = hexlify(vs);
|
383
|
+
if (result._vs) {
|
384
|
+
if (!isHexString(result._vs)) {
|
385
|
+
logger.throwArgumentError("signature invalid _vs", "signature", signature);
|
386
|
+
}
|
387
|
+
result._vs = hexZeroPad(result._vs, 32);
|
388
|
+
}
|
389
|
+
// Set or check the _vs
|
390
|
+
if (result._vs == null) {
|
391
|
+
result._vs = _vs;
|
392
|
+
}
|
393
|
+
else if (result._vs !== _vs) {
|
394
|
+
logger.throwArgumentError("signature _vs mismatch v and s", "signature", signature);
|
395
|
+
}
|
396
|
+
}
|
397
|
+
result.yParityAndS = result._vs;
|
398
|
+
result.compact = result.r + result.yParityAndS.substring(2);
|
399
|
+
return result;
|
400
|
+
}
|
401
|
+
|
402
|
+
export { arrayify, concat, hexConcat, hexDataLength, hexDataSlice, hexStripZeros, hexValue, hexZeroPad, hexlify, isBytes, isBytesLike, isHexString, splitSignature, stripZeros, zeroPad };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { BigNumber } from '../../bignumber/lib.esm/bignumber.js';
|
2
|
+
|
3
|
+
const NegativeOne = ( /*#__PURE__*/BigNumber.from(-1));
|
4
|
+
const Zero = ( /*#__PURE__*/BigNumber.from(0));
|
5
|
+
const One = ( /*#__PURE__*/BigNumber.from(1));
|
6
|
+
const MaxUint256 = ( /*#__PURE__*/BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
|
7
|
+
|
8
|
+
export { MaxUint256, NegativeOne, One, Zero };
|