@hfunlabs/hyperliquid 0.30.0-hfunlabs.1 → 0.30.2-hfunlabs.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/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +58 -0
- package/esm/_dnt.shims.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +457 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +207 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +555 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1222 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +283 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +241 -0
- package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +147 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +67 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +90 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +397 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +254 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +243 -0
- package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +144 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +96 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +98 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +535 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +207 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +298 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +6 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +180 -0
- package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2001 -0
- package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.js +704 -0
- package/esm/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +137 -0
- package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
- package/esm/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
- package/esm/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/_base/_nonce.js +3 -2
- package/esm/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
- package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
- package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/_base/_semaphore.js +34 -47
- package/esm/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
- package/esm/src/api/exchange/_methods/_base/execute.d.ts +14 -3
- package/esm/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/_base/execute.js +44 -10
- package/esm/src/api/exchange/_methods/_base/execute.js.map +1 -1
- package/esm/src/api/exchange/_methods/batchModify.d.ts +6 -6
- package/esm/src/api/exchange/_methods/createVault.d.ts +5 -5
- package/esm/src/api/exchange/_methods/modify.d.ts +5 -5
- package/esm/src/api/exchange/_methods/order.d.ts +13 -13
- package/esm/src/api/exchange/_methods/order.d.ts.map +1 -1
- package/esm/src/api/exchange/_methods/order.js +4 -2
- package/esm/src/api/exchange/_methods/order.js.map +1 -1
- package/esm/src/api/exchange/client.d.ts +1 -1
- package/esm/src/api/exchange/client.d.ts.map +1 -1
- package/esm/src/api/exchange/client.js.map +1 -1
- package/esm/src/api/exchange/mod.d.ts +1 -1
- package/esm/src/api/exchange/mod.d.ts.map +1 -1
- package/esm/src/api/exchange/mod.js.map +1 -1
- package/esm/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
- package/esm/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
- package/esm/src/api/info/_methods/historicalOrders.d.ts +4 -4
- package/esm/src/api/info/_methods/l3Orders.d.ts +11 -11
- package/esm/src/api/info/_methods/l4Orders.d.ts +6 -6
- package/esm/src/api/info/_methods/openOrders.d.ts +3 -3
- package/esm/src/api/info/_methods/orderStatus.d.ts +5 -5
- package/esm/src/api/info/_methods/recentTrades.d.ts +2 -2
- package/esm/src/api/info/_methods/twapHistory.d.ts +4 -4
- package/esm/src/api/info/_methods/userFills.d.ts +3 -3
- package/esm/src/api/info/_methods/userFillsByTime.d.ts +4 -4
- package/esm/src/api/info/_methods/userFunding.d.ts +3 -3
- package/esm/src/api/info/_methods/userFunding.js +2 -2
- package/esm/src/api/info/_methods/userFunding.js.map +1 -1
- package/esm/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
- package/esm/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
- package/esm/src/api/info/_methods/webData2.d.ts +9 -9
- package/esm/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
- package/esm/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/assetCtxs.js.map +1 -1
- package/esm/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
- package/esm/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/clearinghouseState.js +2 -0
- package/esm/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
- package/esm/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
- package/esm/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/explorerBlock.js +2 -0
- package/esm/src/api/subscription/_methods/explorerBlock.js.map +1 -1
- package/esm/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
- package/esm/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/explorerTxs.js +2 -0
- package/esm/src/api/subscription/_methods/explorerTxs.js.map +1 -1
- package/esm/src/api/subscription/_methods/openOrders.d.ts +5 -5
- package/esm/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
- package/esm/src/api/subscription/_methods/trades.d.ts +3 -3
- package/esm/src/api/subscription/_methods/twapStates.d.ts +9 -4
- package/esm/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
- package/esm/src/api/subscription/_methods/twapStates.js +6 -1
- package/esm/src/api/subscription/_methods/twapStates.js.map +1 -1
- package/esm/src/api/subscription/_methods/userEvents.d.ts +17 -17
- package/esm/src/api/subscription/_methods/userFills.d.ts +5 -5
- package/esm/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
- package/esm/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
- package/esm/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
- package/esm/src/api/subscription/_methods/webData2.d.ts +11 -11
- package/esm/src/signing/_privateKeySigner.js +1 -1
- package/esm/src/signing/_privateKeySigner.js.map +1 -1
- package/esm/src/signing/mod.js +1 -1
- package/esm/src/signing/mod.js.map +1 -1
- package/package.json +2 -3
- package/script/_dnt.shims.d.ts +2 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +61 -0
- package/script/_dnt.shims.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +468 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +215 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +578 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1232 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +286 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +273 -0
- package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +153 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +90 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +95 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +439 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +259 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +304 -0
- package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +182 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +99 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +134 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +576 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +211 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +308 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +21 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +195 -0
- package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2032 -0
- package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.js +710 -0
- package/script/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +141 -0
- package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
- package/script/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
- package/script/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/_base/_nonce.js +4 -3
- package/script/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
- package/script/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
- package/script/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/_base/_semaphore.js +35 -50
- package/script/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
- package/script/src/api/exchange/_methods/_base/execute.d.ts +14 -3
- package/script/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/_base/execute.js +43 -9
- package/script/src/api/exchange/_methods/_base/execute.js.map +1 -1
- package/script/src/api/exchange/_methods/batchModify.d.ts +6 -6
- package/script/src/api/exchange/_methods/createVault.d.ts +5 -5
- package/script/src/api/exchange/_methods/modify.d.ts +5 -5
- package/script/src/api/exchange/_methods/order.d.ts +13 -13
- package/script/src/api/exchange/_methods/order.d.ts.map +1 -1
- package/script/src/api/exchange/_methods/order.js +4 -2
- package/script/src/api/exchange/_methods/order.js.map +1 -1
- package/script/src/api/exchange/client.d.ts +1 -1
- package/script/src/api/exchange/client.d.ts.map +1 -1
- package/script/src/api/exchange/client.js.map +1 -1
- package/script/src/api/exchange/mod.d.ts +1 -1
- package/script/src/api/exchange/mod.d.ts.map +1 -1
- package/script/src/api/exchange/mod.js.map +1 -1
- package/script/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
- package/script/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
- package/script/src/api/info/_methods/historicalOrders.d.ts +4 -4
- package/script/src/api/info/_methods/l3Orders.d.ts +11 -11
- package/script/src/api/info/_methods/l4Orders.d.ts +6 -6
- package/script/src/api/info/_methods/openOrders.d.ts +3 -3
- package/script/src/api/info/_methods/orderStatus.d.ts +5 -5
- package/script/src/api/info/_methods/recentTrades.d.ts +2 -2
- package/script/src/api/info/_methods/twapHistory.d.ts +4 -4
- package/script/src/api/info/_methods/userFills.d.ts +3 -3
- package/script/src/api/info/_methods/userFillsByTime.d.ts +4 -4
- package/script/src/api/info/_methods/userFunding.d.ts +3 -3
- package/script/src/api/info/_methods/userFunding.js +2 -2
- package/script/src/api/info/_methods/userFunding.js.map +1 -1
- package/script/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
- package/script/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
- package/script/src/api/info/_methods/webData2.d.ts +9 -9
- package/script/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
- package/script/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/assetCtxs.js.map +1 -1
- package/script/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
- package/script/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/clearinghouseState.js +2 -0
- package/script/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
- package/script/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
- package/script/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/explorerBlock.js +2 -0
- package/script/src/api/subscription/_methods/explorerBlock.js.map +1 -1
- package/script/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
- package/script/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/explorerTxs.js +2 -0
- package/script/src/api/subscription/_methods/explorerTxs.js.map +1 -1
- package/script/src/api/subscription/_methods/openOrders.d.ts +5 -5
- package/script/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
- package/script/src/api/subscription/_methods/trades.d.ts +3 -3
- package/script/src/api/subscription/_methods/twapStates.d.ts +9 -4
- package/script/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
- package/script/src/api/subscription/_methods/twapStates.js +6 -1
- package/script/src/api/subscription/_methods/twapStates.js.map +1 -1
- package/script/src/api/subscription/_methods/userEvents.d.ts +17 -17
- package/script/src/api/subscription/_methods/userFills.d.ts +5 -5
- package/script/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
- package/script/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
- package/script/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
- package/script/src/api/subscription/_methods/webData2.d.ts +11 -11
- package/script/src/signing/_privateKeySigner.js +3 -3
- package/script/src/signing/_privateKeySigner.js.map +1 -1
- package/script/src/signing/mod.js +2 -2
- package/script/src/signing/mod.js.map +1 -1
- package/src/_dnt.shims.ts +60 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.ts +633 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.ts +292 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.ts +621 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.ts +1562 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.ts +327 -0
- package/src/deps/jsr.io/@noble/curves/2.0.1/src/utils.ts +306 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_md.ts +156 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.ts +91 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.ts +94 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.ts +469 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.ts +295 -0
- package/src/deps/jsr.io/@noble/hashes/2.0.1/src/utils.ts +340 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.ts +212 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.ts +100 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.ts +104 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.ts +626 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.ts +274 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.ts +391 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.ts +12 -0
- package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.ts +233 -0
- package/src/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.ts +2196 -0
- package/src/deps/jsr.io/@scure/base/2.0.0/index.ts +857 -0
- package/src/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.ts +146 -0
- package/src/src/api/exchange/_methods/_base/_nonce.ts +3 -2
- package/src/src/api/exchange/_methods/_base/_semaphore.ts +34 -59
- package/src/src/api/exchange/_methods/_base/execute.ts +60 -12
- package/src/src/api/exchange/_methods/order.ts +5 -3
- package/src/src/api/exchange/client.ts +5 -1
- package/src/src/api/exchange/mod.ts +5 -1
- package/src/src/api/info/_methods/userFunding.ts +2 -2
- package/src/src/api/subscription/_methods/assetCtxs.ts +2 -0
- package/src/src/api/subscription/_methods/clearinghouseState.ts +2 -0
- package/src/src/api/subscription/_methods/explorerBlock.ts +2 -0
- package/src/src/api/subscription/_methods/explorerTxs.ts +2 -0
- package/src/src/api/subscription/_methods/twapStates.ts +9 -1
- package/src/src/signing/_privateKeySigner.ts +1 -1
- package/src/src/signing/mod.ts +1 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -292
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -46
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -295
- package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -62
- package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
- package/src/deps/jsr.io/@std/msgpack/1.0.3/decode.ts +0 -391
- package/src/deps/jsr.io/@std/msgpack/1.0.3/mod.ts +0 -47
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { abytes, asafenumber, asciiToBytes, bytesToNumberBE, concatBytes, isBytes, validateObject, } from '../utils.js';
|
|
2
|
+
import { FpInvertBatch, mod } from './modular.js';
|
|
3
|
+
// Octet Stream to Integer. "spec" implementation of os2ip is 2.5x slower vs bytesToNumberBE.
|
|
4
|
+
const os2ip = bytesToNumberBE;
|
|
5
|
+
// Integer to Octet Stream (numberToBytesBE)
|
|
6
|
+
function i2osp(value, length) {
|
|
7
|
+
asafenumber(value);
|
|
8
|
+
asafenumber(length);
|
|
9
|
+
if (value < 0 || value >= 1 << (8 * length))
|
|
10
|
+
throw new Error('invalid I2OSP input: ' + value);
|
|
11
|
+
const res = Array.from({ length }).fill(0);
|
|
12
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
13
|
+
res[i] = value & 0xff;
|
|
14
|
+
value >>>= 8;
|
|
15
|
+
}
|
|
16
|
+
return new Uint8Array(res);
|
|
17
|
+
}
|
|
18
|
+
function strxor(a, b) {
|
|
19
|
+
const arr = new Uint8Array(a.length);
|
|
20
|
+
for (let i = 0; i < a.length; i++) {
|
|
21
|
+
arr[i] = a[i] ^ b[i];
|
|
22
|
+
}
|
|
23
|
+
return arr;
|
|
24
|
+
}
|
|
25
|
+
// User can always use utf8 if they want, by passing Uint8Array.
|
|
26
|
+
// If string is passed, we treat it as ASCII: other formats are likely a mistake.
|
|
27
|
+
function normDST(DST) {
|
|
28
|
+
if (!isBytes(DST) && typeof DST !== 'string')
|
|
29
|
+
throw new Error('DST must be Uint8Array or ascii string');
|
|
30
|
+
return typeof DST === 'string' ? asciiToBytes(DST) : DST;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits.
|
|
34
|
+
* [RFC 9380 5.3.1](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.1).
|
|
35
|
+
*/
|
|
36
|
+
export function expand_message_xmd(msg, DST, lenInBytes, H) {
|
|
37
|
+
abytes(msg);
|
|
38
|
+
asafenumber(lenInBytes);
|
|
39
|
+
DST = normDST(DST);
|
|
40
|
+
// https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3
|
|
41
|
+
if (DST.length > 255)
|
|
42
|
+
DST = H(concatBytes(asciiToBytes('H2C-OVERSIZE-DST-'), DST));
|
|
43
|
+
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
|
|
44
|
+
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
|
45
|
+
if (lenInBytes > 65535 || ell > 255)
|
|
46
|
+
throw new Error('expand_message_xmd: invalid lenInBytes');
|
|
47
|
+
const DST_prime = concatBytes(DST, i2osp(DST.length, 1));
|
|
48
|
+
const Z_pad = i2osp(0, r_in_bytes);
|
|
49
|
+
const l_i_b_str = i2osp(lenInBytes, 2); // len_in_bytes_str
|
|
50
|
+
const b = new Array(ell);
|
|
51
|
+
const b_0 = H(concatBytes(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
|
|
52
|
+
b[0] = H(concatBytes(b_0, i2osp(1, 1), DST_prime));
|
|
53
|
+
for (let i = 1; i <= ell; i++) {
|
|
54
|
+
const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];
|
|
55
|
+
b[i] = H(concatBytes(...args));
|
|
56
|
+
}
|
|
57
|
+
const pseudo_random_bytes = concatBytes(...b);
|
|
58
|
+
return pseudo_random_bytes.slice(0, lenInBytes);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Produces a uniformly random byte string using an extendable-output function (XOF) H.
|
|
62
|
+
* 1. The collision resistance of H MUST be at least k bits.
|
|
63
|
+
* 2. H MUST be an XOF that has been proved indifferentiable from
|
|
64
|
+
* a random oracle under a reasonable cryptographic assumption.
|
|
65
|
+
* [RFC 9380 5.3.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.2).
|
|
66
|
+
*/
|
|
67
|
+
export function expand_message_xof(msg, DST, lenInBytes, k, H) {
|
|
68
|
+
abytes(msg);
|
|
69
|
+
asafenumber(lenInBytes);
|
|
70
|
+
DST = normDST(DST);
|
|
71
|
+
// https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3
|
|
72
|
+
// DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8));
|
|
73
|
+
if (DST.length > 255) {
|
|
74
|
+
const dkLen = Math.ceil((2 * k) / 8);
|
|
75
|
+
DST = H.create({ dkLen }).update(asciiToBytes('H2C-OVERSIZE-DST-')).update(DST).digest();
|
|
76
|
+
}
|
|
77
|
+
if (lenInBytes > 65535 || DST.length > 255)
|
|
78
|
+
throw new Error('expand_message_xof: invalid lenInBytes');
|
|
79
|
+
return (H.create({ dkLen: lenInBytes })
|
|
80
|
+
.update(msg)
|
|
81
|
+
.update(i2osp(lenInBytes, 2))
|
|
82
|
+
// 2. DST_prime = DST || I2OSP(len(DST), 1)
|
|
83
|
+
.update(DST)
|
|
84
|
+
.update(i2osp(DST.length, 1))
|
|
85
|
+
.digest());
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F.
|
|
89
|
+
* [RFC 9380 5.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.2).
|
|
90
|
+
* @param msg a byte string containing the message to hash
|
|
91
|
+
* @param count the number of elements of F to output
|
|
92
|
+
* @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above
|
|
93
|
+
* @returns [u_0, ..., u_(count - 1)], a list of field elements.
|
|
94
|
+
*/
|
|
95
|
+
export function hash_to_field(msg, count, options) {
|
|
96
|
+
validateObject(options, {
|
|
97
|
+
p: 'bigint',
|
|
98
|
+
m: 'number',
|
|
99
|
+
k: 'number',
|
|
100
|
+
hash: 'function',
|
|
101
|
+
});
|
|
102
|
+
const { p, k, m, hash, expand, DST } = options;
|
|
103
|
+
asafenumber(hash.outputLen, 'valid hash');
|
|
104
|
+
abytes(msg);
|
|
105
|
+
asafenumber(count);
|
|
106
|
+
const log2p = p.toString(2).length;
|
|
107
|
+
const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above
|
|
108
|
+
const len_in_bytes = count * m * L;
|
|
109
|
+
let prb; // pseudo_random_bytes
|
|
110
|
+
if (expand === 'xmd') {
|
|
111
|
+
prb = expand_message_xmd(msg, DST, len_in_bytes, hash);
|
|
112
|
+
}
|
|
113
|
+
else if (expand === 'xof') {
|
|
114
|
+
prb = expand_message_xof(msg, DST, len_in_bytes, k, hash);
|
|
115
|
+
}
|
|
116
|
+
else if (expand === '_internal_pass') {
|
|
117
|
+
// for internal tests only
|
|
118
|
+
prb = msg;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
throw new Error('expand must be "xmd" or "xof"');
|
|
122
|
+
}
|
|
123
|
+
const u = new Array(count);
|
|
124
|
+
for (let i = 0; i < count; i++) {
|
|
125
|
+
const e = new Array(m);
|
|
126
|
+
for (let j = 0; j < m; j++) {
|
|
127
|
+
const elm_offset = L * (j + i * m);
|
|
128
|
+
const tv = prb.subarray(elm_offset, elm_offset + L);
|
|
129
|
+
e[j] = mod(os2ip(tv), p);
|
|
130
|
+
}
|
|
131
|
+
u[i] = e;
|
|
132
|
+
}
|
|
133
|
+
return u;
|
|
134
|
+
}
|
|
135
|
+
export function isogenyMap(field, map) {
|
|
136
|
+
// Make same order as in spec
|
|
137
|
+
const coeff = map.map((i) => Array.from(i).reverse());
|
|
138
|
+
return (x, y) => {
|
|
139
|
+
const [xn, xd, yn, yd] = coeff.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i)));
|
|
140
|
+
// 6.6.3
|
|
141
|
+
// Exceptional cases of iso_map are inputs that cause the denominator of
|
|
142
|
+
// either rational function to evaluate to zero; such cases MUST return
|
|
143
|
+
// the identity point on E.
|
|
144
|
+
const [xd_inv, yd_inv] = FpInvertBatch(field, [xd, yd], true);
|
|
145
|
+
x = field.mul(xn, xd_inv); // xNum / xDen
|
|
146
|
+
y = field.mul(y, field.mul(yn, yd_inv)); // y * (yNum / yDev)
|
|
147
|
+
return { x, y };
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
export const _DST_scalar = asciiToBytes('HashToScalar-');
|
|
151
|
+
/** Creates hash-to-curve methods from EC Point and mapToCurve function. See {@link H2CHasher}. */
|
|
152
|
+
export function createHasher(Point, mapToCurve, defaults) {
|
|
153
|
+
if (typeof mapToCurve !== 'function')
|
|
154
|
+
throw new Error('mapToCurve() must be defined');
|
|
155
|
+
function map(num) {
|
|
156
|
+
return Point.fromAffine(mapToCurve(num));
|
|
157
|
+
}
|
|
158
|
+
function clear(initial) {
|
|
159
|
+
const P = initial.clearCofactor();
|
|
160
|
+
if (P.equals(Point.ZERO))
|
|
161
|
+
return Point.ZERO; // zero will throw in assert
|
|
162
|
+
P.assertValidity();
|
|
163
|
+
return P;
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
defaults: Object.freeze(defaults),
|
|
167
|
+
Point,
|
|
168
|
+
hashToCurve(msg, options) {
|
|
169
|
+
const opts = Object.assign({}, defaults, options);
|
|
170
|
+
const u = hash_to_field(msg, 2, opts);
|
|
171
|
+
const u0 = map(u[0]);
|
|
172
|
+
const u1 = map(u[1]);
|
|
173
|
+
return clear(u0.add(u1));
|
|
174
|
+
},
|
|
175
|
+
encodeToCurve(msg, options) {
|
|
176
|
+
const optsDst = defaults.encodeDST ? { DST: defaults.encodeDST } : {};
|
|
177
|
+
const opts = Object.assign({}, defaults, optsDst, options);
|
|
178
|
+
const u = hash_to_field(msg, 1, opts);
|
|
179
|
+
const u0 = map(u[0]);
|
|
180
|
+
return clear(u0);
|
|
181
|
+
},
|
|
182
|
+
/** See {@link H2CHasher} */
|
|
183
|
+
mapToCurve(scalars) {
|
|
184
|
+
// Curves with m=1 accept only single scalar
|
|
185
|
+
if (defaults.m === 1) {
|
|
186
|
+
if (typeof scalars !== 'bigint')
|
|
187
|
+
throw new Error('expected bigint (m=1)');
|
|
188
|
+
return clear(map([scalars]));
|
|
189
|
+
}
|
|
190
|
+
if (!Array.isArray(scalars))
|
|
191
|
+
throw new Error('expected array of bigints');
|
|
192
|
+
for (const i of scalars)
|
|
193
|
+
if (typeof i !== 'bigint')
|
|
194
|
+
throw new Error('expected array of bigints');
|
|
195
|
+
return clear(map(scalars));
|
|
196
|
+
},
|
|
197
|
+
// hash_to_scalar can produce 0: https://www.rfc-editor.org/errata/eid8393
|
|
198
|
+
// RFC 9380, draft-irtf-cfrg-bbs-signatures-08
|
|
199
|
+
hashToScalar(msg, options) {
|
|
200
|
+
// @ts-ignore
|
|
201
|
+
const N = Point.Fn.ORDER;
|
|
202
|
+
const opts = Object.assign({}, defaults, { p: N, m: 1, DST: _DST_scalar }, options);
|
|
203
|
+
return hash_to_field(msg, 1, opts)[0][0];
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=hash-to-curve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-to-curve.js","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,MAAM,EACN,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,OAAO,EACP,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,GAAG,EAAe,MAAM,cAAc,CAAC;AAgD/D,6FAA6F;AAC7F,MAAM,KAAK,GAAG,eAAe,CAAC;AAE9B,4CAA4C;AAC5C,SAAS,KAAK,CAAC,KAAa,EAAE,MAAc;IAC1C,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,WAAW,CAAC,MAAM,CAAC,CAAC;IACpB,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;IAC9F,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAa,CAAC;IACvD,KAAK,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;QACtB,KAAK,MAAM,CAAC,CAAC;IACf,CAAC;IACD,OAAO,I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O,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,0EAA0E;QAC1E,8CAA8C;QAC9C,YAAY,CAAC,GAAe,EAAE,OAAoB;YAChD,aAAa;YACb,MAAM,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;YACzB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;YACpF,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export declare function mod(a: bigint, b: bigint): bigint;
|
|
2
|
+
/**
|
|
3
|
+
* Efficiently raise num to power and do modular division.
|
|
4
|
+
* Unsafe in some contexts: uses ladder, so can expose bigint bits.
|
|
5
|
+
* @example
|
|
6
|
+
* pow(2n, 6n, 11n) // 64n % 11n == 9n
|
|
7
|
+
*/
|
|
8
|
+
export declare function pow(num: bigint, power: bigint, modulo: bigint): bigint;
|
|
9
|
+
/** Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)` */
|
|
10
|
+
export declare function pow2(x: bigint, power: bigint, modulo: bigint): bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Inverses number over modulo.
|
|
13
|
+
* Implemented using [Euclidean GCD](https://brilliant.org/wiki/extended-euclidean-algorithm/).
|
|
14
|
+
*/
|
|
15
|
+
export declare function invert(number: bigint, modulo: bigint): bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Tonelli-Shanks square root search algorithm.
|
|
18
|
+
* 1. https://eprint.iacr.org/2012/685.pdf (page 12)
|
|
19
|
+
* 2. Square Roots from 1; 24, 51, 10 to Dan Shanks
|
|
20
|
+
* @param P field order
|
|
21
|
+
* @returns function that takes field Fp (created from P) and number n
|
|
22
|
+
*/
|
|
23
|
+
export declare function tonelliShanks(P: bigint): <T>(Fp: IField<T>, n: T) => T;
|
|
24
|
+
/**
|
|
25
|
+
* Square root for a finite field. Will try optimized versions first:
|
|
26
|
+
*
|
|
27
|
+
* 1. P ≡ 3 (mod 4)
|
|
28
|
+
* 2. P ≡ 5 (mod 8)
|
|
29
|
+
* 3. P ≡ 9 (mod 16)
|
|
30
|
+
* 4. Tonelli-Shanks algorithm
|
|
31
|
+
*
|
|
32
|
+
* Different algorithms can give different roots, it is up to user to decide which one they want.
|
|
33
|
+
* For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve).
|
|
34
|
+
*/
|
|
35
|
+
export declare function FpSqrt(P: bigint): <T>(Fp: IField<T>, n: T) => T;
|
|
36
|
+
export declare const isNegativeLE: (num: bigint, modulo: bigint) => boolean;
|
|
37
|
+
/** Field is not always over prime: for example, Fp2 has ORDER(q)=p^m. */
|
|
38
|
+
export interface IField<T> {
|
|
39
|
+
ORDER: bigint;
|
|
40
|
+
BYTES: number;
|
|
41
|
+
BITS: number;
|
|
42
|
+
isLE: boolean;
|
|
43
|
+
ZERO: T;
|
|
44
|
+
ONE: T;
|
|
45
|
+
create: (num: T) => T;
|
|
46
|
+
isValid: (num: T) => boolean;
|
|
47
|
+
is0: (num: T) => boolean;
|
|
48
|
+
isValidNot0: (num: T) => boolean;
|
|
49
|
+
neg(num: T): T;
|
|
50
|
+
inv(num: T): T;
|
|
51
|
+
sqrt(num: T): T;
|
|
52
|
+
sqr(num: T): T;
|
|
53
|
+
eql(lhs: T, rhs: T): boolean;
|
|
54
|
+
add(lhs: T, rhs: T): T;
|
|
55
|
+
sub(lhs: T, rhs: T): T;
|
|
56
|
+
mul(lhs: T, rhs: T | bigint): T;
|
|
57
|
+
pow(lhs: T, power: bigint): T;
|
|
58
|
+
div(lhs: T, rhs: T | bigint): T;
|
|
59
|
+
addN(lhs: T, rhs: T): T;
|
|
60
|
+
subN(lhs: T, rhs: T): T;
|
|
61
|
+
mulN(lhs: T, rhs: T | bigint): T;
|
|
62
|
+
sqrN(num: T): T;
|
|
63
|
+
isOdd?(num: T): boolean;
|
|
64
|
+
invertBatch: (lst: T[]) => T[];
|
|
65
|
+
toBytes(num: T): Uint8Array;
|
|
66
|
+
fromBytes(bytes: Uint8Array, skipValidation?: boolean): T;
|
|
67
|
+
cmov(a: T, b: T, c: boolean): T;
|
|
68
|
+
}
|
|
69
|
+
export declare function validateField<T>(field: IField<T>): IField<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Same as `pow` but for Fp: non-constant-time.
|
|
72
|
+
* Unsafe in some contexts: uses ladder, so can expose bigint bits.
|
|
73
|
+
*/
|
|
74
|
+
export declare function FpPow<T>(Fp: IField<T>, num: T, power: bigint): T;
|
|
75
|
+
/**
|
|
76
|
+
* Efficiently invert an array of Field elements.
|
|
77
|
+
* Exception-free. Will return `undefined` for 0 elements.
|
|
78
|
+
* @param passZero map 0 to 0 (instead of undefined)
|
|
79
|
+
*/
|
|
80
|
+
export declare function FpInvertBatch<T>(Fp: IField<T>, nums: T[], passZero?: boolean): T[];
|
|
81
|
+
export declare function FpDiv<T>(Fp: IField<T>, lhs: T, rhs: T | bigint): T;
|
|
82
|
+
/**
|
|
83
|
+
* Legendre symbol.
|
|
84
|
+
* Legendre constant is used to calculate Legendre symbol (a | p)
|
|
85
|
+
* which denotes the value of a^((p-1)/2) (mod p).
|
|
86
|
+
*
|
|
87
|
+
* * (a | p) ≡ 1 if a is a square (mod p), quadratic residue
|
|
88
|
+
* * (a | p) ≡ -1 if a is not a square (mod p), quadratic non residue
|
|
89
|
+
* * (a | p) ≡ 0 if a ≡ 0 (mod p)
|
|
90
|
+
*/
|
|
91
|
+
export declare function FpLegendre<T>(Fp: IField<T>, n: T): -1 | 0 | 1;
|
|
92
|
+
export declare function FpIsSquare<T>(Fp: IField<T>, n: T): boolean;
|
|
93
|
+
export type NLength = {
|
|
94
|
+
nByteLength: number;
|
|
95
|
+
nBitLength: number;
|
|
96
|
+
};
|
|
97
|
+
export declare function nLength(n: bigint, nBitLength?: number): NLength;
|
|
98
|
+
type FpField = IField<bigint> & Required<Pick<IField<bigint>, 'isOdd'>>;
|
|
99
|
+
type SqrtFn = (n: bigint) => bigint;
|
|
100
|
+
type FieldOpts = Partial<{
|
|
101
|
+
isLE: boolean;
|
|
102
|
+
BITS: number;
|
|
103
|
+
sqrt: SqrtFn;
|
|
104
|
+
allowedLengths?: readonly number[];
|
|
105
|
+
modFromBytes: boolean;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Creates a finite field. Major performance optimizations:
|
|
109
|
+
* * 1. Denormalized operations like mulN instead of mul.
|
|
110
|
+
* * 2. Identical object shape: never add or remove keys.
|
|
111
|
+
* * 3. `Object.freeze`.
|
|
112
|
+
* Fragile: always run a benchmark on a change.
|
|
113
|
+
* Security note: operations don't check 'isValid' for all elements for performance reasons,
|
|
114
|
+
* it is caller responsibility to check this.
|
|
115
|
+
* This is low-level code, please make sure you know what you're doing.
|
|
116
|
+
*
|
|
117
|
+
* Note about field properties:
|
|
118
|
+
* * CHARACTERISTIC p = prime number, number of elements in main subgroup.
|
|
119
|
+
* * ORDER q = similar to cofactor in curves, may be composite `q = p^m`.
|
|
120
|
+
*
|
|
121
|
+
* @param ORDER field order, probably prime, or could be composite
|
|
122
|
+
* @param bitLen how many bits the field consumes
|
|
123
|
+
* @param isLE (default: false) if encoding / decoding should be in little-endian
|
|
124
|
+
* @param redef optional faster redefinitions of sqrt and other methods
|
|
125
|
+
*/
|
|
126
|
+
export declare function Field(ORDER: bigint, opts?: FieldOpts): Readonly<FpField>;
|
|
127
|
+
export declare function FpSqrtOdd<T>(Fp: IField<T>, elm: T): T;
|
|
128
|
+
export declare function FpSqrtEven<T>(Fp: IField<T>, elm: T): T;
|
|
129
|
+
/**
|
|
130
|
+
* Returns total number of bytes consumed by the field element.
|
|
131
|
+
* For example, 32 bytes for usual 256-bit weierstrass curve.
|
|
132
|
+
* @param fieldOrder number of field elements, usually CURVE.n
|
|
133
|
+
* @returns byte length of field
|
|
134
|
+
*/
|
|
135
|
+
export declare function getFieldBytesLength(fieldOrder: bigint): number;
|
|
136
|
+
/**
|
|
137
|
+
* Returns minimal amount of bytes that can be safely reduced
|
|
138
|
+
* by field order.
|
|
139
|
+
* Should be 2^-128 for 128-bit curve such as P256.
|
|
140
|
+
* @param fieldOrder number of field elements, usually CURVE.n
|
|
141
|
+
* @returns byte length of target hash
|
|
142
|
+
*/
|
|
143
|
+
export declare function getMinHashLength(fieldOrder: bigint): number;
|
|
144
|
+
/**
|
|
145
|
+
* "Constant-time" private key generation utility.
|
|
146
|
+
* Can take (n + n/2) or more bytes of uniform input e.g. from CSPRNG or KDF
|
|
147
|
+
* and convert them into private scalar, with the modulo bias being negligible.
|
|
148
|
+
* Needs at least 48 bytes of input for 32-byte private key.
|
|
149
|
+
* https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
|
|
150
|
+
* FIPS 186-5, A.2 https://csrc.nist.gov/publications/detail/fips/186/5/final
|
|
151
|
+
* RFC 9380, https://www.rfc-editor.org/rfc/rfc9380#section-5
|
|
152
|
+
* @param hash hash output from SHA3 or a similar function
|
|
153
|
+
* @param groupOrder size of subgroup - (e.g. secp256k1.Point.Fn.ORDER)
|
|
154
|
+
* @param isLE interpret hash bytes as LE num
|
|
155
|
+
* @returns valid private scalar
|
|
156
|
+
*/
|
|
157
|
+
export declare function mapHashToField(key: Uint8Array, fieldOrder: bigint, isLE?: boolean): Uint8Array;
|
|
158
|
+
export {};
|
|
159
|
+
//# sourceMappingURL=modular.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modular.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.ts"],"names":[],"mappings":"AA2BA,wBAAgB,GAAG,CAAC,C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