fsevents 1.0.5 → 1.0.6

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.

Potentially problematic release.


This version of fsevents might be problematic. Click here for more details.

Files changed (360) hide show
  1. package/Readme.md +12 -13
  2. package/node_modules/ansi/package.json +1 -2
  3. package/node_modules/are-we-there-yet/package.json +1 -2
  4. package/node_modules/asn1/.travis.yml +4 -0
  5. package/node_modules/asn1/lib/ber/reader.js +27 -33
  6. package/node_modules/asn1/lib/ber/writer.js +10 -11
  7. package/node_modules/asn1/package.json +21 -19
  8. package/node_modules/asn1/tst/ber/reader.test.js +36 -0
  9. package/node_modules/asn1/tst/ber/writer.test.js +74 -0
  10. package/node_modules/assert-plus/package.json +1 -0
  11. package/node_modules/{ctype → bl/node_modules/readable-stream/node_modules/core-util-is}/LICENSE +1 -6
  12. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +11 -11
  13. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json +17 -12
  14. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/test.js +68 -0
  15. package/node_modules/boom/package.json +1 -1
  16. package/node_modules/commander/package.json +1 -1
  17. package/node_modules/core-util-is/LICENSE +19 -0
  18. package/node_modules/core-util-is/lib/util.js +11 -11
  19. package/node_modules/core-util-is/package.json +17 -12
  20. package/node_modules/core-util-is/test.js +68 -0
  21. package/node_modules/dashdash/README.md +508 -0
  22. package/node_modules/dashdash/lib/dashdash.js +813 -0
  23. package/node_modules/dashdash/package.json +87 -0
  24. package/node_modules/deep-extend/LICENSE +1 -1
  25. package/node_modules/deep-extend/README.md +89 -52
  26. package/node_modules/deep-extend/index.js +1 -90
  27. package/node_modules/deep-extend/lib/deep-extend.js +144 -0
  28. package/node_modules/deep-extend/package.json +47 -16
  29. package/node_modules/deep-extend/test/index.spec.js +168 -5
  30. package/node_modules/delegates/package.json +1 -2
  31. package/node_modules/ecc-jsbn/.npmignore +15 -0
  32. package/node_modules/ecc-jsbn/LICENSE +21 -0
  33. package/node_modules/ecc-jsbn/README.md +8 -0
  34. package/node_modules/ecc-jsbn/index.js +57 -0
  35. package/node_modules/ecc-jsbn/lib/LICENSE-jsbn +40 -0
  36. package/node_modules/ecc-jsbn/lib/ec.js +561 -0
  37. package/node_modules/ecc-jsbn/lib/sec.js +170 -0
  38. package/node_modules/ecc-jsbn/package.json +63 -0
  39. package/node_modules/ecc-jsbn/test.js +14 -0
  40. package/node_modules/extsprintf/.gitmodules +6 -0
  41. package/node_modules/{path-is-absolute/license → extsprintf/LICENSE} +2 -4
  42. package/node_modules/extsprintf/Makefile +23 -0
  43. package/node_modules/extsprintf/Makefile.deps +39 -0
  44. package/node_modules/extsprintf/Makefile.targ +285 -0
  45. package/node_modules/extsprintf/README.md +39 -0
  46. package/node_modules/extsprintf/examples/simple.js +2 -0
  47. package/node_modules/{ctype/tools/jsl.conf → extsprintf/jsl.node.conf} +71 -63
  48. package/node_modules/extsprintf/lib/extsprintf.js +166 -0
  49. package/node_modules/extsprintf/package.json +48 -0
  50. package/node_modules/fstream/package.json +1 -2
  51. package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/package.json +4 -22
  52. package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/package.json +3 -21
  53. package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/package.json +4 -23
  54. package/node_modules/fstream-ignore/node_modules/minimatch/package.json +4 -24
  55. package/node_modules/fstream-ignore/package.json +1 -2
  56. package/node_modules/gauge/package.json +1 -2
  57. package/node_modules/har-validator/package.json +15 -15
  58. package/node_modules/has-unicode/package.json +1 -2
  59. package/node_modules/hawk/dist/client.js +340 -0
  60. package/node_modules/hawk/lib/browser.js +14 -20
  61. package/node_modules/hawk/package.json +10 -10
  62. package/node_modules/hawk/test/browser.js +134 -101
  63. package/node_modules/hawk/test/index.js +61 -61
  64. package/node_modules/hawk/test/server.js +72 -84
  65. package/node_modules/hawk/test/uri.js +52 -63
  66. package/node_modules/http-signature/CHANGES.md +39 -0
  67. package/node_modules/http-signature/http_signing.md +16 -17
  68. package/node_modules/http-signature/lib/index.js +6 -4
  69. package/node_modules/http-signature/lib/parser.js +43 -29
  70. package/node_modules/http-signature/lib/signer.js +290 -74
  71. package/node_modules/http-signature/lib/utils.js +112 -0
  72. package/node_modules/http-signature/lib/verify.js +47 -15
  73. package/node_modules/http-signature/package.json +20 -14
  74. package/node_modules/is-my-json-valid/index.js +16 -14
  75. package/node_modules/is-my-json-valid/package.json +16 -12
  76. package/node_modules/is-typedarray/LICENSE.md +18 -0
  77. package/node_modules/is-typedarray/README.md +16 -0
  78. package/node_modules/is-typedarray/index.js +41 -0
  79. package/node_modules/is-typedarray/package.json +63 -0
  80. package/node_modules/is-typedarray/test.js +34 -0
  81. package/node_modules/jodid25519/.npmignore +11 -0
  82. package/node_modules/jodid25519/.travis.yml +7 -0
  83. package/node_modules/jodid25519/AUTHORS.md +3 -0
  84. package/node_modules/jodid25519/LICENSE +23 -0
  85. package/node_modules/jodid25519/README.md +51 -0
  86. package/node_modules/jodid25519/almond.0 +42 -0
  87. package/node_modules/jodid25519/almond.1 +13 -0
  88. package/node_modules/jodid25519/index.js +35 -0
  89. package/node_modules/jodid25519/jsdoc.json +19 -0
  90. package/node_modules/jodid25519/lib/core.js +481 -0
  91. package/node_modules/jodid25519/lib/curve255.js +221 -0
  92. package/node_modules/jodid25519/lib/dh.js +111 -0
  93. package/node_modules/jodid25519/lib/eddsa.js +573 -0
  94. package/node_modules/jodid25519/lib/utils.js +198 -0
  95. package/node_modules/jodid25519/package.json +77 -0
  96. package/node_modules/jsbn/.npmignore +2 -0
  97. package/node_modules/jsbn/LICENSE +40 -0
  98. package/node_modules/jsbn/README.md +175 -0
  99. package/node_modules/jsbn/example.html +12 -0
  100. package/node_modules/jsbn/example.js +3 -0
  101. package/node_modules/jsbn/index.js +1358 -0
  102. package/node_modules/jsbn/package.json +60 -0
  103. package/node_modules/json-schema/README.md +5 -0
  104. package/node_modules/json-schema/draft-00/hyper-schema +68 -0
  105. package/node_modules/json-schema/draft-00/json-ref +26 -0
  106. package/node_modules/json-schema/draft-00/links +33 -0
  107. package/node_modules/json-schema/draft-00/schema +155 -0
  108. package/node_modules/json-schema/draft-01/hyper-schema +68 -0
  109. package/node_modules/json-schema/draft-01/json-ref +26 -0
  110. package/node_modules/json-schema/draft-01/links +33 -0
  111. package/node_modules/json-schema/draft-01/schema +155 -0
  112. package/node_modules/json-schema/draft-02/hyper-schema +68 -0
  113. package/node_modules/json-schema/draft-02/json-ref +26 -0
  114. package/node_modules/json-schema/draft-02/links +35 -0
  115. package/node_modules/json-schema/draft-02/schema +166 -0
  116. package/node_modules/json-schema/draft-03/examples/address +20 -0
  117. package/node_modules/json-schema/draft-03/examples/calendar +53 -0
  118. package/node_modules/json-schema/draft-03/examples/card +105 -0
  119. package/node_modules/json-schema/draft-03/examples/geo +8 -0
  120. package/node_modules/json-schema/draft-03/examples/interfaces +23 -0
  121. package/node_modules/json-schema/draft-03/hyper-schema +60 -0
  122. package/node_modules/json-schema/draft-03/json-ref +26 -0
  123. package/node_modules/json-schema/draft-03/links +35 -0
  124. package/node_modules/json-schema/draft-03/schema +174 -0
  125. package/node_modules/json-schema/draft-04/hyper-schema +60 -0
  126. package/node_modules/json-schema/draft-04/links +41 -0
  127. package/node_modules/json-schema/draft-04/schema +189 -0
  128. package/node_modules/json-schema/draft-zyp-json-schema-03.xml +1120 -0
  129. package/node_modules/json-schema/draft-zyp-json-schema-04.xml +1072 -0
  130. package/node_modules/json-schema/lib/links.js +52 -0
  131. package/node_modules/json-schema/lib/validate.js +260 -0
  132. package/node_modules/json-schema/package.json +67 -0
  133. package/node_modules/json-schema/test/tests.js +95 -0
  134. package/node_modules/jsprim/CHANGES.md +30 -0
  135. package/node_modules/jsprim/LICENSE +19 -0
  136. package/node_modules/jsprim/README.md +228 -0
  137. package/node_modules/jsprim/lib/jsprim.js +478 -0
  138. package/node_modules/jsprim/package.json +54 -0
  139. package/node_modules/lodash._basetostring/package.json +1 -2
  140. package/node_modules/lodash._createpadding/package.json +1 -2
  141. package/node_modules/lodash.pad/package.json +1 -2
  142. package/node_modules/lodash.padleft/package.json +1 -2
  143. package/node_modules/lodash.padright/package.json +1 -2
  144. package/node_modules/lodash.repeat/package.json +1 -2
  145. package/node_modules/node-pre-gyp/CHANGELOG.md +8 -0
  146. package/node_modules/node-pre-gyp/README.md +570 -0
  147. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +4 -0
  148. package/node_modules/node-pre-gyp/node_modules/nopt/lib/nopt.js +2 -1
  149. package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/package.json +30 -37
  150. package/node_modules/node-pre-gyp/node_modules/nopt/package.json +37 -57
  151. package/node_modules/node-pre-gyp/node_modules/nopt/test/basic.js +22 -0
  152. package/node_modules/node-pre-gyp/package.json +17 -17
  153. package/node_modules/node-uuid/.npmignore +2 -0
  154. package/node_modules/node-uuid/README.md +12 -1
  155. package/node_modules/node-uuid/bower.json +1 -1
  156. package/node_modules/node-uuid/component.json +11 -4
  157. package/node_modules/node-uuid/package.json +25 -12
  158. package/node_modules/node-uuid/test/test.js +3 -0
  159. package/node_modules/node-uuid/uuid.js +70 -45
  160. package/node_modules/npmlog/.travis.yml +14 -0
  161. package/node_modules/npmlog/log.js +3 -0
  162. package/node_modules/npmlog/package.json +23 -20
  163. package/node_modules/npmlog/test/basic.js +8 -1
  164. package/node_modules/once/package.json +2 -3
  165. package/node_modules/pinkie/index.js +23 -7
  166. package/node_modules/pinkie/package.json +22 -15
  167. package/node_modules/pinkie/readme.md +17 -9
  168. package/node_modules/pinkie-promise/package.json +16 -14
  169. package/node_modules/pinkie-promise/readme.md +5 -3
  170. package/node_modules/rc/README.md +1 -1
  171. package/node_modules/rc/index.js +1 -1
  172. package/node_modules/rc/node_modules/minimist/package.json +1 -1
  173. package/node_modules/rc/package.json +12 -12
  174. package/node_modules/request/.eslintrc +1 -1
  175. package/node_modules/request/.travis.yml +4 -4
  176. package/node_modules/request/CHANGELOG.md +25 -0
  177. package/node_modules/request/README.md +12 -13
  178. package/node_modules/request/lib/har.js +84 -75
  179. package/node_modules/request/lib/redirect.js +2 -3
  180. package/node_modules/request/lib/tunnel.js +13 -18
  181. package/node_modules/request/package.json +17 -16
  182. package/node_modules/request/request.js +16 -59
  183. package/node_modules/rimraf/README.md +7 -2
  184. package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/package.json +5 -25
  185. package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/package.json +5 -25
  186. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/LICENSE +16 -0
  187. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/README.md +42 -0
  188. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits.js +1 -0
  189. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
  190. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json +58 -0
  191. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/test.js +25 -0
  192. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +3 -0
  193. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +122 -0
  194. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
  195. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
  196. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
  197. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +3 -0
  198. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md +21 -0
  199. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
  200. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
  201. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
  202. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
  203. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +79 -0
  204. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
  205. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +4 -0
  206. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
  207. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
  208. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
  209. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
  210. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +90 -0
  211. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
  212. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +81 -0
  213. package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/package.json +3 -21
  214. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
  215. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +58 -0
  216. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
  217. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
  218. package/node_modules/rimraf/node_modules/glob/node_modules/once/package.json +70 -0
  219. package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/package.json +4 -22
  220. package/node_modules/rimraf/node_modules/glob/package.json +2 -20
  221. package/node_modules/rimraf/package.json +10 -10
  222. package/node_modules/semver/README.md +25 -1
  223. package/node_modules/semver/package.json +10 -10
  224. package/node_modules/semver/range.bnf +16 -0
  225. package/node_modules/semver/semver.js +0 -12
  226. package/node_modules/sshpk/.npmignore +8 -0
  227. package/node_modules/sshpk/.travis.yml +11 -0
  228. package/node_modules/sshpk/LICENSE +18 -0
  229. package/node_modules/sshpk/README.md +436 -0
  230. package/node_modules/sshpk/bin/sshpk-conv +183 -0
  231. package/node_modules/sshpk/lib/algs.js +168 -0
  232. package/node_modules/sshpk/lib/dhe.js +312 -0
  233. package/node_modules/sshpk/lib/ed-compat.js +94 -0
  234. package/node_modules/sshpk/lib/errors.js +58 -0
  235. package/node_modules/sshpk/lib/fingerprint.js +140 -0
  236. package/node_modules/sshpk/lib/formats/auto.js +73 -0
  237. package/node_modules/sshpk/lib/formats/pem.js +152 -0
  238. package/node_modules/sshpk/lib/formats/pkcs1.js +320 -0
  239. package/node_modules/sshpk/lib/formats/pkcs8.js +510 -0
  240. package/node_modules/sshpk/lib/formats/rfc4253.js +145 -0
  241. package/node_modules/sshpk/lib/formats/ssh-private.js +138 -0
  242. package/node_modules/sshpk/lib/formats/ssh.js +114 -0
  243. package/node_modules/sshpk/lib/index.js +25 -0
  244. package/node_modules/sshpk/lib/key.js +260 -0
  245. package/node_modules/sshpk/lib/private-key.js +224 -0
  246. package/node_modules/sshpk/lib/signature.js +237 -0
  247. package/node_modules/sshpk/lib/ssh-buffer.js +123 -0
  248. package/node_modules/sshpk/lib/utils.js +207 -0
  249. package/node_modules/sshpk/node_modules/assert-plus/AUTHORS +6 -0
  250. package/node_modules/sshpk/node_modules/assert-plus/CHANGES.md +8 -0
  251. package/node_modules/sshpk/node_modules/assert-plus/README.md +155 -0
  252. package/node_modules/sshpk/node_modules/assert-plus/assert.js +206 -0
  253. package/node_modules/sshpk/node_modules/assert-plus/package.json +88 -0
  254. package/node_modules/sshpk/package.json +92 -0
  255. package/node_modules/strip-json-comments/cli.js +2 -2
  256. package/node_modules/strip-json-comments/package.json +13 -12
  257. package/node_modules/strip-json-comments/readme.md +11 -5
  258. package/node_modules/strip-json-comments/strip-json-comments.js +16 -7
  259. package/node_modules/tar/package.json +1 -2
  260. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/LICENSE +19 -0
  261. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +11 -11
  262. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/package.json +17 -12
  263. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/test.js +68 -0
  264. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/inherits/package.json +1 -1
  265. package/node_modules/tar-pack/node_modules/rimraf/package.json +1 -2
  266. package/node_modules/tar-pack/package.json +1 -2
  267. package/node_modules/tough-cookie/lib/cookie.js +1 -1
  268. package/node_modules/tough-cookie/package.json +7 -7
  269. package/node_modules/tweetnacl/.npmignore +4 -0
  270. package/node_modules/tweetnacl/CHANGELOG.md +128 -0
  271. package/node_modules/tweetnacl/README.md +463 -0
  272. package/node_modules/tweetnacl/nacl-fast.js +2418 -0
  273. package/node_modules/tweetnacl/nacl-fast.min.js +2 -0
  274. package/node_modules/tweetnacl/nacl.js +1205 -0
  275. package/node_modules/tweetnacl/nacl.min.js +1 -0
  276. package/node_modules/tweetnacl/package.json +101 -0
  277. package/node_modules/uid-number/package.json +2 -3
  278. package/node_modules/verror/.gitmodules +0 -0
  279. package/node_modules/verror/LICENSE +19 -0
  280. package/node_modules/verror/Makefile +35 -0
  281. package/node_modules/verror/Makefile.targ +285 -0
  282. package/node_modules/verror/README.md +120 -0
  283. package/node_modules/verror/examples/levels-verror.js +36 -0
  284. package/node_modules/verror/examples/levels-werror.js +34 -0
  285. package/node_modules/verror/examples/varargs.js +6 -0
  286. package/node_modules/verror/examples/verror.js +13 -0
  287. package/node_modules/verror/examples/werror.js +14 -0
  288. package/node_modules/verror/jsl.node.conf +139 -0
  289. package/node_modules/verror/lib/verror.js +157 -0
  290. package/node_modules/verror/package.json +51 -0
  291. package/node_modules/verror/tests/tst.inherit.js +100 -0
  292. package/node_modules/verror/tests/tst.verror.js +156 -0
  293. package/node_modules/verror/tests/tst.werror.js +179 -0
  294. package/package.json +3 -3
  295. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/util.js +0 -106
  296. package/node_modules/core-util-is/util.js +0 -106
  297. package/node_modules/ctype/.npmignore +0 -1
  298. package/node_modules/ctype/CHANGELOG +0 -78
  299. package/node_modules/ctype/README +0 -82
  300. package/node_modules/ctype/README.old +0 -298
  301. package/node_modules/ctype/ctf.js +0 -245
  302. package/node_modules/ctype/ctio.js +0 -1485
  303. package/node_modules/ctype/ctype.js +0 -944
  304. package/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
  305. package/node_modules/ctype/package.json +0 -51
  306. package/node_modules/ctype/tools/jsstyle +0 -839
  307. package/node_modules/http-signature/lib/util.js +0 -306
  308. package/node_modules/inflight/node_modules/once/package.json +0 -86
  309. package/node_modules/inflight/node_modules/once/test/once.js +0 -23
  310. package/node_modules/rimraf/node_modules/glob/LICENSE +0 -15
  311. package/node_modules/rimraf/node_modules/minimatch/LICENSE +0 -15
  312. package/node_modules/rimraf/node_modules/once/LICENSE +0 -15
  313. package/node_modules/rimraf/node_modules/once/README.md +0 -51
  314. package/node_modules/rimraf/node_modules/once/once.js +0 -21
  315. package/node_modules/rimraf/node_modules/once/package.json +0 -84
  316. package/node_modules/rimraf/node_modules/once/test/once.js +0 -23
  317. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/util.js +0 -106
  318. package/node_modules/wrappy/LICENSE +0 -15
  319. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/.npmignore +0 -0
  320. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/README.md +0 -0
  321. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/example.js +0 -0
  322. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/index.js +0 -0
  323. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.npmignore +0 -0
  324. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.travis.yml +0 -0
  325. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/LICENSE.md +0 -0
  326. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/Makefile +0 -0
  327. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/README.md +0 -0
  328. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/example.js +0 -0
  329. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/index.js +0 -0
  330. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/test/balanced.js +0 -0
  331. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/.travis.yml +0 -0
  332. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/LICENSE +0 -0
  333. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/README.markdown +0 -0
  334. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/example/map.js +0 -0
  335. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/index.js +0 -0
  336. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/test/map.js +0 -0
  337. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/.npmignore +0 -0
  338. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/.travis.yml +0 -0
  339. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/CONTRIBUTING.md +0 -0
  340. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/LICENSE +0 -0
  341. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/README.md +0 -0
  342. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/abbrev.js +0 -0
  343. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/test.js +0 -0
  344. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/.eslintrc +0 -0
  345. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/LICENSE +0 -0
  346. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/README.md +0 -0
  347. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/inflight.js +0 -0
  348. /package/node_modules/{fstream-ignore/node_modules/minimatch → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/LICENSE +0 -0
  349. /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/README.md +0 -0
  350. /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/test/basic.js +0 -0
  351. /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/wrappy.js +0 -0
  352. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/test.js +0 -0
  353. /package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/README.md +0 -0
  354. /package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/minimatch.js +0 -0
  355. /package/node_modules/{inflight → rimraf/node_modules/glob}/node_modules/once/README.md +0 -0
  356. /package/node_modules/{inflight/node_modules/once → rimraf/node_modules/glob/node_modules/once/node_modules/wrappy}/LICENSE +0 -0
  357. /package/node_modules/{inflight → rimraf/node_modules/glob}/node_modules/once/once.js +0 -0
  358. /package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/index.js +0 -0
  359. /package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/readme.md +0 -0
  360. /package/node_modules/{deep-extend → verror}/.npmignore +0 -0
@@ -0,0 +1,561 @@
1
+ // Basic Javascript Elliptic Curve implementation
2
+ // Ported loosely from BouncyCastle's Java EC code
3
+ // Only Fp curves implemented for now
4
+
5
+ // Requires jsbn.js and jsbn2.js
6
+ var BigInteger = require('jsbn').BigInteger
7
+ var Barrett = BigInteger.prototype.Barrett
8
+
9
+ // ----------------
10
+ // ECFieldElementFp
11
+
12
+ // constructor
13
+ function ECFieldElementFp(q,x) {
14
+ this.x = x;
15
+ // TODO if(x.compareTo(q) >= 0) error
16
+ this.q = q;
17
+ }
18
+
19
+ function feFpEquals(other) {
20
+ if(other == this) return true;
21
+ return (this.q.equals(other.q) && this.x.equals(other.x));
22
+ }
23
+
24
+ function feFpToBigInteger() {
25
+ return this.x;
26
+ }
27
+
28
+ function feFpNegate() {
29
+ return new ECFieldElementFp(this.q, this.x.negate().mod(this.q));
30
+ }
31
+
32
+ function feFpAdd(b) {
33
+ return new ECFieldElementFp(this.q, this.x.add(b.toBigInteger()).mod(this.q));
34
+ }
35
+
36
+ function feFpSubtract(b) {
37
+ return new ECFieldElementFp(this.q, this.x.subtract(b.toBigInteger()).mod(this.q));
38
+ }
39
+
40
+ function feFpMultiply(b) {
41
+ return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger()).mod(this.q));
42
+ }
43
+
44
+ function feFpSquare() {
45
+ return new ECFieldElementFp(this.q, this.x.square().mod(this.q));
46
+ }
47
+
48
+ function feFpDivide(b) {
49
+ return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q));
50
+ }
51
+
52
+ ECFieldElementFp.prototype.equals = feFpEquals;
53
+ ECFieldElementFp.prototype.toBigInteger = feFpToBigInteger;
54
+ ECFieldElementFp.prototype.negate = feFpNegate;
55
+ ECFieldElementFp.prototype.add = feFpAdd;
56
+ ECFieldElementFp.prototype.subtract = feFpSubtract;
57
+ ECFieldElementFp.prototype.multiply = feFpMultiply;
58
+ ECFieldElementFp.prototype.square = feFpSquare;
59
+ ECFieldElementFp.prototype.divide = feFpDivide;
60
+
61
+ // ----------------
62
+ // ECPointFp
63
+
64
+ // constructor
65
+ function ECPointFp(curve,x,y,z) {
66
+ this.curve = curve;
67
+ this.x = x;
68
+ this.y = y;
69
+ // Projective coordinates: either zinv == null or z * zinv == 1
70
+ // z and zinv are just BigIntegers, not fieldElements
71
+ if(z == null) {
72
+ this.z = BigInteger.ONE;
73
+ }
74
+ else {
75
+ this.z = z;
76
+ }
77
+ this.zinv = null;
78
+ //TODO: compression flag
79
+ }
80
+
81
+ function pointFpGetX() {
82
+ if(this.zinv == null) {
83
+ this.zinv = this.z.modInverse(this.curve.q);
84
+ }
85
+ var r = this.x.toBigInteger().multiply(this.zinv);
86
+ this.curve.reduce(r);
87
+ return this.curve.fromBigInteger(r);
88
+ }
89
+
90
+ function pointFpGetY() {
91
+ if(this.zinv == null) {
92
+ this.zinv = this.z.modInverse(this.curve.q);
93
+ }
94
+ var r = this.y.toBigInteger().multiply(this.zinv);
95
+ this.curve.reduce(r);
96
+ return this.curve.fromBigInteger(r);
97
+ }
98
+
99
+ function pointFpEquals(other) {
100
+ if(other == this) return true;
101
+ if(this.isInfinity()) return other.isInfinity();
102
+ if(other.isInfinity()) return this.isInfinity();
103
+ var u, v;
104
+ // u = Y2 * Z1 - Y1 * Z2
105
+ u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q);
106
+ if(!u.equals(BigInteger.ZERO)) return false;
107
+ // v = X2 * Z1 - X1 * Z2
108
+ v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q);
109
+ return v.equals(BigInteger.ZERO);
110
+ }
111
+
112
+ function pointFpIsInfinity() {
113
+ if((this.x == null) && (this.y == null)) return true;
114
+ return this.z.equals(BigInteger.ZERO) && !this.y.toBigInteger().equals(BigInteger.ZERO);
115
+ }
116
+
117
+ function pointFpNegate() {
118
+ return new ECPointFp(this.curve, this.x, this.y.negate(), this.z);
119
+ }
120
+
121
+ function pointFpAdd(b) {
122
+ if(this.isInfinity()) return b;
123
+ if(b.isInfinity()) return this;
124
+
125
+ // u = Y2 * Z1 - Y1 * Z2
126
+ var u = b.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(b.z)).mod(this.curve.q);
127
+ // v = X2 * Z1 - X1 * Z2
128
+ var v = b.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(b.z)).mod(this.curve.q);
129
+
130
+ if(BigInteger.ZERO.equals(v)) {
131
+ if(BigInteger.ZERO.equals(u)) {
132
+ return this.twice(); // this == b, so double
133
+ }
134
+ return this.curve.getInfinity(); // this = -b, so infinity
135
+ }
136
+
137
+ var THREE = new BigInteger("3");
138
+ var x1 = this.x.toBigInteger();
139
+ var y1 = this.y.toBigInteger();
140
+ var x2 = b.x.toBigInteger();
141
+ var y2 = b.y.toBigInteger();
142
+
143
+ var v2 = v.square();
144
+ var v3 = v2.multiply(v);
145
+ var x1v2 = x1.multiply(v2);
146
+ var zu2 = u.square().multiply(this.z);
147
+
148
+ // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
149
+ var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.q);
150
+ // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
151
+ var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.q);
152
+ // z3 = v^3 * z1 * z2
153
+ var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.q);
154
+
155
+ return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3);
156
+ }
157
+
158
+ function pointFpTwice() {
159
+ if(this.isInfinity()) return this;
160
+ if(this.y.toBigInteger().signum() == 0) return this.curve.getInfinity();
161
+
162
+ // TODO: optimized handling of constants
163
+ var THREE = new BigInteger("3");
164
+ var x1 = this.x.toBigInteger();
165
+ var y1 = this.y.toBigInteger();
166
+
167
+ var y1z1 = y1.multiply(this.z);
168
+ var y1sqz1 = y1z1.multiply(y1).mod(this.curve.q);
169
+ var a = this.curve.a.toBigInteger();
170
+
171
+ // w = 3 * x1^2 + a * z1^2
172
+ var w = x1.square().multiply(THREE);
173
+ if(!BigInteger.ZERO.equals(a)) {
174
+ w = w.add(this.z.square().multiply(a));
175
+ }
176
+ w = w.mod(this.curve.q);
177
+ //this.curve.reduce(w);
178
+ // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
179
+ var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.q);
180
+ // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
181
+ var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.square().multiply(w)).mod(this.curve.q);
182
+ // z3 = 8 * (y1 * z1)^3
183
+ var z3 = y1z1.square().multiply(y1z1).shiftLeft(3).mod(this.curve.q);
184
+
185
+ return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3);
186
+ }
187
+
188
+ // Simple NAF (Non-Adjacent Form) multiplication algorithm
189
+ // TODO: modularize the multiplication algorithm
190
+ function pointFpMultiply(k) {
191
+ if(this.isInfinity()) return this;
192
+ if(k.signum() == 0) return this.curve.getInfinity();
193
+
194
+ var e = k;
195
+ var h = e.multiply(new BigInteger("3"));
196
+
197
+ var neg = this.negate();
198
+ var R = this;
199
+
200
+ var i;
201
+ for(i = h.bitLength() - 2; i > 0; --i) {
202
+ R = R.twice();
203
+
204
+ var hBit = h.testBit(i);
205
+ var eBit = e.testBit(i);
206
+
207
+ if (hBit != eBit) {
208
+ R = R.add(hBit ? this : neg);
209
+ }
210
+ }
211
+
212
+ return R;
213
+ }
214
+
215
+ // Compute this*j + x*k (simultaneous multiplication)
216
+ function pointFpMultiplyTwo(j,x,k) {
217
+ var i;
218
+ if(j.bitLength() > k.bitLength())
219
+ i = j.bitLength() - 1;
220
+ else
221
+ i = k.bitLength() - 1;
222
+
223
+ var R = this.curve.getInfinity();
224
+ var both = this.add(x);
225
+ while(i >= 0) {
226
+ R = R.twice();
227
+ if(j.testBit(i)) {
228
+ if(k.testBit(i)) {
229
+ R = R.add(both);
230
+ }
231
+ else {
232
+ R = R.add(this);
233
+ }
234
+ }
235
+ else {
236
+ if(k.testBit(i)) {
237
+ R = R.add(x);
238
+ }
239
+ }
240
+ --i;
241
+ }
242
+
243
+ return R;
244
+ }
245
+
246
+ ECPointFp.prototype.getX = pointFpGetX;
247
+ ECPointFp.prototype.getY = pointFpGetY;
248
+ ECPointFp.prototype.equals = pointFpEquals;
249
+ ECPointFp.prototype.isInfinity = pointFpIsInfinity;
250
+ ECPointFp.prototype.negate = pointFpNegate;
251
+ ECPointFp.prototype.add = pointFpAdd;
252
+ ECPointFp.prototype.twice = pointFpTwice;
253
+ ECPointFp.prototype.multiply = pointFpMultiply;
254
+ ECPointFp.prototype.multiplyTwo = pointFpMultiplyTwo;
255
+
256
+ // ----------------
257
+ // ECCurveFp
258
+
259
+ // constructor
260
+ function ECCurveFp(q,a,b) {
261
+ this.q = q;
262
+ this.a = this.fromBigInteger(a);
263
+ this.b = this.fromBigInteger(b);
264
+ this.infinity = new ECPointFp(this, null, null);
265
+ this.reducer = new Barrett(this.q);
266
+ }
267
+
268
+ function curveFpGetQ() {
269
+ return this.q;
270
+ }
271
+
272
+ function curveFpGetA() {
273
+ return this.a;
274
+ }
275
+
276
+ function curveFpGetB() {
277
+ return this.b;
278
+ }
279
+
280
+ function curveFpEquals(other) {
281
+ if(other == this) return true;
282
+ return(this.q.equals(other.q) && this.a.equals(other.a) && this.b.equals(other.b));
283
+ }
284
+
285
+ function curveFpGetInfinity() {
286
+ return this.infinity;
287
+ }
288
+
289
+ function curveFpFromBigInteger(x) {
290
+ return new ECFieldElementFp(this.q, x);
291
+ }
292
+
293
+ function curveReduce(x) {
294
+ this.reducer.reduce(x);
295
+ }
296
+
297
+ // for now, work with hex strings because they're easier in JS
298
+ function curveFpDecodePointHex(s) {
299
+ switch(parseInt(s.substr(0,2), 16)) { // first byte
300
+ case 0:
301
+ return this.infinity;
302
+ case 2:
303
+ case 3:
304
+ // point compression not supported yet
305
+ return null;
306
+ case 4:
307
+ case 6:
308
+ case 7:
309
+ var len = (s.length - 2) / 2;
310
+ var xHex = s.substr(2, len);
311
+ var yHex = s.substr(len+2, len);
312
+
313
+ return new ECPointFp(this,
314
+ this.fromBigInteger(new BigInteger(xHex, 16)),
315
+ this.fromBigInteger(new BigInteger(yHex, 16)));
316
+
317
+ default: // unsupported
318
+ return null;
319
+ }
320
+ }
321
+
322
+ function curveFpEncodePointHex(p) {
323
+ if (p.isInfinity()) return "00";
324
+ var xHex = p.getX().toBigInteger().toString(16);
325
+ var yHex = p.getY().toBigInteger().toString(16);
326
+ var oLen = this.getQ().toString(16).length;
327
+ if ((oLen % 2) != 0) oLen++;
328
+ while (xHex.length < oLen) {
329
+ xHex = "0" + xHex;
330
+ }
331
+ while (yHex.length < oLen) {
332
+ yHex = "0" + yHex;
333
+ }
334
+ return "04" + xHex + yHex;
335
+ }
336
+
337
+ ECCurveFp.prototype.getQ = curveFpGetQ;
338
+ ECCurveFp.prototype.getA = curveFpGetA;
339
+ ECCurveFp.prototype.getB = curveFpGetB;
340
+ ECCurveFp.prototype.equals = curveFpEquals;
341
+ ECCurveFp.prototype.getInfinity = curveFpGetInfinity;
342
+ ECCurveFp.prototype.fromBigInteger = curveFpFromBigInteger;
343
+ ECCurveFp.prototype.reduce = curveReduce;
344
+ //ECCurveFp.prototype.decodePointHex = curveFpDecodePointHex;
345
+ ECCurveFp.prototype.encodePointHex = curveFpEncodePointHex;
346
+
347
+ // from: https://github.com/kaielvin/jsbn-ec-point-compression
348
+ ECCurveFp.prototype.decodePointHex = function(s)
349
+ {
350
+ var yIsEven;
351
+ switch(parseInt(s.substr(0,2), 16)) { // first byte
352
+ case 0:
353
+ return this.infinity;
354
+ case 2:
355
+ yIsEven = false;
356
+ case 3:
357
+ if(yIsEven == undefined) yIsEven = true;
358
+ var len = s.length - 2;
359
+ var xHex = s.substr(2, len);
360
+ var x = this.fromBigInteger(new BigInteger(xHex,16));
361
+ var alpha = x.multiply(x.square().add(this.getA())).add(this.getB());
362
+ var beta = alpha.sqrt();
363
+
364
+ if (beta == null) throw "Invalid point compression";
365
+
366
+ var betaValue = beta.toBigInteger();
367
+ if (betaValue.testBit(0) != yIsEven)
368
+ {
369
+ // Use the other root
370
+ beta = this.fromBigInteger(this.getQ().subtract(betaValue));
371
+ }
372
+ return new ECPointFp(this,x,beta);
373
+ case 4:
374
+ case 6:
375
+ case 7:
376
+ var len = (s.length - 2) / 2;
377
+ var xHex = s.substr(2, len);
378
+ var yHex = s.substr(len+2, len);
379
+
380
+ return new ECPointFp(this,
381
+ this.fromBigInteger(new BigInteger(xHex, 16)),
382
+ this.fromBigInteger(new BigInteger(yHex, 16)));
383
+
384
+ default: // unsupported
385
+ return null;
386
+ }
387
+ }
388
+ ECCurveFp.prototype.encodeCompressedPointHex = function(p)
389
+ {
390
+ if (p.isInfinity()) return "00";
391
+ var xHex = p.getX().toBigInteger().toString(16);
392
+ var oLen = this.getQ().toString(16).length;
393
+ if ((oLen % 2) != 0) oLen++;
394
+ while (xHex.length < oLen)
395
+ xHex = "0" + xHex;
396
+ var yPrefix;
397
+ if(p.getY().toBigInteger().isEven()) yPrefix = "02";
398
+ else yPrefix = "03";
399
+
400
+ return yPrefix + xHex;
401
+ }
402
+
403
+
404
+ ECFieldElementFp.prototype.getR = function()
405
+ {
406
+ if(this.r != undefined) return this.r;
407
+
408
+ this.r = null;
409
+ var bitLength = this.q.bitLength();
410
+ if (bitLength > 128)
411
+ {
412
+ var firstWord = this.q.shiftRight(bitLength - 64);
413
+ if (firstWord.intValue() == -1)
414
+ {
415
+ this.r = BigInteger.ONE.shiftLeft(bitLength).subtract(this.q);
416
+ }
417
+ }
418
+ return this.r;
419
+ }
420
+ ECFieldElementFp.prototype.modMult = function(x1,x2)
421
+ {
422
+ return this.modReduce(x1.multiply(x2));
423
+ }
424
+ ECFieldElementFp.prototype.modReduce = function(x)
425
+ {
426
+ if (this.getR() != null)
427
+ {
428
+ var qLen = q.bitLength();
429
+ while (x.bitLength() > (qLen + 1))
430
+ {
431
+ var u = x.shiftRight(qLen);
432
+ var v = x.subtract(u.shiftLeft(qLen));
433
+ if (!this.getR().equals(BigInteger.ONE))
434
+ {
435
+ u = u.multiply(this.getR());
436
+ }
437
+ x = u.add(v);
438
+ }
439
+ while (x.compareTo(q) >= 0)
440
+ {
441
+ x = x.subtract(q);
442
+ }
443
+ }
444
+ else
445
+ {
446
+ x = x.mod(q);
447
+ }
448
+ return x;
449
+ }
450
+ ECFieldElementFp.prototype.sqrt = function()
451
+ {
452
+ if (!this.q.testBit(0)) throw "unsupported";
453
+
454
+ // p mod 4 == 3
455
+ if (this.q.testBit(1))
456
+ {
457
+ var z = new ECFieldElementFp(this.q,this.x.modPow(this.q.shiftRight(2).add(BigInteger.ONE),this.q));
458
+ return z.square().equals(this) ? z : null;
459
+ }
460
+
461
+ // p mod 4 == 1
462
+ var qMinusOne = this.q.subtract(BigInteger.ONE);
463
+
464
+ var legendreExponent = qMinusOne.shiftRight(1);
465
+ if (!(this.x.modPow(legendreExponent, this.q).equals(BigInteger.ONE)))
466
+ {
467
+ return null;
468
+ }
469
+
470
+ var u = qMinusOne.shiftRight(2);
471
+ var k = u.shiftLeft(1).add(BigInteger.ONE);
472
+
473
+ var Q = this.x;
474
+ var fourQ = modDouble(modDouble(Q));
475
+
476
+ var U, V;
477
+ do
478
+ {
479
+ var P;
480
+ do
481
+ {
482
+ P = new BigInteger(this.q.bitLength(), new SecureRandom());
483
+ }
484
+ while (P.compareTo(this.q) >= 0
485
+ || !(P.multiply(P).subtract(fourQ).modPow(legendreExponent, this.q).equals(qMinusOne)));
486
+
487
+ var result = this.lucasSequence(P, Q, k);
488
+ U = result[0];
489
+ V = result[1];
490
+
491
+ if (this.modMult(V, V).equals(fourQ))
492
+ {
493
+ // Integer division by 2, mod q
494
+ if (V.testBit(0))
495
+ {
496
+ V = V.add(q);
497
+ }
498
+
499
+ V = V.shiftRight(1);
500
+
501
+ return new ECFieldElementFp(q,V);
502
+ }
503
+ }
504
+ while (U.equals(BigInteger.ONE) || U.equals(qMinusOne));
505
+
506
+ return null;
507
+ }
508
+ ECFieldElementFp.prototype.lucasSequence = function(P,Q,k)
509
+ {
510
+ var n = k.bitLength();
511
+ var s = k.getLowestSetBit();
512
+
513
+ var Uh = BigInteger.ONE;
514
+ var Vl = BigInteger.TWO;
515
+ var Vh = P;
516
+ var Ql = BigInteger.ONE;
517
+ var Qh = BigInteger.ONE;
518
+
519
+ for (var j = n - 1; j >= s + 1; --j)
520
+ {
521
+ Ql = this.modMult(Ql, Qh);
522
+
523
+ if (k.testBit(j))
524
+ {
525
+ Qh = this.modMult(Ql, Q);
526
+ Uh = this.modMult(Uh, Vh);
527
+ Vl = this.modReduce(Vh.multiply(Vl).subtract(P.multiply(Ql)));
528
+ Vh = this.modReduce(Vh.multiply(Vh).subtract(Qh.shiftLeft(1)));
529
+ }
530
+ else
531
+ {
532
+ Qh = Ql;
533
+ Uh = this.modReduce(Uh.multiply(Vl).subtract(Ql));
534
+ Vh = this.modReduce(Vh.multiply(Vl).subtract(P.multiply(Ql)));
535
+ Vl = this.modReduce(Vl.multiply(Vl).subtract(Ql.shiftLeft(1)));
536
+ }
537
+ }
538
+
539
+ Ql = this.modMult(Ql, Qh);
540
+ Qh = this.modMult(Ql, Q);
541
+ Uh = this.modReduce(Uh.multiply(Vl).subtract(Ql));
542
+ Vl = this.modReduce(Vh.multiply(Vl).subtract(P.multiply(Ql)));
543
+ Ql = this.modMult(Ql, Qh);
544
+
545
+ for (var j = 1; j <= s; ++j)
546
+ {
547
+ Uh = this.modMult(Uh, Vl);
548
+ Vl = this.modReduce(Vl.multiply(Vl).subtract(Ql.shiftLeft(1)));
549
+ Ql = this.modMult(Ql, Ql);
550
+ }
551
+
552
+ return [ Uh, Vl ];
553
+ }
554
+
555
+ var exports = {
556
+ ECCurveFp: ECCurveFp,
557
+ ECPointFp: ECPointFp,
558
+ ECFieldElementFp: ECFieldElementFp
559
+ }
560
+
561
+ module.exports = exports