@argent/x-shared 1.79.0 → 1.79.2
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/dist/.ts-temp/tsconfig.tsbuildinfo +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/_virtual/_rolldown/runtime.js +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +112 -488
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/_shortw_utils.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/_shortw_utils.js +11 -11
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/curve.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/curve.js +62 -85
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/modular.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/modular.js +153 -190
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/poseidon.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/poseidon.js +56 -65
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/utils.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/utils.js +125 -151
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/weierstrass.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/weierstrass.js +470 -575
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/_assert.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/_assert.js +26 -40
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/crypto.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/crypto.js +4 -4
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/hmac.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/hmac.js +38 -42
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/utils.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/utils.js +28 -42
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_assert.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_assert.js +17 -26
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_sha2.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_sha2.js +52 -59
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_u64.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_u64.js +20 -19
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha256.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha256.js +118 -113
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha3.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha3.js +95 -105
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/utils.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/utils.js +26 -32
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_md.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_md.js +71 -82
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_u64.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_u64.js +20 -20
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha2.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha2.js +125 -124
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha3.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha3.js +102 -116
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/utils.cjs +1 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/utils.js +62 -76
- package/dist/node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.cjs +1 -1
- package/dist/node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js +519 -614
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Hash.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Hash.js +15 -19
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_ListCache.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_ListCache.js +15 -19
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_MapCache.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_MapCache.js +15 -19
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Set.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Set.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_SetCache.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_SetCache.js +10 -12
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludes.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludes.js +6 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludesWith.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludesWith.js +6 -8
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assocIndexOf.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assocIndexOf.js +7 -9
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseFindIndex.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseFindIndex.js +6 -8
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +9 -9
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIndexOf.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIndexOf.js +7 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNaN.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNaN.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNative.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNative.js +10 -15
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUniq.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUniq.js +26 -32
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cacheHas.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cacheHas.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_coreJsData.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_coreJsData.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createSet.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createSet.js +7 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +4 -4
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getMapData.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getMapData.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getNative.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getNative.js +8 -8
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +12 -13
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getValue.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getValue.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashClear.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashClear.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashDelete.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashDelete.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashGet.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashGet.js +11 -11
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashHas.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashHas.js +8 -8
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashSet.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashSet.js +7 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKeyable.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKeyable.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isMasked.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isMasked.js +9 -9
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheDelete.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheDelete.js +8 -11
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheGet.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheGet.js +7 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheHas.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheHas.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheSet.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheSet.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js +11 -11
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheDelete.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheDelete.js +7 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheGet.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheGet.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheHas.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheHas.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheSet.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheSet.js +7 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeCreate.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeCreate.js +4 -4
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +4 -4
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheAdd.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheAdd.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheHas.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheHas.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToArray.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToArray.js +8 -8
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_strictIndexOf.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_strictIndexOf.js +6 -8
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toSource.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toSource.js +14 -16
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/eq.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/eq.js +5 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js +10 -11
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +6 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.js +4 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/uniqWith.cjs +1 -1
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/uniqWith.js +6 -6
- package/dist/node_modules/.pnpm/micro-starknet@0.2.3/node_modules/micro-starknet/lib/esm/index.cjs +1 -1
- package/dist/node_modules/.pnpm/micro-starknet@0.2.3/node_modules/micro-starknet/lib/esm/index.js +121 -118
- package/dist/node_modules/.pnpm/numeral@2.0.6/node_modules/numeral/numeral.cjs +1 -1
- package/dist/node_modules/.pnpm/numeral@2.0.6/node_modules/numeral/numeral.js +377 -417
- package/dist/node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.cjs +1 -1
- package/dist/node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js +546 -635
- package/dist/paymaster.cjs +1 -1
- package/dist/paymaster.js +2 -11
- package/dist/simulation.cjs +1 -1
- package/dist/simulation.js +22 -90
- package/dist/src/account/account.model.cjs +1 -1
- package/dist/src/account/account.model.js +58 -52
- package/dist/src/account/accountv4.cjs +1 -1
- package/dist/src/account/accountv4.js +9 -11
- package/dist/src/account/preferences.model.cjs +1 -1
- package/dist/src/account/preferences.model.js +12 -10
- package/dist/src/accountNameGenerator/colors.cjs +1 -1
- package/dist/src/accountNameGenerator/colors.js +24 -24
- package/dist/src/accountNameGenerator/index.cjs +1 -1
- package/dist/src/accountNameGenerator/index.js +23 -23
- package/dist/src/accountNameGenerator/x-names.json.cjs +1 -1
- package/dist/src/accountNameGenerator/x-names.json.js +1922 -7
- package/dist/src/assets/tokens.json.cjs +1 -1
- package/dist/src/assets/tokens.json.js +180 -180
- package/dist/src/backend/schema.cjs +1 -1
- package/dist/src/backend/schema.js +9 -12
- package/dist/src/backend/sessionKeys/schema.cjs +1 -1
- package/dist/src/backend/sessionKeys/schema.js +27 -30
- package/dist/src/bigdecimal/constants.cjs +1 -1
- package/dist/src/bigdecimal/constants.js +6 -3
- package/dist/src/bigdecimal/createUnitsSchema.cjs +1 -1
- package/dist/src/bigdecimal/createUnitsSchema.js +7 -7
- package/dist/src/bigdecimal/formatUnits.cjs +1 -1
- package/dist/src/bigdecimal/formatUnits.js +9 -10
- package/dist/src/bigdecimal/index.cjs +1 -1
- package/dist/src/bigdecimal/index.js +45 -41
- package/dist/src/bigdecimal/lib.cjs +1 -1
- package/dist/src/bigdecimal/lib.js +105 -117
- package/dist/src/bigdecimal/parseUnits.cjs +1 -1
- package/dist/src/bigdecimal/parseUnits.js +18 -21
- package/dist/src/bigdecimal/utils.cjs +1 -1
- package/dist/src/bigdecimal/utils.js +33 -30
- package/dist/src/cache/CacheService.cjs +1 -1
- package/dist/src/cache/CacheService.js +32 -36
- package/dist/src/chains/starknet/address.cjs +1 -1
- package/dist/src/chains/starknet/address.js +73 -117
- package/dist/src/chains/starknet/addressDomain.cjs +1 -1
- package/dist/src/chains/starknet/addressDomain.js +14 -29
- package/dist/src/chains/starknet/addressInput.cjs +1 -1
- package/dist/src/chains/starknet/addressInput.js +6 -7
- package/dist/src/chains/starknet/argentName.cjs +1 -1
- package/dist/src/chains/starknet/argentName.js +10 -14
- package/dist/src/chains/starknet/cairoVersionSchema.cjs +1 -1
- package/dist/src/chains/starknet/cairoVersionSchema.js +5 -5
- package/dist/src/chains/starknet/constants.cjs +1 -1
- package/dist/src/chains/starknet/constants.js +4 -10
- package/dist/src/chains/starknet/getAddressFromArgentName.cjs +1 -1
- package/dist/src/chains/starknet/getAddressFromArgentName.js +38 -46
- package/dist/src/chains/starknet/getAddressFromStarkName.cjs +1 -1
- package/dist/src/chains/starknet/getAddressFromStarkName.js +59 -66
- package/dist/src/chains/starknet/network.cjs +1 -1
- package/dist/src/chains/starknet/network.js +20 -26
- package/dist/src/chains/starknet/services/address/StarknetAddressService.cjs +1 -1
- package/dist/src/chains/starknet/services/address/StarknetAddressService.js +31 -36
- package/dist/src/chains/starknet/services/deploymentData/constants.cjs +1 -1
- package/dist/src/chains/starknet/services/deploymentData/constants.js +14 -21
- package/dist/src/chains/starknet/services/deploymentData/deploymentData.schema.cjs +1 -1
- package/dist/src/chains/starknet/services/deploymentData/deploymentData.schema.js +15 -17
- package/dist/src/chains/starknet/services/deploymentData/findImplementationForAccount.cjs +1 -1
- package/dist/src/chains/starknet/services/deploymentData/findImplementationForAccount.js +61 -65
- package/dist/src/chains/starknet/services/deploymentData/getAccountClassHash.cjs +1 -1
- package/dist/src/chains/starknet/services/deploymentData/getAccountClassHash.js +46 -65
- package/dist/src/chains/starknet/starknetId.cjs +1 -1
- package/dist/src/chains/starknet/starknetId.js +10 -14
- package/dist/src/currencyFetchService/CurrencyFetchService.cjs +1 -1
- package/dist/src/currencyFetchService/CurrencyFetchService.js +13 -18
- package/dist/src/currencyFetchService/types.ts.cjs +1 -1
- package/dist/src/currencyFetchService/types.ts.js +9 -12
- package/dist/src/errors/account.cjs +1 -1
- package/dist/src/errors/account.js +12 -13
- package/dist/src/errors/address.cjs +1 -1
- package/dist/src/errors/address.js +11 -12
- package/dist/src/errors/baseErrors.cjs +1 -1
- package/dist/src/errors/baseErrors.js +14 -14
- package/dist/src/errors/call.cjs +1 -1
- package/dist/src/errors/call.js +12 -13
- package/dist/src/errors/network.cjs +1 -1
- package/dist/src/errors/network.js +11 -12
- package/dist/src/errors/review.cjs +1 -1
- package/dist/src/errors/review.js +11 -12
- package/dist/src/errors/swap.cjs +1 -1
- package/dist/src/errors/swap.js +12 -13
- package/dist/src/features/paymaster/PaymasterService.cjs +1 -1
- package/dist/src/features/paymaster/PaymasterService.js +73 -87
- package/dist/src/features/paymaster/types.cjs +1 -1
- package/dist/src/features/paymaster/types.js +41 -51
- package/dist/src/features/simulation/activity/normalize.cjs +1 -1
- package/dist/src/features/simulation/activity/normalize.js +36 -38
- package/dist/src/features/simulation/activity/schema.cjs +1 -1
- package/dist/src/features/simulation/activity/schema.js +224 -250
- package/dist/src/features/simulation/activity/utils/createNativeActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/createNativeActivity.js +23 -27
- package/dist/src/features/simulation/activity/utils/getAnyActivityTitle.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/getAnyActivityTitle.js +14 -21
- package/dist/src/features/simulation/activity/utils/getOverallLastModified.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/getOverallLastModified.js +5 -5
- package/dist/src/features/simulation/activity/utils/hasDelegationActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/hasDelegationActivity.js +4 -4
- package/dist/src/features/simulation/activity/utils/isAddMultisigSignersActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/isAddMultisigSignersActivity.js +15 -19
- package/dist/src/features/simulation/activity/utils/isChangeMultisigThresholdActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/isChangeMultisigThresholdActivity.js +15 -19
- package/dist/src/features/simulation/activity/utils/isMulticallWithDeploymentActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/isMulticallWithDeploymentActivity.js +5 -5
- package/dist/src/features/simulation/activity/utils/isRejectOnChainActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/isRejectOnChainActivity.js +19 -21
- package/dist/src/features/simulation/activity/utils/isRemoveMultisigSignersActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/isRemoveMultisigSignersActivity.js +15 -19
- package/dist/src/features/simulation/activity/utils/isSwapActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/isSwapActivity.js +17 -18
- package/dist/src/features/simulation/activity/utils/isUpgradeActivity.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/isUpgradeActivity.js +15 -19
- package/dist/src/features/simulation/activity/utils/parseAccountActivities.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/parseAccountActivities.js +12 -12
- package/dist/src/features/simulation/activity/utils/parseFinanceActivities.cjs +1 -1
- package/dist/src/features/simulation/activity/utils/parseFinanceActivities.js +32 -32
- package/dist/src/features/simulation/fees/schema.cjs +1 -1
- package/dist/src/features/simulation/fees/schema.js +33 -47
- package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.js +15 -17
- package/dist/src/features/simulation/transactionReview/getMessageFromSimulationError.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/getMessageFromSimulationError.js +5 -5
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.js +221 -242
- package/dist/src/features/simulation/warning/helper.cjs +1 -1
- package/dist/src/features/simulation/warning/helper.js +12 -11
- package/dist/src/features/simulation/warning/schema.cjs +1 -1
- package/dist/src/features/simulation/warning/schema.js +10 -11
- package/dist/src/features/swap/models/order.model.cjs +1 -1
- package/dist/src/features/swap/models/order.model.js +16 -19
- package/dist/src/features/swap/models/quote.model.cjs +1 -1
- package/dist/src/features/swap/models/quote.model.js +31 -35
- package/dist/src/features/swap/models/trade.model.cjs +1 -1
- package/dist/src/features/swap/models/trade.model.js +25 -27
- package/dist/src/features/swap/services/SwapSharedService.cjs +1 -1
- package/dist/src/features/swap/services/SwapSharedService.js +71 -75
- package/dist/src/features/swap/services/SwapTransactionService.cjs +1 -1
- package/dist/src/features/swap/services/SwapTransactionService.js +57 -63
- package/dist/src/features/swap/utils/slippage.cjs +1 -1
- package/dist/src/features/swap/utils/slippage.js +18 -25
- package/dist/src/features/swap/utils/totalFee.cjs +1 -1
- package/dist/src/features/swap/utils/totalFee.js +12 -12
- package/dist/src/http/DateService.cjs +1 -1
- package/dist/src/http/DateService.js +15 -18
- package/dist/src/http/HttpError.cjs +1 -1
- package/dist/src/http/HttpError.js +7 -7
- package/dist/src/http/HttpService.cjs +1 -1
- package/dist/src/http/HttpService.js +117 -134
- package/dist/src/http/IHttpService.cjs +1 -1
- package/dist/src/http/IHttpService.js +6 -6
- package/dist/src/http/SWRService.cjs +1 -1
- package/dist/src/http/SWRService.js +50 -57
- package/dist/src/http/fetcher.cjs +1 -1
- package/dist/src/http/fetcher.js +29 -35
- package/dist/src/http/time.cjs +1 -1
- package/dist/src/http/time.js +15 -18
- package/dist/src/knownDapps/KnownDappsBackendService.cjs +1 -1
- package/dist/src/knownDapps/KnownDappsBackendService.js +13 -14
- package/dist/src/knownDapps/schema.cjs +1 -1
- package/dist/src/knownDapps/schema.js +41 -44
- package/dist/src/knownDapps/utils/getDapplandUrl.cjs +1 -1
- package/dist/src/knownDapps/utils/getDapplandUrl.js +7 -8
- package/dist/src/nameResolution/ResolveNameService.cjs +1 -1
- package/dist/src/nameResolution/ResolveNameService.js +34 -41
- package/dist/src/nameResolution/schema.cjs +1 -1
- package/dist/src/nameResolution/schema.js +20 -25
- package/dist/src/nfts/BackendNftService.cjs +1 -1
- package/dist/src/nfts/BackendNftService.js +103 -116
- package/dist/src/nfts/BackendPaginationError.cjs +1 -1
- package/dist/src/nfts/BackendPaginationError.js +11 -12
- package/dist/src/nfts/utils.cjs +1 -1
- package/dist/src/nfts/utils.js +11 -14
- package/dist/src/onchainRecovery/OnchainRecoveryService.cjs +1 -1
- package/dist/src/onchainRecovery/OnchainRecoveryService.js +38 -68
- package/dist/src/onchainRecovery/schema.cjs +1 -1
- package/dist/src/onchainRecovery/schema.js +35 -49
- package/dist/src/platform/isBraveBrowser.cjs +1 -1
- package/dist/src/platform/isBraveBrowser.js +8 -10
- package/dist/src/platform/isBrowser.cjs +1 -1
- package/dist/src/platform/isBrowser.js +17 -22
- package/dist/src/signer/mergeOwnerGuardianSignatures.cjs +1 -1
- package/dist/src/signer/mergeOwnerGuardianSignatures.js +28 -30
- package/dist/src/signer/multisigner.cjs +1 -1
- package/dist/src/signer/multisigner.js +16 -17
- package/dist/src/signer/seedphrase.cjs +1 -1
- package/dist/src/signer/seedphrase.js +7 -7
- package/dist/src/staking/schema.cjs +1 -1
- package/dist/src/staking/schema.js +146 -162
- package/dist/src/storage/base.cjs +1 -1
- package/dist/src/storage/base.js +33 -34
- package/dist/src/storage/utils.cjs +1 -1
- package/dist/src/storage/utils.js +19 -28
- package/dist/src/tokens/balances.cjs +1 -1
- package/dist/src/tokens/balances.js +34 -38
- package/dist/src/tokens/constants.cjs +1 -1
- package/dist/src/tokens/constants.js +4 -4
- package/dist/src/tokens/convertCurrencyValueToTokenAmount.cjs +1 -1
- package/dist/src/tokens/convertCurrencyValueToTokenAmount.js +8 -9
- package/dist/src/tokens/convertTokenAmountToCurrencyValue.cjs +1 -1
- package/dist/src/tokens/convertTokenAmountToCurrencyValue.js +14 -15
- package/dist/src/tokens/convertTokenUnitAmountWithDecimals.cjs +1 -1
- package/dist/src/tokens/convertTokenUnitAmountWithDecimals.js +8 -9
- package/dist/src/tokens/ensureDecimals.cjs +1 -1
- package/dist/src/tokens/ensureDecimals.js +4 -4
- package/dist/src/tokens/getCurrencySymbol.cjs +1 -1
- package/dist/src/tokens/getCurrencySymbol.js +14 -14
- package/dist/src/tokens/isUnlimitedAmount.cjs +1 -1
- package/dist/src/tokens/isUnlimitedAmount.js +5 -5
- package/dist/src/tokens/prettifyCurrencyValue.cjs +1 -1
- package/dist/src/tokens/prettifyCurrencyValue.js +13 -14
- package/dist/src/tokens/prettifyTokenAmount.cjs +1 -1
- package/dist/src/tokens/prettifyTokenAmount.js +22 -22
- package/dist/src/tokens/service/implementation.cjs +1 -1
- package/dist/src/tokens/service/implementation.js +28 -40
- package/dist/src/tokens/service/tokenError.cjs +1 -1
- package/dist/src/tokens/service/tokenError.js +11 -12
- package/dist/src/tokens/service/types/backend.model.cjs +1 -1
- package/dist/src/tokens/service/types/backend.model.js +128 -163
- package/dist/src/tokens/service/types/defiPosition.model.cjs +1 -1
- package/dist/src/tokens/service/types/defiPosition.model.js +83 -99
- package/dist/src/tokens/service/types/defiPositionType.model.cjs +1 -1
- package/dist/src/tokens/service/types/defiPositionType.model.js +9 -9
- package/dist/src/tokens/service/types/unclaimedRewards.model.cjs +1 -1
- package/dist/src/tokens/service/types/unclaimedRewards.model.js +15 -16
- package/dist/src/tokens/service/types/webToken.model.cjs +1 -1
- package/dist/src/tokens/service/types/webToken.model.js +28 -51
- package/dist/src/tokens/utils.cjs +1 -1
- package/dist/src/tokens/utils.js +5 -9
- package/dist/src/transactions/amount.cjs +1 -1
- package/dist/src/transactions/amount.js +17 -24
- package/dist/src/transactions/buildTransactions.cjs +1 -1
- package/dist/src/transactions/buildTransactions.js +30 -33
- package/dist/src/transactions/errors.cjs +1 -1
- package/dist/src/transactions/errors.js +11 -18
- package/dist/src/transactions/estimate/adjustment.cjs +1 -1
- package/dist/src/transactions/estimate/adjustment.js +6 -6
- package/dist/src/transactions/estimate/argentMaxFee.cjs +1 -1
- package/dist/src/transactions/estimate/argentMaxFee.js +10 -13
- package/dist/src/transactions/estimate/error.cjs +1 -1
- package/dist/src/transactions/estimate/error.js +12 -13
- package/dist/src/transactions/estimate/model.cjs +1 -1
- package/dist/src/transactions/estimate/model.js +18 -13
- package/dist/src/transactions/estimate/utils.cjs +1 -1
- package/dist/src/transactions/estimate/utils.js +139 -172
- package/dist/src/transactions/findTransfersAndApprovals.cjs +1 -1
- package/dist/src/transactions/findTransfersAndApprovals.js +34 -30
- package/dist/src/transactions/getPrettyRcpError.cjs +1 -1
- package/dist/src/transactions/getPrettyRcpError.js +8 -10
- package/dist/src/transactions/service/implementation.cjs +1 -1
- package/dist/src/transactions/service/implementation.js +187 -208
- package/dist/src/transactions/service/types.cjs +1 -1
- package/dist/src/transactions/service/types.js +9 -9
- package/dist/src/transactions/service/utils.cjs +1 -1
- package/dist/src/transactions/service/utils.js +24 -25
- package/dist/src/transactions/transactionExecuteTypes.cjs +1 -1
- package/dist/src/transactions/transactionExecuteTypes.js +8 -9
- package/dist/src/transactions/transactionReviewTypes.cjs +1 -1
- package/dist/src/transactions/transactionReviewTypes.js +9 -9
- package/dist/src/transactions/transactionVersion.cjs +1 -1
- package/dist/src/transactions/transactionVersion.js +8 -13
- package/dist/src/transactions/txv3.cjs +1 -1
- package/dist/src/transactions/txv3.js +10 -11
- package/dist/src/utils/address.cjs +1 -1
- package/dist/src/utils/address.js +4 -4
- package/dist/src/utils/arrays.cjs +1 -1
- package/dist/src/utils/arrays.js +4 -4
- package/dist/src/utils/avatarImage.cjs +4 -4
- package/dist/src/utils/avatarImage.js +35 -40
- package/dist/src/utils/base58.cjs +1 -1
- package/dist/src/utils/base58.js +12 -15
- package/dist/src/utils/bigNumber.cjs +1 -1
- package/dist/src/utils/bigNumber.d.ts +1 -1
- package/dist/src/utils/bigNumber.js +5 -7
- package/dist/src/utils/bips.cjs +1 -1
- package/dist/src/utils/bips.js +12 -10
- package/dist/src/utils/daysBetween.cjs +1 -1
- package/dist/src/utils/daysBetween.js +6 -6
- package/dist/src/utils/env.cjs +1 -1
- package/dist/src/utils/env.js +4 -4
- package/dist/src/utils/hex.cjs +1 -1
- package/dist/src/utils/hex.js +7 -8
- package/dist/src/utils/id.cjs +1 -1
- package/dist/src/utils/id.js +7 -7
- package/dist/src/utils/initials.cjs +1 -1
- package/dist/src/utils/initials.js +12 -15
- package/dist/src/utils/isContractDeployed.cjs +1 -1
- package/dist/src/utils/isContractDeployed.js +9 -9
- package/dist/src/utils/nonNullable.cjs +1 -1
- package/dist/src/utils/nonNullable.js +6 -6
- package/dist/src/utils/number/abbreviateNumber.cjs +1 -1
- package/dist/src/utils/number/abbreviateNumber.js +13 -14
- package/dist/src/utils/number/isAllowedAddressHexInputValue.cjs +1 -1
- package/dist/src/utils/number/isAllowedAddressHexInputValue.js +4 -7
- package/dist/src/utils/number/isAllowedNumericInputValue.cjs +1 -1
- package/dist/src/utils/number/isAllowedNumericInputValue.js +5 -5
- package/dist/src/utils/number/isNumeric.cjs +1 -1
- package/dist/src/utils/number/isNumeric.js +4 -4
- package/dist/src/utils/number/prettifyNumber.cjs +1 -1
- package/dist/src/utils/number/prettifyNumber.js +65 -75
- package/dist/src/utils/parseAmount.cjs +1 -1
- package/dist/src/utils/parseAmount.js +10 -11
- package/dist/src/utils/pluralise.cjs +1 -1
- package/dist/src/utils/pluralise.js +4 -4
- package/dist/src/utils/readFileAsString.cjs +1 -1
- package/dist/src/utils/readFileAsString.js +6 -6
- package/dist/src/utils/retryUntilInitialised.cjs +1 -1
- package/dist/src/utils/retryUntilInitialised.js +21 -20
- package/dist/src/utils/schemas.cjs +1 -1
- package/dist/src/utils/schemas.js +29 -26
- package/dist/src/utils/starknet/starknet.cjs +1 -1
- package/dist/src/utils/starknet/starknet.js +64 -77
- package/dist/src/utils/starknet/starknetLibTypes.cjs +1 -1
- package/dist/src/utils/starknet/starknetLibTypes.js +7 -7
- package/dist/src/utils/starknet/starknetSchemas.cjs +1 -1
- package/dist/src/utils/starknet/starknetSchemas.js +84 -99
- package/dist/src/utils/transactions.cjs +1 -1
- package/dist/src/utils/transactions.js +10 -10
- package/dist/src/utils/url/urlWithQuery.cjs +1 -1
- package/dist/src/utils/url/urlWithQuery.js +8 -8
- package/dist/src/utils/voidify.cjs +1 -1
- package/dist/src/utils/voidify.js +7 -7
- package/dist/swap.cjs +1 -1
- package/dist/swap.js +8 -22
- package/package.json +20 -19
- package/dist/.eslintrc.d.cts +0 -39
- package/dist/_virtual/_commonjsHelpers.cjs +0 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -6
- package/dist/_virtual/numeral.cjs +0 -1
- package/dist/_virtual/numeral.js +0 -7
- package/dist/_virtual/numeral2.cjs +0 -1
- package/dist/_virtual/numeral2.js +0 -4
- package/dist/_virtual/semver.cjs +0 -1
- package/dist/_virtual/semver.js +0 -7
- package/dist/_virtual/semver2.cjs +0 -1
- package/dist/_virtual/semver2.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`./modular.cjs`);function t(t){let{Fp:n}=t;e.validateField(n);for(let e of[`t`,`roundsFull`,`roundsPartial`])if(typeof t[e]!=`number`||!Number.isSafeInteger(t[e]))throw Error(`Poseidon: invalid param ${e}=${t[e]} (${typeof t[e]})`);if(t.reversePartialPowIdx!==void 0&&typeof t.reversePartialPowIdx!=`boolean`)throw Error(`Poseidon: invalid param reversePartialPowIdx=${t.reversePartialPowIdx}`);let r=t.sboxPower;if(r===void 0&&(r=5),typeof r!=`number`||!Number.isSafeInteger(r))throw Error(`Poseidon wrong sboxPower=${r}`);let i=BigInt(r),a=t=>e.FpPow(n,t,i);if(r===3?a=e=>n.mul(n.sqrN(e),e):r===5&&(a=e=>n.mul(n.sqrN(n.sqrN(e)),e)),t.roundsFull%2!=0)throw Error(`Poseidon roundsFull is not even: ${t.roundsFull}`);let o=t.roundsFull+t.roundsPartial;if(!Array.isArray(t.roundConstants)||t.roundConstants.length!==o)throw Error(`Poseidon: wrong round constants`);let s=t.roundConstants.map(e=>{if(!Array.isArray(e)||e.length!==t.t)throw Error(`Poseidon wrong round constants: ${e}`);return e.map(e=>{if(typeof e!=`bigint`||!n.isValid(e))throw Error(`Poseidon wrong round constant=${e}`);return n.create(e)})});if(!Array.isArray(t.mds)||t.mds.length!==t.t)throw Error(`Poseidon: wrong MDS matrix`);let c=t.mds.map(e=>{if(!Array.isArray(e)||e.length!==t.t)throw Error(`Poseidon MDS matrix row: ${e}`);return e.map(e=>{if(typeof e!=`bigint`)throw Error(`Poseidon MDS matrix value=${e}`);return n.create(e)})});return Object.freeze({...t,rounds:o,sboxFn:a,roundConstants:s,mds:c})}function n(e){let{t:n,Fp:r,rounds:i,sboxFn:a,reversePartialPowIdx:o}=t(e),s=Math.floor(e.roundsFull/2),c=o?n-1:0,l=(t,n,i)=>(t=t.map((t,n)=>r.add(t,e.roundConstants[i][n])),n?t=t.map(e=>a(e)):t[c]=a(t[c]),t=e.mds.map(e=>e.reduce((e,n,i)=>r.add(e,r.mulN(n,t[i])),r.ZERO)),t),u=function(t){if(!Array.isArray(t)||t.length!==n)throw Error(`Poseidon: wrong values (expected array of bigints with length ${n})`);t=t.map(e=>{if(typeof e!=`bigint`)throw Error(`Poseidon: wrong value=${e} (${typeof e})`);return r.create(e)});let a=0;for(let e=0;e<s;e++)t=l(t,!0,a++);for(let n=0;n<e.roundsPartial;n++)t=l(t,!1,a++);for(let e=0;e<s;e++)t=l(t,!0,a++);if(a!==i)throw Error(`Poseidon: wrong number of rounds: last round=${a}, total=${i}`);return t};return u.roundConstants=e.roundConstants,u}exports.poseidon=n;
|
|
@@ -1,67 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return Object.freeze({ ...r, rounds: w, sboxFn: f, roundConstants: l, mds: P });
|
|
1
|
+
import { FpPow as e, validateField as t } from "./modular.js";
|
|
2
|
+
//#region node_modules/.pnpm/@noble+curves@1.0.0/node_modules/@noble/curves/esm/abstract/poseidon.js
|
|
3
|
+
function n(n) {
|
|
4
|
+
let { Fp: r } = n;
|
|
5
|
+
t(r);
|
|
6
|
+
for (let e of [
|
|
7
|
+
"t",
|
|
8
|
+
"roundsFull",
|
|
9
|
+
"roundsPartial"
|
|
10
|
+
]) if (typeof n[e] != "number" || !Number.isSafeInteger(n[e])) throw Error(`Poseidon: invalid param ${e}=${n[e]} (${typeof n[e]})`);
|
|
11
|
+
if (n.reversePartialPowIdx !== void 0 && typeof n.reversePartialPowIdx != "boolean") throw Error(`Poseidon: invalid param reversePartialPowIdx=${n.reversePartialPowIdx}`);
|
|
12
|
+
let i = n.sboxPower;
|
|
13
|
+
if (i === void 0 && (i = 5), typeof i != "number" || !Number.isSafeInteger(i)) throw Error(`Poseidon wrong sboxPower=${i}`);
|
|
14
|
+
let a = BigInt(i), o = (t) => e(r, t, a);
|
|
15
|
+
if (i === 3 ? o = (e) => r.mul(r.sqrN(e), e) : i === 5 && (o = (e) => r.mul(r.sqrN(r.sqrN(e)), e)), n.roundsFull % 2 != 0) throw Error(`Poseidon roundsFull is not even: ${n.roundsFull}`);
|
|
16
|
+
let s = n.roundsFull + n.roundsPartial;
|
|
17
|
+
if (!Array.isArray(n.roundConstants) || n.roundConstants.length !== s) throw Error("Poseidon: wrong round constants");
|
|
18
|
+
let c = n.roundConstants.map((e) => {
|
|
19
|
+
if (!Array.isArray(e) || e.length !== n.t) throw Error(`Poseidon wrong round constants: ${e}`);
|
|
20
|
+
return e.map((e) => {
|
|
21
|
+
if (typeof e != "bigint" || !r.isValid(e)) throw Error(`Poseidon wrong round constant=${e}`);
|
|
22
|
+
return r.create(e);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
if (!Array.isArray(n.mds) || n.mds.length !== n.t) throw Error("Poseidon: wrong MDS matrix");
|
|
26
|
+
let l = n.mds.map((e) => {
|
|
27
|
+
if (!Array.isArray(e) || e.length !== n.t) throw Error(`Poseidon MDS matrix row: ${e}`);
|
|
28
|
+
return e.map((e) => {
|
|
29
|
+
if (typeof e != "bigint") throw Error(`Poseidon MDS matrix value=${e}`);
|
|
30
|
+
return r.create(e);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
...n,
|
|
35
|
+
rounds: s,
|
|
36
|
+
sboxFn: o,
|
|
37
|
+
roundConstants: c,
|
|
38
|
+
mds: l
|
|
39
|
+
});
|
|
41
40
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
i = n(i, !0, s++);
|
|
58
|
-
if (s !== u)
|
|
59
|
-
throw new Error(`Poseidon: wrong number of rounds: last round=${s}, total=${u}`);
|
|
60
|
-
return i;
|
|
61
|
-
};
|
|
62
|
-
return d.roundConstants = r.roundConstants, d;
|
|
41
|
+
function r(e) {
|
|
42
|
+
let { t, Fp: r, rounds: i, sboxFn: a, reversePartialPowIdx: o } = n(e), s = Math.floor(e.roundsFull / 2), c = o ? t - 1 : 0, l = (t, n, i) => (t = t.map((t, n) => r.add(t, e.roundConstants[i][n])), n ? t = t.map((e) => a(e)) : t[c] = a(t[c]), t = e.mds.map((e) => e.reduce((e, n, i) => r.add(e, r.mulN(n, t[i])), r.ZERO)), t), u = function(n) {
|
|
43
|
+
if (!Array.isArray(n) || n.length !== t) throw Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);
|
|
44
|
+
n = n.map((e) => {
|
|
45
|
+
if (typeof e != "bigint") throw Error(`Poseidon: wrong value=${e} (${typeof e})`);
|
|
46
|
+
return r.create(e);
|
|
47
|
+
});
|
|
48
|
+
let a = 0;
|
|
49
|
+
for (let e = 0; e < s; e++) n = l(n, !0, a++);
|
|
50
|
+
for (let t = 0; t < e.roundsPartial; t++) n = l(n, !1, a++);
|
|
51
|
+
for (let e = 0; e < s; e++) n = l(n, !0, a++);
|
|
52
|
+
if (a !== i) throw Error(`Poseidon: wrong number of rounds: last round=${a}, total=${i}`);
|
|
53
|
+
return n;
|
|
54
|
+
};
|
|
55
|
+
return u.roundConstants = e.roundConstants, u;
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
b as validateOpts
|
|
67
|
-
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { r as poseidon };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=require(`../../../../../../../../_virtual/_rolldown/runtime.cjs`).__exportAll({bitGet:()=>b,bitLen:()=>y,bitMask:()=>S,bitSet:()=>x,bytesToHex:()=>o,bytesToNumberBE:()=>u,bytesToNumberLE:()=>d,concatBytes:()=>g,createHmacDrbg:()=>T,ensureBytes:()=>h,equalBytes:()=>_,hexToBytes:()=>l,hexToNumber:()=>c,numberToBytesBE:()=>f,numberToBytesLE:()=>p,numberToHexUnpadded:()=>s,numberToVarBytesBE:()=>m,utf8ToBytes:()=>v,validateObject:()=>D}),t=BigInt(0),n=BigInt(1),r=BigInt(2),i=e=>e instanceof Uint8Array,a=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function o(e){if(!i(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n<e.length;n++)t+=a[e[n]];return t}function s(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function c(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}function l(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(e.length%2)throw Error(`hex string is invalid: unpadded `+e.length);let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){let r=n*2,i=e.slice(r,r+2),a=Number.parseInt(i,16);if(Number.isNaN(a)||a<0)throw Error(`invalid byte sequence`);t[n]=a}return t}function u(e){return c(o(e))}function d(e){if(!i(e))throw Error(`Uint8Array expected`);return c(o(Uint8Array.from(e).reverse()))}var f=(e,t)=>l(e.toString(16).padStart(t*2,`0`)),p=(e,t)=>f(e,t).reverse(),m=e=>l(s(e));function h(e,t,n){let r;if(typeof t==`string`)try{r=l(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(i(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let a=r.length;if(typeof n==`number`&&a!==n)throw Error(`${e} expected ${n} bytes, got ${a}`);return r}function g(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!i(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}function _(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function v(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function y(e){let r;for(r=0;e>t;e>>=n,r+=1);return r}var b=(e,t)=>e>>BigInt(t)&n,x=(e,r,i)=>e|(i?n:t)<<BigInt(r),S=e=>(r<<BigInt(e-1))-n,C=e=>new Uint8Array(e),w=e=>Uint8Array.from(e);function T(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=C(e),i=C(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=C())=>{i=s(w([0]),e),r=s(),e.length!==0&&(i=s(w([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return g(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var E={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function D(e,t,n={}){let r=(t,n,r)=>{let i=E[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}exports.bitMask=S,exports.bytesToHex=o,exports.bytesToNumberBE=u,exports.bytesToNumberLE=d,exports.concatBytes=g,exports.createHmacDrbg=T,exports.ensureBytes=h,exports.hexToBytes=l,exports.numberToBytesBE=f,exports.numberToBytesLE=p,Object.defineProperty(exports,`utils_exports`,{enumerable:!0,get:function(){return e}}),exports.validateObject=D;
|
package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/utils.js
CHANGED
|
@@ -1,165 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { __exportAll as e } from "../../../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region node_modules/.pnpm/@noble+curves@1.0.0/node_modules/@noble/curves/esm/abstract/utils.js
|
|
3
|
+
var t = /* @__PURE__ */ e({
|
|
4
|
+
bitGet: () => x,
|
|
5
|
+
bitLen: () => b,
|
|
6
|
+
bitMask: () => C,
|
|
7
|
+
bitSet: () => S,
|
|
8
|
+
bytesToHex: () => s,
|
|
9
|
+
bytesToNumberBE: () => d,
|
|
10
|
+
bytesToNumberLE: () => f,
|
|
11
|
+
concatBytes: () => _,
|
|
12
|
+
createHmacDrbg: () => E,
|
|
13
|
+
ensureBytes: () => g,
|
|
14
|
+
equalBytes: () => v,
|
|
15
|
+
hexToBytes: () => u,
|
|
16
|
+
hexToNumber: () => l,
|
|
17
|
+
numberToBytesBE: () => p,
|
|
18
|
+
numberToBytesLE: () => m,
|
|
19
|
+
numberToHexUnpadded: () => c,
|
|
20
|
+
numberToVarBytesBE: () => h,
|
|
21
|
+
utf8ToBytes: () => y,
|
|
22
|
+
validateObject: () => O
|
|
23
|
+
}), n = BigInt(0), r = BigInt(1), i = BigInt(2), a = (e) => e instanceof Uint8Array, o = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
24
|
+
function s(e) {
|
|
25
|
+
if (!a(e)) throw Error("Uint8Array expected");
|
|
26
|
+
let t = "";
|
|
27
|
+
for (let n = 0; n < e.length; n++) t += o[e[n]];
|
|
28
|
+
return t;
|
|
9
29
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
function c(e) {
|
|
31
|
+
let t = e.toString(16);
|
|
32
|
+
return t.length & 1 ? `0${t}` : t;
|
|
13
33
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return BigInt(t === "" ? "0" : `0x${t}`);
|
|
34
|
+
function l(e) {
|
|
35
|
+
if (typeof e != "string") throw Error("hex string expected, got " + typeof e);
|
|
36
|
+
return BigInt(e === "" ? "0" : `0x${e}`);
|
|
18
37
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
e[r] = i;
|
|
30
|
-
}
|
|
31
|
-
return e;
|
|
38
|
+
function u(e) {
|
|
39
|
+
if (typeof e != "string") throw Error("hex string expected, got " + typeof e);
|
|
40
|
+
if (e.length % 2) throw Error("hex string is invalid: unpadded " + e.length);
|
|
41
|
+
let t = new Uint8Array(e.length / 2);
|
|
42
|
+
for (let n = 0; n < t.length; n++) {
|
|
43
|
+
let r = n * 2, i = e.slice(r, r + 2), a = Number.parseInt(i, 16);
|
|
44
|
+
if (Number.isNaN(a) || a < 0) throw Error("invalid byte sequence");
|
|
45
|
+
t[n] = a;
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
32
48
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
49
|
+
function d(e) {
|
|
50
|
+
return l(s(e));
|
|
35
51
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return m(b(Uint8Array.from(t).reverse()));
|
|
52
|
+
function f(e) {
|
|
53
|
+
if (!a(e)) throw Error("Uint8Array expected");
|
|
54
|
+
return l(s(Uint8Array.from(e).reverse()));
|
|
40
55
|
}
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const o = n.length;
|
|
55
|
-
if (typeof r == "number" && o !== r)
|
|
56
|
-
throw new Error(`${t} expected ${r} bytes, got ${o}`);
|
|
57
|
-
return n;
|
|
56
|
+
var p = (e, t) => u(e.toString(16).padStart(t * 2, "0")), m = (e, t) => p(e, t).reverse(), h = (e) => u(c(e));
|
|
57
|
+
function g(e, t, n) {
|
|
58
|
+
let r;
|
|
59
|
+
if (typeof t == "string") try {
|
|
60
|
+
r = u(t);
|
|
61
|
+
} catch (n) {
|
|
62
|
+
throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`);
|
|
63
|
+
}
|
|
64
|
+
else if (a(t)) r = Uint8Array.from(t);
|
|
65
|
+
else throw Error(`${e} must be hex string or Uint8Array`);
|
|
66
|
+
let i = r.length;
|
|
67
|
+
if (typeof n == "number" && i !== n) throw Error(`${e} expected ${n} bytes, got ${i}`);
|
|
68
|
+
return r;
|
|
58
69
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
e.set(n, r), r += n.length;
|
|
66
|
-
}), e;
|
|
70
|
+
function _(...e) {
|
|
71
|
+
let t = new Uint8Array(e.reduce((e, t) => e + t.length, 0)), n = 0;
|
|
72
|
+
return e.forEach((e) => {
|
|
73
|
+
if (!a(e)) throw Error("Uint8Array expected");
|
|
74
|
+
t.set(e, n), n += e.length;
|
|
75
|
+
}), t;
|
|
67
76
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (t[r] !== e[r])
|
|
73
|
-
return !1;
|
|
74
|
-
return !0;
|
|
77
|
+
function v(e, t) {
|
|
78
|
+
if (e.length !== t.length) return !1;
|
|
79
|
+
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
80
|
+
return !0;
|
|
75
81
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return new TextEncoder().encode(t);
|
|
82
|
+
function y(e) {
|
|
83
|
+
if (typeof e != "string") throw Error(`utf8ToBytes expected string, got ${typeof e}`);
|
|
84
|
+
return new TextEncoder().encode(e);
|
|
80
85
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return e;
|
|
86
|
+
function b(e) {
|
|
87
|
+
let t;
|
|
88
|
+
for (t = 0; e > n; e >>= r, t += 1);
|
|
89
|
+
return t;
|
|
86
90
|
}
|
|
87
|
-
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return (f, a) => {
|
|
113
|
-
c(), u(f);
|
|
114
|
-
let l;
|
|
115
|
-
for (; !(l = a(E())); )
|
|
116
|
-
u();
|
|
117
|
-
return c(), l;
|
|
118
|
-
};
|
|
91
|
+
var x = (e, t) => e >> BigInt(t) & r, S = (e, t, i) => e | (i ? r : n) << BigInt(t), C = (e) => (i << BigInt(e - 1)) - r, w = (e) => new Uint8Array(e), T = (e) => Uint8Array.from(e);
|
|
92
|
+
function E(e, t, n) {
|
|
93
|
+
if (typeof e != "number" || e < 2) throw Error("hashLen must be a number");
|
|
94
|
+
if (typeof t != "number" || t < 2) throw Error("qByteLen must be a number");
|
|
95
|
+
if (typeof n != "function") throw Error("hmacFn must be a function");
|
|
96
|
+
let r = w(e), i = w(e), a = 0, o = () => {
|
|
97
|
+
r.fill(1), i.fill(0), a = 0;
|
|
98
|
+
}, s = (...e) => n(i, r, ...e), c = (e = w()) => {
|
|
99
|
+
i = s(T([0]), e), r = s(), e.length !== 0 && (i = s(T([1]), e), r = s());
|
|
100
|
+
}, l = () => {
|
|
101
|
+
if (a++ >= 1e3) throw Error("drbg: tried 1000 values");
|
|
102
|
+
let e = 0, n = [];
|
|
103
|
+
for (; e < t;) {
|
|
104
|
+
r = s();
|
|
105
|
+
let t = r.slice();
|
|
106
|
+
n.push(t), e += r.length;
|
|
107
|
+
}
|
|
108
|
+
return _(...n);
|
|
109
|
+
};
|
|
110
|
+
return (e, t) => {
|
|
111
|
+
o(), c(e);
|
|
112
|
+
let n;
|
|
113
|
+
for (; !(n = t(l()));) c();
|
|
114
|
+
return o(), n;
|
|
115
|
+
};
|
|
119
116
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
var D = {
|
|
118
|
+
bigint: (e) => typeof e == "bigint",
|
|
119
|
+
function: (e) => typeof e == "function",
|
|
120
|
+
boolean: (e) => typeof e == "boolean",
|
|
121
|
+
string: (e) => typeof e == "string",
|
|
122
|
+
isSafeInteger: (e) => Number.isSafeInteger(e),
|
|
123
|
+
array: (e) => Array.isArray(e),
|
|
124
|
+
field: (e, t) => t.Fp.isValid(e),
|
|
125
|
+
hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen)
|
|
129
126
|
};
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
n(o, i, !1);
|
|
141
|
-
for (const [o, i] of Object.entries(r))
|
|
142
|
-
n(o, i, !0);
|
|
143
|
-
return t;
|
|
127
|
+
function O(e, t, n = {}) {
|
|
128
|
+
let r = (t, n, r) => {
|
|
129
|
+
let i = D[n];
|
|
130
|
+
if (typeof i != "function") throw Error(`Invalid validator "${n}", expected function`);
|
|
131
|
+
let a = e[t];
|
|
132
|
+
if (!(r && a === void 0) && !i(a, e)) throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`);
|
|
133
|
+
};
|
|
134
|
+
for (let [e, n] of Object.entries(t)) r(e, n, !1);
|
|
135
|
+
for (let [e, t] of Object.entries(n)) r(e, t, !0);
|
|
136
|
+
return e;
|
|
144
137
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
V as bitLen,
|
|
148
|
-
q as bitMask,
|
|
149
|
-
j as bitSet,
|
|
150
|
-
b as bytesToHex,
|
|
151
|
-
T as bytesToNumberBE,
|
|
152
|
-
N as bytesToNumberLE,
|
|
153
|
-
v as concatBytes,
|
|
154
|
-
C as createHmacDrbg,
|
|
155
|
-
F as ensureBytes,
|
|
156
|
-
H as equalBytes,
|
|
157
|
-
d as hexToBytes,
|
|
158
|
-
m as hexToNumber,
|
|
159
|
-
U as numberToBytesBE,
|
|
160
|
-
S as numberToBytesLE,
|
|
161
|
-
A as numberToHexUnpadded,
|
|
162
|
-
k as numberToVarBytesBE,
|
|
163
|
-
O as utf8ToBytes,
|
|
164
|
-
D as validateObject
|
|
165
|
-
};
|
|
138
|
+
//#endregion
|
|
139
|
+
export { C as bitMask, s as bytesToHex, d as bytesToNumberBE, f as bytesToNumberLE, _ as concatBytes, E as createHmacDrbg, g as ensureBytes, u as hexToBytes, p as numberToBytesBE, m as numberToBytesLE, t as utils_exports, O as validateObject };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./modular.cjs"),m=require("./utils.cjs"),et=require("./curve.cjs");function at(v){const n=et.validateBasic(v);m.validateObject(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:x,a:O}=n;if(t){if(!x.eql(O,x.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}const{bytesToNumberBE:ct,hexToBytes:ut}=m,$={Err:class extends Error{constructor(n=""){super(n)}},_parseInt(v){const{Err:n}=$;if(v.length<2||v[0]!==2)throw new n("Invalid signature integer tag");const t=v[1],x=v.subarray(2,t+2);if(!t||x.length!==t)throw new n("Invalid signature integer: wrong length");if(x[0]&128)throw new n("Invalid signature integer: negative");if(x[0]===0&&!(x[1]&128))throw new n("Invalid signature integer: unnecessary leading zero");return{d:ct(x),l:v.subarray(t+2)}},toSig(v){const{Err:n}=$,t=typeof v=="string"?ut(v):v;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let x=t.length;if(x<2||t[0]!=48)throw new n("Invalid signature tag");if(t[1]!==x-2)throw new n("Invalid signature: incorrect length");const{d:O,l:T}=$._parseInt(t.subarray(2)),{d:F,l:R}=$._parseInt(T);if(R.length)throw new n("Invalid signature: left bytes after parsing");return{r:O,s:F}},hexFromSig(v){const n=S=>Number.parseInt(S[0],16)&8?"00"+S:S,t=S=>{const V=S.toString(16);return V.length&1?`0${V}`:V},x=n(t(v.s)),O=n(t(v.r)),T=x.length/2,F=O.length/2,R=t(T),L=t(F);return`30${t(F+T+4)}02${L}${O}02${R}${x}`}},P=BigInt(0),U=BigInt(1);BigInt(2);const ot=BigInt(3);BigInt(4);function it(v){const n=at(v),{Fp:t}=n,x=n.toBytes||((y,r,i)=>{const o=r.toAffine();return m.concatBytes(Uint8Array.from([4]),t.toBytes(o.x),t.toBytes(o.y))}),O=n.fromBytes||(y=>{const r=y.subarray(1),i=t.fromBytes(r.subarray(0,t.BYTES)),o=t.fromBytes(r.subarray(t.BYTES,2*t.BYTES));return{x:i,y:o}});function T(y){const{a:r,b:i}=n,o=t.sqr(y),u=t.mul(o,y);return t.add(t.add(u,t.mul(y,r)),i)}if(!t.eql(t.sqr(n.Gy),T(n.Gx)))throw new Error("bad generator point: equation left != right");function F(y){return typeof y=="bigint"&&P<y&&y<n.n}function R(y){if(!F(y))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function L(y){const{allowedPrivateKeyLengths:r,nByteLength:i,wrapPrivateKey:o,n:u}=n;if(r&&typeof y!="bigint"){if(y instanceof Uint8Array&&(y=m.bytesToHex(y)),typeof y!="string"||!r.includes(y.length))throw new Error("Invalid key");y=y.padStart(i*2,"0")}let f;try{f=typeof y=="bigint"?y:m.bytesToNumberBE(m.ensureBytes("private key",y,i))}catch{throw new Error(`private key must be ${i} bytes, hex or bigint, not ${typeof y}`)}return o&&(f=_.mod(f,u)),R(f),f}const S=new Map;function V(y){if(!(y instanceof w))throw new Error("ProjectivePoint expected")}class w{constructor(r,i,o){if(this.px=r,this.py=i,this.pz=o,r==null||!t.isValid(r))throw new Error("x required");if(i==null||!t.isValid(i))throw new Error("y required");if(o==null||!t.isValid(o))throw new Error("z required")}static fromAffine(r){const{x:i,y:o}=r||{};if(!r||!t.isValid(i)||!t.isValid(o))throw new Error("invalid affine point");if(r instanceof w)throw new Error("projective point not allowed");const u=f=>t.eql(f,t.ZERO);return u(i)&&u(o)?w.ZERO:new w(i,o,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(r){const i=t.invertBatch(r.map(o=>o.pz));return r.map((o,u)=>o.toAffine(i[u])).map(w.fromAffine)}static fromHex(r){const i=w.fromAffine(O(m.ensureBytes("pointHex",r)));return i.assertValidity(),i}static fromPrivateKey(r){return w.BASE.multiply(L(r))}_setWindowSize(r){this._WINDOW_SIZE=r,S.delete(this)}assertValidity(){if(this.is0()){if(n.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:r,y:i}=this.toAffine();if(!t.isValid(r)||!t.isValid(i))throw new Error("bad point: x or y not FE");const o=t.sqr(i),u=T(r);if(!t.eql(o,u))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:r}=this.toAffine();if(t.isOdd)return!t.isOdd(r);throw new Error("Field doesn't support isOdd")}equals(r){V(r);const{px:i,py:o,pz:u}=this,{px:f,py:g,pz:h}=r,a=t.eql(t.mul(i,h),t.mul(f,u)),c=t.eql(t.mul(o,h),t.mul(g,u));return a&&c}negate(){return new w(this.px,t.neg(this.py),this.pz)}double(){const{a:r,b:i}=n,o=t.mul(i,ot),{px:u,py:f,pz:g}=this;let h=t.ZERO,a=t.ZERO,c=t.ZERO,d=t.mul(u,u),q=t.mul(f,f),B=t.mul(g,g),p=t.mul(u,f);return p=t.add(p,p),c=t.mul(u,g),c=t.add(c,c),h=t.mul(r,c),a=t.mul(o,B),a=t.add(h,a),h=t.sub(q,a),a=t.add(q,a),a=t.mul(h,a),h=t.mul(p,h),c=t.mul(o,c),B=t.mul(r,B),p=t.sub(d,B),p=t.mul(r,p),p=t.add(p,c),c=t.add(d,d),d=t.add(c,d),d=t.add(d,B),d=t.mul(d,p),a=t.add(a,d),B=t.mul(f,g),B=t.add(B,B),d=t.mul(B,p),h=t.sub(h,d),c=t.mul(B,q),c=t.add(c,c),c=t.add(c,c),new w(h,a,c)}add(r){V(r);const{px:i,py:o,pz:u}=this,{px:f,py:g,pz:h}=r;let a=t.ZERO,c=t.ZERO,d=t.ZERO;const q=n.a,B=t.mul(n.b,ot);let p=t.mul(i,f),N=t.mul(o,g),Z=t.mul(u,h),H=t.add(i,o),e=t.add(f,g);H=t.mul(H,e),e=t.add(p,N),H=t.sub(H,e),e=t.add(i,u);let s=t.add(f,h);return e=t.mul(e,s),s=t.add(p,Z),e=t.sub(e,s),s=t.add(o,u),a=t.add(g,h),s=t.mul(s,a),a=t.add(N,Z),s=t.sub(s,a),d=t.mul(q,e),a=t.mul(B,Z),d=t.add(a,d),a=t.sub(N,d),d=t.add(N,d),c=t.mul(a,d),N=t.add(p,p),N=t.add(N,p),Z=t.mul(q,Z),e=t.mul(B,e),N=t.add(N,Z),Z=t.sub(p,Z),Z=t.mul(q,Z),e=t.add(e,Z),p=t.mul(N,e),c=t.add(c,p),p=t.mul(s,e),a=t.mul(H,a),a=t.sub(a,p),p=t.mul(H,N),d=t.mul(s,d),d=t.add(d,p),new w(a,c,d)}subtract(r){return this.add(r.negate())}is0(){return this.equals(w.ZERO)}wNAF(r){return C.wNAFCached(this,S,r,i=>{const o=t.invertBatch(i.map(u=>u.pz));return i.map((u,f)=>u.toAffine(o[f])).map(w.fromAffine)})}multiplyUnsafe(r){const i=w.ZERO;if(r===P)return i;if(R(r),r===U)return this;const{endo:o}=n;if(!o)return C.unsafeLadder(this,r);let{k1neg:u,k1:f,k2neg:g,k2:h}=o.splitScalar(r),a=i,c=i,d=this;for(;f>P||h>P;)f&U&&(a=a.add(d)),h&U&&(c=c.add(d)),d=d.double(),f>>=U,h>>=U;return u&&(a=a.negate()),g&&(c=c.negate()),c=new w(t.mul(c.px,o.beta),c.py,c.pz),a.add(c)}multiply(r){R(r);let i=r,o,u;const{endo:f}=n;if(f){const{k1neg:g,k1:h,k2neg:a,k2:c}=f.splitScalar(i);let{p:d,f:q}=this.wNAF(h),{p:B,f:p}=this.wNAF(c);d=C.constTimeNegate(g,d),B=C.constTimeNegate(a,B),B=new w(t.mul(B.px,f.beta),B.py,B.pz),o=d.add(B),u=q.add(p)}else{const{p:g,f:h}=this.wNAF(i);o=g,u=h}return w.normalizeZ([o,u])[0]}multiplyAndAddUnsafe(r,i,o){const u=w.BASE,f=(h,a)=>a===P||a===U||!h.equals(u)?h.multiplyUnsafe(a):h.multiply(a),g=f(this,i).add(f(r,o));return g.is0()?void 0:g}toAffine(r){const{px:i,py:o,pz:u}=this,f=this.is0();r==null&&(r=f?t.ONE:t.inv(u));const g=t.mul(i,r),h=t.mul(o,r),a=t.mul(u,r);if(f)return{x:t.ZERO,y:t.ZERO};if(!t.eql(a,t.ONE))throw new Error("invZ was invalid");return{x:g,y:h}}isTorsionFree(){const{h:r,isTorsionFree:i}=n;if(r===U)return!0;if(i)return i(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:r,clearCofactor:i}=n;return r===U?this:i?i(w,this):this.multiplyUnsafe(n.h)}toRawBytes(r=!0){return this.assertValidity(),x(w,this,r)}toHex(r=!0){return m.bytesToHex(this.toRawBytes(r))}}w.BASE=new w(n.Gx,n.Gy,t.ONE),w.ZERO=new w(t.ZERO,t.ONE,t.ZERO);const W=n.nBitLength,C=et.wNAF(w,n.endo?Math.ceil(W/2):W);return{CURVE:n,ProjectivePoint:w,normPrivateKeyToScalar:L,weierstrassEquation:T,isWithinCurveOrder:F}}function lt(v){const n=et.validateBasic(v);return m.validateObject(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}function ft(v){const n=lt(v),{Fp:t,n:x}=n,O=t.BYTES+1,T=2*t.BYTES+1;function F(e){return P<e&&e<t.ORDER}function R(e){return _.mod(e,x)}function L(e){return _.invert(e,x)}const{ProjectivePoint:S,normPrivateKeyToScalar:V,weierstrassEquation:w,isWithinCurveOrder:W}=it({...n,toBytes(e,s,l){const b=s.toAffine(),E=t.toBytes(b.x),A=m.concatBytes;return l?A(Uint8Array.from([s.hasEvenY()?2:3]),E):A(Uint8Array.from([4]),E,t.toBytes(b.y))},fromBytes(e){const s=e.length,l=e[0],b=e.subarray(1);if(s===O&&(l===2||l===3)){const E=m.bytesToNumberBE(b);if(!F(E))throw new Error("Point is not on curve");const A=w(E);let z=t.sqrt(A);const I=(z&U)===U;return(l&1)===1!==I&&(z=t.neg(z)),{x:E,y:z}}else if(s===T&&l===4){const E=t.fromBytes(b.subarray(0,t.BYTES)),A=t.fromBytes(b.subarray(t.BYTES,2*t.BYTES));return{x:E,y:A}}else throw new Error(`Point of length ${s} was invalid. Expected ${O} compressed bytes or ${T} uncompressed bytes`)}}),C=e=>m.bytesToHex(m.numberToBytesBE(e,n.nByteLength));function y(e){const s=x>>U;return e>s}function r(e){return y(e)?R(-e):e}const i=(e,s,l)=>m.bytesToNumberBE(e.slice(s,l));class o{constructor(s,l,b){this.r=s,this.s=l,this.recovery=b,this.assertValidity()}static fromCompact(s){const l=n.nByteLength;return s=m.ensureBytes("compactSignature",s,l*2),new o(i(s,0,l),i(s,l,2*l))}static fromDER(s){const{r:l,s:b}=$.toSig(m.ensureBytes("DER",s));return new o(l,b)}assertValidity(){if(!W(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!W(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(s){return new o(this.r,this.s,s)}recoverPublicKey(s){const{r:l,s:b,recovery:E}=this,A=c(m.ensureBytes("msgHash",s));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const z=E===2||E===3?l+n.n:l;if(z>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const I=(E&1)===0?"02":"03",D=S.fromHex(I+C(z)),j=L(z),X=R(-A*j),Q=R(b*j),K=S.BASE.multiplyAndAddUnsafe(D,X,Q);if(!K)throw new Error("point at infinify");return K.assertValidity(),K}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new o(this.r,R(-this.s),this.recovery):this}toDERRawBytes(){return m.hexToBytes(this.toDERHex())}toDERHex(){return $.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return m.hexToBytes(this.toCompactHex())}toCompactHex(){return C(this.r)+C(this.s)}}const u={isValidPrivateKey(e){try{return V(e),!0}catch{return!1}},normPrivateKeyToScalar:V,randomPrivateKey:()=>{const e=n.randomBytes(t.BYTES+8),s=_.hashToPrivateScalar(e,x);return m.numberToBytesBE(s,n.nByteLength)},precompute(e=8,s=S.BASE){return s._setWindowSize(e),s.multiply(BigInt(3)),s}};function f(e,s=!0){return S.fromPrivateKey(e).toRawBytes(s)}function g(e){const s=e instanceof Uint8Array,l=typeof e=="string",b=(s||l)&&e.length;return s?b===O||b===T:l?b===2*O||b===2*T:e instanceof S}function h(e,s,l=!0){if(g(e))throw new Error("first arg must be private key");if(!g(s))throw new Error("second arg must be public key");return S.fromHex(s).multiply(V(e)).toRawBytes(l)}const a=n.bits2int||function(e){const s=m.bytesToNumberBE(e),l=e.length*8-n.nBitLength;return l>0?s>>BigInt(l):s},c=n.bits2int_modN||function(e){return R(a(e))},d=m.bitMask(n.nBitLength);function q(e){if(typeof e!="bigint")throw new Error("bigint expected");if(!(P<=e&&e<d))throw new Error(`bigint expected < 2^${n.nBitLength}`);return m.numberToBytesBE(e,n.nByteLength)}function B(e,s,l=p){if(["recovered","canonical"].some(k=>k in l))throw new Error("sign() legacy options not supported");const{hash:b,randomBytes:E}=n;let{lowS:A,prehash:z,extraEntropy:I}=l;A==null&&(A=!0),e=m.ensureBytes("msgHash",e),z&&(e=m.ensureBytes("prehashed msgHash",b(e)));const D=c(e),j=V(s),X=[q(j),q(D)];if(I!=null){const k=I===!0?E(t.BYTES):I;X.push(m.ensureBytes("extraEntropy",k,t.BYTES))}const Q=m.concatBytes(...X),K=D;function tt(k){const G=a(k);if(!W(G))return;const rt=L(G),Y=S.BASE.multiply(G).toAffine(),M=R(Y.x);if(M===P)return;const J=R(rt*R(K+M*j));if(J===P)return;let nt=(Y.x===M?0:2)|Number(Y.y&U),st=J;return A&&y(J)&&(st=r(J),nt^=1),new o(M,st,nt)}return{seed:Q,k2sig:tt}}const p={lowS:n.lowS,prehash:!1},N={lowS:n.lowS,prehash:!1};function Z(e,s,l=p){const{seed:b,k2sig:E}=B(e,s,l);return m.createHmacDrbg(n.hash.outputLen,n.nByteLength,n.hmac)(b,E)}S.BASE._setWindowSize(8);function H(e,s,l,b=N){const E=e;if(s=m.ensureBytes("msgHash",s),l=m.ensureBytes("publicKey",l),"strict"in b)throw new Error("options.strict was renamed to lowS");const{lowS:A,prehash:z}=b;let I,D;try{if(typeof E=="string"||E instanceof Uint8Array)try{I=o.fromDER(E)}catch(Y){if(!(Y instanceof $.Err))throw Y;I=o.fromCompact(E)}else if(typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint"){const{r:Y,s:M}=E;I=new o(Y,M)}else throw new Error("PARSE");D=S.fromHex(l)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(A&&I.hasHighS())return!1;z&&(s=n.hash(s));const{r:j,s:X}=I,Q=c(s),K=L(X),tt=R(Q*K),k=R(j*K),G=S.BASE.multiplyAndAddUnsafe(D,tt,k)?.toAffine();return G?R(G.x)===j:!1}return{CURVE:n,getPublicKey:f,getSharedSecret:h,sign:Z,verify:H,ProjectivePoint:S,Signature:o,utils:u}}exports.DER=$;exports.weierstrass=ft;exports.weierstrassPoints=it;
|
|
1
|
+
const e=require(`./utils.cjs`),t=require(`./modular.cjs`),n=require(`./curve.cjs`);function r(t){let r=n.validateBasic(t);e.validateObject(r,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:i,Fp:a,a:o}=r;if(i){if(!a.eql(o,a.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof i!=`object`||typeof i.beta!=`bigint`||typeof i.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...r})}var{bytesToNumberBE:i,hexToBytes:a}=e.utils_exports,o={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=o;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:i(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=o,n=typeof e==`string`?a(e):e;if(!(n instanceof Uint8Array))throw Error(`ui8a expected`);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:s}=o._parseInt(n.subarray(2)),{d:c,l}=o._parseInt(s);if(l.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:c}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},s=BigInt(0),c=BigInt(1),l=BigInt(3);function u(i){let a=r(i),{Fp:o}=a,u=a.toBytes||((t,n,r)=>{let i=n.toAffine();return e.concatBytes(Uint8Array.from([4]),o.toBytes(i.x),o.toBytes(i.y))}),d=a.fromBytes||(e=>{let t=e.subarray(1);return{x:o.fromBytes(t.subarray(0,o.BYTES)),y:o.fromBytes(t.subarray(o.BYTES,2*o.BYTES))}});function f(e){let{a:t,b:n}=a,r=o.sqr(e),i=o.mul(r,e);return o.add(o.add(i,o.mul(e,t)),n)}if(!o.eql(o.sqr(a.Gy),f(a.Gx)))throw Error(`bad generator point: equation left != right`);function p(e){return typeof e==`bigint`&&s<e&&e<a.n}function m(e){if(!p(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function h(n){let{allowedPrivateKeyLengths:r,nByteLength:i,wrapPrivateKey:o,n:s}=a;if(r&&typeof n!=`bigint`){if(n instanceof Uint8Array&&(n=e.bytesToHex(n)),typeof n!=`string`||!r.includes(n.length))throw Error(`Invalid key`);n=n.padStart(i*2,`0`)}let c;try{c=typeof n==`bigint`?n:e.bytesToNumberBE(e.ensureBytes(`private key`,n,i))}catch{throw Error(`private key must be ${i} bytes, hex or bigint, not ${typeof n}`)}return o&&(c=t.mod(c,s)),m(c),c}let g=new Map;function _(e){if(!(e instanceof v))throw Error(`ProjectivePoint expected`)}class v{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,e==null||!o.isValid(e))throw Error(`x required`);if(t==null||!o.isValid(t))throw Error(`y required`);if(n==null||!o.isValid(n))throw Error(`z required`)}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!o.isValid(t)||!o.isValid(n))throw Error(`invalid affine point`);if(e instanceof v)throw Error(`projective point not allowed`);let r=e=>o.eql(e,o.ZERO);return r(t)&&r(n)?v.ZERO:new v(t,n,o.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=o.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(v.fromAffine)}static fromHex(t){let n=v.fromAffine(d(e.ensureBytes(`pointHex`,t)));return n.assertValidity(),n}static fromPrivateKey(e){return v.BASE.multiply(h(e))}_setWindowSize(e){this._WINDOW_SIZE=e,g.delete(this)}assertValidity(){if(this.is0()){if(a.allowInfinityPoint)return;throw Error(`bad point: ZERO`)}let{x:e,y:t}=this.toAffine();if(!o.isValid(e)||!o.isValid(t))throw Error(`bad point: x or y not FE`);let n=o.sqr(t),r=f(e);if(!o.eql(n,r))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(o.isOdd)return!o.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){_(e);let{px:t,py:n,pz:r}=this,{px:i,py:a,pz:s}=e,c=o.eql(o.mul(t,s),o.mul(i,r)),l=o.eql(o.mul(n,s),o.mul(a,r));return c&&l}negate(){return new v(this.px,o.neg(this.py),this.pz)}double(){let{a:e,b:t}=a,n=o.mul(t,l),{px:r,py:i,pz:s}=this,c=o.ZERO,u=o.ZERO,d=o.ZERO,f=o.mul(r,r),p=o.mul(i,i),m=o.mul(s,s),h=o.mul(r,i);return h=o.add(h,h),d=o.mul(r,s),d=o.add(d,d),c=o.mul(e,d),u=o.mul(n,m),u=o.add(c,u),c=o.sub(p,u),u=o.add(p,u),u=o.mul(c,u),c=o.mul(h,c),d=o.mul(n,d),m=o.mul(e,m),h=o.sub(f,m),h=o.mul(e,h),h=o.add(h,d),d=o.add(f,f),f=o.add(d,f),f=o.add(f,m),f=o.mul(f,h),u=o.add(u,f),m=o.mul(i,s),m=o.add(m,m),f=o.mul(m,h),c=o.sub(c,f),d=o.mul(m,p),d=o.add(d,d),d=o.add(d,d),new v(c,u,d)}add(e){_(e);let{px:t,py:n,pz:r}=this,{px:i,py:s,pz:c}=e,u=o.ZERO,d=o.ZERO,f=o.ZERO,p=a.a,m=o.mul(a.b,l),h=o.mul(t,i),g=o.mul(n,s),y=o.mul(r,c),b=o.add(t,n),x=o.add(i,s);b=o.mul(b,x),x=o.add(h,g),b=o.sub(b,x),x=o.add(t,r);let S=o.add(i,c);return x=o.mul(x,S),S=o.add(h,y),x=o.sub(x,S),S=o.add(n,r),u=o.add(s,c),S=o.mul(S,u),u=o.add(g,y),S=o.sub(S,u),f=o.mul(p,x),u=o.mul(m,y),f=o.add(u,f),u=o.sub(g,f),f=o.add(g,f),d=o.mul(u,f),g=o.add(h,h),g=o.add(g,h),y=o.mul(p,y),x=o.mul(m,x),g=o.add(g,y),y=o.sub(h,y),y=o.mul(p,y),x=o.add(x,y),h=o.mul(g,x),d=o.add(d,h),h=o.mul(S,x),u=o.mul(b,u),u=o.sub(u,h),h=o.mul(b,g),f=o.mul(S,f),f=o.add(f,h),new v(u,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return b.wNAFCached(this,g,e,e=>{let t=o.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(v.fromAffine)})}multiplyUnsafe(e){let t=v.ZERO;if(e===s)return t;if(m(e),e===c)return this;let{endo:n}=a;if(!n)return b.unsafeLadder(this,e);let{k1neg:r,k1:i,k2neg:l,k2:u}=n.splitScalar(e),d=t,f=t,p=this;for(;i>s||u>s;)i&c&&(d=d.add(p)),u&c&&(f=f.add(p)),p=p.double(),i>>=c,u>>=c;return r&&(d=d.negate()),l&&(f=f.negate()),f=new v(o.mul(f.px,n.beta),f.py,f.pz),d.add(f)}multiply(e){m(e);let t=e,n,r,{endo:i}=a;if(i){let{k1neg:e,k1:a,k2neg:s,k2:c}=i.splitScalar(t),{p:l,f:u}=this.wNAF(a),{p:d,f}=this.wNAF(c);l=b.constTimeNegate(e,l),d=b.constTimeNegate(s,d),d=new v(o.mul(d.px,i.beta),d.py,d.pz),n=l.add(d),r=u.add(f)}else{let{p:e,f:i}=this.wNAF(t);n=e,r=i}return v.normalizeZ([n,r])[0]}multiplyAndAddUnsafe(e,t,n){let r=v.BASE,i=(e,t)=>t===s||t===c||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:n,pz:r}=this,i=this.is0();e??=i?o.ONE:o.inv(r);let a=o.mul(t,e),s=o.mul(n,e),c=o.mul(r,e);if(i)return{x:o.ZERO,y:o.ZERO};if(!o.eql(c,o.ONE))throw Error(`invZ was invalid`);return{x:a,y:s}}isTorsionFree(){let{h:e,isTorsionFree:t}=a;if(e===c)return!0;if(t)return t(v,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:t}=a;return e===c?this:t?t(v,this):this.multiplyUnsafe(a.h)}toRawBytes(e=!0){return this.assertValidity(),u(v,this,e)}toHex(t=!0){return e.bytesToHex(this.toRawBytes(t))}}v.BASE=new v(a.Gx,a.Gy,o.ONE),v.ZERO=new v(o.ZERO,o.ONE,o.ZERO);let y=a.nBitLength,b=n.wNAF(v,a.endo?Math.ceil(y/2):y);return{CURVE:a,ProjectivePoint:v,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:p}}function d(t){let r=n.validateBasic(t);return e.validateObject(r,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...r})}function f(n){let r=d(n),{Fp:i,n:a}=r,l=i.BYTES+1,f=2*i.BYTES+1;function p(e){return s<e&&e<i.ORDER}function m(e){return t.mod(e,a)}function h(e){return t.invert(e,a)}let{ProjectivePoint:g,normPrivateKeyToScalar:_,weierstrassEquation:v,isWithinCurveOrder:y}=u({...r,toBytes(t,n,r){let a=n.toAffine(),o=i.toBytes(a.x),s=e.concatBytes;return r?s(Uint8Array.from([n.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,i.toBytes(a.y))},fromBytes(t){let n=t.length,r=t[0],a=t.subarray(1);if(n===l&&(r===2||r===3)){let t=e.bytesToNumberBE(a);if(!p(t))throw Error(`Point is not on curve`);let n=v(t),o=i.sqrt(n),s=(o&c)===c;return(r&1)==1!==s&&(o=i.neg(o)),{x:t,y:o}}else if(n===f&&r===4)return{x:i.fromBytes(a.subarray(0,i.BYTES)),y:i.fromBytes(a.subarray(i.BYTES,2*i.BYTES))};else throw Error(`Point of length ${n} was invalid. Expected ${l} compressed bytes or ${f} uncompressed bytes`)}}),b=t=>e.bytesToHex(e.numberToBytesBE(t,r.nByteLength));function x(e){return e>a>>c}function S(e){return x(e)?m(-e):e}let C=(t,n,r)=>e.bytesToNumberBE(t.slice(n,r));class w{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(t){let n=r.nByteLength;return t=e.ensureBytes(`compactSignature`,t,n*2),new w(C(t,0,n),C(t,n,2*n))}static fromDER(t){let{r:n,s:r}=o.toSig(e.ensureBytes(`DER`,t));return new w(n,r)}assertValidity(){if(!y(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!y(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:a,recovery:o}=this,s=A(e.ensureBytes(`msgHash`,t));if(o==null||![0,1,2,3].includes(o))throw Error(`recovery id invalid`);let c=o===2||o===3?n+r.n:n;if(c>=i.ORDER)throw Error(`recovery id 2 or 3 invalid`);let l=o&1?`03`:`02`,u=g.fromHex(l+b(c)),d=h(c),f=m(-s*d),p=m(a*d),_=g.BASE.multiplyAndAddUnsafe(u,f,p);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return x(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,m(-this.s),this.recovery):this}toDERRawBytes(){return e.hexToBytes(this.toDERHex())}toDERHex(){return o.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return e.hexToBytes(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}let T={isValidPrivateKey(e){try{return _(e),!0}catch{return!1}},normPrivateKeyToScalar:_,randomPrivateKey:()=>{let n=r.randomBytes(i.BYTES+8),o=t.hashToPrivateScalar(n,a);return e.numberToBytesBE(o,r.nByteLength)},precompute(e=8,t=g.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function E(e,t=!0){return g.fromPrivateKey(e).toRawBytes(t)}function D(e){let t=e instanceof Uint8Array,n=typeof e==`string`,r=(t||n)&&e.length;return t?r===l||r===f:n?r===2*l||r===2*f:e instanceof g}function O(e,t,n=!0){if(D(e))throw Error(`first arg must be private key`);if(!D(t))throw Error(`second arg must be public key`);return g.fromHex(t).multiply(_(e)).toRawBytes(n)}let k=r.bits2int||function(t){let n=e.bytesToNumberBE(t),i=t.length*8-r.nBitLength;return i>0?n>>BigInt(i):n},A=r.bits2int_modN||function(e){return m(k(e))},j=e.bitMask(r.nBitLength);function M(t){if(typeof t!=`bigint`)throw Error(`bigint expected`);if(!(s<=t&&t<j))throw Error(`bigint expected < 2^${r.nBitLength}`);return e.numberToBytesBE(t,r.nByteLength)}function N(t,n,a=P){if([`recovered`,`canonical`].some(e=>e in a))throw Error(`sign() legacy options not supported`);let{hash:o,randomBytes:l}=r,{lowS:u,prehash:d,extraEntropy:f}=a;u??=!0,t=e.ensureBytes(`msgHash`,t),d&&(t=e.ensureBytes(`prehashed msgHash`,o(t)));let p=A(t),v=_(n),b=[M(v),M(p)];if(f!=null){let t=f===!0?l(i.BYTES):f;b.push(e.ensureBytes(`extraEntropy`,t,i.BYTES))}let C=e.concatBytes(...b),T=p;function E(e){let t=k(e);if(!y(t))return;let n=h(t),r=g.BASE.multiply(t).toAffine(),i=m(r.x);if(i===s)return;let a=m(n*m(T+i*v));if(a===s)return;let o=(r.x===i?0:2)|Number(r.y&c),l=a;return u&&x(a)&&(l=S(a),o^=1),new w(i,l,o)}return{seed:C,k2sig:E}}let P={lowS:r.lowS,prehash:!1},F={lowS:r.lowS,prehash:!1};function I(t,n,i=P){let{seed:a,k2sig:o}=N(t,n,i);return e.createHmacDrbg(r.hash.outputLen,r.nByteLength,r.hmac)(a,o)}g.BASE._setWindowSize(8);function L(t,n,i,a=F){let s=t;if(n=e.ensureBytes(`msgHash`,n),i=e.ensureBytes(`publicKey`,i),`strict`in a)throw Error(`options.strict was renamed to lowS`);let{lowS:c,prehash:l}=a,u,d;try{if(typeof s==`string`||s instanceof Uint8Array)try{u=w.fromDER(s)}catch(e){if(!(e instanceof o.Err))throw e;u=w.fromCompact(s)}else if(typeof s==`object`&&typeof s.r==`bigint`&&typeof s.s==`bigint`){let{r:e,s:t}=s;u=new w(e,t)}else throw Error(`PARSE`);d=g.fromHex(i)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(c&&u.hasHighS())return!1;l&&(n=r.hash(n));let{r:f,s:p}=u,_=A(n),v=h(p),y=m(_*v),b=m(f*v),x=g.BASE.multiplyAndAddUnsafe(d,y,b)?.toAffine();return x?m(x.x)===f:!1}return{CURVE:r,getPublicKey:E,getSharedSecret:O,sign:I,verify:L,ProjectivePoint:g,Signature:w,utils:T}}exports.weierstrass=f;
|