ccxt 4.2.18 → 4.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/ccxt.browser.js +34202 -33193
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +12 -1
- package/dist/cjs/src/alpaca.js +18 -18
- package/dist/cjs/src/ascendex.js +13 -6
- package/dist/cjs/src/base/Exchange.js +266 -27
- package/dist/cjs/src/bigone.js +434 -168
- package/dist/cjs/src/binance.js +163 -34
- package/dist/cjs/src/binanceus.js +8 -0
- package/dist/cjs/src/bingx.js +183 -41
- package/dist/cjs/src/bitfinex.js +2 -3
- package/dist/cjs/src/bitget.js +59 -16
- package/dist/cjs/src/bitmart.js +5 -5
- package/dist/cjs/src/bitmex.js +4 -6
- package/dist/cjs/src/bitpanda.js +5 -1991
- package/dist/cjs/src/bitstamp.js +8 -0
- package/dist/cjs/src/bybit.js +27 -47
- package/dist/cjs/src/coinbase.js +176 -26
- package/dist/cjs/src/coincheck.js +1 -0
- package/dist/cjs/src/coinex.js +3 -0
- package/dist/cjs/src/coinlist.js +13 -6
- package/dist/cjs/src/coinone.js +2 -2
- package/dist/cjs/src/coinsph.js +4 -5
- package/dist/cjs/src/delta.js +7 -1
- package/dist/cjs/src/deribit.js +17 -4
- package/dist/cjs/src/gate.js +151 -169
- package/dist/cjs/src/gemini.js +1 -1
- package/dist/cjs/src/hitbtc.js +2 -3
- package/dist/cjs/src/htx.js +157 -7
- package/dist/cjs/src/huobijp.js +2 -3
- package/dist/cjs/src/independentreserve.js +7 -5
- package/dist/cjs/src/kraken.js +86 -54
- package/dist/cjs/src/kucoin.js +5 -0
- package/dist/cjs/src/kucoinfutures.js +131 -77
- package/dist/cjs/src/lbank.js +60 -33
- package/dist/cjs/src/luno.js +84 -2
- package/dist/cjs/src/mexc.js +3 -3
- package/dist/cjs/src/oceanex.js +1 -1
- package/dist/cjs/src/okx.js +23 -11
- package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
- package/dist/cjs/src/phemex.js +37 -27
- package/dist/cjs/src/poloniexfutures.js +1 -0
- package/dist/cjs/src/pro/binance.js +66 -25
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitpanda.js +5 -1330
- package/dist/cjs/src/pro/coinbase.js +4 -1
- package/dist/cjs/src/pro/hitbtc.js +5 -4
- package/dist/cjs/src/pro/htx.js +6 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/krakenfutures.js +7 -1
- package/dist/cjs/src/pro/kucoin.js +46 -36
- package/dist/cjs/src/pro/kucoinfutures.js +45 -37
- package/dist/cjs/src/pro/lbank.js +881 -0
- package/dist/cjs/src/pro/okx.js +52 -2
- package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
- package/dist/cjs/src/pro/poloniex.js +2 -2
- package/dist/cjs/src/pro/poloniexfutures.js +43 -35
- package/dist/cjs/src/pro/woo.js +126 -0
- package/dist/cjs/src/probit.js +4 -2
- package/dist/cjs/src/upbit.js +12 -12
- package/dist/cjs/src/wavesexchange.js +1 -1
- package/dist/cjs/src/whitebit.js +1 -0
- package/dist/cjs/src/woo.js +56 -0
- package/js/ccxt.d.ts +11 -2
- package/js/ccxt.js +8 -2
- package/js/src/abstract/bitpanda.d.ts +4 -4
- package/js/src/abstract/bitstamp.d.ts +8 -0
- package/js/src/abstract/gate.d.ts +1 -0
- package/js/src/abstract/gateio.d.ts +1 -0
- package/js/src/abstract/htx.d.ts +3 -0
- package/js/src/abstract/huobi.d.ts +3 -0
- package/js/src/abstract/luno.d.ts +1 -0
- package/js/src/abstract/onetrading.d.ts +38 -0
- package/js/src/ascendex.js +2 -0
- package/js/src/bingx.js +1 -1
- package/js/src/bitget.js +22 -3
- package/js/src/bitpanda.d.ts +2 -72
- package/js/src/bitpanda.js +5 -1991
- package/js/src/bitstamp.js +8 -0
- package/js/src/deribit.js +11 -3
- package/js/src/gate.d.ts +1 -0
- package/js/src/gate.js +50 -110
- package/js/src/htx.js +3 -0
- package/js/src/kraken.d.ts +1 -0
- package/js/src/kraken.js +39 -38
- package/js/src/lbank.js +1 -0
- package/js/src/luno.d.ts +3 -1
- package/js/src/luno.js +84 -2
- package/js/src/mexc.js +1 -2
- package/js/src/onetrading.d.ts +74 -0
- package/js/src/onetrading.js +2003 -0
- package/js/src/poloniexfutures.js +1 -0
- package/js/src/pro/binance.js +6 -1
- package/js/src/pro/bitpanda.d.ts +2 -34
- package/js/src/pro/bitpanda.js +5 -1330
- package/js/src/pro/lbank.d.ts +29 -0
- package/js/src/pro/lbank.js +882 -0
- package/js/src/pro/onetrading.d.ts +36 -0
- package/js/src/pro/onetrading.js +1339 -0
- package/package.json +2 -2
- package/rollup.config.js +2 -0
- package/skip-tests.json +2 -1
- package/test-commonjs.cjs +25 -1
- package/dist/cjs/js/ccxt.js +0 -478
- package/dist/cjs/js/src/abstract/alpaca.js +0 -9
- package/dist/cjs/js/src/abstract/ascendex.js +0 -9
- package/dist/cjs/js/src/abstract/bigone.js +0 -9
- package/dist/cjs/js/src/abstract/binance.js +0 -9
- package/dist/cjs/js/src/abstract/bingx.js +0 -9
- package/dist/cjs/js/src/abstract/bit2c.js +0 -9
- package/dist/cjs/js/src/abstract/bitbank.js +0 -9
- package/dist/cjs/js/src/abstract/bitbns.js +0 -9
- package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
- package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
- package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
- package/dist/cjs/js/src/abstract/bitforex.js +0 -9
- package/dist/cjs/js/src/abstract/bitget.js +0 -9
- package/dist/cjs/js/src/abstract/bithumb.js +0 -9
- package/dist/cjs/js/src/abstract/bitmart.js +0 -9
- package/dist/cjs/js/src/abstract/bitmex.js +0 -9
- package/dist/cjs/js/src/abstract/bitopro.js +0 -9
- package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
- package/dist/cjs/js/src/abstract/bitrue.js +0 -9
- package/dist/cjs/js/src/abstract/bitso.js +0 -9
- package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
- package/dist/cjs/js/src/abstract/bitteam.js +0 -9
- package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
- package/dist/cjs/js/src/abstract/bl3p.js +0 -9
- package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
- package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
- package/dist/cjs/js/src/abstract/btcbox.js +0 -9
- package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
- package/dist/cjs/js/src/abstract/btcturk.js +0 -9
- package/dist/cjs/js/src/abstract/bybit.js +0 -9
- package/dist/cjs/js/src/abstract/cex.js +0 -9
- package/dist/cjs/js/src/abstract/coinbase.js +0 -9
- package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
- package/dist/cjs/js/src/abstract/coincheck.js +0 -9
- package/dist/cjs/js/src/abstract/coinex.js +0 -9
- package/dist/cjs/js/src/abstract/coinlist.js +0 -9
- package/dist/cjs/js/src/abstract/coinmate.js +0 -9
- package/dist/cjs/js/src/abstract/coinone.js +0 -9
- package/dist/cjs/js/src/abstract/coinsph.js +0 -9
- package/dist/cjs/js/src/abstract/coinspot.js +0 -9
- package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
- package/dist/cjs/js/src/abstract/currencycom.js +0 -9
- package/dist/cjs/js/src/abstract/delta.js +0 -9
- package/dist/cjs/js/src/abstract/deribit.js +0 -9
- package/dist/cjs/js/src/abstract/digifinex.js +0 -9
- package/dist/cjs/js/src/abstract/exmo.js +0 -9
- package/dist/cjs/js/src/abstract/gate.js +0 -9
- package/dist/cjs/js/src/abstract/gemini.js +0 -9
- package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
- package/dist/cjs/js/src/abstract/hollaex.js +0 -9
- package/dist/cjs/js/src/abstract/htx.js +0 -9
- package/dist/cjs/js/src/abstract/huobijp.js +0 -9
- package/dist/cjs/js/src/abstract/idex.js +0 -9
- package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
- package/dist/cjs/js/src/abstract/indodax.js +0 -9
- package/dist/cjs/js/src/abstract/kraken.js +0 -9
- package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
- package/dist/cjs/js/src/abstract/kucoin.js +0 -9
- package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
- package/dist/cjs/js/src/abstract/kuna.js +0 -9
- package/dist/cjs/js/src/abstract/latoken.js +0 -9
- package/dist/cjs/js/src/abstract/lbank.js +0 -9
- package/dist/cjs/js/src/abstract/luno.js +0 -9
- package/dist/cjs/js/src/abstract/lykke.js +0 -9
- package/dist/cjs/js/src/abstract/mercado.js +0 -9
- package/dist/cjs/js/src/abstract/mexc.js +0 -9
- package/dist/cjs/js/src/abstract/ndax.js +0 -9
- package/dist/cjs/js/src/abstract/novadax.js +0 -9
- package/dist/cjs/js/src/abstract/oceanex.js +0 -9
- package/dist/cjs/js/src/abstract/okcoin.js +0 -9
- package/dist/cjs/js/src/abstract/okx.js +0 -9
- package/dist/cjs/js/src/abstract/p2b.js +0 -9
- package/dist/cjs/js/src/abstract/paymium.js +0 -9
- package/dist/cjs/js/src/abstract/phemex.js +0 -9
- package/dist/cjs/js/src/abstract/poloniex.js +0 -9
- package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
- package/dist/cjs/js/src/abstract/probit.js +0 -9
- package/dist/cjs/js/src/abstract/timex.js +0 -9
- package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
- package/dist/cjs/js/src/abstract/upbit.js +0 -9
- package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
- package/dist/cjs/js/src/abstract/wazirx.js +0 -9
- package/dist/cjs/js/src/abstract/whitebit.js +0 -9
- package/dist/cjs/js/src/abstract/woo.js +0 -9
- package/dist/cjs/js/src/abstract/yobit.js +0 -9
- package/dist/cjs/js/src/abstract/zaif.js +0 -9
- package/dist/cjs/js/src/abstract/zonda.js +0 -9
- package/dist/cjs/js/src/ace.js +0 -1058
- package/dist/cjs/js/src/alpaca.js +0 -1125
- package/dist/cjs/js/src/ascendex.js +0 -3365
- package/dist/cjs/js/src/base/Exchange.js +0 -5260
- package/dist/cjs/js/src/base/Precise.js +0 -263
- package/dist/cjs/js/src/base/errors.js +0 -299
- package/dist/cjs/js/src/base/functions/crypto.js +0 -78
- package/dist/cjs/js/src/base/functions/encode.js +0 -44
- package/dist/cjs/js/src/base/functions/generic.js +0 -193
- package/dist/cjs/js/src/base/functions/misc.js +0 -96
- package/dist/cjs/js/src/base/functions/number.js +0 -297
- package/dist/cjs/js/src/base/functions/platform.js +0 -28
- package/dist/cjs/js/src/base/functions/rsa.js +0 -34
- package/dist/cjs/js/src/base/functions/string.js +0 -48
- package/dist/cjs/js/src/base/functions/throttle.js +0 -66
- package/dist/cjs/js/src/base/functions/time.js +0 -187
- package/dist/cjs/js/src/base/functions/totp.js +0 -24
- package/dist/cjs/js/src/base/functions/type.js +0 -162
- package/dist/cjs/js/src/base/functions.js +0 -157
- package/dist/cjs/js/src/base/ws/Cache.js +0 -254
- package/dist/cjs/js/src/base/ws/Client.js +0 -299
- package/dist/cjs/js/src/base/ws/Future.js +0 -34
- package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
- package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
- package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
- package/dist/cjs/js/src/bequant.js +0 -33
- package/dist/cjs/js/src/bigone.js +0 -2213
- package/dist/cjs/js/src/binance.js +0 -9851
- package/dist/cjs/js/src/binancecoinm.js +0 -45
- package/dist/cjs/js/src/binanceus.js +0 -92
- package/dist/cjs/js/src/binanceusdm.js +0 -58
- package/dist/cjs/js/src/bingx.js +0 -3872
- package/dist/cjs/js/src/bit2c.js +0 -916
- package/dist/cjs/js/src/bitbank.js +0 -1000
- package/dist/cjs/js/src/bitbay.js +0 -17
- package/dist/cjs/js/src/bitbns.js +0 -1220
- package/dist/cjs/js/src/bitcoincom.js +0 -17
- package/dist/cjs/js/src/bitfinex.js +0 -1670
- package/dist/cjs/js/src/bitfinex2.js +0 -2990
- package/dist/cjs/js/src/bitflyer.js +0 -1045
- package/dist/cjs/js/src/bitforex.js +0 -852
- package/dist/cjs/js/src/bitget.js +0 -8295
- package/dist/cjs/js/src/bithumb.js +0 -1090
- package/dist/cjs/js/src/bitmart.js +0 -4454
- package/dist/cjs/js/src/bitmex.js +0 -2881
- package/dist/cjs/js/src/bitopro.js +0 -1724
- package/dist/cjs/js/src/bitrue.js +0 -3253
- package/dist/cjs/js/src/bitso.js +0 -1753
- package/dist/cjs/js/src/bitstamp.js +0 -2188
- package/dist/cjs/js/src/bitteam.js +0 -2309
- package/dist/cjs/js/src/bitvavo.js +0 -1968
- package/dist/cjs/js/src/bl3p.js +0 -447
- package/dist/cjs/js/src/blockchaincom.js +0 -1160
- package/dist/cjs/js/src/btcalpha.js +0 -929
- package/dist/cjs/js/src/btcbox.js +0 -565
- package/dist/cjs/js/src/btcmarkets.js +0 -1237
- package/dist/cjs/js/src/btcturk.js +0 -929
- package/dist/cjs/js/src/bybit.js +0 -7624
- package/dist/cjs/js/src/cex.js +0 -1693
- package/dist/cjs/js/src/coinbase.js +0 -3424
- package/dist/cjs/js/src/coinbasepro.js +0 -1866
- package/dist/cjs/js/src/coincheck.js +0 -844
- package/dist/cjs/js/src/coinex.js +0 -5417
- package/dist/cjs/js/src/coinlist.js +0 -2337
- package/dist/cjs/js/src/coinmate.js +0 -989
- package/dist/cjs/js/src/coinone.js +0 -1185
- package/dist/cjs/js/src/coinsph.js +0 -1933
- package/dist/cjs/js/src/coinspot.js +0 -548
- package/dist/cjs/js/src/cryptocom.js +0 -3007
- package/dist/cjs/js/src/currencycom.js +0 -2015
- package/dist/cjs/js/src/delta.js +0 -3262
- package/dist/cjs/js/src/deribit.js +0 -3310
- package/dist/cjs/js/src/digifinex.js +0 -4307
- package/dist/cjs/js/src/exmo.js +0 -2645
- package/dist/cjs/js/src/fmfwio.js +0 -34
- package/dist/cjs/js/src/gate.js +0 -7077
- package/dist/cjs/js/src/gateio.js +0 -16
- package/dist/cjs/js/src/gemini.js +0 -1801
- package/dist/cjs/js/src/hitbtc.js +0 -3660
- package/dist/cjs/js/src/hitbtc3.js +0 -19
- package/dist/cjs/js/src/hollaex.js +0 -1882
- package/dist/cjs/js/src/htx.js +0 -9174
- package/dist/cjs/js/src/huobi.js +0 -16
- package/dist/cjs/js/src/huobijp.js +0 -1918
- package/dist/cjs/js/src/idex.js +0 -1770
- package/dist/cjs/js/src/independentreserve.js +0 -761
- package/dist/cjs/js/src/indodax.js +0 -1069
- package/dist/cjs/js/src/kraken.js +0 -2891
- package/dist/cjs/js/src/krakenfutures.js +0 -2407
- package/dist/cjs/js/src/kucoin.js +0 -4494
- package/dist/cjs/js/src/kucoinfutures.js +0 -2529
- package/dist/cjs/js/src/kuna.js +0 -1949
- package/dist/cjs/js/src/latoken.js +0 -1729
- package/dist/cjs/js/src/lbank.js +0 -2851
- package/dist/cjs/js/src/luno.js +0 -1044
- package/dist/cjs/js/src/lykke.js +0 -1303
- package/dist/cjs/js/src/mercado.js +0 -897
- package/dist/cjs/js/src/mexc.js +0 -5407
- package/dist/cjs/js/src/ndax.js +0 -2450
- package/dist/cjs/js/src/novadax.js +0 -1556
- package/dist/cjs/js/src/oceanex.js +0 -964
- package/dist/cjs/js/src/okcoin.js +0 -3115
- package/dist/cjs/js/src/okx.js +0 -7331
- package/dist/cjs/js/src/p2b.js +0 -1243
- package/dist/cjs/js/src/paymium.js +0 -597
- package/dist/cjs/js/src/phemex.js +0 -4725
- package/dist/cjs/js/src/poloniex.js +0 -2356
- package/dist/cjs/js/src/poloniexfutures.js +0 -1794
- package/dist/cjs/js/src/pro/alpaca.js +0 -714
- package/dist/cjs/js/src/pro/ascendex.js +0 -957
- package/dist/cjs/js/src/pro/bequant.js +0 -33
- package/dist/cjs/js/src/pro/binance.js +0 -2796
- package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
- package/dist/cjs/js/src/pro/binanceus.js +0 -51
- package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
- package/dist/cjs/js/src/pro/bingx.js +0 -944
- package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
- package/dist/cjs/js/src/pro/bitfinex.js +0 -672
- package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
- package/dist/cjs/js/src/pro/bitget.js +0 -1733
- package/dist/cjs/js/src/pro/bitmart.js +0 -1486
- package/dist/cjs/js/src/pro/bitmex.js +0 -1576
- package/dist/cjs/js/src/pro/bitopro.js +0 -327
- package/dist/cjs/js/src/pro/bitrue.js +0 -462
- package/dist/cjs/js/src/pro/bitstamp.js +0 -547
- package/dist/cjs/js/src/pro/bitvavo.js +0 -704
- package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
- package/dist/cjs/js/src/pro/bybit.js +0 -1843
- package/dist/cjs/js/src/pro/cex.js +0 -1510
- package/dist/cjs/js/src/pro/coinbase.js +0 -561
- package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
- package/dist/cjs/js/src/pro/coinex.js +0 -1095
- package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
- package/dist/cjs/js/src/pro/currencycom.js +0 -563
- package/dist/cjs/js/src/pro/deribit.js +0 -825
- package/dist/cjs/js/src/pro/exmo.js +0 -658
- package/dist/cjs/js/src/pro/gate.js +0 -1316
- package/dist/cjs/js/src/pro/gateio.js +0 -16
- package/dist/cjs/js/src/pro/gemini.js +0 -649
- package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
- package/dist/cjs/js/src/pro/hollaex.js +0 -597
- package/dist/cjs/js/src/pro/htx.js +0 -2388
- package/dist/cjs/js/src/pro/huobi.js +0 -16
- package/dist/cjs/js/src/pro/huobijp.js +0 -606
- package/dist/cjs/js/src/pro/idex.js +0 -714
- package/dist/cjs/js/src/pro/independentreserve.js +0 -280
- package/dist/cjs/js/src/pro/kraken.js +0 -1364
- package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
- package/dist/cjs/js/src/pro/kucoin.js +0 -1062
- package/dist/cjs/js/src/pro/kucoinfutures.js +0 -989
- package/dist/cjs/js/src/pro/luno.js +0 -322
- package/dist/cjs/js/src/pro/mexc.js +0 -1170
- package/dist/cjs/js/src/pro/ndax.js +0 -545
- package/dist/cjs/js/src/pro/okcoin.js +0 -760
- package/dist/cjs/js/src/pro/okx.js +0 -1608
- package/dist/cjs/js/src/pro/phemex.js +0 -1511
- package/dist/cjs/js/src/pro/poloniex.js +0 -1253
- package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1022
- package/dist/cjs/js/src/pro/probit.js +0 -586
- package/dist/cjs/js/src/pro/upbit.js +0 -234
- package/dist/cjs/js/src/pro/wazirx.js +0 -776
- package/dist/cjs/js/src/pro/whitebit.js +0 -927
- package/dist/cjs/js/src/pro/woo.js +0 -895
- package/dist/cjs/js/src/probit.js +0 -1867
- package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
- package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
- package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
- package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
- package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
- package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
- package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
- package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
- package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
- package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
- package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
- package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
- package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
- package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
- package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
- package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
- package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
- package/dist/cjs/js/src/timex.js +0 -1562
- package/dist/cjs/js/src/tokocrypto.js +0 -2542
- package/dist/cjs/js/src/upbit.js +0 -1844
- package/dist/cjs/js/src/wavesexchange.js +0 -2607
- package/dist/cjs/js/src/wazirx.js +0 -953
- package/dist/cjs/js/src/whitebit.js +0 -2310
- package/dist/cjs/js/src/woo.js +0 -2769
- package/dist/cjs/js/src/yobit.js +0 -1314
- package/dist/cjs/js/src/zaif.js +0 -736
- package/dist/cjs/js/src/zonda.js +0 -1883
- package/dist/cjs/src/abstract/bitpanda.js +0 -9
- package/test.ts +0 -0
- /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
- /package/dist/cjs/{js/src → src}/pro/coincheck.js +0 -0
- /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
- /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
/*!
|
|
6
|
-
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
|
|
7
|
-
Code licensed under the BSD License:
|
|
8
|
-
http://developer.yahoo.com/yui/license.html
|
|
9
|
-
version: 2.9.0
|
|
10
|
-
*/
|
|
11
|
-
var YAHOO = {};
|
|
12
|
-
YAHOO.lang = {
|
|
13
|
-
/**
|
|
14
|
-
* Utility to set up the prototype, constructor and superclass properties to
|
|
15
|
-
* support an inheritance strategy that can chain constructors and methods.
|
|
16
|
-
* Static members will not be inherited.
|
|
17
|
-
*
|
|
18
|
-
* @method extend
|
|
19
|
-
* @static
|
|
20
|
-
* @param {Function} subc the object to modify
|
|
21
|
-
* @param {Function} superc the object to inherit
|
|
22
|
-
* @param {Object} overrides additional properties/methods to add to the
|
|
23
|
-
* subclass prototype. These will override the
|
|
24
|
-
* matching items obtained from the superclass
|
|
25
|
-
* if present.
|
|
26
|
-
*/
|
|
27
|
-
extend: function (subc, superc, overrides) {
|
|
28
|
-
if (!superc || !subc) {
|
|
29
|
-
throw new Error("YAHOO.lang.extend failed, please check that " +
|
|
30
|
-
"all dependencies are included.");
|
|
31
|
-
}
|
|
32
|
-
var F = function () { };
|
|
33
|
-
F.prototype = superc.prototype;
|
|
34
|
-
subc.prototype = new F();
|
|
35
|
-
subc.prototype.constructor = subc;
|
|
36
|
-
subc.superclass = superc.prototype;
|
|
37
|
-
if (superc.prototype.constructor == Object.prototype.constructor) {
|
|
38
|
-
superc.prototype.constructor = superc;
|
|
39
|
-
}
|
|
40
|
-
if (overrides) {
|
|
41
|
-
var i;
|
|
42
|
-
for (i in overrides) {
|
|
43
|
-
subc.prototype[i] = overrides[i];
|
|
44
|
-
}
|
|
45
|
-
/*
|
|
46
|
-
* IE will not enumerate native functions in a derived object even if the
|
|
47
|
-
* function was overridden. This is a workaround for specific functions
|
|
48
|
-
* we care about on the Object prototype.
|
|
49
|
-
* @property _IEEnumFix
|
|
50
|
-
* @param {Function} r the object to receive the augmentation
|
|
51
|
-
* @param {Function} s the object that supplies the properties to augment
|
|
52
|
-
* @static
|
|
53
|
-
* @private
|
|
54
|
-
*/
|
|
55
|
-
var _IEEnumFix = function () { }, ADD = ["toString", "valueOf"];
|
|
56
|
-
try {
|
|
57
|
-
if (/MSIE/.test(navigator.userAgent)) {
|
|
58
|
-
_IEEnumFix = function (r, s) {
|
|
59
|
-
for (i = 0; i < ADD.length; i = i + 1) {
|
|
60
|
-
var fname = ADD[i], f = s[fname];
|
|
61
|
-
if (typeof f === 'function' && f != Object.prototype[fname]) {
|
|
62
|
-
r[fname] = f;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
catch (ex) { }
|
|
69
|
-
_IEEnumFix(subc.prototype, overrides);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
exports.YAHOO = YAHOO;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var hmac = require('../noble-hashes/hmac.js');
|
|
6
|
-
var utils = require('../noble-hashes/utils.js');
|
|
7
|
-
var weierstrass = require('./abstract/weierstrass.js');
|
|
8
|
-
|
|
9
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
10
|
-
// connects noble-curves to noble-hashes
|
|
11
|
-
function getHash(hash) {
|
|
12
|
-
return {
|
|
13
|
-
hash,
|
|
14
|
-
hmac: (key, ...msgs) => hmac.hmac(hash, key, utils.concatBytes(...msgs)),
|
|
15
|
-
randomBytes: utils.randomBytes,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function createCurve(curveDef, defHash) {
|
|
19
|
-
const create = (hash) => weierstrass.weierstrass({ ...curveDef, ...getHash(hash) });
|
|
20
|
-
return Object.freeze({ ...create(defHash), create });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.createCurve = createCurve;
|
|
24
|
-
exports.getHash = getHash;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var modular = require('./modular.js');
|
|
6
|
-
var utils = require('./utils.js');
|
|
7
|
-
|
|
8
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
9
|
-
const _0n = BigInt(0);
|
|
10
|
-
const _1n = BigInt(1);
|
|
11
|
-
// Elliptic curve multiplication of Point by scalar. Fragile.
|
|
12
|
-
// Scalars should always be less than curve order: this should be checked inside of a curve itself.
|
|
13
|
-
// Creates precomputation tables for fast multiplication:
|
|
14
|
-
// - private scalar is split by fixed size windows of W bits
|
|
15
|
-
// - every window point is collected from window's table & added to accumulator
|
|
16
|
-
// - since windows are different, same point inside tables won't be accessed more than once per calc
|
|
17
|
-
// - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar)
|
|
18
|
-
// - +1 window is neccessary for wNAF
|
|
19
|
-
// - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication
|
|
20
|
-
// TODO: Research returning 2d JS array of windows, instead of a single window. This would allow
|
|
21
|
-
// windows to be in different memory locations
|
|
22
|
-
function wNAF(c, bits) {
|
|
23
|
-
const constTimeNegate = (condition, item) => {
|
|
24
|
-
const neg = item.negate();
|
|
25
|
-
return condition ? neg : item;
|
|
26
|
-
};
|
|
27
|
-
const opts = (W) => {
|
|
28
|
-
const windows = Math.ceil(bits / W) + 1; // +1, because
|
|
29
|
-
const windowSize = 2 ** (W - 1); // -1 because we skip zero
|
|
30
|
-
return { windows, windowSize };
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
constTimeNegate,
|
|
34
|
-
// non-const time multiplication ladder
|
|
35
|
-
unsafeLadder(elm, n) {
|
|
36
|
-
let p = c.ZERO;
|
|
37
|
-
let d = elm;
|
|
38
|
-
while (n > _0n) {
|
|
39
|
-
if (n & _1n)
|
|
40
|
-
p = p.add(d);
|
|
41
|
-
d = d.double();
|
|
42
|
-
n >>= _1n;
|
|
43
|
-
}
|
|
44
|
-
return p;
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Creates a wNAF precomputation window. Used for caching.
|
|
48
|
-
* Default window size is set by `utils.precompute()` and is equal to 8.
|
|
49
|
-
* Number of precomputed points depends on the curve size:
|
|
50
|
-
* 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
|
|
51
|
-
* - 𝑊 is the window size
|
|
52
|
-
* - 𝑛 is the bitlength of the curve order.
|
|
53
|
-
* For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
|
|
54
|
-
* @returns precomputed point tables flattened to a single array
|
|
55
|
-
*/
|
|
56
|
-
precomputeWindow(elm, W) {
|
|
57
|
-
const { windows, windowSize } = opts(W);
|
|
58
|
-
const points = [];
|
|
59
|
-
let p = elm;
|
|
60
|
-
let base = p;
|
|
61
|
-
for (let window = 0; window < windows; window++) {
|
|
62
|
-
base = p;
|
|
63
|
-
points.push(base);
|
|
64
|
-
// =1, because we skip zero
|
|
65
|
-
for (let i = 1; i < windowSize; i++) {
|
|
66
|
-
base = base.add(p);
|
|
67
|
-
points.push(base);
|
|
68
|
-
}
|
|
69
|
-
p = base.double();
|
|
70
|
-
}
|
|
71
|
-
return points;
|
|
72
|
-
},
|
|
73
|
-
/**
|
|
74
|
-
* Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
|
|
75
|
-
* @param W window size
|
|
76
|
-
* @param precomputes precomputed tables
|
|
77
|
-
* @param n scalar (we don't check here, but should be less than curve order)
|
|
78
|
-
* @returns real and fake (for const-time) points
|
|
79
|
-
*/
|
|
80
|
-
wNAF(W, precomputes, n) {
|
|
81
|
-
// TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise
|
|
82
|
-
// But need to carefully remove other checks before wNAF. ORDER == bits here
|
|
83
|
-
const { windows, windowSize } = opts(W);
|
|
84
|
-
let p = c.ZERO;
|
|
85
|
-
let f = c.BASE;
|
|
86
|
-
const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc.
|
|
87
|
-
const maxNumber = 2 ** W;
|
|
88
|
-
const shiftBy = BigInt(W);
|
|
89
|
-
for (let window = 0; window < windows; window++) {
|
|
90
|
-
const offset = window * windowSize;
|
|
91
|
-
// Extract W bits.
|
|
92
|
-
let wbits = Number(n & mask);
|
|
93
|
-
// Shift number by W bits.
|
|
94
|
-
n >>= shiftBy;
|
|
95
|
-
// If the bits are bigger than max size, we'll split those.
|
|
96
|
-
// +224 => 256 - 32
|
|
97
|
-
if (wbits > windowSize) {
|
|
98
|
-
wbits -= maxNumber;
|
|
99
|
-
n += _1n;
|
|
100
|
-
}
|
|
101
|
-
// This code was first written with assumption that 'f' and 'p' will never be infinity point:
|
|
102
|
-
// since each addition is multiplied by 2 ** W, it cannot cancel each other. However,
|
|
103
|
-
// there is negate now: it is possible that negated element from low value
|
|
104
|
-
// would be the same as high element, which will create carry into next window.
|
|
105
|
-
// It's not obvious how this can fail, but still worth investigating later.
|
|
106
|
-
// Check if we're onto Zero point.
|
|
107
|
-
// Add random point inside current window to f.
|
|
108
|
-
const offset1 = offset;
|
|
109
|
-
const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero
|
|
110
|
-
const cond1 = window % 2 !== 0;
|
|
111
|
-
const cond2 = wbits < 0;
|
|
112
|
-
if (wbits === 0) {
|
|
113
|
-
// The most important part for const-time getPublicKey
|
|
114
|
-
f = f.add(constTimeNegate(cond1, precomputes[offset1]));
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
p = p.add(constTimeNegate(cond2, precomputes[offset2]));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
// JIT-compiler should not eliminate f here, since it will later be used in normalizeZ()
|
|
121
|
-
// Even if the variable is still unused, there are some checks which will
|
|
122
|
-
// throw an exception, so compiler needs to prove they won't happen, which is hard.
|
|
123
|
-
// At this point there is a way to F be infinity-point even if p is not,
|
|
124
|
-
// which makes it less const-time: around 1 bigint multiply.
|
|
125
|
-
return { p, f };
|
|
126
|
-
},
|
|
127
|
-
wNAFCached(P, precomputesMap, n, transform) {
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
const W = P._WINDOW_SIZE || 1;
|
|
130
|
-
// Calculate precomputes on a first run, reuse them after
|
|
131
|
-
let comp = precomputesMap.get(P);
|
|
132
|
-
if (!comp) {
|
|
133
|
-
comp = this.precomputeWindow(P, W);
|
|
134
|
-
if (W !== 1) {
|
|
135
|
-
precomputesMap.set(P, transform(comp));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return this.wNAF(W, comp, n);
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function validateBasic(curve) {
|
|
143
|
-
modular.validateField(curve.Fp);
|
|
144
|
-
utils.validateObject(curve, {
|
|
145
|
-
n: 'bigint',
|
|
146
|
-
h: 'bigint',
|
|
147
|
-
Gx: 'field',
|
|
148
|
-
Gy: 'field',
|
|
149
|
-
}, {
|
|
150
|
-
nBitLength: 'isSafeInteger',
|
|
151
|
-
nByteLength: 'isSafeInteger',
|
|
152
|
-
});
|
|
153
|
-
// Set defaults
|
|
154
|
-
return Object.freeze({ ...modular.nLength(curve.n, curve.nBitLength), ...curve });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
exports.validateBasic = validateBasic;
|
|
158
|
-
exports.wNAF = wNAF;
|
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var modular = require('./modular.js');
|
|
6
|
-
var utils = require('./utils.js');
|
|
7
|
-
var curve = require('./curve.js');
|
|
8
|
-
|
|
9
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
10
|
-
// Be friendly to bad ECMAScript parsers by not using bigint literals like 123n
|
|
11
|
-
const _0n = BigInt(0);
|
|
12
|
-
const _1n = BigInt(1);
|
|
13
|
-
const _2n = BigInt(2);
|
|
14
|
-
const _8n = BigInt(8);
|
|
15
|
-
function validateOpts(curve$1) {
|
|
16
|
-
const opts = curve.validateBasic(curve$1);
|
|
17
|
-
utils.validateObject(curve$1, {
|
|
18
|
-
hash: 'function',
|
|
19
|
-
a: 'bigint',
|
|
20
|
-
d: 'bigint',
|
|
21
|
-
randomBytes: 'function',
|
|
22
|
-
}, {
|
|
23
|
-
adjustScalarBytes: 'function',
|
|
24
|
-
domain: 'function',
|
|
25
|
-
uvRatio: 'function',
|
|
26
|
-
mapToCurve: 'function',
|
|
27
|
-
});
|
|
28
|
-
// Set defaults
|
|
29
|
-
return Object.freeze({ ...opts });
|
|
30
|
-
}
|
|
31
|
-
// It is not generic twisted curve for now, but ed25519/ed448 generic implementation
|
|
32
|
-
function twistedEdwards(curveDef) {
|
|
33
|
-
const CURVE = validateOpts(curveDef);
|
|
34
|
-
const { Fp, n: CURVE_ORDER, preHash, hash: cHash, randomBytes, nByteLength, h: cofactor } = CURVE;
|
|
35
|
-
const MASK = _2n ** BigInt(nByteLength * 8);
|
|
36
|
-
const modP = Fp.create; // Function overrides
|
|
37
|
-
// sqrt(u/v)
|
|
38
|
-
const uvRatio = CURVE.uvRatio ||
|
|
39
|
-
((u, v) => {
|
|
40
|
-
try {
|
|
41
|
-
return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) };
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
return { isValid: false, value: _0n };
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes); // NOOP
|
|
48
|
-
const domain = CURVE.domain ||
|
|
49
|
-
((data, ctx, phflag) => {
|
|
50
|
-
if (ctx.length || phflag)
|
|
51
|
-
throw new Error('Contexts/pre-hash are not supported');
|
|
52
|
-
return data;
|
|
53
|
-
}); // NOOP
|
|
54
|
-
const inBig = (n) => typeof n === 'bigint' && 0n < n; // n in [1..]
|
|
55
|
-
const inRange = (n, max) => inBig(n) && inBig(max) && n < max; // n in [1..max-1]
|
|
56
|
-
const in0MaskRange = (n) => n === _0n || inRange(n, MASK); // n in [0..MASK-1]
|
|
57
|
-
function assertInRange(n, max) {
|
|
58
|
-
// n in [1..max-1]
|
|
59
|
-
if (inRange(n, max))
|
|
60
|
-
return n;
|
|
61
|
-
throw new Error(`Expected valid scalar < ${max}, got ${typeof n} ${n}`);
|
|
62
|
-
}
|
|
63
|
-
function assertGE0(n) {
|
|
64
|
-
// n in [0..CURVE_ORDER-1]
|
|
65
|
-
return n === _0n ? n : assertInRange(n, CURVE_ORDER); // GE = prime subgroup, not full group
|
|
66
|
-
}
|
|
67
|
-
const pointPrecomputes = new Map();
|
|
68
|
-
function isPoint(other) {
|
|
69
|
-
if (!(other instanceof Point))
|
|
70
|
-
throw new Error('ExtendedPoint expected');
|
|
71
|
-
}
|
|
72
|
-
// Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy).
|
|
73
|
-
// https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates
|
|
74
|
-
class Point {
|
|
75
|
-
constructor(ex, ey, ez, et) {
|
|
76
|
-
this.ex = ex;
|
|
77
|
-
this.ey = ey;
|
|
78
|
-
this.ez = ez;
|
|
79
|
-
this.et = et;
|
|
80
|
-
if (!in0MaskRange(ex))
|
|
81
|
-
throw new Error('x required');
|
|
82
|
-
if (!in0MaskRange(ey))
|
|
83
|
-
throw new Error('y required');
|
|
84
|
-
if (!in0MaskRange(ez))
|
|
85
|
-
throw new Error('z required');
|
|
86
|
-
if (!in0MaskRange(et))
|
|
87
|
-
throw new Error('t required');
|
|
88
|
-
}
|
|
89
|
-
get x() {
|
|
90
|
-
return this.toAffine().x;
|
|
91
|
-
}
|
|
92
|
-
get y() {
|
|
93
|
-
return this.toAffine().y;
|
|
94
|
-
}
|
|
95
|
-
static fromAffine(p) {
|
|
96
|
-
if (p instanceof Point)
|
|
97
|
-
throw new Error('extended point not allowed');
|
|
98
|
-
const { x, y } = p || {};
|
|
99
|
-
if (!in0MaskRange(x) || !in0MaskRange(y))
|
|
100
|
-
throw new Error('invalid affine point');
|
|
101
|
-
return new Point(x, y, _1n, modP(x * y));
|
|
102
|
-
}
|
|
103
|
-
static normalizeZ(points) {
|
|
104
|
-
const toInv = Fp.invertBatch(points.map((p) => p.ez));
|
|
105
|
-
return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);
|
|
106
|
-
}
|
|
107
|
-
// "Private method", don't use it directly
|
|
108
|
-
_setWindowSize(windowSize) {
|
|
109
|
-
this._WINDOW_SIZE = windowSize;
|
|
110
|
-
pointPrecomputes.delete(this);
|
|
111
|
-
}
|
|
112
|
-
// Not required for fromHex(), which always creates valid points.
|
|
113
|
-
// Could be useful for fromAffine().
|
|
114
|
-
assertValidity() {
|
|
115
|
-
const { a, d } = CURVE;
|
|
116
|
-
if (this.is0())
|
|
117
|
-
throw new Error('bad point: ZERO'); // TODO: optimize, with vars below?
|
|
118
|
-
// Equation in affine coordinates: ax² + y² = 1 + dx²y²
|
|
119
|
-
// Equation in projective coordinates (X/Z, Y/Z, Z): (aX² + Y²)Z² = Z⁴ + dX²Y²
|
|
120
|
-
const { ex: X, ey: Y, ez: Z, et: T } = this;
|
|
121
|
-
const X2 = modP(X * X); // X²
|
|
122
|
-
const Y2 = modP(Y * Y); // Y²
|
|
123
|
-
const Z2 = modP(Z * Z); // Z²
|
|
124
|
-
const Z4 = modP(Z2 * Z2); // Z⁴
|
|
125
|
-
const aX2 = modP(X2 * a); // aX²
|
|
126
|
-
const left = modP(Z2 * modP(aX2 + Y2)); // (aX² + Y²)Z²
|
|
127
|
-
const right = modP(Z4 + modP(d * modP(X2 * Y2))); // Z⁴ + dX²Y²
|
|
128
|
-
if (left !== right)
|
|
129
|
-
throw new Error('bad point: equation left != right (1)');
|
|
130
|
-
// In Extended coordinates we also have T, which is x*y=T/Z: check X*Y == Z*T
|
|
131
|
-
const XY = modP(X * Y);
|
|
132
|
-
const ZT = modP(Z * T);
|
|
133
|
-
if (XY !== ZT)
|
|
134
|
-
throw new Error('bad point: equation left != right (2)');
|
|
135
|
-
}
|
|
136
|
-
// Compare one point to another.
|
|
137
|
-
equals(other) {
|
|
138
|
-
isPoint(other);
|
|
139
|
-
const { ex: X1, ey: Y1, ez: Z1 } = this;
|
|
140
|
-
const { ex: X2, ey: Y2, ez: Z2 } = other;
|
|
141
|
-
const X1Z2 = modP(X1 * Z2);
|
|
142
|
-
const X2Z1 = modP(X2 * Z1);
|
|
143
|
-
const Y1Z2 = modP(Y1 * Z2);
|
|
144
|
-
const Y2Z1 = modP(Y2 * Z1);
|
|
145
|
-
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
146
|
-
}
|
|
147
|
-
is0() {
|
|
148
|
-
return this.equals(Point.ZERO);
|
|
149
|
-
}
|
|
150
|
-
negate() {
|
|
151
|
-
// Flips point sign to a negative one (-x, y in affine coords)
|
|
152
|
-
return new Point(modP(-this.ex), this.ey, this.ez, modP(-this.et));
|
|
153
|
-
}
|
|
154
|
-
// Fast algo for doubling Extended Point.
|
|
155
|
-
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd
|
|
156
|
-
// Cost: 4M + 4S + 1*a + 6add + 1*2.
|
|
157
|
-
double() {
|
|
158
|
-
const { a } = CURVE;
|
|
159
|
-
const { ex: X1, ey: Y1, ez: Z1 } = this;
|
|
160
|
-
const A = modP(X1 * X1); // A = X12
|
|
161
|
-
const B = modP(Y1 * Y1); // B = Y12
|
|
162
|
-
const C = modP(_2n * modP(Z1 * Z1)); // C = 2*Z12
|
|
163
|
-
const D = modP(a * A); // D = a*A
|
|
164
|
-
const x1y1 = X1 + Y1;
|
|
165
|
-
const E = modP(modP(x1y1 * x1y1) - A - B); // E = (X1+Y1)2-A-B
|
|
166
|
-
const G = D + B; // G = D+B
|
|
167
|
-
const F = G - C; // F = G-C
|
|
168
|
-
const H = D - B; // H = D-B
|
|
169
|
-
const X3 = modP(E * F); // X3 = E*F
|
|
170
|
-
const Y3 = modP(G * H); // Y3 = G*H
|
|
171
|
-
const T3 = modP(E * H); // T3 = E*H
|
|
172
|
-
const Z3 = modP(F * G); // Z3 = F*G
|
|
173
|
-
return new Point(X3, Y3, Z3, T3);
|
|
174
|
-
}
|
|
175
|
-
// Fast algo for adding 2 Extended Points.
|
|
176
|
-
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
|
|
177
|
-
// Cost: 9M + 1*a + 1*d + 7add.
|
|
178
|
-
add(other) {
|
|
179
|
-
isPoint(other);
|
|
180
|
-
const { a, d } = CURVE;
|
|
181
|
-
const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;
|
|
182
|
-
const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;
|
|
183
|
-
// Faster algo for adding 2 Extended Points when curve's a=-1.
|
|
184
|
-
// http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4
|
|
185
|
-
// Cost: 8M + 8add + 2*2.
|
|
186
|
-
// Note: It does not check whether the `other` point is valid.
|
|
187
|
-
if (a === BigInt(-1)) {
|
|
188
|
-
const A = modP((Y1 - X1) * (Y2 + X2));
|
|
189
|
-
const B = modP((Y1 + X1) * (Y2 - X2));
|
|
190
|
-
const F = modP(B - A);
|
|
191
|
-
if (F === _0n)
|
|
192
|
-
return this.double(); // Same point. Tests say it doesn't affect timing
|
|
193
|
-
const C = modP(Z1 * _2n * T2);
|
|
194
|
-
const D = modP(T1 * _2n * Z2);
|
|
195
|
-
const E = D + C;
|
|
196
|
-
const G = B + A;
|
|
197
|
-
const H = D - C;
|
|
198
|
-
const X3 = modP(E * F);
|
|
199
|
-
const Y3 = modP(G * H);
|
|
200
|
-
const T3 = modP(E * H);
|
|
201
|
-
const Z3 = modP(F * G);
|
|
202
|
-
return new Point(X3, Y3, Z3, T3);
|
|
203
|
-
}
|
|
204
|
-
const A = modP(X1 * X2); // A = X1*X2
|
|
205
|
-
const B = modP(Y1 * Y2); // B = Y1*Y2
|
|
206
|
-
const C = modP(T1 * d * T2); // C = T1*d*T2
|
|
207
|
-
const D = modP(Z1 * Z2); // D = Z1*Z2
|
|
208
|
-
const E = modP((X1 + Y1) * (X2 + Y2) - A - B); // E = (X1+Y1)*(X2+Y2)-A-B
|
|
209
|
-
const F = D - C; // F = D-C
|
|
210
|
-
const G = D + C; // G = D+C
|
|
211
|
-
const H = modP(B - a * A); // H = B-a*A
|
|
212
|
-
const X3 = modP(E * F); // X3 = E*F
|
|
213
|
-
const Y3 = modP(G * H); // Y3 = G*H
|
|
214
|
-
const T3 = modP(E * H); // T3 = E*H
|
|
215
|
-
const Z3 = modP(F * G); // Z3 = F*G
|
|
216
|
-
return new Point(X3, Y3, Z3, T3);
|
|
217
|
-
}
|
|
218
|
-
subtract(other) {
|
|
219
|
-
return this.add(other.negate());
|
|
220
|
-
}
|
|
221
|
-
wNAF(n) {
|
|
222
|
-
return wnaf.wNAFCached(this, pointPrecomputes, n, Point.normalizeZ);
|
|
223
|
-
}
|
|
224
|
-
// Constant-time multiplication.
|
|
225
|
-
multiply(scalar) {
|
|
226
|
-
const { p, f } = this.wNAF(assertInRange(scalar, CURVE_ORDER));
|
|
227
|
-
return Point.normalizeZ([p, f])[0];
|
|
228
|
-
}
|
|
229
|
-
// Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
230
|
-
// It's faster, but should only be used when you don't care about
|
|
231
|
-
// an exposed private key e.g. sig verification.
|
|
232
|
-
multiplyUnsafe(scalar) {
|
|
233
|
-
let n = assertGE0(scalar);
|
|
234
|
-
if (n === _0n)
|
|
235
|
-
return I;
|
|
236
|
-
if (this.equals(I) || n === _1n)
|
|
237
|
-
return this;
|
|
238
|
-
if (this.equals(G))
|
|
239
|
-
return this.wNAF(n).p;
|
|
240
|
-
return wnaf.unsafeLadder(this, n);
|
|
241
|
-
}
|
|
242
|
-
// Checks if point is of small order.
|
|
243
|
-
// If you add something to small order point, you will have "dirty"
|
|
244
|
-
// point with torsion component.
|
|
245
|
-
// Multiplies point by cofactor and checks if the result is 0.
|
|
246
|
-
isSmallOrder() {
|
|
247
|
-
return this.multiplyUnsafe(cofactor).is0();
|
|
248
|
-
}
|
|
249
|
-
// Multiplies point by curve order and checks if the result is 0.
|
|
250
|
-
// Returns `false` is the point is dirty.
|
|
251
|
-
isTorsionFree() {
|
|
252
|
-
return wnaf.unsafeLadder(this, CURVE_ORDER).is0();
|
|
253
|
-
}
|
|
254
|
-
// Converts Extended point to default (x, y) coordinates.
|
|
255
|
-
// Can accept precomputed Z^-1 - for example, from invertBatch.
|
|
256
|
-
toAffine(iz) {
|
|
257
|
-
const { ex: x, ey: y, ez: z } = this;
|
|
258
|
-
const is0 = this.is0();
|
|
259
|
-
if (iz == null)
|
|
260
|
-
iz = is0 ? _8n : Fp.inv(z); // 8 was chosen arbitrarily
|
|
261
|
-
const ax = modP(x * iz);
|
|
262
|
-
const ay = modP(y * iz);
|
|
263
|
-
const zz = modP(z * iz);
|
|
264
|
-
if (is0)
|
|
265
|
-
return { x: _0n, y: _1n };
|
|
266
|
-
if (zz !== _1n)
|
|
267
|
-
throw new Error('invZ was invalid');
|
|
268
|
-
return { x: ax, y: ay };
|
|
269
|
-
}
|
|
270
|
-
clearCofactor() {
|
|
271
|
-
const { h: cofactor } = CURVE;
|
|
272
|
-
if (cofactor === _1n)
|
|
273
|
-
return this;
|
|
274
|
-
return this.multiplyUnsafe(cofactor);
|
|
275
|
-
}
|
|
276
|
-
// Converts hash string or Uint8Array to Point.
|
|
277
|
-
// Uses algo from RFC8032 5.1.3.
|
|
278
|
-
static fromHex(hex, strict = true) {
|
|
279
|
-
const { d, a } = CURVE;
|
|
280
|
-
const len = Fp.BYTES;
|
|
281
|
-
hex = utils.ensureBytes('pointHex', hex, len); // copy hex to a new array
|
|
282
|
-
const normed = hex.slice(); // copy again, we'll manipulate it
|
|
283
|
-
const lastByte = hex[len - 1]; // select last byte
|
|
284
|
-
normed[len - 1] = lastByte & ~0x80; // clear last bit
|
|
285
|
-
const y = utils.bytesToNumberLE(normed);
|
|
286
|
-
if (y === _0n) ;
|
|
287
|
-
else {
|
|
288
|
-
// RFC8032 prohibits >= p, but ZIP215 doesn't
|
|
289
|
-
if (strict)
|
|
290
|
-
assertInRange(y, Fp.ORDER); // strict=true [1..P-1] (2^255-19-1 for ed25519)
|
|
291
|
-
else
|
|
292
|
-
assertInRange(y, MASK); // strict=false [1..MASK-1] (2^256-1 for ed25519)
|
|
293
|
-
}
|
|
294
|
-
// Ed25519: x² = (y²-1)/(dy²+1) mod p. Ed448: x² = (y²-1)/(dy²-1) mod p. Generic case:
|
|
295
|
-
// ax²+y²=1+dx²y² => y²-1=dx²y²-ax² => y²-1=x²(dy²-a) => x²=(y²-1)/(dy²-a)
|
|
296
|
-
const y2 = modP(y * y); // denominator is always non-0 mod p.
|
|
297
|
-
const u = modP(y2 - _1n); // u = y² - 1
|
|
298
|
-
const v = modP(d * y2 - a); // v = d y² + 1.
|
|
299
|
-
let { isValid, value: x } = uvRatio(u, v); // √(u/v)
|
|
300
|
-
if (!isValid)
|
|
301
|
-
throw new Error('Point.fromHex: invalid y coordinate');
|
|
302
|
-
const isXOdd = (x & _1n) === _1n; // There are 2 square roots. Use x_0 bit to select proper
|
|
303
|
-
const isLastByteOdd = (lastByte & 0x80) !== 0; // if x=0 and x_0 = 1, fail
|
|
304
|
-
if (isLastByteOdd !== isXOdd)
|
|
305
|
-
x = modP(-x); // if x_0 != x mod 2, set x = p-x
|
|
306
|
-
return Point.fromAffine({ x, y });
|
|
307
|
-
}
|
|
308
|
-
static fromPrivateKey(privKey) {
|
|
309
|
-
return getExtendedPublicKey(privKey).point;
|
|
310
|
-
}
|
|
311
|
-
toRawBytes() {
|
|
312
|
-
const { x, y } = this.toAffine();
|
|
313
|
-
const bytes = utils.numberToBytesLE(y, Fp.BYTES); // each y has 2 x values (x, -y)
|
|
314
|
-
bytes[bytes.length - 1] |= x & _1n ? 0x80 : 0; // when compressing, it's enough to store y
|
|
315
|
-
return bytes; // and use the last byte to encode sign of x
|
|
316
|
-
}
|
|
317
|
-
toHex() {
|
|
318
|
-
return utils.bytesToHex(this.toRawBytes()); // Same as toRawBytes, but returns string.
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy));
|
|
322
|
-
Point.ZERO = new Point(_0n, _1n, _1n, _0n); // 0, 1, 1, 0
|
|
323
|
-
const { BASE: G, ZERO: I } = Point;
|
|
324
|
-
const wnaf = curve.wNAF(Point, nByteLength * 8);
|
|
325
|
-
function modN(a) {
|
|
326
|
-
return modular.mod(a, CURVE_ORDER);
|
|
327
|
-
}
|
|
328
|
-
// Little-endian SHA512 with modulo n
|
|
329
|
-
function modN_LE(hash) {
|
|
330
|
-
return modN(utils.bytesToNumberLE(hash));
|
|
331
|
-
}
|
|
332
|
-
/** Convenience method that creates public key and other stuff. RFC8032 5.1.5 */
|
|
333
|
-
function getExtendedPublicKey(key) {
|
|
334
|
-
const len = nByteLength;
|
|
335
|
-
key = utils.ensureBytes('private key', key, len);
|
|
336
|
-
// Hash private key with curve's hash function to produce uniformingly random input
|
|
337
|
-
// Check byte lengths: ensure(64, h(ensure(32, key)))
|
|
338
|
-
const hashed = utils.ensureBytes('hashed private key', cHash(key), 2 * len);
|
|
339
|
-
const head = adjustScalarBytes(hashed.slice(0, len)); // clear first half bits, produce FE
|
|
340
|
-
const prefix = hashed.slice(len, 2 * len); // second half is called key prefix (5.1.6)
|
|
341
|
-
const scalar = modN_LE(head); // The actual private scalar
|
|
342
|
-
const point = G.multiply(scalar); // Point on Edwards curve aka public key
|
|
343
|
-
const pointBytes = point.toRawBytes(); // Uint8Array representation
|
|
344
|
-
return { head, prefix, scalar, point, pointBytes };
|
|
345
|
-
}
|
|
346
|
-
// Calculates EdDSA pub key. RFC8032 5.1.5. Privkey is hashed. Use first half with 3 bits cleared
|
|
347
|
-
function getPublicKey(privKey) {
|
|
348
|
-
return getExtendedPublicKey(privKey).pointBytes;
|
|
349
|
-
}
|
|
350
|
-
// int('LE', SHA512(dom2(F, C) || msgs)) mod N
|
|
351
|
-
function hashDomainToScalar(context = new Uint8Array(), ...msgs) {
|
|
352
|
-
const msg = utils.concatBytes(...msgs);
|
|
353
|
-
return modN_LE(cHash(domain(msg, utils.ensureBytes('context', context), !!preHash)));
|
|
354
|
-
}
|
|
355
|
-
/** Signs message with privateKey. RFC8032 5.1.6 */
|
|
356
|
-
function sign(msg, privKey, context) {
|
|
357
|
-
msg = utils.ensureBytes('message', msg);
|
|
358
|
-
if (preHash)
|
|
359
|
-
msg = preHash(msg); // for ed25519ph etc.
|
|
360
|
-
const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey);
|
|
361
|
-
const r = hashDomainToScalar(context, prefix, msg); // r = dom2(F, C) || prefix || PH(M)
|
|
362
|
-
const R = G.multiply(r).toRawBytes(); // R = rG
|
|
363
|
-
const k = hashDomainToScalar(context, R, pointBytes, msg); // R || A || PH(M)
|
|
364
|
-
const s = modN(r + k * scalar); // S = (r + k * s) mod L
|
|
365
|
-
assertGE0(s); // 0 <= s < l
|
|
366
|
-
const res = utils.concatBytes(R, utils.numberToBytesLE(s, Fp.BYTES));
|
|
367
|
-
return utils.ensureBytes('result', res, nByteLength * 2); // 64-byte signature
|
|
368
|
-
}
|
|
369
|
-
function signModified(msg, privKey, context) {
|
|
370
|
-
msg = utils.ensureBytes('message', msg);
|
|
371
|
-
const privKeyBytes = utils.ensureBytes('privKey', privKey);
|
|
372
|
-
const privKeyNumber = utils.bytesToNumberLE(privKeyBytes);
|
|
373
|
-
const publicKey = G.multiply(modN(privKeyNumber)).toRawBytes();
|
|
374
|
-
const signBit = publicKey[31] & 0x80;
|
|
375
|
-
const r = hashDomainToScalar(context, privKeyBytes, msg); // r = dom2(F, C) || prefix || PH(M)
|
|
376
|
-
const R = G.multiply(r).toRawBytes(); // R = rG
|
|
377
|
-
const k = hashDomainToScalar(context, R, publicKey, msg); // R || A || PH(M)
|
|
378
|
-
const s = k * privKeyNumber; // S = (r + k * s) mod L
|
|
379
|
-
const S = modN(r + s);
|
|
380
|
-
assertGE0(S); // 0 <= s < l
|
|
381
|
-
const Sencoded = utils.numberToBytesLE(S, Fp.BYTES);
|
|
382
|
-
Sencoded[31] |= signBit;
|
|
383
|
-
const res = utils.concatBytes(R, Sencoded);
|
|
384
|
-
return utils.ensureBytes('result', res, nByteLength * 2); // 64-byte signature
|
|
385
|
-
}
|
|
386
|
-
function verify(sig, msg, publicKey, context) {
|
|
387
|
-
const len = Fp.BYTES; // Verifies EdDSA signature against message and public key. RFC8032 5.1.7.
|
|
388
|
-
sig = utils.ensureBytes('signature', sig, 2 * len); // An extended group equation is checked.
|
|
389
|
-
msg = utils.ensureBytes('message', msg); // ZIP215 compliant, which means not fully RFC8032 compliant.
|
|
390
|
-
if (preHash)
|
|
391
|
-
msg = preHash(msg); // for ed25519ph, etc
|
|
392
|
-
const A = Point.fromHex(publicKey, false); // Check for s bounds, hex validity
|
|
393
|
-
const R = Point.fromHex(sig.slice(0, len), false); // 0 <= R < 2^256: ZIP215 R can be >= P
|
|
394
|
-
const s = utils.bytesToNumberLE(sig.slice(len, 2 * len)); // 0 <= s < l
|
|
395
|
-
const SB = G.multiplyUnsafe(s);
|
|
396
|
-
const k = hashDomainToScalar(context, R.toRawBytes(), A.toRawBytes(), msg);
|
|
397
|
-
const RkA = R.add(A.multiplyUnsafe(k));
|
|
398
|
-
// [8][S]B = [8]R + [8][k]A'
|
|
399
|
-
return RkA.subtract(SB).clearCofactor().equals(Point.ZERO);
|
|
400
|
-
}
|
|
401
|
-
G._setWindowSize(8); // Enable precomputes. Slows down first publicKey computation by 20ms.
|
|
402
|
-
const utils$1 = {
|
|
403
|
-
getExtendedPublicKey,
|
|
404
|
-
// ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1.
|
|
405
|
-
randomPrivateKey: () => randomBytes(Fp.BYTES),
|
|
406
|
-
/**
|
|
407
|
-
* We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT
|
|
408
|
-
* values. This slows down first getPublicKey() by milliseconds (see Speed section),
|
|
409
|
-
* but allows to speed-up subsequent getPublicKey() calls up to 20x.
|
|
410
|
-
* @param windowSize 2, 4, 8, 16
|
|
411
|
-
*/
|
|
412
|
-
precompute(windowSize = 8, point = Point.BASE) {
|
|
413
|
-
point._setWindowSize(windowSize);
|
|
414
|
-
point.multiply(BigInt(3));
|
|
415
|
-
return point;
|
|
416
|
-
},
|
|
417
|
-
};
|
|
418
|
-
return {
|
|
419
|
-
CURVE,
|
|
420
|
-
getPublicKey,
|
|
421
|
-
sign,
|
|
422
|
-
signModified,
|
|
423
|
-
verify,
|
|
424
|
-
ExtendedPoint: Point,
|
|
425
|
-
utils: utils$1,
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
exports.twistedEdwards = twistedEdwards;
|