filecat 5.16.1 → 5.16.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/build/dist/{523.cd76e6fafa6440cc1693.js → 523.dccd16b3d9a55836ef44.js} +2 -2
- package/build/dist/{943.7e28d7ce1a69f0d15eb2.js → 943.b94459fa6f46eef06e48.js} +2 -2
- package/build/dist/index.html +1 -1
- package/build/dist/{main.7d110d8fdcc3c74c6c82.js → main.7b13a8b34814c54500af.js} +2 -2
- package/build/main.js +2 -0
- package/build/main.js.LICENSE.txt +445 -0
- package/build/unrar.wasm +0 -0
- package/build/{server/main/watch.js → watch.js} +86 -68
- package/package.json +4 -3
- package/shell/config/webpack.npm.config.js +1 -1
- package/build/server/common/Env.js +0 -188
- package/build/server/common/Env.js.map +0 -1
- package/build/server/common/FileMenuType.js +0 -45
- package/build/server/common/FileMenuType.js.map +0 -1
- package/build/server/common/ListUtil.js +0 -174
- package/build/server/common/ListUtil.js.map +0 -1
- package/build/server/common/Result.pojo.js +0 -14
- package/build/server/common/Result.pojo.js.map +0 -1
- package/build/server/common/RouterConfig.js +0 -16
- package/build/server/common/RouterConfig.js.map +0 -1
- package/build/server/common/StringUtil.js +0 -153
- package/build/server/common/StringUtil.js.map +0 -1
- package/build/server/common/ValueUtil.js +0 -49
- package/build/server/common/ValueUtil.js.map +0 -1
- package/build/server/common/common.util.js +0 -10
- package/build/server/common/common.util.js.map +0 -1
- package/build/server/common/file.pojo.js +0 -56
- package/build/server/common/file.pojo.js.map +0 -1
- package/build/server/common/findPort.js +0 -34
- package/build/server/common/findPort.js.map +0 -1
- package/build/server/common/frame/WsData.js +0 -168
- package/build/server/common/frame/WsData.js.map +0 -1
- package/build/server/common/frame/router.js +0 -25
- package/build/server/common/frame/router.js.map +0 -1
- package/build/server/common/frame/ws.client.js +0 -295
- package/build/server/common/frame/ws.client.js.map +0 -1
- package/build/server/common/frame/ws.server.js +0 -226
- package/build/server/common/frame/ws.server.js.map +0 -1
- package/build/server/common/http.js +0 -47
- package/build/server/common/http.js.map +0 -1
- package/build/server/common/install.js +0 -139
- package/build/server/common/install.js.map +0 -1
- package/build/server/common/path_util.js +0 -86
- package/build/server/common/path_util.js.map +0 -1
- package/build/server/common/proto/proto.generate.js +0 -23
- package/build/server/common/proto/proto.generate.js.map +0 -1
- package/build/server/common/proto/proto.js +0 -172
- package/build/server/common/proto/proto.js.map +0 -1
- package/build/server/common/req/common.pojo.js +0 -17
- package/build/server/common/req/common.pojo.js.map +0 -1
- package/build/server/common/req/customerRouter.pojo.js +0 -9
- package/build/server/common/req/customerRouter.pojo.js.map +0 -1
- package/build/server/common/req/data.pojo.js +0 -3
- package/build/server/common/req/data.pojo.js.map +0 -1
- package/build/server/common/req/ddns.pojo.js +0 -39
- package/build/server/common/req/ddns.pojo.js.map +0 -1
- package/build/server/common/req/file.req.js +0 -46
- package/build/server/common/req/file.req.js.map +0 -1
- package/build/server/common/req/http_controller_router.js +0 -13
- package/build/server/common/req/http_controller_router.js.map +0 -1
- package/build/server/common/req/net.pojo.js +0 -49
- package/build/server/common/req/net.pojo.js.map +0 -1
- package/build/server/common/req/setting.req.js +0 -37
- package/build/server/common/req/setting.req.js.map +0 -1
- package/build/server/common/req/ssh.pojo.js +0 -13
- package/build/server/common/req/ssh.pojo.js.map +0 -1
- package/build/server/common/req/sys.pojo.js +0 -23
- package/build/server/common/req/sys.pojo.js.map +0 -1
- package/build/server/common/req/user.req.js +0 -91
- package/build/server/common/req/user.req.js.map +0 -1
- package/build/server/common/word_detection_js.js +0 -142
- package/build/server/common/word_detection_js.js.map +0 -1
- package/build/server/main/domain/bin/bin.js +0 -149
- package/build/server/main/domain/bin/bin.js.map +0 -1
- package/build/server/main/domain/crypto/crypto.controller.js +0 -63
- package/build/server/main/domain/crypto/crypto.controller.js.map +0 -1
- package/build/server/main/domain/crypto/crypto.service.js +0 -112
- package/build/server/main/domain/crypto/crypto.service.js.map +0 -1
- package/build/server/main/domain/data/DataUtil.js +0 -111
- package/build/server/main/domain/data/DataUtil.js.map +0 -1
- package/build/server/main/domain/data/basedata/base_data_util.js +0 -241
- package/build/server/main/domain/data/basedata/base_data_util.js.map +0 -1
- package/build/server/main/domain/data/data_type.js +0 -74
- package/build/server/main/domain/data/data_type.js.map +0 -1
- package/build/server/main/domain/ddns/ddns.ali.server.js +0 -88
- package/build/server/main/domain/ddns/ddns.ali.server.js.map +0 -1
- package/build/server/main/domain/ddns/ddns.controller.js +0 -103
- package/build/server/main/domain/ddns/ddns.controller.js.map +0 -1
- package/build/server/main/domain/ddns/ddns.dnspod.service.js +0 -121
- package/build/server/main/domain/ddns/ddns.dnspod.service.js.map +0 -1
- package/build/server/main/domain/ddns/ddns.pre.js +0 -120
- package/build/server/main/domain/ddns/ddns.pre.js.map +0 -1
- package/build/server/main/domain/ddns/ddns.service.js +0 -175
- package/build/server/main/domain/ddns/ddns.service.js.map +0 -1
- package/build/server/main/domain/ddns/ddns.tengxun.service.js +0 -57
- package/build/server/main/domain/ddns/ddns.tengxun.service.js.map +0 -1
- package/build/server/main/domain/ddns/tx/abstract_client.js +0 -270
- package/build/server/main/domain/ddns/tx/abstract_client.js.map +0 -1
- package/build/server/main/domain/ddns/tx/dnspod_client.js +0 -65
- package/build/server/main/domain/ddns/tx/dnspod_client.js.map +0 -1
- package/build/server/main/domain/ddns/tx/dnspod_models.js +0 -3
- package/build/server/main/domain/ddns/tx/dnspod_models.js.map +0 -1
- package/build/server/main/domain/ddns/tx/exception/tencent_cloud_sdk_exception.js +0 -38
- package/build/server/main/domain/ddns/tx/exception/tencent_cloud_sdk_exception.js.map +0 -1
- package/build/server/main/domain/ddns/tx/http/fetch.js +0 -3
- package/build/server/main/domain/ddns/tx/http/fetch.js.map +0 -1
- package/build/server/main/domain/ddns/tx/http/http_connection.js +0 -194
- package/build/server/main/domain/ddns/tx/http/http_connection.js.map +0 -1
- package/build/server/main/domain/ddns/tx/interface.js +0 -5
- package/build/server/main/domain/ddns/tx/interface.js.map +0 -1
- package/build/server/main/domain/ddns/tx/sdk_version.js +0 -5
- package/build/server/main/domain/ddns/tx/sdk_version.js.map +0 -1
- package/build/server/main/domain/ddns/tx/sign.js +0 -142
- package/build/server/main/domain/ddns/tx/sign.js.map +0 -1
- package/build/server/main/domain/ddns/tx/sse_response_model.js +0 -124
- package/build/server/main/domain/ddns/tx/sse_response_model.js.map +0 -1
- package/build/server/main/domain/file/FileUtil.js +0 -96
- package/build/server/main/domain/file/FileUtil.js.map +0 -1
- package/build/server/main/domain/file/file.compress.js +0 -131
- package/build/server/main/domain/file/file.compress.js.map +0 -1
- package/build/server/main/domain/file/file.controller.js +0 -483
- package/build/server/main/domain/file/file.controller.js.map +0 -1
- package/build/server/main/domain/file/file.service.js +0 -1123
- package/build/server/main/domain/file/file.service.js.map +0 -1
- package/build/server/main/domain/file/search/file.search.js +0 -83
- package/build/server/main/domain/file/search/file.search.js.map +0 -1
- package/build/server/main/domain/file/search/file.search.worker.js +0 -100
- package/build/server/main/domain/file/search/file.search.worker.js.map +0 -1
- package/build/server/main/domain/file/search/file.type.js +0 -3
- package/build/server/main/domain/file/search/file.type.js.map +0 -1
- package/build/server/main/domain/file/workflow/workflow.process.js +0 -104
- package/build/server/main/domain/file/workflow/workflow.process.js.map +0 -1
- package/build/server/main/domain/file/workflow/workflow.service.js +0 -687
- package/build/server/main/domain/file/workflow/workflow.service.js.map +0 -1
- package/build/server/main/domain/file/workflow/workflow.util.js +0 -121
- package/build/server/main/domain/file/workflow/workflow.util.js.map +0 -1
- package/build/server/main/domain/navindex/navindex.controller.js +0 -73
- package/build/server/main/domain/navindex/navindex.controller.js.map +0 -1
- package/build/server/main/domain/net/net.controller.js +0 -196
- package/build/server/main/domain/net/net.controller.js.map +0 -1
- package/build/server/main/domain/net/net.datautil.js +0 -8
- package/build/server/main/domain/net/net.datautil.js.map +0 -1
- package/build/server/main/domain/net/net.service.js +0 -415
- package/build/server/main/domain/net/net.service.js.map +0 -1
- package/build/server/main/domain/net/util/NetClientUtil.js +0 -246
- package/build/server/main/domain/net/util/NetClientUtil.js.map +0 -1
- package/build/server/main/domain/net/util/NetServerUtil.js +0 -128
- package/build/server/main/domain/net/util/NetServerUtil.js.map +0 -1
- package/build/server/main/domain/net/util/NetUtil.js +0 -129
- package/build/server/main/domain/net/util/NetUtil.js.map +0 -1
- package/build/server/main/domain/net/util/tcp.util.js +0 -137
- package/build/server/main/domain/net/util/tcp.util.js.map +0 -1
- package/build/server/main/domain/net/util/udp.util.js +0 -28
- package/build/server/main/domain/net/util/udp.util.js.map +0 -1
- package/build/server/main/domain/net/virtual/tcp_proxy.js +0 -106
- package/build/server/main/domain/net/virtual/tcp_proxy.js.map +0 -1
- package/build/server/main/domain/net/virtual/virtual.client.service.js +0 -445
- package/build/server/main/domain/net/virtual/virtual.client.service.js.map +0 -1
- package/build/server/main/domain/net/virtual/virtual.controller.js +0 -263
- package/build/server/main/domain/net/virtual/virtual.controller.js.map +0 -1
- package/build/server/main/domain/net/virtual/virtual.server.service.js +0 -91
- package/build/server/main/domain/net/virtual/virtual.server.service.js.map +0 -1
- package/build/server/main/domain/pre/lifeRecordService.js +0 -92
- package/build/server/main/domain/pre/lifeRecordService.js.map +0 -1
- package/build/server/main/domain/rdp/lib/asn1/ber.js +0 -66
- package/build/server/main/domain/rdp/lib/asn1/ber.js.map +0 -1
- package/build/server/main/domain/rdp/lib/asn1/index.js +0 -9
- package/build/server/main/domain/rdp/lib/asn1/index.js.map +0 -1
- package/build/server/main/domain/rdp/lib/asn1/spec.js +0 -56
- package/build/server/main/domain/rdp/lib/asn1/spec.js.map +0 -1
- package/build/server/main/domain/rdp/lib/asn1/univ.js +0 -315
- package/build/server/main/domain/rdp/lib/asn1/univ.js.map +0 -1
- package/build/server/main/domain/rdp/lib/core/error.js +0 -25
- package/build/server/main/domain/rdp/lib/core/error.js.map +0 -1
- package/build/server/main/domain/rdp/lib/core/index.js +0 -13
- package/build/server/main/domain/rdp/lib/core/index.js.map +0 -1
- package/build/server/main/domain/rdp/lib/core/layer.js +0 -135
- package/build/server/main/domain/rdp/lib/core/layer.js.map +0 -1
- package/build/server/main/domain/rdp/lib/core/log.js +0 -25
- package/build/server/main/domain/rdp/lib/core/log.js.map +0 -1
- package/build/server/main/domain/rdp/lib/core/rle.js +0 -22699
- package/build/server/main/domain/rdp/lib/core/rle.js.map +0 -1
- package/build/server/main/domain/rdp/lib/core/type.js +0 -245
- package/build/server/main/domain/rdp/lib/core/type.js.map +0 -1
- package/build/server/main/domain/rdp/lib/index.js +0 -6
- package/build/server/main/domain/rdp/lib/index.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/cert.js +0 -115
- package/build/server/main/domain/rdp/lib/protocol/cert.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/index.js +0 -11
- package/build/server/main/domain/rdp/lib/protocol/index.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/nla.js +0 -549
- package/build/server/main/domain/rdp/lib/protocol/nla.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/pdu/caps.js +0 -486
- package/build/server/main/domain/rdp/lib/protocol/pdu/caps.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/pdu/cliprdr.js +0 -167
- package/build/server/main/domain/rdp/lib/protocol/pdu/cliprdr.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/pdu/data.js +0 -876
- package/build/server/main/domain/rdp/lib/protocol/pdu/data.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/pdu/global.js +0 -260
- package/build/server/main/domain/rdp/lib/protocol/pdu/global.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/pdu/index.js +0 -13
- package/build/server/main/domain/rdp/lib/protocol/pdu/index.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/pdu/lic.js +0 -199
- package/build/server/main/domain/rdp/lib/protocol/pdu/lic.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/pdu/sec.js +0 -333
- package/build/server/main/domain/rdp/lib/protocol/pdu/sec.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/rdp.js +0 -255
- package/build/server/main/domain/rdp/lib/protocol/rdp.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/t125/gcc.js +0 -354
- package/build/server/main/domain/rdp/lib/protocol/t125/gcc.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/t125/index.js +0 -7
- package/build/server/main/domain/rdp/lib/protocol/t125/index.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/t125/mcs.js +0 -318
- package/build/server/main/domain/rdp/lib/protocol/t125/mcs.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/t125/per.js +0 -188
- package/build/server/main/domain/rdp/lib/protocol/t125/per.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/tpkt.js +0 -94
- package/build/server/main/domain/rdp/lib/protocol/tpkt.js.map +0 -1
- package/build/server/main/domain/rdp/lib/protocol/x224.js +0 -207
- package/build/server/main/domain/rdp/lib/protocol/x224.js.map +0 -1
- package/build/server/main/domain/rdp/lib/security/index.js +0 -7
- package/build/server/main/domain/rdp/lib/security/index.js.map +0 -1
- package/build/server/main/domain/rdp/lib/security/jsbn.js +0 -1372
- package/build/server/main/domain/rdp/lib/security/jsbn.js.map +0 -1
- package/build/server/main/domain/rdp/lib/security/md4.js +0 -401
- package/build/server/main/domain/rdp/lib/security/md4.js.map +0 -1
- package/build/server/main/domain/rdp/lib/security/rc4.js +0 -45
- package/build/server/main/domain/rdp/lib/security/rc4.js.map +0 -1
- package/build/server/main/domain/rdp/lib/security/rsa.js +0 -15
- package/build/server/main/domain/rdp/lib/security/rsa.js.map +0 -1
- package/build/server/main/domain/rdp/lib/security/x509.js +0 -106
- package/build/server/main/domain/rdp/lib/security/x509.js.map +0 -1
- package/build/server/main/domain/rdp/rdp.controller.js +0 -137
- package/build/server/main/domain/rdp/rdp.controller.js.map +0 -1
- package/build/server/main/domain/rdp/rdp.service.js +0 -137
- package/build/server/main/domain/rdp/rdp.service.js.map +0 -1
- package/build/server/main/domain/setting/setting.controller.js +0 -518
- package/build/server/main/domain/setting/setting.controller.js.map +0 -1
- package/build/server/main/domain/setting/setting.prefile.js +0 -74
- package/build/server/main/domain/setting/setting.prefile.js.map +0 -1
- package/build/server/main/domain/setting/setting.service.js +0 -550
- package/build/server/main/domain/setting/setting.service.js.map +0 -1
- package/build/server/main/domain/shell/shell.controller.js +0 -115
- package/build/server/main/domain/shell/shell.controller.js.map +0 -1
- package/build/server/main/domain/shell/shell.service.js +0 -443
- package/build/server/main/domain/shell/shell.service.js.map +0 -1
- package/build/server/main/domain/ssh/ssh.controller.js +0 -236
- package/build/server/main/domain/ssh/ssh.controller.js.map +0 -1
- package/build/server/main/domain/ssh/ssh.service.js +0 -271
- package/build/server/main/domain/ssh/ssh.service.js.map +0 -1
- package/build/server/main/domain/ssh/ssh.ssh2.js +0 -250
- package/build/server/main/domain/ssh/ssh.ssh2.js.map +0 -1
- package/build/server/main/domain/sys/sys.controller.js +0 -395
- package/build/server/main/domain/sys/sys.controller.js.map +0 -1
- package/build/server/main/domain/sys/sys.docker.service.js +0 -367
- package/build/server/main/domain/sys/sys.docker.service.js.map +0 -1
- package/build/server/main/domain/sys/sys.process.service.js +0 -239
- package/build/server/main/domain/sys/sys.process.service.js.map +0 -1
- package/build/server/main/domain/sys/sys.service.js +0 -101
- package/build/server/main/domain/sys/sys.service.js.map +0 -1
- package/build/server/main/domain/sys/sys.sys.service.js +0 -192
- package/build/server/main/domain/sys/sys.sys.service.js.map +0 -1
- package/build/server/main/domain/sys/sys.systemd.service.js +0 -306
- package/build/server/main/domain/sys/sys.systemd.service.js.map +0 -1
- package/build/server/main/domain/sys/sys.utl.js +0 -23
- package/build/server/main/domain/sys/sys.utl.js.map +0 -1
- package/build/server/main/domain/user/user.controller.js +0 -264
- package/build/server/main/domain/user/user.controller.js.map +0 -1
- package/build/server/main/domain/user/user.hash.js +0 -8
- package/build/server/main/domain/user/user.hash.js.map +0 -1
- package/build/server/main/domain/user/user.service.js +0 -573
- package/build/server/main/domain/user/user.service.js.map +0 -1
- package/build/server/main/domain/video/video.controller.js +0 -71
- package/build/server/main/domain/video/video.controller.js.map +0 -1
- package/build/server/main/domain/video/video.service.js +0 -45
- package/build/server/main/domain/video/video.service.js.map +0 -1
- package/build/server/main/other/Result.js +0 -25
- package/build/server/main/other/Result.js.map +0 -1
- package/build/server/main/other/cache.js +0 -50
- package/build/server/main/other/cache.js.map +0 -1
- package/build/server/main/other/config.js +0 -6
- package/build/server/main/other/config.js.map +0 -1
- package/build/server/main/other/middleware/AuthMiddleware.js +0 -72
- package/build/server/main/other/middleware/AuthMiddleware.js.map +0 -1
- package/build/server/main/other/middleware/GlobalErrorHandler.js +0 -23
- package/build/server/main/other/middleware/GlobalErrorHandler.js.map +0 -1
- package/build/server/main/other/middleware/redirect.js +0 -20
- package/build/server/main/other/middleware/redirect.js.map +0 -1
- package/build/server/main/server.js +0 -155
- package/build/server/main/server.js.map +0 -1
- package/build/server/main/watch.js.map +0 -1
- package/build/server/tsconfig.tsbuildinfo +0 -1
- package/build/server/web/project/util/noty.js +0 -60
- package/build/server/web/project/util/noty.js.map +0 -1
- package/build/server/web/project/util/ws.js +0 -7
- package/build/server/web/project/util/ws.js.map +0 -1
- /package/build/dist/{523.cd76e6fafa6440cc1693.js.LICENSE.txt → 523.dccd16b3d9a55836ef44.js.LICENSE.txt} +0 -0
- /package/build/dist/{943.7e28d7ce1a69f0d15eb2.js.LICENSE.txt → 943.b94459fa6f46eef06e48.js.LICENSE.txt} +0 -0
- /package/build/dist/{main.7d110d8fdcc3c74c6c82.js.LICENSE.txt → main.7b13a8b34814c54500af.js.LICENSE.txt} +0 -0
|
@@ -1,1372 +0,0 @@
|
|
|
1
|
-
var crypt = require('crypto');
|
|
2
|
-
function isObjectLike(value) { return !!value && typeof value == 'object'; }
|
|
3
|
-
const isNumber = function isNumber(value) { return typeof value == 'number' || (isObjectLike(value) && Object.prototype.toString.call(value) == '[object Number]'); };
|
|
4
|
-
var dbits;
|
|
5
|
-
var canary = 0xdeadbeefcafe;
|
|
6
|
-
var j_lm = ((canary & 0xffffff) == 0xefcafe);
|
|
7
|
-
function BigInteger(a, b) {
|
|
8
|
-
if (a != null) {
|
|
9
|
-
if ("number" == typeof a) {
|
|
10
|
-
this.fromNumber(a, b);
|
|
11
|
-
}
|
|
12
|
-
else if (Buffer.isBuffer(a)) {
|
|
13
|
-
this.fromBuffer(a);
|
|
14
|
-
}
|
|
15
|
-
else if (b == null && "string" != typeof a) {
|
|
16
|
-
this.fromByteArray(a);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
this.fromString(a, b);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function nbi() {
|
|
24
|
-
return new BigInteger(null);
|
|
25
|
-
}
|
|
26
|
-
function am1(i, x, w, j, c, n) {
|
|
27
|
-
while (--n >= 0) {
|
|
28
|
-
var v = x * this[i++] + w[j] + c;
|
|
29
|
-
c = Math.floor(v / 0x4000000);
|
|
30
|
-
w[j++] = v & 0x3ffffff;
|
|
31
|
-
}
|
|
32
|
-
return c;
|
|
33
|
-
}
|
|
34
|
-
function am2(i, x, w, j, c, n) {
|
|
35
|
-
var xl = x & 0x7fff, xh = x >> 15;
|
|
36
|
-
while (--n >= 0) {
|
|
37
|
-
var l = this[i] & 0x7fff;
|
|
38
|
-
var h = this[i++] >> 15;
|
|
39
|
-
var m = xh * l + h * xl;
|
|
40
|
-
l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
|
|
41
|
-
c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
|
|
42
|
-
w[j++] = l & 0x3fffffff;
|
|
43
|
-
}
|
|
44
|
-
return c;
|
|
45
|
-
}
|
|
46
|
-
function am3(i, x, w, j, c, n) {
|
|
47
|
-
var xl = x & 0x3fff, xh = x >> 14;
|
|
48
|
-
while (--n >= 0) {
|
|
49
|
-
var l = this[i] & 0x3fff;
|
|
50
|
-
var h = this[i++] >> 14;
|
|
51
|
-
var m = xh * l + h * xl;
|
|
52
|
-
l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
|
|
53
|
-
c = (l >> 28) + (m >> 14) + xh * h;
|
|
54
|
-
w[j++] = l & 0xfffffff;
|
|
55
|
-
}
|
|
56
|
-
return c;
|
|
57
|
-
}
|
|
58
|
-
BigInteger.prototype.am = am3;
|
|
59
|
-
dbits = 28;
|
|
60
|
-
BigInteger.prototype.DB = dbits;
|
|
61
|
-
BigInteger.prototype.DM = ((1 << dbits) - 1);
|
|
62
|
-
BigInteger.prototype.DV = (1 << dbits);
|
|
63
|
-
var BI_FP = 52;
|
|
64
|
-
BigInteger.prototype.FV = Math.pow(2, BI_FP);
|
|
65
|
-
BigInteger.prototype.F1 = BI_FP - dbits;
|
|
66
|
-
BigInteger.prototype.F2 = 2 * dbits - BI_FP;
|
|
67
|
-
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
68
|
-
var BI_RC = new Array();
|
|
69
|
-
var rr, vv;
|
|
70
|
-
rr = "0".charCodeAt(0);
|
|
71
|
-
for (vv = 0; vv <= 9; ++vv)
|
|
72
|
-
BI_RC[rr++] = vv;
|
|
73
|
-
rr = "a".charCodeAt(0);
|
|
74
|
-
for (vv = 10; vv < 36; ++vv)
|
|
75
|
-
BI_RC[rr++] = vv;
|
|
76
|
-
rr = "A".charCodeAt(0);
|
|
77
|
-
for (vv = 10; vv < 36; ++vv)
|
|
78
|
-
BI_RC[rr++] = vv;
|
|
79
|
-
function int2char(n) {
|
|
80
|
-
return BI_RM.charAt(n);
|
|
81
|
-
}
|
|
82
|
-
function intAt(s, i) {
|
|
83
|
-
var c = BI_RC[s.charCodeAt(i)];
|
|
84
|
-
return (c == null) ? -1 : c;
|
|
85
|
-
}
|
|
86
|
-
function bnpCopyTo(r) {
|
|
87
|
-
for (var i = this.t - 1; i >= 0; --i)
|
|
88
|
-
r[i] = this[i];
|
|
89
|
-
r.t = this.t;
|
|
90
|
-
r.s = this.s;
|
|
91
|
-
}
|
|
92
|
-
function bnpFromInt(x) {
|
|
93
|
-
this.t = 1;
|
|
94
|
-
this.s = (x < 0) ? -1 : 0;
|
|
95
|
-
if (x > 0)
|
|
96
|
-
this[0] = x;
|
|
97
|
-
else if (x < -1)
|
|
98
|
-
this[0] = x + DV;
|
|
99
|
-
else
|
|
100
|
-
this.t = 0;
|
|
101
|
-
}
|
|
102
|
-
function nbv(i) {
|
|
103
|
-
var r = nbi();
|
|
104
|
-
r.fromInt(i);
|
|
105
|
-
return r;
|
|
106
|
-
}
|
|
107
|
-
function bnpFromString(data, radix, unsigned) {
|
|
108
|
-
var k;
|
|
109
|
-
switch (radix) {
|
|
110
|
-
case 2:
|
|
111
|
-
k = 1;
|
|
112
|
-
break;
|
|
113
|
-
case 4:
|
|
114
|
-
k = 2;
|
|
115
|
-
break;
|
|
116
|
-
case 8:
|
|
117
|
-
k = 3;
|
|
118
|
-
break;
|
|
119
|
-
case 16:
|
|
120
|
-
k = 4;
|
|
121
|
-
break;
|
|
122
|
-
case 32:
|
|
123
|
-
k = 5;
|
|
124
|
-
break;
|
|
125
|
-
case 256:
|
|
126
|
-
k = 8;
|
|
127
|
-
break;
|
|
128
|
-
default:
|
|
129
|
-
this.fromRadix(data, radix);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
this.t = 0;
|
|
133
|
-
this.s = 0;
|
|
134
|
-
var i = data.length;
|
|
135
|
-
var mi = false;
|
|
136
|
-
var sh = 0;
|
|
137
|
-
while (--i >= 0) {
|
|
138
|
-
var x = (k == 8) ? data[i] & 0xff : intAt(data, i);
|
|
139
|
-
if (x < 0) {
|
|
140
|
-
if (data.charAt(i) == "-")
|
|
141
|
-
mi = true;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
mi = false;
|
|
145
|
-
if (sh === 0)
|
|
146
|
-
this[this.t++] = x;
|
|
147
|
-
else if (sh + k > this.DB) {
|
|
148
|
-
this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
|
|
149
|
-
this[this.t++] = (x >> (this.DB - sh));
|
|
150
|
-
}
|
|
151
|
-
else
|
|
152
|
-
this[this.t - 1] |= x << sh;
|
|
153
|
-
sh += k;
|
|
154
|
-
if (sh >= this.DB)
|
|
155
|
-
sh -= this.DB;
|
|
156
|
-
}
|
|
157
|
-
if ((!unsigned) && k == 8 && (data[0] & 0x80) != 0) {
|
|
158
|
-
this.s = -1;
|
|
159
|
-
if (sh > 0)
|
|
160
|
-
this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
|
|
161
|
-
}
|
|
162
|
-
this.clamp();
|
|
163
|
-
if (mi)
|
|
164
|
-
BigInteger.ZERO.subTo(this, this);
|
|
165
|
-
}
|
|
166
|
-
function bnpFromByteArray(a, unsigned) {
|
|
167
|
-
this.fromString(a, 256, unsigned);
|
|
168
|
-
}
|
|
169
|
-
function bnpFromBuffer(a) {
|
|
170
|
-
this.fromString(a, 256, true);
|
|
171
|
-
}
|
|
172
|
-
function bnpClamp() {
|
|
173
|
-
var c = this.s & this.DM;
|
|
174
|
-
while (this.t > 0 && this[this.t - 1] == c)
|
|
175
|
-
--this.t;
|
|
176
|
-
}
|
|
177
|
-
function bnToString(b) {
|
|
178
|
-
if (this.s < 0)
|
|
179
|
-
return "-" + this.negate().toString(b);
|
|
180
|
-
var k;
|
|
181
|
-
if (b == 16)
|
|
182
|
-
k = 4;
|
|
183
|
-
else if (b == 8)
|
|
184
|
-
k = 3;
|
|
185
|
-
else if (b == 2)
|
|
186
|
-
k = 1;
|
|
187
|
-
else if (b == 32)
|
|
188
|
-
k = 5;
|
|
189
|
-
else if (b == 4)
|
|
190
|
-
k = 2;
|
|
191
|
-
else
|
|
192
|
-
return this.toRadix(b);
|
|
193
|
-
var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
|
|
194
|
-
var p = this.DB - (i * this.DB) % k;
|
|
195
|
-
if (i-- > 0) {
|
|
196
|
-
if (p < this.DB && (d = this[i] >> p) > 0) {
|
|
197
|
-
m = true;
|
|
198
|
-
r = int2char(d);
|
|
199
|
-
}
|
|
200
|
-
while (i >= 0) {
|
|
201
|
-
if (p < k) {
|
|
202
|
-
d = (this[i] & ((1 << p) - 1)) << (k - p);
|
|
203
|
-
d |= this[--i] >> (p += this.DB - k);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
d = (this[i] >> (p -= k)) & km;
|
|
207
|
-
if (p <= 0) {
|
|
208
|
-
p += this.DB;
|
|
209
|
-
--i;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (d > 0)
|
|
213
|
-
m = true;
|
|
214
|
-
if (m)
|
|
215
|
-
r += int2char(d);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return m ? r : "0";
|
|
219
|
-
}
|
|
220
|
-
function bnNegate() {
|
|
221
|
-
var r = nbi();
|
|
222
|
-
BigInteger.ZERO.subTo(this, r);
|
|
223
|
-
return r;
|
|
224
|
-
}
|
|
225
|
-
function bnAbs() {
|
|
226
|
-
return (this.s < 0) ? this.negate() : this;
|
|
227
|
-
}
|
|
228
|
-
function bnCompareTo(a) {
|
|
229
|
-
var r = this.s - a.s;
|
|
230
|
-
if (r != 0)
|
|
231
|
-
return r;
|
|
232
|
-
var i = this.t;
|
|
233
|
-
r = i - a.t;
|
|
234
|
-
if (r != 0)
|
|
235
|
-
return (this.s < 0) ? -r : r;
|
|
236
|
-
while (--i >= 0)
|
|
237
|
-
if ((r = this[i] - a[i]) != 0)
|
|
238
|
-
return r;
|
|
239
|
-
return 0;
|
|
240
|
-
}
|
|
241
|
-
function nbits(x) {
|
|
242
|
-
var r = 1, t;
|
|
243
|
-
if ((t = x >>> 16) != 0) {
|
|
244
|
-
x = t;
|
|
245
|
-
r += 16;
|
|
246
|
-
}
|
|
247
|
-
if ((t = x >> 8) != 0) {
|
|
248
|
-
x = t;
|
|
249
|
-
r += 8;
|
|
250
|
-
}
|
|
251
|
-
if ((t = x >> 4) != 0) {
|
|
252
|
-
x = t;
|
|
253
|
-
r += 4;
|
|
254
|
-
}
|
|
255
|
-
if ((t = x >> 2) != 0) {
|
|
256
|
-
x = t;
|
|
257
|
-
r += 2;
|
|
258
|
-
}
|
|
259
|
-
if ((t = x >> 1) != 0) {
|
|
260
|
-
x = t;
|
|
261
|
-
r += 1;
|
|
262
|
-
}
|
|
263
|
-
return r;
|
|
264
|
-
}
|
|
265
|
-
function bnBitLength() {
|
|
266
|
-
if (this.t <= 0)
|
|
267
|
-
return 0;
|
|
268
|
-
return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
|
|
269
|
-
}
|
|
270
|
-
function bnpDLShiftTo(n, r) {
|
|
271
|
-
var i;
|
|
272
|
-
for (i = this.t - 1; i >= 0; --i)
|
|
273
|
-
r[i + n] = this[i];
|
|
274
|
-
for (i = n - 1; i >= 0; --i)
|
|
275
|
-
r[i] = 0;
|
|
276
|
-
r.t = this.t + n;
|
|
277
|
-
r.s = this.s;
|
|
278
|
-
}
|
|
279
|
-
function bnpDRShiftTo(n, r) {
|
|
280
|
-
for (var i = n; i < this.t; ++i)
|
|
281
|
-
r[i - n] = this[i];
|
|
282
|
-
r.t = Math.max(this.t - n, 0);
|
|
283
|
-
r.s = this.s;
|
|
284
|
-
}
|
|
285
|
-
function bnpLShiftTo(n, r) {
|
|
286
|
-
var bs = n % this.DB;
|
|
287
|
-
var cbs = this.DB - bs;
|
|
288
|
-
var bm = (1 << cbs) - 1;
|
|
289
|
-
var ds = Math.floor(n / this.DB), c = (this.s << bs) & this.DM, i;
|
|
290
|
-
for (i = this.t - 1; i >= 0; --i) {
|
|
291
|
-
r[i + ds + 1] = (this[i] >> cbs) | c;
|
|
292
|
-
c = (this[i] & bm) << bs;
|
|
293
|
-
}
|
|
294
|
-
for (i = ds - 1; i >= 0; --i)
|
|
295
|
-
r[i] = 0;
|
|
296
|
-
r[ds] = c;
|
|
297
|
-
r.t = this.t + ds + 1;
|
|
298
|
-
r.s = this.s;
|
|
299
|
-
r.clamp();
|
|
300
|
-
}
|
|
301
|
-
function bnpRShiftTo(n, r) {
|
|
302
|
-
r.s = this.s;
|
|
303
|
-
var ds = Math.floor(n / this.DB);
|
|
304
|
-
if (ds >= this.t) {
|
|
305
|
-
r.t = 0;
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
var bs = n % this.DB;
|
|
309
|
-
var cbs = this.DB - bs;
|
|
310
|
-
var bm = (1 << bs) - 1;
|
|
311
|
-
r[0] = this[ds] >> bs;
|
|
312
|
-
for (var i = ds + 1; i < this.t; ++i) {
|
|
313
|
-
r[i - ds - 1] |= (this[i] & bm) << cbs;
|
|
314
|
-
r[i - ds] = this[i] >> bs;
|
|
315
|
-
}
|
|
316
|
-
if (bs > 0)
|
|
317
|
-
r[this.t - ds - 1] |= (this.s & bm) << cbs;
|
|
318
|
-
r.t = this.t - ds;
|
|
319
|
-
r.clamp();
|
|
320
|
-
}
|
|
321
|
-
function bnpSubTo(a, r) {
|
|
322
|
-
var i = 0, c = 0, m = Math.min(a.t, this.t);
|
|
323
|
-
while (i < m) {
|
|
324
|
-
c += this[i] - a[i];
|
|
325
|
-
r[i++] = c & this.DM;
|
|
326
|
-
c >>= this.DB;
|
|
327
|
-
}
|
|
328
|
-
if (a.t < this.t) {
|
|
329
|
-
c -= a.s;
|
|
330
|
-
while (i < this.t) {
|
|
331
|
-
c += this[i];
|
|
332
|
-
r[i++] = c & this.DM;
|
|
333
|
-
c >>= this.DB;
|
|
334
|
-
}
|
|
335
|
-
c += this.s;
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
c += this.s;
|
|
339
|
-
while (i < a.t) {
|
|
340
|
-
c -= a[i];
|
|
341
|
-
r[i++] = c & this.DM;
|
|
342
|
-
c >>= this.DB;
|
|
343
|
-
}
|
|
344
|
-
c -= a.s;
|
|
345
|
-
}
|
|
346
|
-
r.s = (c < 0) ? -1 : 0;
|
|
347
|
-
if (c < -1)
|
|
348
|
-
r[i++] = this.DV + c;
|
|
349
|
-
else if (c > 0)
|
|
350
|
-
r[i++] = c;
|
|
351
|
-
r.t = i;
|
|
352
|
-
r.clamp();
|
|
353
|
-
}
|
|
354
|
-
function bnpMultiplyTo(a, r) {
|
|
355
|
-
var x = this.abs(), y = a.abs();
|
|
356
|
-
var i = x.t;
|
|
357
|
-
r.t = i + y.t;
|
|
358
|
-
while (--i >= 0)
|
|
359
|
-
r[i] = 0;
|
|
360
|
-
for (i = 0; i < y.t; ++i)
|
|
361
|
-
r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
|
|
362
|
-
r.s = 0;
|
|
363
|
-
r.clamp();
|
|
364
|
-
if (this.s != a.s)
|
|
365
|
-
BigInteger.ZERO.subTo(r, r);
|
|
366
|
-
}
|
|
367
|
-
function bnpSquareTo(r) {
|
|
368
|
-
var x = this.abs();
|
|
369
|
-
var i = r.t = 2 * x.t;
|
|
370
|
-
while (--i >= 0)
|
|
371
|
-
r[i] = 0;
|
|
372
|
-
for (i = 0; i < x.t - 1; ++i) {
|
|
373
|
-
var c = x.am(i, x[i], r, 2 * i, 0, 1);
|
|
374
|
-
if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
|
|
375
|
-
r[i + x.t] -= x.DV;
|
|
376
|
-
r[i + x.t + 1] = 1;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
if (r.t > 0)
|
|
380
|
-
r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
|
|
381
|
-
r.s = 0;
|
|
382
|
-
r.clamp();
|
|
383
|
-
}
|
|
384
|
-
function bnpDivRemTo(m, q, r) {
|
|
385
|
-
var pm = m.abs();
|
|
386
|
-
if (pm.t <= 0)
|
|
387
|
-
return;
|
|
388
|
-
var pt = this.abs();
|
|
389
|
-
if (pt.t < pm.t) {
|
|
390
|
-
if (q != null)
|
|
391
|
-
q.fromInt(0);
|
|
392
|
-
if (r != null)
|
|
393
|
-
this.copyTo(r);
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
if (r == null)
|
|
397
|
-
r = nbi();
|
|
398
|
-
var y = nbi(), ts = this.s, ms = m.s;
|
|
399
|
-
var nsh = this.DB - nbits(pm[pm.t - 1]);
|
|
400
|
-
if (nsh > 0) {
|
|
401
|
-
pm.lShiftTo(nsh, y);
|
|
402
|
-
pt.lShiftTo(nsh, r);
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
pm.copyTo(y);
|
|
406
|
-
pt.copyTo(r);
|
|
407
|
-
}
|
|
408
|
-
var ys = y.t;
|
|
409
|
-
var y0 = y[ys - 1];
|
|
410
|
-
if (y0 === 0)
|
|
411
|
-
return;
|
|
412
|
-
var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
|
|
413
|
-
var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
|
|
414
|
-
var i = r.t, j = i - ys, t = (q == null) ? nbi() : q;
|
|
415
|
-
y.dlShiftTo(j, t);
|
|
416
|
-
if (r.compareTo(t) >= 0) {
|
|
417
|
-
r[r.t++] = 1;
|
|
418
|
-
r.subTo(t, r);
|
|
419
|
-
}
|
|
420
|
-
BigInteger.ONE.dlShiftTo(ys, t);
|
|
421
|
-
t.subTo(y, y);
|
|
422
|
-
while (y.t < ys)
|
|
423
|
-
y[y.t++] = 0;
|
|
424
|
-
while (--j >= 0) {
|
|
425
|
-
var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
|
|
426
|
-
if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {
|
|
427
|
-
y.dlShiftTo(j, t);
|
|
428
|
-
r.subTo(t, r);
|
|
429
|
-
while (r[i] < --qd)
|
|
430
|
-
r.subTo(t, r);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
if (q != null) {
|
|
434
|
-
r.drShiftTo(ys, q);
|
|
435
|
-
if (ts != ms)
|
|
436
|
-
BigInteger.ZERO.subTo(q, q);
|
|
437
|
-
}
|
|
438
|
-
r.t = ys;
|
|
439
|
-
r.clamp();
|
|
440
|
-
if (nsh > 0)
|
|
441
|
-
r.rShiftTo(nsh, r);
|
|
442
|
-
if (ts < 0)
|
|
443
|
-
BigInteger.ZERO.subTo(r, r);
|
|
444
|
-
}
|
|
445
|
-
function bnMod(a) {
|
|
446
|
-
var r = nbi();
|
|
447
|
-
this.abs().divRemTo(a, null, r);
|
|
448
|
-
if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0)
|
|
449
|
-
a.subTo(r, r);
|
|
450
|
-
return r;
|
|
451
|
-
}
|
|
452
|
-
function Classic(m) {
|
|
453
|
-
this.m = m;
|
|
454
|
-
}
|
|
455
|
-
function cConvert(x) {
|
|
456
|
-
if (x.s < 0 || x.compareTo(this.m) >= 0)
|
|
457
|
-
return x.mod(this.m);
|
|
458
|
-
else
|
|
459
|
-
return x;
|
|
460
|
-
}
|
|
461
|
-
function cRevert(x) {
|
|
462
|
-
return x;
|
|
463
|
-
}
|
|
464
|
-
function cReduce(x) {
|
|
465
|
-
x.divRemTo(this.m, null, x);
|
|
466
|
-
}
|
|
467
|
-
function cMulTo(x, y, r) {
|
|
468
|
-
x.multiplyTo(y, r);
|
|
469
|
-
this.reduce(r);
|
|
470
|
-
}
|
|
471
|
-
function cSqrTo(x, r) {
|
|
472
|
-
x.squareTo(r);
|
|
473
|
-
this.reduce(r);
|
|
474
|
-
}
|
|
475
|
-
Classic.prototype.convert = cConvert;
|
|
476
|
-
Classic.prototype.revert = cRevert;
|
|
477
|
-
Classic.prototype.reduce = cReduce;
|
|
478
|
-
Classic.prototype.mulTo = cMulTo;
|
|
479
|
-
Classic.prototype.sqrTo = cSqrTo;
|
|
480
|
-
function bnpInvDigit() {
|
|
481
|
-
if (this.t < 1)
|
|
482
|
-
return 0;
|
|
483
|
-
var x = this[0];
|
|
484
|
-
if ((x & 1) === 0)
|
|
485
|
-
return 0;
|
|
486
|
-
var y = x & 3;
|
|
487
|
-
y = (y * (2 - (x & 0xf) * y)) & 0xf;
|
|
488
|
-
y = (y * (2 - (x & 0xff) * y)) & 0xff;
|
|
489
|
-
y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff;
|
|
490
|
-
y = (y * (2 - x * y % this.DV)) % this.DV;
|
|
491
|
-
return (y > 0) ? this.DV - y : -y;
|
|
492
|
-
}
|
|
493
|
-
function Montgomery(m) {
|
|
494
|
-
this.m = m;
|
|
495
|
-
this.mp = m.invDigit();
|
|
496
|
-
this.mpl = this.mp & 0x7fff;
|
|
497
|
-
this.mph = this.mp >> 15;
|
|
498
|
-
this.um = (1 << (m.DB - 15)) - 1;
|
|
499
|
-
this.mt2 = 2 * m.t;
|
|
500
|
-
}
|
|
501
|
-
function montConvert(x) {
|
|
502
|
-
var r = nbi();
|
|
503
|
-
x.abs().dlShiftTo(this.m.t, r);
|
|
504
|
-
r.divRemTo(this.m, null, r);
|
|
505
|
-
if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0)
|
|
506
|
-
this.m.subTo(r, r);
|
|
507
|
-
return r;
|
|
508
|
-
}
|
|
509
|
-
function montRevert(x) {
|
|
510
|
-
var r = nbi();
|
|
511
|
-
x.copyTo(r);
|
|
512
|
-
this.reduce(r);
|
|
513
|
-
return r;
|
|
514
|
-
}
|
|
515
|
-
function montReduce(x) {
|
|
516
|
-
while (x.t <= this.mt2)
|
|
517
|
-
x[x.t++] = 0;
|
|
518
|
-
for (var i = 0; i < this.m.t; ++i) {
|
|
519
|
-
var j = x[i] & 0x7fff;
|
|
520
|
-
var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
|
|
521
|
-
j = i + this.m.t;
|
|
522
|
-
x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
|
|
523
|
-
while (x[j] >= x.DV) {
|
|
524
|
-
x[j] -= x.DV;
|
|
525
|
-
x[++j]++;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
x.clamp();
|
|
529
|
-
x.drShiftTo(this.m.t, x);
|
|
530
|
-
if (x.compareTo(this.m) >= 0)
|
|
531
|
-
x.subTo(this.m, x);
|
|
532
|
-
}
|
|
533
|
-
function montSqrTo(x, r) {
|
|
534
|
-
x.squareTo(r);
|
|
535
|
-
this.reduce(r);
|
|
536
|
-
}
|
|
537
|
-
function montMulTo(x, y, r) {
|
|
538
|
-
x.multiplyTo(y, r);
|
|
539
|
-
this.reduce(r);
|
|
540
|
-
}
|
|
541
|
-
Montgomery.prototype.convert = montConvert;
|
|
542
|
-
Montgomery.prototype.revert = montRevert;
|
|
543
|
-
Montgomery.prototype.reduce = montReduce;
|
|
544
|
-
Montgomery.prototype.mulTo = montMulTo;
|
|
545
|
-
Montgomery.prototype.sqrTo = montSqrTo;
|
|
546
|
-
function bnpIsEven() {
|
|
547
|
-
return ((this.t > 0) ? (this[0] & 1) : this.s) === 0;
|
|
548
|
-
}
|
|
549
|
-
function bnpExp(e, z) {
|
|
550
|
-
if (e > 0xffffffff || e < 1)
|
|
551
|
-
return BigInteger.ONE;
|
|
552
|
-
var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;
|
|
553
|
-
g.copyTo(r);
|
|
554
|
-
while (--i >= 0) {
|
|
555
|
-
z.sqrTo(r, r2);
|
|
556
|
-
if ((e & (1 << i)) > 0)
|
|
557
|
-
z.mulTo(r2, g, r);
|
|
558
|
-
else {
|
|
559
|
-
var t = r;
|
|
560
|
-
r = r2;
|
|
561
|
-
r2 = t;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
return z.revert(r);
|
|
565
|
-
}
|
|
566
|
-
function bnModPowInt(e, m) {
|
|
567
|
-
var z;
|
|
568
|
-
if (e < 256 || m.isEven())
|
|
569
|
-
z = new Classic(m);
|
|
570
|
-
else
|
|
571
|
-
z = new Montgomery(m);
|
|
572
|
-
return this.exp(e, z);
|
|
573
|
-
}
|
|
574
|
-
function bnClone() {
|
|
575
|
-
var r = nbi();
|
|
576
|
-
this.copyTo(r);
|
|
577
|
-
return r;
|
|
578
|
-
}
|
|
579
|
-
function bnIntValue() {
|
|
580
|
-
if (this.s < 0) {
|
|
581
|
-
if (this.t == 1)
|
|
582
|
-
return this[0] - this.DV;
|
|
583
|
-
else if (this.t === 0)
|
|
584
|
-
return -1;
|
|
585
|
-
}
|
|
586
|
-
else if (this.t == 1)
|
|
587
|
-
return this[0];
|
|
588
|
-
else if (this.t === 0)
|
|
589
|
-
return 0;
|
|
590
|
-
return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
|
|
591
|
-
}
|
|
592
|
-
function bnByteValue() {
|
|
593
|
-
return (this.t == 0) ? this.s : (this[0] << 24) >> 24;
|
|
594
|
-
}
|
|
595
|
-
function bnShortValue() {
|
|
596
|
-
return (this.t == 0) ? this.s : (this[0] << 16) >> 16;
|
|
597
|
-
}
|
|
598
|
-
function bnpChunkSize(r) {
|
|
599
|
-
return Math.floor(Math.LN2 * this.DB / Math.log(r));
|
|
600
|
-
}
|
|
601
|
-
function bnSigNum() {
|
|
602
|
-
if (this.s < 0)
|
|
603
|
-
return -1;
|
|
604
|
-
else if (this.t <= 0 || (this.t == 1 && this[0] <= 0))
|
|
605
|
-
return 0;
|
|
606
|
-
else
|
|
607
|
-
return 1;
|
|
608
|
-
}
|
|
609
|
-
function bnpToRadix(b) {
|
|
610
|
-
if (b == null)
|
|
611
|
-
b = 10;
|
|
612
|
-
if (this.signum() === 0 || b < 2 || b > 36)
|
|
613
|
-
return "0";
|
|
614
|
-
var cs = this.chunkSize(b);
|
|
615
|
-
var a = Math.pow(b, cs);
|
|
616
|
-
var d = nbv(a), y = nbi(), z = nbi(), r = "";
|
|
617
|
-
this.divRemTo(d, y, z);
|
|
618
|
-
while (y.signum() > 0) {
|
|
619
|
-
r = (a + z.intValue()).toString(b).substr(1) + r;
|
|
620
|
-
y.divRemTo(d, y, z);
|
|
621
|
-
}
|
|
622
|
-
return z.intValue().toString(b) + r;
|
|
623
|
-
}
|
|
624
|
-
function bnpFromRadix(s, b) {
|
|
625
|
-
this.fromInt(0);
|
|
626
|
-
if (b == null)
|
|
627
|
-
b = 10;
|
|
628
|
-
var cs = this.chunkSize(b);
|
|
629
|
-
var d = Math.pow(b, cs), mi = false, j = 0, w = 0;
|
|
630
|
-
for (var i = 0; i < s.length; ++i) {
|
|
631
|
-
var x = intAt(s, i);
|
|
632
|
-
if (x < 0) {
|
|
633
|
-
if (s.charAt(i) == "-" && this.signum() === 0)
|
|
634
|
-
mi = true;
|
|
635
|
-
continue;
|
|
636
|
-
}
|
|
637
|
-
w = b * w + x;
|
|
638
|
-
if (++j >= cs) {
|
|
639
|
-
this.dMultiply(d);
|
|
640
|
-
this.dAddOffset(w, 0);
|
|
641
|
-
j = 0;
|
|
642
|
-
w = 0;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
if (j > 0) {
|
|
646
|
-
this.dMultiply(Math.pow(b, j));
|
|
647
|
-
this.dAddOffset(w, 0);
|
|
648
|
-
}
|
|
649
|
-
if (mi)
|
|
650
|
-
BigInteger.ZERO.subTo(this, this);
|
|
651
|
-
}
|
|
652
|
-
function bnpFromNumber(a, b) {
|
|
653
|
-
if ("number" == typeof b) {
|
|
654
|
-
if (a < 2)
|
|
655
|
-
this.fromInt(1);
|
|
656
|
-
else {
|
|
657
|
-
this.fromNumber(a);
|
|
658
|
-
if (!this.testBit(a - 1))
|
|
659
|
-
this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
|
|
660
|
-
if (this.isEven())
|
|
661
|
-
this.dAddOffset(1, 0);
|
|
662
|
-
while (!this.isProbablePrime(b)) {
|
|
663
|
-
this.dAddOffset(2, 0);
|
|
664
|
-
if (this.bitLength() > a)
|
|
665
|
-
this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
var x = crypt.randomBytes((a >> 3) + 1);
|
|
671
|
-
var t = a & 7;
|
|
672
|
-
if (t > 0)
|
|
673
|
-
x[0] &= ((1 << t) - 1);
|
|
674
|
-
else
|
|
675
|
-
x[0] = 0;
|
|
676
|
-
this.fromByteArray(x);
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
function bnToByteArray() {
|
|
680
|
-
var i = this.t, r = new Array();
|
|
681
|
-
r[0] = this.s;
|
|
682
|
-
var p = this.DB - (i * this.DB) % 8, d, k = 0;
|
|
683
|
-
if (i-- > 0) {
|
|
684
|
-
if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)
|
|
685
|
-
r[k++] = d | (this.s << (this.DB - p));
|
|
686
|
-
while (i >= 0) {
|
|
687
|
-
if (p < 8) {
|
|
688
|
-
d = (this[i] & ((1 << p) - 1)) << (8 - p);
|
|
689
|
-
d |= this[--i] >> (p += this.DB - 8);
|
|
690
|
-
}
|
|
691
|
-
else {
|
|
692
|
-
d = (this[i] >> (p -= 8)) & 0xff;
|
|
693
|
-
if (p <= 0) {
|
|
694
|
-
p += this.DB;
|
|
695
|
-
--i;
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
if ((d & 0x80) != 0)
|
|
699
|
-
d |= -256;
|
|
700
|
-
if (k === 0 && (this.s & 0x80) != (d & 0x80))
|
|
701
|
-
++k;
|
|
702
|
-
if (k > 0 || d != this.s)
|
|
703
|
-
r[k++] = d;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
return r;
|
|
707
|
-
}
|
|
708
|
-
function bnToBuffer(trimOrSize) {
|
|
709
|
-
var res = Buffer.from(this.toByteArray());
|
|
710
|
-
if (trimOrSize === true && res[0] === 0) {
|
|
711
|
-
res = res.slice(1);
|
|
712
|
-
}
|
|
713
|
-
else if (isNumber(trimOrSize)) {
|
|
714
|
-
if (res.length > trimOrSize) {
|
|
715
|
-
for (var i = 0; i < res.length - trimOrSize; i++) {
|
|
716
|
-
if (res[i] !== 0) {
|
|
717
|
-
return null;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
return res.slice(res.length - trimOrSize);
|
|
721
|
-
}
|
|
722
|
-
else if (res.length < trimOrSize) {
|
|
723
|
-
var padded = Buffer.alloc(trimOrSize);
|
|
724
|
-
padded.fill(0, 0, trimOrSize - res.length);
|
|
725
|
-
res.copy(padded, trimOrSize - res.length);
|
|
726
|
-
return padded;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
return res;
|
|
730
|
-
}
|
|
731
|
-
function bnEquals(a) {
|
|
732
|
-
return (this.compareTo(a) == 0);
|
|
733
|
-
}
|
|
734
|
-
function bnMin(a) {
|
|
735
|
-
return (this.compareTo(a) < 0) ? this : a;
|
|
736
|
-
}
|
|
737
|
-
function bnMax(a) {
|
|
738
|
-
return (this.compareTo(a) > 0) ? this : a;
|
|
739
|
-
}
|
|
740
|
-
function bnpBitwiseTo(a, op, r) {
|
|
741
|
-
var i, f, m = Math.min(a.t, this.t);
|
|
742
|
-
for (i = 0; i < m; ++i)
|
|
743
|
-
r[i] = op(this[i], a[i]);
|
|
744
|
-
if (a.t < this.t) {
|
|
745
|
-
f = a.s & this.DM;
|
|
746
|
-
for (i = m; i < this.t; ++i)
|
|
747
|
-
r[i] = op(this[i], f);
|
|
748
|
-
r.t = this.t;
|
|
749
|
-
}
|
|
750
|
-
else {
|
|
751
|
-
f = this.s & this.DM;
|
|
752
|
-
for (i = m; i < a.t; ++i)
|
|
753
|
-
r[i] = op(f, a[i]);
|
|
754
|
-
r.t = a.t;
|
|
755
|
-
}
|
|
756
|
-
r.s = op(this.s, a.s);
|
|
757
|
-
r.clamp();
|
|
758
|
-
}
|
|
759
|
-
function op_and(x, y) {
|
|
760
|
-
return x & y;
|
|
761
|
-
}
|
|
762
|
-
function bnAnd(a) {
|
|
763
|
-
var r = nbi();
|
|
764
|
-
this.bitwiseTo(a, op_and, r);
|
|
765
|
-
return r;
|
|
766
|
-
}
|
|
767
|
-
function op_or(x, y) {
|
|
768
|
-
return x | y;
|
|
769
|
-
}
|
|
770
|
-
function bnOr(a) {
|
|
771
|
-
var r = nbi();
|
|
772
|
-
this.bitwiseTo(a, op_or, r);
|
|
773
|
-
return r;
|
|
774
|
-
}
|
|
775
|
-
function op_xor(x, y) {
|
|
776
|
-
return x ^ y;
|
|
777
|
-
}
|
|
778
|
-
function bnXor(a) {
|
|
779
|
-
var r = nbi();
|
|
780
|
-
this.bitwiseTo(a, op_xor, r);
|
|
781
|
-
return r;
|
|
782
|
-
}
|
|
783
|
-
function op_andnot(x, y) {
|
|
784
|
-
return x & ~y;
|
|
785
|
-
}
|
|
786
|
-
function bnAndNot(a) {
|
|
787
|
-
var r = nbi();
|
|
788
|
-
this.bitwiseTo(a, op_andnot, r);
|
|
789
|
-
return r;
|
|
790
|
-
}
|
|
791
|
-
function bnNot() {
|
|
792
|
-
var r = nbi();
|
|
793
|
-
for (var i = 0; i < this.t; ++i)
|
|
794
|
-
r[i] = this.DM & ~this[i];
|
|
795
|
-
r.t = this.t;
|
|
796
|
-
r.s = ~this.s;
|
|
797
|
-
return r;
|
|
798
|
-
}
|
|
799
|
-
function bnShiftLeft(n) {
|
|
800
|
-
var r = nbi();
|
|
801
|
-
if (n < 0)
|
|
802
|
-
this.rShiftTo(-n, r);
|
|
803
|
-
else
|
|
804
|
-
this.lShiftTo(n, r);
|
|
805
|
-
return r;
|
|
806
|
-
}
|
|
807
|
-
function bnShiftRight(n) {
|
|
808
|
-
var r = nbi();
|
|
809
|
-
if (n < 0)
|
|
810
|
-
this.lShiftTo(-n, r);
|
|
811
|
-
else
|
|
812
|
-
this.rShiftTo(n, r);
|
|
813
|
-
return r;
|
|
814
|
-
}
|
|
815
|
-
function lbit(x) {
|
|
816
|
-
if (x === 0)
|
|
817
|
-
return -1;
|
|
818
|
-
var r = 0;
|
|
819
|
-
if ((x & 0xffff) === 0) {
|
|
820
|
-
x >>= 16;
|
|
821
|
-
r += 16;
|
|
822
|
-
}
|
|
823
|
-
if ((x & 0xff) === 0) {
|
|
824
|
-
x >>= 8;
|
|
825
|
-
r += 8;
|
|
826
|
-
}
|
|
827
|
-
if ((x & 0xf) === 0) {
|
|
828
|
-
x >>= 4;
|
|
829
|
-
r += 4;
|
|
830
|
-
}
|
|
831
|
-
if ((x & 3) === 0) {
|
|
832
|
-
x >>= 2;
|
|
833
|
-
r += 2;
|
|
834
|
-
}
|
|
835
|
-
if ((x & 1) === 0)
|
|
836
|
-
++r;
|
|
837
|
-
return r;
|
|
838
|
-
}
|
|
839
|
-
function bnGetLowestSetBit() {
|
|
840
|
-
for (var i = 0; i < this.t; ++i)
|
|
841
|
-
if (this[i] != 0)
|
|
842
|
-
return i * this.DB + lbit(this[i]);
|
|
843
|
-
if (this.s < 0)
|
|
844
|
-
return this.t * this.DB;
|
|
845
|
-
return -1;
|
|
846
|
-
}
|
|
847
|
-
function cbit(x) {
|
|
848
|
-
var r = 0;
|
|
849
|
-
while (x != 0) {
|
|
850
|
-
x &= x - 1;
|
|
851
|
-
++r;
|
|
852
|
-
}
|
|
853
|
-
return r;
|
|
854
|
-
}
|
|
855
|
-
function bnBitCount() {
|
|
856
|
-
var r = 0, x = this.s & this.DM;
|
|
857
|
-
for (var i = 0; i < this.t; ++i)
|
|
858
|
-
r += cbit(this[i] ^ x);
|
|
859
|
-
return r;
|
|
860
|
-
}
|
|
861
|
-
function bnTestBit(n) {
|
|
862
|
-
var j = Math.floor(n / this.DB);
|
|
863
|
-
if (j >= this.t)
|
|
864
|
-
return (this.s != 0);
|
|
865
|
-
return ((this[j] & (1 << (n % this.DB))) != 0);
|
|
866
|
-
}
|
|
867
|
-
function bnpChangeBit(n, op) {
|
|
868
|
-
var r = BigInteger.ONE.shiftLeft(n);
|
|
869
|
-
this.bitwiseTo(r, op, r);
|
|
870
|
-
return r;
|
|
871
|
-
}
|
|
872
|
-
function bnSetBit(n) {
|
|
873
|
-
return this.changeBit(n, op_or);
|
|
874
|
-
}
|
|
875
|
-
function bnClearBit(n) {
|
|
876
|
-
return this.changeBit(n, op_andnot);
|
|
877
|
-
}
|
|
878
|
-
function bnFlipBit(n) {
|
|
879
|
-
return this.changeBit(n, op_xor);
|
|
880
|
-
}
|
|
881
|
-
function bnpAddTo(a, r) {
|
|
882
|
-
var i = 0, c = 0, m = Math.min(a.t, this.t);
|
|
883
|
-
while (i < m) {
|
|
884
|
-
c += this[i] + a[i];
|
|
885
|
-
r[i++] = c & this.DM;
|
|
886
|
-
c >>= this.DB;
|
|
887
|
-
}
|
|
888
|
-
if (a.t < this.t) {
|
|
889
|
-
c += a.s;
|
|
890
|
-
while (i < this.t) {
|
|
891
|
-
c += this[i];
|
|
892
|
-
r[i++] = c & this.DM;
|
|
893
|
-
c >>= this.DB;
|
|
894
|
-
}
|
|
895
|
-
c += this.s;
|
|
896
|
-
}
|
|
897
|
-
else {
|
|
898
|
-
c += this.s;
|
|
899
|
-
while (i < a.t) {
|
|
900
|
-
c += a[i];
|
|
901
|
-
r[i++] = c & this.DM;
|
|
902
|
-
c >>= this.DB;
|
|
903
|
-
}
|
|
904
|
-
c += a.s;
|
|
905
|
-
}
|
|
906
|
-
r.s = (c < 0) ? -1 : 0;
|
|
907
|
-
if (c > 0)
|
|
908
|
-
r[i++] = c;
|
|
909
|
-
else if (c < -1)
|
|
910
|
-
r[i++] = this.DV + c;
|
|
911
|
-
r.t = i;
|
|
912
|
-
r.clamp();
|
|
913
|
-
}
|
|
914
|
-
function bnAdd(a) {
|
|
915
|
-
var r = nbi();
|
|
916
|
-
this.addTo(a, r);
|
|
917
|
-
return r;
|
|
918
|
-
}
|
|
919
|
-
function bnSubtract(a) {
|
|
920
|
-
var r = nbi();
|
|
921
|
-
this.subTo(a, r);
|
|
922
|
-
return r;
|
|
923
|
-
}
|
|
924
|
-
function bnMultiply(a) {
|
|
925
|
-
var r = nbi();
|
|
926
|
-
this.multiplyTo(a, r);
|
|
927
|
-
return r;
|
|
928
|
-
}
|
|
929
|
-
function bnSquare() {
|
|
930
|
-
var r = nbi();
|
|
931
|
-
this.squareTo(r);
|
|
932
|
-
return r;
|
|
933
|
-
}
|
|
934
|
-
function bnDivide(a) {
|
|
935
|
-
var r = nbi();
|
|
936
|
-
this.divRemTo(a, r, null);
|
|
937
|
-
return r;
|
|
938
|
-
}
|
|
939
|
-
function bnRemainder(a) {
|
|
940
|
-
var r = nbi();
|
|
941
|
-
this.divRemTo(a, null, r);
|
|
942
|
-
return r;
|
|
943
|
-
}
|
|
944
|
-
function bnDivideAndRemainder(a) {
|
|
945
|
-
var q = nbi(), r = nbi();
|
|
946
|
-
this.divRemTo(a, q, r);
|
|
947
|
-
return new Array(q, r);
|
|
948
|
-
}
|
|
949
|
-
function bnpDMultiply(n) {
|
|
950
|
-
this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
|
|
951
|
-
++this.t;
|
|
952
|
-
this.clamp();
|
|
953
|
-
}
|
|
954
|
-
function bnpDAddOffset(n, w) {
|
|
955
|
-
if (n === 0)
|
|
956
|
-
return;
|
|
957
|
-
while (this.t <= w)
|
|
958
|
-
this[this.t++] = 0;
|
|
959
|
-
this[w] += n;
|
|
960
|
-
while (this[w] >= this.DV) {
|
|
961
|
-
this[w] -= this.DV;
|
|
962
|
-
if (++w >= this.t)
|
|
963
|
-
this[this.t++] = 0;
|
|
964
|
-
++this[w];
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
function NullExp() {
|
|
968
|
-
}
|
|
969
|
-
function nNop(x) {
|
|
970
|
-
return x;
|
|
971
|
-
}
|
|
972
|
-
function nMulTo(x, y, r) {
|
|
973
|
-
x.multiplyTo(y, r);
|
|
974
|
-
}
|
|
975
|
-
function nSqrTo(x, r) {
|
|
976
|
-
x.squareTo(r);
|
|
977
|
-
}
|
|
978
|
-
NullExp.prototype.convert = nNop;
|
|
979
|
-
NullExp.prototype.revert = nNop;
|
|
980
|
-
NullExp.prototype.mulTo = nMulTo;
|
|
981
|
-
NullExp.prototype.sqrTo = nSqrTo;
|
|
982
|
-
function bnPow(e) {
|
|
983
|
-
return this.exp(e, new NullExp());
|
|
984
|
-
}
|
|
985
|
-
function bnpMultiplyLowerTo(a, n, r) {
|
|
986
|
-
var i = Math.min(this.t + a.t, n);
|
|
987
|
-
r.s = 0;
|
|
988
|
-
r.t = i;
|
|
989
|
-
while (i > 0)
|
|
990
|
-
r[--i] = 0;
|
|
991
|
-
var j;
|
|
992
|
-
for (j = r.t - this.t; i < j; ++i)
|
|
993
|
-
r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
|
|
994
|
-
for (j = Math.min(a.t, n); i < j; ++i)
|
|
995
|
-
this.am(0, a[i], r, i, 0, n - i);
|
|
996
|
-
r.clamp();
|
|
997
|
-
}
|
|
998
|
-
function bnpMultiplyUpperTo(a, n, r) {
|
|
999
|
-
--n;
|
|
1000
|
-
var i = r.t = this.t + a.t - n;
|
|
1001
|
-
r.s = 0;
|
|
1002
|
-
while (--i >= 0)
|
|
1003
|
-
r[i] = 0;
|
|
1004
|
-
for (i = Math.max(n - this.t, 0); i < a.t; ++i)
|
|
1005
|
-
r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
|
|
1006
|
-
r.clamp();
|
|
1007
|
-
r.drShiftTo(1, r);
|
|
1008
|
-
}
|
|
1009
|
-
function Barrett(m) {
|
|
1010
|
-
this.r2 = nbi();
|
|
1011
|
-
this.q3 = nbi();
|
|
1012
|
-
BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
|
|
1013
|
-
this.mu = this.r2.divide(m);
|
|
1014
|
-
this.m = m;
|
|
1015
|
-
}
|
|
1016
|
-
function barrettConvert(x) {
|
|
1017
|
-
if (x.s < 0 || x.t > 2 * this.m.t)
|
|
1018
|
-
return x.mod(this.m);
|
|
1019
|
-
else if (x.compareTo(this.m) < 0)
|
|
1020
|
-
return x;
|
|
1021
|
-
else {
|
|
1022
|
-
var r = nbi();
|
|
1023
|
-
x.copyTo(r);
|
|
1024
|
-
this.reduce(r);
|
|
1025
|
-
return r;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
function barrettRevert(x) {
|
|
1029
|
-
return x;
|
|
1030
|
-
}
|
|
1031
|
-
function barrettReduce(x) {
|
|
1032
|
-
x.drShiftTo(this.m.t - 1, this.r2);
|
|
1033
|
-
if (x.t > this.m.t + 1) {
|
|
1034
|
-
x.t = this.m.t + 1;
|
|
1035
|
-
x.clamp();
|
|
1036
|
-
}
|
|
1037
|
-
this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
|
|
1038
|
-
this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
|
|
1039
|
-
while (x.compareTo(this.r2) < 0)
|
|
1040
|
-
x.dAddOffset(1, this.m.t + 1);
|
|
1041
|
-
x.subTo(this.r2, x);
|
|
1042
|
-
while (x.compareTo(this.m) >= 0)
|
|
1043
|
-
x.subTo(this.m, x);
|
|
1044
|
-
}
|
|
1045
|
-
function barrettSqrTo(x, r) {
|
|
1046
|
-
x.squareTo(r);
|
|
1047
|
-
this.reduce(r);
|
|
1048
|
-
}
|
|
1049
|
-
function barrettMulTo(x, y, r) {
|
|
1050
|
-
x.multiplyTo(y, r);
|
|
1051
|
-
this.reduce(r);
|
|
1052
|
-
}
|
|
1053
|
-
Barrett.prototype.convert = barrettConvert;
|
|
1054
|
-
Barrett.prototype.revert = barrettRevert;
|
|
1055
|
-
Barrett.prototype.reduce = barrettReduce;
|
|
1056
|
-
Barrett.prototype.mulTo = barrettMulTo;
|
|
1057
|
-
Barrett.prototype.sqrTo = barrettSqrTo;
|
|
1058
|
-
function bnModPow(e, m) {
|
|
1059
|
-
var i = e.bitLength(), k, r = nbv(1), z;
|
|
1060
|
-
if (i <= 0)
|
|
1061
|
-
return r;
|
|
1062
|
-
else if (i < 18)
|
|
1063
|
-
k = 1;
|
|
1064
|
-
else if (i < 48)
|
|
1065
|
-
k = 3;
|
|
1066
|
-
else if (i < 144)
|
|
1067
|
-
k = 4;
|
|
1068
|
-
else if (i < 768)
|
|
1069
|
-
k = 5;
|
|
1070
|
-
else
|
|
1071
|
-
k = 6;
|
|
1072
|
-
if (i < 8)
|
|
1073
|
-
z = new Classic(m);
|
|
1074
|
-
else if (m.isEven())
|
|
1075
|
-
z = new Barrett(m);
|
|
1076
|
-
else
|
|
1077
|
-
z = new Montgomery(m);
|
|
1078
|
-
var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;
|
|
1079
|
-
g[1] = z.convert(this);
|
|
1080
|
-
if (k > 1) {
|
|
1081
|
-
var g2 = nbi();
|
|
1082
|
-
z.sqrTo(g[1], g2);
|
|
1083
|
-
while (n <= km) {
|
|
1084
|
-
g[n] = nbi();
|
|
1085
|
-
z.mulTo(g2, g[n - 2], g[n]);
|
|
1086
|
-
n += 2;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
var j = e.t - 1, w, is1 = true, r2 = nbi(), t;
|
|
1090
|
-
i = nbits(e[j]) - 1;
|
|
1091
|
-
while (j >= 0) {
|
|
1092
|
-
if (i >= k1)
|
|
1093
|
-
w = (e[j] >> (i - k1)) & km;
|
|
1094
|
-
else {
|
|
1095
|
-
w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
|
|
1096
|
-
if (j > 0)
|
|
1097
|
-
w |= e[j - 1] >> (this.DB + i - k1);
|
|
1098
|
-
}
|
|
1099
|
-
n = k;
|
|
1100
|
-
while ((w & 1) === 0) {
|
|
1101
|
-
w >>= 1;
|
|
1102
|
-
--n;
|
|
1103
|
-
}
|
|
1104
|
-
if ((i -= n) < 0) {
|
|
1105
|
-
i += this.DB;
|
|
1106
|
-
--j;
|
|
1107
|
-
}
|
|
1108
|
-
if (is1) {
|
|
1109
|
-
g[w].copyTo(r);
|
|
1110
|
-
is1 = false;
|
|
1111
|
-
}
|
|
1112
|
-
else {
|
|
1113
|
-
while (n > 1) {
|
|
1114
|
-
z.sqrTo(r, r2);
|
|
1115
|
-
z.sqrTo(r2, r);
|
|
1116
|
-
n -= 2;
|
|
1117
|
-
}
|
|
1118
|
-
if (n > 0)
|
|
1119
|
-
z.sqrTo(r, r2);
|
|
1120
|
-
else {
|
|
1121
|
-
t = r;
|
|
1122
|
-
r = r2;
|
|
1123
|
-
r2 = t;
|
|
1124
|
-
}
|
|
1125
|
-
z.mulTo(r2, g[w], r);
|
|
1126
|
-
}
|
|
1127
|
-
while (j >= 0 && (e[j] & (1 << i)) === 0) {
|
|
1128
|
-
z.sqrTo(r, r2);
|
|
1129
|
-
t = r;
|
|
1130
|
-
r = r2;
|
|
1131
|
-
r2 = t;
|
|
1132
|
-
if (--i < 0) {
|
|
1133
|
-
i = this.DB - 1;
|
|
1134
|
-
--j;
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
return z.revert(r);
|
|
1139
|
-
}
|
|
1140
|
-
function bnGCD(a) {
|
|
1141
|
-
var x = (this.s < 0) ? this.negate() : this.clone();
|
|
1142
|
-
var y = (a.s < 0) ? a.negate() : a.clone();
|
|
1143
|
-
if (x.compareTo(y) < 0) {
|
|
1144
|
-
var t = x;
|
|
1145
|
-
x = y;
|
|
1146
|
-
y = t;
|
|
1147
|
-
}
|
|
1148
|
-
var i = x.getLowestSetBit(), g = y.getLowestSetBit();
|
|
1149
|
-
if (g < 0)
|
|
1150
|
-
return x;
|
|
1151
|
-
if (i < g)
|
|
1152
|
-
g = i;
|
|
1153
|
-
if (g > 0) {
|
|
1154
|
-
x.rShiftTo(g, x);
|
|
1155
|
-
y.rShiftTo(g, y);
|
|
1156
|
-
}
|
|
1157
|
-
while (x.signum() > 0) {
|
|
1158
|
-
if ((i = x.getLowestSetBit()) > 0)
|
|
1159
|
-
x.rShiftTo(i, x);
|
|
1160
|
-
if ((i = y.getLowestSetBit()) > 0)
|
|
1161
|
-
y.rShiftTo(i, y);
|
|
1162
|
-
if (x.compareTo(y) >= 0) {
|
|
1163
|
-
x.subTo(y, x);
|
|
1164
|
-
x.rShiftTo(1, x);
|
|
1165
|
-
}
|
|
1166
|
-
else {
|
|
1167
|
-
y.subTo(x, y);
|
|
1168
|
-
y.rShiftTo(1, y);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
if (g > 0)
|
|
1172
|
-
y.lShiftTo(g, y);
|
|
1173
|
-
return y;
|
|
1174
|
-
}
|
|
1175
|
-
function bnpModInt(n) {
|
|
1176
|
-
if (n <= 0)
|
|
1177
|
-
return 0;
|
|
1178
|
-
var d = this.DV % n, r = (this.s < 0) ? n - 1 : 0;
|
|
1179
|
-
if (this.t > 0)
|
|
1180
|
-
if (d === 0)
|
|
1181
|
-
r = this[0] % n;
|
|
1182
|
-
else
|
|
1183
|
-
for (var i = this.t - 1; i >= 0; --i)
|
|
1184
|
-
r = (d * r + this[i]) % n;
|
|
1185
|
-
return r;
|
|
1186
|
-
}
|
|
1187
|
-
function bnModInverse(m) {
|
|
1188
|
-
var ac = m.isEven();
|
|
1189
|
-
if ((this.isEven() && ac) || m.signum() === 0)
|
|
1190
|
-
return BigInteger.ZERO;
|
|
1191
|
-
var u = m.clone(), v = this.clone();
|
|
1192
|
-
var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
|
|
1193
|
-
while (u.signum() != 0) {
|
|
1194
|
-
while (u.isEven()) {
|
|
1195
|
-
u.rShiftTo(1, u);
|
|
1196
|
-
if (ac) {
|
|
1197
|
-
if (!a.isEven() || !b.isEven()) {
|
|
1198
|
-
a.addTo(this, a);
|
|
1199
|
-
b.subTo(m, b);
|
|
1200
|
-
}
|
|
1201
|
-
a.rShiftTo(1, a);
|
|
1202
|
-
}
|
|
1203
|
-
else if (!b.isEven())
|
|
1204
|
-
b.subTo(m, b);
|
|
1205
|
-
b.rShiftTo(1, b);
|
|
1206
|
-
}
|
|
1207
|
-
while (v.isEven()) {
|
|
1208
|
-
v.rShiftTo(1, v);
|
|
1209
|
-
if (ac) {
|
|
1210
|
-
if (!c.isEven() || !d.isEven()) {
|
|
1211
|
-
c.addTo(this, c);
|
|
1212
|
-
d.subTo(m, d);
|
|
1213
|
-
}
|
|
1214
|
-
c.rShiftTo(1, c);
|
|
1215
|
-
}
|
|
1216
|
-
else if (!d.isEven())
|
|
1217
|
-
d.subTo(m, d);
|
|
1218
|
-
d.rShiftTo(1, d);
|
|
1219
|
-
}
|
|
1220
|
-
if (u.compareTo(v) >= 0) {
|
|
1221
|
-
u.subTo(v, u);
|
|
1222
|
-
if (ac)
|
|
1223
|
-
a.subTo(c, a);
|
|
1224
|
-
b.subTo(d, b);
|
|
1225
|
-
}
|
|
1226
|
-
else {
|
|
1227
|
-
v.subTo(u, v);
|
|
1228
|
-
if (ac)
|
|
1229
|
-
c.subTo(a, c);
|
|
1230
|
-
d.subTo(b, d);
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
if (v.compareTo(BigInteger.ONE) != 0)
|
|
1234
|
-
return BigInteger.ZERO;
|
|
1235
|
-
if (d.compareTo(m) >= 0)
|
|
1236
|
-
return d.subtract(m);
|
|
1237
|
-
if (d.signum() < 0)
|
|
1238
|
-
d.addTo(m, d);
|
|
1239
|
-
else
|
|
1240
|
-
return d;
|
|
1241
|
-
if (d.signum() < 0)
|
|
1242
|
-
return d.add(m);
|
|
1243
|
-
else
|
|
1244
|
-
return d;
|
|
1245
|
-
}
|
|
1246
|
-
var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
|
|
1247
|
-
var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
|
|
1248
|
-
function bnIsProbablePrime(t) {
|
|
1249
|
-
var i, x = this.abs();
|
|
1250
|
-
if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
|
|
1251
|
-
for (i = 0; i < lowprimes.length; ++i)
|
|
1252
|
-
if (x[0] == lowprimes[i])
|
|
1253
|
-
return true;
|
|
1254
|
-
return false;
|
|
1255
|
-
}
|
|
1256
|
-
if (x.isEven())
|
|
1257
|
-
return false;
|
|
1258
|
-
i = 1;
|
|
1259
|
-
while (i < lowprimes.length) {
|
|
1260
|
-
var m = lowprimes[i], j = i + 1;
|
|
1261
|
-
while (j < lowprimes.length && m < lplim)
|
|
1262
|
-
m *= lowprimes[j++];
|
|
1263
|
-
m = x.modInt(m);
|
|
1264
|
-
while (i < j)
|
|
1265
|
-
if (m % lowprimes[i++] === 0)
|
|
1266
|
-
return false;
|
|
1267
|
-
}
|
|
1268
|
-
return x.millerRabin(t);
|
|
1269
|
-
}
|
|
1270
|
-
function bnpMillerRabin(t) {
|
|
1271
|
-
var n1 = this.subtract(BigInteger.ONE);
|
|
1272
|
-
var k = n1.getLowestSetBit();
|
|
1273
|
-
if (k <= 0)
|
|
1274
|
-
return false;
|
|
1275
|
-
var r = n1.shiftRight(k);
|
|
1276
|
-
t = (t + 1) >> 1;
|
|
1277
|
-
if (t > lowprimes.length)
|
|
1278
|
-
t = lowprimes.length;
|
|
1279
|
-
var a = nbi();
|
|
1280
|
-
for (var i = 0; i < t; ++i) {
|
|
1281
|
-
a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
|
|
1282
|
-
var y = a.modPow(r, this);
|
|
1283
|
-
if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
|
|
1284
|
-
var j = 1;
|
|
1285
|
-
while (j++ < k && y.compareTo(n1) != 0) {
|
|
1286
|
-
y = y.modPowInt(2, this);
|
|
1287
|
-
if (y.compareTo(BigInteger.ONE) === 0)
|
|
1288
|
-
return false;
|
|
1289
|
-
}
|
|
1290
|
-
if (y.compareTo(n1) != 0)
|
|
1291
|
-
return false;
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
return true;
|
|
1295
|
-
}
|
|
1296
|
-
BigInteger.prototype.copyTo = bnpCopyTo;
|
|
1297
|
-
BigInteger.prototype.fromInt = bnpFromInt;
|
|
1298
|
-
BigInteger.prototype.fromString = bnpFromString;
|
|
1299
|
-
BigInteger.prototype.fromByteArray = bnpFromByteArray;
|
|
1300
|
-
BigInteger.prototype.fromBuffer = bnpFromBuffer;
|
|
1301
|
-
BigInteger.prototype.clamp = bnpClamp;
|
|
1302
|
-
BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
|
|
1303
|
-
BigInteger.prototype.drShiftTo = bnpDRShiftTo;
|
|
1304
|
-
BigInteger.prototype.lShiftTo = bnpLShiftTo;
|
|
1305
|
-
BigInteger.prototype.rShiftTo = bnpRShiftTo;
|
|
1306
|
-
BigInteger.prototype.subTo = bnpSubTo;
|
|
1307
|
-
BigInteger.prototype.multiplyTo = bnpMultiplyTo;
|
|
1308
|
-
BigInteger.prototype.squareTo = bnpSquareTo;
|
|
1309
|
-
BigInteger.prototype.divRemTo = bnpDivRemTo;
|
|
1310
|
-
BigInteger.prototype.invDigit = bnpInvDigit;
|
|
1311
|
-
BigInteger.prototype.isEven = bnpIsEven;
|
|
1312
|
-
BigInteger.prototype.exp = bnpExp;
|
|
1313
|
-
BigInteger.prototype.chunkSize = bnpChunkSize;
|
|
1314
|
-
BigInteger.prototype.toRadix = bnpToRadix;
|
|
1315
|
-
BigInteger.prototype.fromRadix = bnpFromRadix;
|
|
1316
|
-
BigInteger.prototype.fromNumber = bnpFromNumber;
|
|
1317
|
-
BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
|
|
1318
|
-
BigInteger.prototype.changeBit = bnpChangeBit;
|
|
1319
|
-
BigInteger.prototype.addTo = bnpAddTo;
|
|
1320
|
-
BigInteger.prototype.dMultiply = bnpDMultiply;
|
|
1321
|
-
BigInteger.prototype.dAddOffset = bnpDAddOffset;
|
|
1322
|
-
BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
|
|
1323
|
-
BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
|
|
1324
|
-
BigInteger.prototype.modInt = bnpModInt;
|
|
1325
|
-
BigInteger.prototype.millerRabin = bnpMillerRabin;
|
|
1326
|
-
BigInteger.prototype.toString = bnToString;
|
|
1327
|
-
BigInteger.prototype.negate = bnNegate;
|
|
1328
|
-
BigInteger.prototype.abs = bnAbs;
|
|
1329
|
-
BigInteger.prototype.compareTo = bnCompareTo;
|
|
1330
|
-
BigInteger.prototype.bitLength = bnBitLength;
|
|
1331
|
-
BigInteger.prototype.mod = bnMod;
|
|
1332
|
-
BigInteger.prototype.modPowInt = bnModPowInt;
|
|
1333
|
-
BigInteger.prototype.clone = bnClone;
|
|
1334
|
-
BigInteger.prototype.intValue = bnIntValue;
|
|
1335
|
-
BigInteger.prototype.byteValue = bnByteValue;
|
|
1336
|
-
BigInteger.prototype.shortValue = bnShortValue;
|
|
1337
|
-
BigInteger.prototype.signum = bnSigNum;
|
|
1338
|
-
BigInteger.prototype.toByteArray = bnToByteArray;
|
|
1339
|
-
BigInteger.prototype.toBuffer = bnToBuffer;
|
|
1340
|
-
BigInteger.prototype.equals = bnEquals;
|
|
1341
|
-
BigInteger.prototype.min = bnMin;
|
|
1342
|
-
BigInteger.prototype.max = bnMax;
|
|
1343
|
-
BigInteger.prototype.and = bnAnd;
|
|
1344
|
-
BigInteger.prototype.or = bnOr;
|
|
1345
|
-
BigInteger.prototype.xor = bnXor;
|
|
1346
|
-
BigInteger.prototype.andNot = bnAndNot;
|
|
1347
|
-
BigInteger.prototype.not = bnNot;
|
|
1348
|
-
BigInteger.prototype.shiftLeft = bnShiftLeft;
|
|
1349
|
-
BigInteger.prototype.shiftRight = bnShiftRight;
|
|
1350
|
-
BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
|
|
1351
|
-
BigInteger.prototype.bitCount = bnBitCount;
|
|
1352
|
-
BigInteger.prototype.testBit = bnTestBit;
|
|
1353
|
-
BigInteger.prototype.setBit = bnSetBit;
|
|
1354
|
-
BigInteger.prototype.clearBit = bnClearBit;
|
|
1355
|
-
BigInteger.prototype.flipBit = bnFlipBit;
|
|
1356
|
-
BigInteger.prototype.add = bnAdd;
|
|
1357
|
-
BigInteger.prototype.subtract = bnSubtract;
|
|
1358
|
-
BigInteger.prototype.multiply = bnMultiply;
|
|
1359
|
-
BigInteger.prototype.divide = bnDivide;
|
|
1360
|
-
BigInteger.prototype.remainder = bnRemainder;
|
|
1361
|
-
BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
|
|
1362
|
-
BigInteger.prototype.modPow = bnModPow;
|
|
1363
|
-
BigInteger.prototype.modInverse = bnModInverse;
|
|
1364
|
-
BigInteger.prototype.pow = bnPow;
|
|
1365
|
-
BigInteger.prototype.gcd = bnGCD;
|
|
1366
|
-
BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
|
|
1367
|
-
BigInteger.int2char = int2char;
|
|
1368
|
-
BigInteger.ZERO = nbv(0);
|
|
1369
|
-
BigInteger.ONE = nbv(1);
|
|
1370
|
-
BigInteger.prototype.square = bnSquare;
|
|
1371
|
-
module.exports = BigInteger;
|
|
1372
|
-
//# sourceMappingURL=jsbn.js.map
|