@waku/rln 0.1.3-f6d5deb → 0.1.4-2a94244.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,39 @@
|
|
1
|
+
import '../../../interfaces/dist/protocols.js';
|
2
|
+
import '../../../interfaces/dist/connection_manager.js';
|
3
|
+
import '../../../interfaces/dist/health_indicator.js';
|
4
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base10.js';
|
5
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base16.js';
|
6
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base2.js';
|
7
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base256emoji.js';
|
8
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base32.js';
|
9
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base36.js';
|
10
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base58.js';
|
11
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base64.js';
|
12
|
+
import '../../../../node_modules/multiformats/dist/src/bases/base8.js';
|
13
|
+
import '../../../../node_modules/multiformats/dist/src/bases/identity.js';
|
14
|
+
import '../../../../node_modules/multiformats/dist/src/codecs/json.js';
|
15
|
+
import { Logger } from '../../../utils/dist/logger/index.js';
|
16
|
+
|
17
|
+
const DefaultEpochUnitSeconds = 10; // the rln-relay epoch length in seconds
|
18
|
+
const log = new Logger("waku:rln:epoch");
|
19
|
+
function dateToEpoch(timestamp, epochUnitSeconds = DefaultEpochUnitSeconds) {
|
20
|
+
const time = timestamp.getTime();
|
21
|
+
const epoch = Math.floor(time / 1000 / epochUnitSeconds);
|
22
|
+
log.info("generated epoch", epoch);
|
23
|
+
return epoch;
|
24
|
+
}
|
25
|
+
function epochIntToBytes(epoch) {
|
26
|
+
const bytes = new Uint8Array(32);
|
27
|
+
const db = new DataView(bytes.buffer);
|
28
|
+
db.setUint32(0, epoch, true);
|
29
|
+
log.info("encoded epoch", epoch, bytes);
|
30
|
+
return bytes;
|
31
|
+
}
|
32
|
+
function epochBytesToInt(bytes) {
|
33
|
+
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
34
|
+
const epoch = dv.getUint32(0, true);
|
35
|
+
log.info("decoded epoch", epoch, bytes);
|
36
|
+
return epoch;
|
37
|
+
}
|
38
|
+
|
39
|
+
export { dateToEpoch, epochBytesToInt, epochIntToBytes };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { poseidonHash as poseidonHash$1 } from '../../../../node_modules/@waku/zerokit-rln-wasm/rln_wasm.js';
|
2
|
+
import { writeUIntLE, concatenate } from './bytes.js';
|
3
|
+
|
4
|
+
function poseidonHash(...input) {
|
5
|
+
const inputLen = writeUIntLE(new Uint8Array(8), input.length, 0, 8);
|
6
|
+
const lenPrefixedData = concatenate(inputLen, ...input);
|
7
|
+
return poseidonHash$1(lenPrefixedData);
|
8
|
+
}
|
9
|
+
|
10
|
+
export { poseidonHash };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Web3Provider } from '../../../../node_modules/@ethersproject/providers/lib.esm/web3-provider.js';
|
2
|
+
|
3
|
+
const extractMetaMaskSigner = async () => {
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5
|
+
const ethereum = window.ethereum;
|
6
|
+
if (!ethereum) {
|
7
|
+
throw Error("Missing or invalid Ethereum provider. Please install a Web3 wallet such as MetaMask.");
|
8
|
+
}
|
9
|
+
await ethereum.request({ method: "eth_requestAccounts" });
|
10
|
+
const provider = new Web3Provider(ethereum, "any");
|
11
|
+
return provider.getSigner();
|
12
|
+
};
|
13
|
+
|
14
|
+
export { extractMetaMaskSigner };
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import { generateExtendedMembershipKey, generateSeededExtendedMembershipKey, insertMember, setLeavesFrom, deleteLeaf, getRoot, getSerializedRLNWitness, RLNWitnessToJson, generate_rln_proof_with_witness, verifyRLNProof, verifyWithRoots } from '../../../node_modules/@waku/zerokit-rln-wasm/rln_wasm.js';
|
2
|
+
import { DEFAULT_RATE_LIMIT, RATE_LIMIT_PARAMS } from './contract/constants.js';
|
3
|
+
import { IdentityCredential } from './identity.js';
|
4
|
+
import { Proof, proofToBytes } from './proof.js';
|
5
|
+
import { writeUIntLE, concatenate } from './utils/bytes.js';
|
6
|
+
import { epochIntToBytes, dateToEpoch } from './utils/epoch.js';
|
7
|
+
|
8
|
+
class Zerokit {
|
9
|
+
zkRLN;
|
10
|
+
witnessCalculator;
|
11
|
+
rateLimit;
|
12
|
+
constructor(zkRLN, witnessCalculator, rateLimit = DEFAULT_RATE_LIMIT) {
|
13
|
+
this.zkRLN = zkRLN;
|
14
|
+
this.witnessCalculator = witnessCalculator;
|
15
|
+
this.rateLimit = rateLimit;
|
16
|
+
}
|
17
|
+
get getZkRLN() {
|
18
|
+
return this.zkRLN;
|
19
|
+
}
|
20
|
+
get getWitnessCalculator() {
|
21
|
+
return this.witnessCalculator;
|
22
|
+
}
|
23
|
+
get getRateLimit() {
|
24
|
+
return this.rateLimit;
|
25
|
+
}
|
26
|
+
generateIdentityCredentials() {
|
27
|
+
const memKeys = generateExtendedMembershipKey(this.zkRLN); // TODO: rename this function in zerokit rln-wasm
|
28
|
+
return IdentityCredential.fromBytes(memKeys);
|
29
|
+
}
|
30
|
+
generateSeededIdentityCredential(seed) {
|
31
|
+
const stringEncoder = new TextEncoder();
|
32
|
+
const seedBytes = stringEncoder.encode(seed);
|
33
|
+
// TODO: rename this function in zerokit rln-wasm
|
34
|
+
const memKeys = generateSeededExtendedMembershipKey(this.zkRLN, seedBytes);
|
35
|
+
return IdentityCredential.fromBytes(memKeys);
|
36
|
+
}
|
37
|
+
insertMember(idCommitment) {
|
38
|
+
insertMember(this.zkRLN, idCommitment);
|
39
|
+
}
|
40
|
+
insertMembers(index, ...idCommitments) {
|
41
|
+
// serializes a seq of IDCommitments to a byte seq
|
42
|
+
// the order of serialization is |id_commitment_len<8>|id_commitment<var>|
|
43
|
+
const idCommitmentLen = writeUIntLE(new Uint8Array(8), idCommitments.length, 0, 8);
|
44
|
+
const idCommitmentBytes = concatenate(idCommitmentLen, ...idCommitments);
|
45
|
+
setLeavesFrom(this.zkRLN, index, idCommitmentBytes);
|
46
|
+
}
|
47
|
+
deleteMember(index) {
|
48
|
+
deleteLeaf(this.zkRLN, index);
|
49
|
+
}
|
50
|
+
getMerkleRoot() {
|
51
|
+
return getRoot(this.zkRLN);
|
52
|
+
}
|
53
|
+
serializeMessage(uint8Msg, memIndex, epoch, idKey, rateLimit) {
|
54
|
+
// calculate message length
|
55
|
+
const msgLen = writeUIntLE(new Uint8Array(8), uint8Msg.length, 0, 8);
|
56
|
+
const memIndexBytes = writeUIntLE(new Uint8Array(8), memIndex, 0, 8);
|
57
|
+
const rateLimitBytes = writeUIntLE(new Uint8Array(8), rateLimit ?? this.rateLimit, 0, 8);
|
58
|
+
// [ id_key<32> | id_index<8> | epoch<32> | signal_len<8> | signal<var> | rate_limit<8> ]
|
59
|
+
return concatenate(idKey, memIndexBytes, epoch, msgLen, uint8Msg, rateLimitBytes);
|
60
|
+
}
|
61
|
+
async generateRLNProof(msg, index, epoch, idSecretHash, rateLimit) {
|
62
|
+
if (epoch === undefined) {
|
63
|
+
epoch = epochIntToBytes(dateToEpoch(new Date()));
|
64
|
+
}
|
65
|
+
else if (epoch instanceof Date) {
|
66
|
+
epoch = epochIntToBytes(dateToEpoch(epoch));
|
67
|
+
}
|
68
|
+
const effectiveRateLimit = rateLimit ?? this.rateLimit;
|
69
|
+
if (epoch.length !== 32)
|
70
|
+
throw new Error("invalid epoch");
|
71
|
+
if (idSecretHash.length !== 32)
|
72
|
+
throw new Error("invalid id secret hash");
|
73
|
+
if (index < 0)
|
74
|
+
throw new Error("index must be >= 0");
|
75
|
+
if (effectiveRateLimit < RATE_LIMIT_PARAMS.MIN_RATE ||
|
76
|
+
effectiveRateLimit > RATE_LIMIT_PARAMS.MAX_RATE) {
|
77
|
+
throw new Error(`Rate limit must be between ${RATE_LIMIT_PARAMS.MIN_RATE} and ${RATE_LIMIT_PARAMS.MAX_RATE}`);
|
78
|
+
}
|
79
|
+
const serialized_msg = this.serializeMessage(msg, index, epoch, idSecretHash, effectiveRateLimit);
|
80
|
+
const rlnWitness = getSerializedRLNWitness(this.zkRLN, serialized_msg);
|
81
|
+
const inputs = RLNWitnessToJson(this.zkRLN, rlnWitness);
|
82
|
+
const calculatedWitness = await this.witnessCalculator.calculateWitness(inputs, false);
|
83
|
+
const proofBytes = generate_rln_proof_with_witness(this.zkRLN, calculatedWitness, rlnWitness);
|
84
|
+
return new Proof(proofBytes);
|
85
|
+
}
|
86
|
+
verifyRLNProof(proof, msg, rateLimit) {
|
87
|
+
let pBytes;
|
88
|
+
if (proof instanceof Uint8Array) {
|
89
|
+
pBytes = proof;
|
90
|
+
}
|
91
|
+
else {
|
92
|
+
pBytes = proofToBytes(proof);
|
93
|
+
}
|
94
|
+
// calculate message length
|
95
|
+
const msgLen = writeUIntLE(new Uint8Array(8), msg.length, 0, 8);
|
96
|
+
const rateLimitBytes = writeUIntLE(new Uint8Array(8), rateLimit ?? this.rateLimit, 0, 8);
|
97
|
+
return verifyRLNProof(this.zkRLN, concatenate(pBytes, msgLen, msg, rateLimitBytes));
|
98
|
+
}
|
99
|
+
verifyWithRoots(proof, msg, roots, rateLimit) {
|
100
|
+
let pBytes;
|
101
|
+
if (proof instanceof Uint8Array) {
|
102
|
+
pBytes = proof;
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
pBytes = proofToBytes(proof);
|
106
|
+
}
|
107
|
+
// calculate message length
|
108
|
+
const msgLen = writeUIntLE(new Uint8Array(8), msg.length, 0, 8);
|
109
|
+
const rateLimitBytes = writeUIntLE(new Uint8Array(8), rateLimit ?? this.rateLimit, 0, 8);
|
110
|
+
const rootsBytes = concatenate(...roots);
|
111
|
+
return verifyWithRoots(this.zkRLN, concatenate(pBytes, msgLen, msg, rateLimitBytes), rootsBytes);
|
112
|
+
}
|
113
|
+
verifyWithNoRoot(proof, msg, rateLimit) {
|
114
|
+
let pBytes;
|
115
|
+
if (proof instanceof Uint8Array) {
|
116
|
+
pBytes = proof;
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
pBytes = proofToBytes(proof);
|
120
|
+
}
|
121
|
+
// calculate message length
|
122
|
+
const msgLen = writeUIntLE(new Uint8Array(8), msg.length, 0, 8);
|
123
|
+
const rateLimitBytes = writeUIntLE(new Uint8Array(8), rateLimit ?? this.rateLimit, 0, 8);
|
124
|
+
return verifyWithRoots(this.zkRLN, concatenate(pBytes, msgLen, msg, rateLimitBytes), new Uint8Array());
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
export { Zerokit };
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as checksum$1 } from '../../../../../../_virtual/checksum.js';
|
3
|
+
import '../node_modules/ethereum-cryptography/sha256.js';
|
4
|
+
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
5
|
+
import { __exports as sha256 } from '../../../../../../_virtual/sha256.js';
|
6
|
+
|
7
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
14
|
+
});
|
15
|
+
};
|
16
|
+
Object.defineProperty(checksum$1, "__esModule", { value: true });
|
17
|
+
checksum$1.verifyChecksum = checksum$1.checksum = checksum$1.defaultSha256Module = undefined;
|
18
|
+
const sha256_1 = sha256;
|
19
|
+
const utils_1 = utilsExports;
|
20
|
+
// default checksum configuration
|
21
|
+
function defaultSha256Module() {
|
22
|
+
return {
|
23
|
+
function: "sha256",
|
24
|
+
};
|
25
|
+
}
|
26
|
+
checksum$1.defaultSha256Module = defaultSha256Module;
|
27
|
+
// checksum operations
|
28
|
+
function checksumData(key, ciphertext) {
|
29
|
+
return utils_1.concatBytes(key.slice(16), ciphertext);
|
30
|
+
}
|
31
|
+
function checksum(mod, key, ciphertext) {
|
32
|
+
if (mod.function === "sha256") {
|
33
|
+
return Promise.resolve(sha256_1.sha256(checksumData(key, ciphertext)));
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
throw new Error("Invalid checksum type");
|
37
|
+
}
|
38
|
+
}
|
39
|
+
checksum$1.checksum = checksum;
|
40
|
+
function verifyChecksum(mod, key, ciphertext) {
|
41
|
+
return __awaiter(this, undefined, undefined, function* () {
|
42
|
+
if (mod.function === "sha256") {
|
43
|
+
return utils_1.equalsBytes(utils_1.hexToBytes(mod.message), sha256_1.sha256(checksumData(key, ciphertext)));
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
throw new Error("Invalid checksum type");
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
50
|
+
checksum$1.verifyChecksum = verifyChecksum;
|
51
|
+
|
52
|
+
export { checksum$1 as default };
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as cipher } from '../../../../../../_virtual/cipher.js';
|
3
|
+
import '../node_modules/ethereum-cryptography/random.js';
|
4
|
+
import '../node_modules/ethereum-cryptography/aes.js';
|
5
|
+
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
6
|
+
import { __exports as random } from '../../../../../../_virtual/random.js';
|
7
|
+
import { __exports as aes } from '../../../../../../_virtual/aes.js';
|
8
|
+
|
9
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
10
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
12
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
13
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
14
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
15
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
16
|
+
});
|
17
|
+
};
|
18
|
+
Object.defineProperty(cipher, "__esModule", { value: true });
|
19
|
+
var cipherDecrypt_1 = cipher.cipherDecrypt = cipher.cipherEncrypt = cipher.defaultAes128CtrModule = undefined;
|
20
|
+
const random_1 = random;
|
21
|
+
const aes_1 = aes;
|
22
|
+
const utils_1 = utilsExports;
|
23
|
+
function defaultAes128CtrModule() {
|
24
|
+
return {
|
25
|
+
function: "aes-128-ctr",
|
26
|
+
params: {
|
27
|
+
iv: utils_1.bytesToHex(random_1.getRandomBytesSync(16)),
|
28
|
+
},
|
29
|
+
};
|
30
|
+
}
|
31
|
+
cipher.defaultAes128CtrModule = defaultAes128CtrModule;
|
32
|
+
function cipherEncrypt(mod, key, data) {
|
33
|
+
return __awaiter(this, undefined, undefined, function* () {
|
34
|
+
if (mod.function === "aes-128-ctr") {
|
35
|
+
try {
|
36
|
+
return yield aes_1.encrypt(data, key, utils_1.hexToBytes(mod.params.iv), mod.function, false);
|
37
|
+
}
|
38
|
+
catch (e) {
|
39
|
+
throw new Error("Unable to encrypt");
|
40
|
+
}
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
throw new Error("Invalid cipher type");
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}
|
47
|
+
cipher.cipherEncrypt = cipherEncrypt;
|
48
|
+
function cipherDecrypt(mod, key) {
|
49
|
+
return __awaiter(this, undefined, undefined, function* () {
|
50
|
+
if (mod.function === "aes-128-ctr") {
|
51
|
+
try {
|
52
|
+
return yield aes_1.decrypt(utils_1.hexToBytes(mod.message), key, utils_1.hexToBytes(mod.params.iv), mod.function, false);
|
53
|
+
}
|
54
|
+
catch (e) {
|
55
|
+
throw new Error("Unable to decrypt");
|
56
|
+
}
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
throw new Error("Invalid cipher type");
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
cipherDecrypt_1 = cipher.cipherDecrypt = cipherDecrypt;
|
64
|
+
|
65
|
+
export { cipherDecrypt_1 as cipherDecrypt, cipher as default };
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as _class } from '../../../../../../_virtual/class.js';
|
3
|
+
import './kdf.js';
|
4
|
+
import './checksum.js';
|
5
|
+
import './cipher.js';
|
6
|
+
import './functional.js';
|
7
|
+
import './schema-validation.js';
|
8
|
+
import { __exports as kdf } from '../../../../../../_virtual/kdf.js';
|
9
|
+
import { __exports as checksum } from '../../../../../../_virtual/checksum.js';
|
10
|
+
import { __exports as cipher } from '../../../../../../_virtual/cipher.js';
|
11
|
+
import { __exports as functional } from '../../../../../../_virtual/functional.js';
|
12
|
+
import { __exports as schemaValidation } from '../../../../../../_virtual/schema-validation.js';
|
13
|
+
|
14
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
21
|
+
});
|
22
|
+
};
|
23
|
+
Object.defineProperty(_class, "__esModule", { value: true });
|
24
|
+
_class.Keystore = undefined;
|
25
|
+
const kdf_1 = kdf;
|
26
|
+
const checksum_1 = checksum;
|
27
|
+
const cipher_1 = cipher;
|
28
|
+
const functional_1 = functional;
|
29
|
+
const schema_validation_1 = schemaValidation;
|
30
|
+
/**
|
31
|
+
* Class-based BLS Keystore
|
32
|
+
*/
|
33
|
+
class Keystore {
|
34
|
+
constructor(obj) {
|
35
|
+
this.version = obj.version;
|
36
|
+
this.uuid = obj.uuid;
|
37
|
+
this.description = obj.description;
|
38
|
+
this.path = obj.path;
|
39
|
+
this.pubkey = obj.pubkey;
|
40
|
+
this.crypto = {
|
41
|
+
kdf: Object.assign({}, obj.crypto.kdf),
|
42
|
+
checksum: Object.assign({}, obj.crypto.checksum),
|
43
|
+
cipher: Object.assign({}, obj.crypto.cipher),
|
44
|
+
};
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Create a new Keystore object
|
48
|
+
*/
|
49
|
+
static create(password, secret, pubkey, path, description = null, kdfMod = kdf_1.defaultPbkdfModule(), checksumMod = checksum_1.defaultSha256Module(), cipherMod = cipher_1.defaultAes128CtrModule()) {
|
50
|
+
return __awaiter(this, undefined, undefined, function* () {
|
51
|
+
const obj = yield functional_1.create(password, secret, pubkey, path, description, kdfMod, checksumMod, cipherMod);
|
52
|
+
return new Keystore(obj);
|
53
|
+
});
|
54
|
+
}
|
55
|
+
/**
|
56
|
+
* Create a keystore from an unknown object
|
57
|
+
*/
|
58
|
+
static fromObject(obj) {
|
59
|
+
schema_validation_1.validateKeystore(obj);
|
60
|
+
return new Keystore(obj);
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Parse a keystore from a JSON string
|
64
|
+
*/
|
65
|
+
static parse(str) {
|
66
|
+
return Keystore.fromObject(JSON.parse(str));
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Decrypt a keystore, returns the secret key or throws on invalid password
|
70
|
+
*/
|
71
|
+
decrypt(password) {
|
72
|
+
return __awaiter(this, undefined, undefined, function* () {
|
73
|
+
return functional_1.decrypt(this, password);
|
74
|
+
});
|
75
|
+
}
|
76
|
+
/**
|
77
|
+
* Verify the password as correct or not
|
78
|
+
*/
|
79
|
+
verifyPassword(password) {
|
80
|
+
return __awaiter(this, undefined, undefined, function* () {
|
81
|
+
return functional_1.verifyPassword(this, password);
|
82
|
+
});
|
83
|
+
}
|
84
|
+
/**
|
85
|
+
* Return the keystore as a plain object
|
86
|
+
*/
|
87
|
+
toObject() {
|
88
|
+
return Object.assign({}, this);
|
89
|
+
}
|
90
|
+
/**
|
91
|
+
* Return the keystore as stringified JSON
|
92
|
+
*/
|
93
|
+
stringify() {
|
94
|
+
return JSON.stringify(this.toObject(), null, 2);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
_class.Keystore = Keystore;
|
98
|
+
|
99
|
+
export { _class as default };
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as functional } from '../../../../../../_virtual/functional.js';
|
3
|
+
import require$$0 from '../../../../../../_virtual/index2.js';
|
4
|
+
import './kdf.js';
|
5
|
+
import './checksum.js';
|
6
|
+
import './cipher.js';
|
7
|
+
import './password.js';
|
8
|
+
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
9
|
+
import { __exports as kdf } from '../../../../../../_virtual/kdf.js';
|
10
|
+
import { __exports as checksum } from '../../../../../../_virtual/checksum.js';
|
11
|
+
import { __exports as cipher } from '../../../../../../_virtual/cipher.js';
|
12
|
+
import { __exports as password } from '../../../../../../_virtual/password.js';
|
13
|
+
|
14
|
+
(function (exports) {
|
15
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
22
|
+
});
|
23
|
+
};
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
+
exports.decrypt = exports.verifyPassword = exports.create = exports.defaultAes128CtrModule = exports.defaultSha256Module = exports.defaultScryptModule = exports.defaultPbkdfModule = undefined;
|
26
|
+
const uuid_1 = require$$0;
|
27
|
+
const kdf_1 = kdf;
|
28
|
+
Object.defineProperty(exports, "defaultPbkdfModule", { enumerable: true, get: function () { return kdf_1.defaultPbkdfModule; } });
|
29
|
+
Object.defineProperty(exports, "defaultScryptModule", { enumerable: true, get: function () { return kdf_1.defaultScryptModule; } });
|
30
|
+
const checksum_1 = checksum;
|
31
|
+
Object.defineProperty(exports, "defaultSha256Module", { enumerable: true, get: function () { return checksum_1.defaultSha256Module; } });
|
32
|
+
const cipher_1 = cipher;
|
33
|
+
Object.defineProperty(exports, "defaultAes128CtrModule", { enumerable: true, get: function () { return cipher_1.defaultAes128CtrModule; } });
|
34
|
+
const password_1 = password;
|
35
|
+
const utils_1 = utilsExports;
|
36
|
+
/**
|
37
|
+
* Create a new keystore object
|
38
|
+
*
|
39
|
+
* @param password password used to encrypt the keystore
|
40
|
+
* @param secret secret key material to be encrypted
|
41
|
+
* @param pubkey public key, not checked for validity
|
42
|
+
* @param path HD path used to generate the secret
|
43
|
+
* @param kdfMod key derivation function (kdf) configuration module
|
44
|
+
* @param checksumMod checksum configuration module
|
45
|
+
* @param cipherMod cipher configuration module
|
46
|
+
*/
|
47
|
+
function create(password, secret, pubkey, path, description = null, kdfMod = kdf_1.defaultPbkdfModule(), checksumMod = checksum_1.defaultSha256Module(), cipherMod = cipher_1.defaultAes128CtrModule()) {
|
48
|
+
return __awaiter(this, undefined, undefined, function* () {
|
49
|
+
const encryptionKey = yield kdf_1.kdf(kdfMod, password_1.normalizePassword(password));
|
50
|
+
const ciphertext = yield cipher_1.cipherEncrypt(cipherMod, encryptionKey.slice(0, 16), secret);
|
51
|
+
return {
|
52
|
+
version: 4,
|
53
|
+
uuid: uuid_1.v4(),
|
54
|
+
description: description || undefined,
|
55
|
+
path: path,
|
56
|
+
pubkey: utils_1.bytesToHex(pubkey),
|
57
|
+
crypto: {
|
58
|
+
kdf: {
|
59
|
+
function: kdfMod.function,
|
60
|
+
params: Object.assign({}, kdfMod.params),
|
61
|
+
message: "",
|
62
|
+
},
|
63
|
+
checksum: {
|
64
|
+
function: checksumMod.function,
|
65
|
+
params: {},
|
66
|
+
message: utils_1.bytesToHex(yield checksum_1.checksum(checksumMod, encryptionKey, ciphertext)),
|
67
|
+
},
|
68
|
+
cipher: {
|
69
|
+
function: cipherMod.function,
|
70
|
+
params: Object.assign({}, cipherMod.params),
|
71
|
+
message: utils_1.bytesToHex(ciphertext),
|
72
|
+
},
|
73
|
+
},
|
74
|
+
};
|
75
|
+
});
|
76
|
+
}
|
77
|
+
exports.create = create;
|
78
|
+
/**
|
79
|
+
* Verify the password of a keystore object
|
80
|
+
*/
|
81
|
+
function verifyPassword(keystore, password) {
|
82
|
+
return __awaiter(this, undefined, undefined, function* () {
|
83
|
+
const decryptionKey = yield kdf_1.kdf(keystore.crypto.kdf, password_1.normalizePassword(password));
|
84
|
+
const ciphertext = utils_1.hexToBytes(keystore.crypto.cipher.message);
|
85
|
+
return checksum_1.verifyChecksum(keystore.crypto.checksum, decryptionKey, ciphertext);
|
86
|
+
});
|
87
|
+
}
|
88
|
+
exports.verifyPassword = verifyPassword;
|
89
|
+
/**
|
90
|
+
* Decrypt a keystore, returns the secret key or throws on invalid password
|
91
|
+
*/
|
92
|
+
function decrypt(keystore, password) {
|
93
|
+
return __awaiter(this, undefined, undefined, function* () {
|
94
|
+
const decryptionKey = yield kdf_1.kdf(keystore.crypto.kdf, password_1.normalizePassword(password));
|
95
|
+
const ciphertext = utils_1.hexToBytes(keystore.crypto.cipher.message);
|
96
|
+
if (!(yield checksum_1.verifyChecksum(keystore.crypto.checksum, decryptionKey, ciphertext))) {
|
97
|
+
throw new Error("Invalid password");
|
98
|
+
}
|
99
|
+
return cipher_1.cipherDecrypt(keystore.crypto.cipher, decryptionKey.slice(0, 16));
|
100
|
+
});
|
101
|
+
}
|
102
|
+
exports.decrypt = decrypt;
|
103
|
+
} (functional));
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as lib } from '../../../../../../_virtual/index.js';
|
3
|
+
import './types.js';
|
4
|
+
import './functional.js';
|
5
|
+
import './class.js';
|
6
|
+
import './schema-validation.js';
|
7
|
+
import { __exports as types } from '../../../../../../_virtual/types.js';
|
8
|
+
import { __exports as functional } from '../../../../../../_virtual/functional.js';
|
9
|
+
import { __exports as _class } from '../../../../../../_virtual/class.js';
|
10
|
+
import { __exports as schemaValidation } from '../../../../../../_virtual/schema-validation.js';
|
11
|
+
|
12
|
+
(function (exports) {
|
13
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
14
|
+
if (k2 === undefined) k2 = k;
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
16
|
+
}) : (function(o, m, k, k2) {
|
17
|
+
if (k2 === undefined) k2 = k;
|
18
|
+
o[k2] = m[k];
|
19
|
+
}));
|
20
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
21
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
22
|
+
};
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
24
|
+
__exportStar(types, exports);
|
25
|
+
__exportStar(functional, exports);
|
26
|
+
__exportStar(_class, exports);
|
27
|
+
__exportStar(schemaValidation, exports);
|
28
|
+
} (lib));
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as kdf$1 } from '../../../../../../_virtual/kdf.js';
|
3
|
+
import '../node_modules/ethereum-cryptography/random.js';
|
4
|
+
import '../node_modules/ethereum-cryptography/pbkdf2.js';
|
5
|
+
import '../node_modules/ethereum-cryptography/scrypt.js';
|
6
|
+
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
7
|
+
import { __exports as random } from '../../../../../../_virtual/random.js';
|
8
|
+
import { __exports as pbkdf2 } from '../../../../../../_virtual/pbkdf2.js';
|
9
|
+
import { __exports as scrypt } from '../../../../../../_virtual/scrypt.js';
|
10
|
+
|
11
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
18
|
+
});
|
19
|
+
};
|
20
|
+
Object.defineProperty(kdf$1, "__esModule", { value: true });
|
21
|
+
var kdf_2 = kdf$1.kdf = kdf$1.defaultScryptModule = kdf$1.defaultPbkdfModule = undefined;
|
22
|
+
const random_1 = random;
|
23
|
+
const pbkdf2_1 = pbkdf2;
|
24
|
+
const scrypt_1 = scrypt;
|
25
|
+
const utils_1 = utilsExports;
|
26
|
+
// default kdf configurations
|
27
|
+
function defaultPbkdfModule() {
|
28
|
+
return {
|
29
|
+
function: "pbkdf2",
|
30
|
+
params: {
|
31
|
+
dklen: 32,
|
32
|
+
c: 262144,
|
33
|
+
prf: "hmac-sha256",
|
34
|
+
salt: utils_1.bytesToHex(random_1.getRandomBytesSync(32)),
|
35
|
+
},
|
36
|
+
};
|
37
|
+
}
|
38
|
+
kdf$1.defaultPbkdfModule = defaultPbkdfModule;
|
39
|
+
function defaultScryptModule() {
|
40
|
+
return {
|
41
|
+
function: "scrypt",
|
42
|
+
params: {
|
43
|
+
dklen: 32,
|
44
|
+
n: 262144,
|
45
|
+
r: 8,
|
46
|
+
p: 1,
|
47
|
+
salt: utils_1.bytesToHex(random_1.getRandomBytesSync(32)),
|
48
|
+
},
|
49
|
+
};
|
50
|
+
}
|
51
|
+
kdf$1.defaultScryptModule = defaultScryptModule;
|
52
|
+
// kdf operations
|
53
|
+
function kdf(mod, password) {
|
54
|
+
return __awaiter(this, undefined, undefined, function* () {
|
55
|
+
if (mod.function === "pbkdf2") {
|
56
|
+
return yield doPbkdf2(mod.params, password);
|
57
|
+
}
|
58
|
+
else if (mod.function === "scrypt") {
|
59
|
+
return yield doScrypt(mod.params, password);
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
throw new Error("Invalid kdf type");
|
63
|
+
}
|
64
|
+
});
|
65
|
+
}
|
66
|
+
kdf_2 = kdf$1.kdf = kdf;
|
67
|
+
function doPbkdf2(params, password) {
|
68
|
+
return __awaiter(this, undefined, undefined, function* () {
|
69
|
+
return pbkdf2_1.pbkdf2(password, utils_1.hexToBytes(params.salt), params.c, params.dklen, params.prf.slice(5));
|
70
|
+
});
|
71
|
+
}
|
72
|
+
function doScrypt(params, password) {
|
73
|
+
return __awaiter(this, undefined, undefined, function* () {
|
74
|
+
return scrypt_1.scrypt(password, utils_1.hexToBytes(params.salt), params.n, params.p, params.r, params.dklen);
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
export { kdf$1 as default, kdf_2 as kdf };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { __exports as password } from '../../../../../../_virtual/password.js';
|
2
|
+
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
3
|
+
|
4
|
+
Object.defineProperty(password, "__esModule", { value: true });
|
5
|
+
var normalizePassword_1 = password.normalizePassword = undefined;
|
6
|
+
const utils_1 = utilsExports;
|
7
|
+
function normalizePassword(password) {
|
8
|
+
if (typeof password === "string") {
|
9
|
+
return utils_1.utf8ToBytes(password.normalize("NFKD"));
|
10
|
+
}
|
11
|
+
else {
|
12
|
+
return password;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
normalizePassword_1 = password.normalizePassword = normalizePassword;
|
16
|
+
|
17
|
+
export { password as default, normalizePassword_1 as normalizePassword };
|