@airgap/coinlib-core 0.13.46 → 0.13.47

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.
Files changed (124) hide show
  1. package/dependencies/src/axios-0.33.0/index.d.ts +345 -0
  2. package/dependencies/src/axios-0.33.0/lib/adapters/http.js +771 -0
  3. package/dependencies/src/axios-0.33.0/lib/adapters/xhr.js +305 -0
  4. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/axios.js +22 -7
  5. package/dependencies/src/axios-0.33.0/lib/cancel/CancelToken.js +118 -0
  6. package/dependencies/src/axios-0.33.0/lib/cancel/CanceledError.js +24 -0
  7. package/dependencies/src/axios-0.33.0/lib/core/Axios.js +178 -0
  8. package/dependencies/src/axios-0.33.0/lib/core/AxiosError.js +173 -0
  9. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/InterceptorManager.js +13 -2
  10. package/dependencies/src/axios-0.33.0/lib/core/buildFullPath.js +23 -0
  11. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/dispatchRequest.js +34 -16
  12. package/dependencies/src/axios-0.33.0/lib/core/mergeConfig.js +117 -0
  13. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/settle.js +4 -4
  14. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/core/transformData.js +5 -2
  15. package/dependencies/src/axios-0.33.0/lib/defaults/index.js +181 -0
  16. package/dependencies/src/axios-0.33.0/lib/defaults/transitional.js +7 -0
  17. package/dependencies/src/axios-0.33.0/lib/env/classes/FormData.js +2 -0
  18. package/dependencies/src/axios-0.33.0/lib/env/data.js +3 -0
  19. package/dependencies/src/axios-0.33.0/lib/helpers/AxiosURLSearchParams.js +50 -0
  20. package/dependencies/src/axios-0.33.0/lib/helpers/bind.js +7 -0
  21. package/dependencies/src/axios-0.33.0/lib/helpers/buildURL.js +63 -0
  22. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/combineURLs.js +1 -1
  23. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/cookies.js +15 -2
  24. package/dependencies/src/axios-0.33.0/lib/helpers/defaultRedactKeys.js +3 -0
  25. package/dependencies/src/axios-0.33.0/lib/helpers/estimateDataURLDecodedBytes.js +79 -0
  26. package/dependencies/src/axios-0.33.0/lib/helpers/formDataToJSON.js +91 -0
  27. package/dependencies/src/axios-0.33.0/lib/helpers/fromDataURI.js +51 -0
  28. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/isAbsoluteURL.js +1 -1
  29. package/dependencies/src/axios-0.33.0/lib/helpers/isAxiosError.js +13 -0
  30. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/isURLSameOrigin.js +12 -12
  31. package/dependencies/src/axios-0.33.0/lib/helpers/null.js +2 -0
  32. package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/parseHeaders.js +2 -2
  33. package/dependencies/src/axios-0.33.0/lib/helpers/parseProtocol.js +6 -0
  34. package/dependencies/src/axios-0.33.0/lib/helpers/sanitizeHeaderValue.js +22 -0
  35. package/dependencies/src/axios-0.33.0/lib/helpers/shouldBypassProxy.js +187 -0
  36. package/dependencies/src/axios-0.33.0/lib/helpers/toFormData.js +212 -0
  37. package/dependencies/src/axios-0.33.0/lib/helpers/toURLEncodedForm.js +18 -0
  38. package/dependencies/src/axios-0.33.0/lib/helpers/validator.js +86 -0
  39. package/dependencies/src/axios-0.33.0/lib/platform/browser/classes/FormData.js +3 -0
  40. package/dependencies/src/axios-0.33.0/lib/platform/browser/classes/URLSearchParams.js +5 -0
  41. package/dependencies/src/axios-0.33.0/lib/platform/browser/index.js +11 -0
  42. package/dependencies/src/axios-0.33.0/lib/platform/index.js +3 -0
  43. package/dependencies/src/axios-0.33.0/lib/platform/node/classes/FormData.js +3 -0
  44. package/dependencies/src/axios-0.33.0/lib/platform/node/classes/URLSearchParams.js +5 -0
  45. package/dependencies/src/axios-0.33.0/lib/platform/node/index.js +11 -0
  46. package/dependencies/src/axios-0.33.0/lib/utils.js +565 -0
  47. package/dependencies/src/axios-0.33.0/package.json +100 -0
  48. package/dependencies/src/{bn.js-4.11.8 → bn.js-4.11.9}/lib/bn.js +7 -1
  49. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curve/base.js +36 -31
  50. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/edwards.js +13 -10
  51. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curve/mont.js +1 -1
  52. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/short.js +48 -47
  53. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/curves.js +21 -21
  54. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/ec/index.js +53 -16
  55. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/ec/key.js +8 -5
  56. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/ec/signature.js +11 -1
  57. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/eddsa/index.js +5 -2
  58. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/eddsa/signature.js +3 -2
  59. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/precomputed/secp256k1.js +197 -197
  60. package/dependencies/src/{elliptic-6.5.3 → elliptic-6.6.1}/lib/elliptic/utils.js +12 -9
  61. package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/package.json +20 -22
  62. package/dependencies/src/ethereumjs-util-5.2.0/index.js +1 -1
  63. package/dependencies/src/follow-redirects-1.16.0/debug.js +15 -0
  64. package/dependencies/src/follow-redirects-1.16.0/index.js +709 -0
  65. package/dependencies/src/follow-redirects-1.16.0/package.json +58 -0
  66. package/dependencies/src/proxy-from-env-1.1.0/index.js +108 -0
  67. package/dependencies/src/proxy-from-env-1.1.0/package.json +34 -0
  68. package/dependencies/src/secp256k1-3.7.1/lib/elliptic/index.js +2 -2
  69. package/dependencies/src/secp256k1-4.0.2/lib/elliptic.js +1 -1
  70. package/dependencies/src/tiny-secp256k1-1.1.3/js.js +2 -2
  71. package/errors/index.d.ts +2 -2
  72. package/errors/index.js.map +1 -1
  73. package/package.json +2 -2
  74. package/utils/remote-data/HttpRemoteData.js +3 -8
  75. package/utils/remote-data/HttpRemoteData.js.map +1 -1
  76. package/utils/remote-data/IpfsRemoteData.js +13 -7
  77. package/utils/remote-data/IpfsRemoteData.js.map +1 -1
  78. package/utils/remote-data/Sha256RemoteData.js +5 -6
  79. package/utils/remote-data/Sha256RemoteData.js.map +1 -1
  80. package/utils/remote-data/remoteDataRequest.d.ts +16 -0
  81. package/utils/remote-data/remoteDataRequest.js +240 -0
  82. package/utils/remote-data/remoteDataRequest.js.map +1 -0
  83. package/dependencies/src/axios-0.19.0/index.d.ts +0 -152
  84. package/dependencies/src/axios-0.19.0/lib/adapters/http.js +0 -275
  85. package/dependencies/src/axios-0.19.0/lib/adapters/xhr.js +0 -174
  86. package/dependencies/src/axios-0.19.0/lib/cancel/Cancel.js +0 -19
  87. package/dependencies/src/axios-0.19.0/lib/cancel/CancelToken.js +0 -57
  88. package/dependencies/src/axios-0.19.0/lib/core/Axios.js +0 -86
  89. package/dependencies/src/axios-0.19.0/lib/core/createError.js +0 -18
  90. package/dependencies/src/axios-0.19.0/lib/core/enhanceError.js +0 -42
  91. package/dependencies/src/axios-0.19.0/lib/core/mergeConfig.js +0 -51
  92. package/dependencies/src/axios-0.19.0/lib/defaults.js +0 -98
  93. package/dependencies/src/axios-0.19.0/lib/helpers/bind.js +0 -11
  94. package/dependencies/src/axios-0.19.0/lib/helpers/buildURL.js +0 -71
  95. package/dependencies/src/axios-0.19.0/lib/utils.js +0 -334
  96. package/dependencies/src/axios-0.19.0/package.json +0 -85
  97. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/base.js +0 -374
  98. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/mont.js +0 -178
  99. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curves.js +0 -206
  100. package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/key.js +0 -118
  101. package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/signature.js +0 -134
  102. package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/index.js +0 -118
  103. package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/signature.js +0 -65
  104. package/dependencies/src/elliptic-6.5.1/lib/elliptic/utils.js +0 -120
  105. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/edwards.js +0 -432
  106. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/index.js +0 -8
  107. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/short.js +0 -937
  108. package/dependencies/src/elliptic-6.5.3/lib/elliptic/ec/index.js +0 -241
  109. package/dependencies/src/elliptic-6.5.3/lib/elliptic/eddsa/key.js +0 -95
  110. package/dependencies/src/elliptic-6.5.3/lib/elliptic/precomputed/secp256k1.js +0 -780
  111. package/dependencies/src/elliptic-6.5.3/lib/elliptic.js +0 -13
  112. package/dependencies/src/elliptic-6.5.3/package.json +0 -55
  113. package/dependencies/src/follow-redirects-1.5.10/index.js +0 -322
  114. package/dependencies/src/is-buffer-2.0.3/index.js +0 -11
  115. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/index.js +0 -0
  116. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/cancel/isCancel.js +0 -0
  117. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/deprecatedMethod.js +0 -0
  118. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/normalizeHeaderName.js +0 -0
  119. /package/dependencies/src/{axios-0.19.0 → axios-0.33.0}/lib/helpers/spread.js +0 -0
  120. /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/curve/index.js +0 -0
  121. /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic/eddsa/key.js +0 -0
  122. /package/dependencies/src/{elliptic-6.5.1 → elliptic-6.6.1}/lib/elliptic.js +0 -0
  123. /package/dependencies/src/{follow-redirects-1.5.10 → follow-redirects-1.16.0}/http.js +0 -0
  124. /package/dependencies/src/{follow-redirects-1.5.10 → follow-redirects-1.16.0}/https.js +0 -0
@@ -1,120 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = exports;
4
- var BN = require('../../../bn.js-4.11.8/lib/bn');
5
- var minAssert = require('../../../minimalistic-assert-1.0.1/index');
6
- var minUtils = require('../../../minimalistic-crypto-utils-1.0.1/lib/utils');
7
-
8
- utils.assert = minAssert;
9
- utils.toArray = minUtils.toArray;
10
- utils.zero2 = minUtils.zero2;
11
- utils.toHex = minUtils.toHex;
12
- utils.encode = minUtils.encode;
13
-
14
- // Represent num in a w-NAF form
15
- function getNAF(num, w) {
16
- var naf = [];
17
- var ws = 1 << (w + 1);
18
- var k = num.clone();
19
- while (k.cmpn(1) >= 0) {
20
- var z;
21
- if (k.isOdd()) {
22
- var mod = k.andln(ws - 1);
23
- if (mod > (ws >> 1) - 1)
24
- z = (ws >> 1) - mod;
25
- else
26
- z = mod;
27
- k.isubn(z);
28
- } else {
29
- z = 0;
30
- }
31
- naf.push(z);
32
-
33
- // Optimization, shift by word if possible
34
- var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
35
- for (var i = 1; i < shift; i++)
36
- naf.push(0);
37
- k.iushrn(shift);
38
- }
39
-
40
- return naf;
41
- }
42
- utils.getNAF = getNAF;
43
-
44
- // Represent k1, k2 in a Joint Sparse Form
45
- function getJSF(k1, k2) {
46
- var jsf = [
47
- [],
48
- []
49
- ];
50
-
51
- k1 = k1.clone();
52
- k2 = k2.clone();
53
- var d1 = 0;
54
- var d2 = 0;
55
- while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
56
-
57
- // First phase
58
- var m14 = (k1.andln(3) + d1) & 3;
59
- var m24 = (k2.andln(3) + d2) & 3;
60
- if (m14 === 3)
61
- m14 = -1;
62
- if (m24 === 3)
63
- m24 = -1;
64
- var u1;
65
- if ((m14 & 1) === 0) {
66
- u1 = 0;
67
- } else {
68
- var m8 = (k1.andln(7) + d1) & 7;
69
- if ((m8 === 3 || m8 === 5) && m24 === 2)
70
- u1 = -m14;
71
- else
72
- u1 = m14;
73
- }
74
- jsf[0].push(u1);
75
-
76
- var u2;
77
- if ((m24 & 1) === 0) {
78
- u2 = 0;
79
- } else {
80
- var m8 = (k2.andln(7) + d2) & 7;
81
- if ((m8 === 3 || m8 === 5) && m14 === 2)
82
- u2 = -m24;
83
- else
84
- u2 = m24;
85
- }
86
- jsf[1].push(u2);
87
-
88
- // Second phase
89
- if (2 * d1 === u1 + 1)
90
- d1 = 1 - d1;
91
- if (2 * d2 === u2 + 1)
92
- d2 = 1 - d2;
93
- k1.iushrn(1);
94
- k2.iushrn(1);
95
- }
96
-
97
- return jsf;
98
- }
99
- utils.getJSF = getJSF;
100
-
101
- function cachedProperty(obj, name, computer) {
102
- var key = '_' + name;
103
- obj.prototype[name] = function cachedProperty() {
104
- return this[key] !== undefined ? this[key] :
105
- this[key] = computer.call(this);
106
- };
107
- }
108
- utils.cachedProperty = cachedProperty;
109
-
110
- function parseBytes(bytes) {
111
- return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
112
- bytes;
113
- }
114
- utils.parseBytes = parseBytes;
115
-
116
- function intFromLE(bytes) {
117
- return new BN(bytes, 'hex', 'le');
118
- }
119
- utils.intFromLE = intFromLE;
120
-
@@ -1,432 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('../utils');
4
- var BN = require('../../../../bn.js-4.11.8/lib/bn');
5
- var inherits = require('../../../../inherits-2.0.4/inherits');
6
- var Base = require('./base');
7
-
8
- var assert = utils.assert;
9
-
10
- function EdwardsCurve(conf) {
11
- // NOTE: Important as we are creating point in Base.call()
12
- this.twisted = (conf.a | 0) !== 1;
13
- this.mOneA = this.twisted && (conf.a | 0) === -1;
14
- this.extended = this.mOneA;
15
-
16
- Base.call(this, 'edwards', conf);
17
-
18
- this.a = new BN(conf.a, 16).umod(this.red.m);
19
- this.a = this.a.toRed(this.red);
20
- this.c = new BN(conf.c, 16).toRed(this.red);
21
- this.c2 = this.c.redSqr();
22
- this.d = new BN(conf.d, 16).toRed(this.red);
23
- this.dd = this.d.redAdd(this.d);
24
-
25
- assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
26
- this.oneC = (conf.c | 0) === 1;
27
- }
28
- inherits(EdwardsCurve, Base);
29
- module.exports = EdwardsCurve;
30
-
31
- EdwardsCurve.prototype._mulA = function _mulA(num) {
32
- if (this.mOneA)
33
- return num.redNeg();
34
- else
35
- return this.a.redMul(num);
36
- };
37
-
38
- EdwardsCurve.prototype._mulC = function _mulC(num) {
39
- if (this.oneC)
40
- return num;
41
- else
42
- return this.c.redMul(num);
43
- };
44
-
45
- // Just for compatibility with Short curve
46
- EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
47
- return this.point(x, y, z, t);
48
- };
49
-
50
- EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
51
- x = new BN(x, 16);
52
- if (!x.red)
53
- x = x.toRed(this.red);
54
-
55
- var x2 = x.redSqr();
56
- var rhs = this.c2.redSub(this.a.redMul(x2));
57
- var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
58
-
59
- var y2 = rhs.redMul(lhs.redInvm());
60
- var y = y2.redSqrt();
61
- if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
62
- throw new Error('invalid point');
63
-
64
- var isOdd = y.fromRed().isOdd();
65
- if (odd && !isOdd || !odd && isOdd)
66
- y = y.redNeg();
67
-
68
- return this.point(x, y);
69
- };
70
-
71
- EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
72
- y = new BN(y, 16);
73
- if (!y.red)
74
- y = y.toRed(this.red);
75
-
76
- // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
77
- var y2 = y.redSqr();
78
- var lhs = y2.redSub(this.c2);
79
- var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
80
- var x2 = lhs.redMul(rhs.redInvm());
81
-
82
- if (x2.cmp(this.zero) === 0) {
83
- if (odd)
84
- throw new Error('invalid point');
85
- else
86
- return this.point(this.zero, y);
87
- }
88
-
89
- var x = x2.redSqrt();
90
- if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
91
- throw new Error('invalid point');
92
-
93
- if (x.fromRed().isOdd() !== odd)
94
- x = x.redNeg();
95
-
96
- return this.point(x, y);
97
- };
98
-
99
- EdwardsCurve.prototype.validate = function validate(point) {
100
- if (point.isInfinity())
101
- return true;
102
-
103
- // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
104
- point.normalize();
105
-
106
- var x2 = point.x.redSqr();
107
- var y2 = point.y.redSqr();
108
- var lhs = x2.redMul(this.a).redAdd(y2);
109
- var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
110
-
111
- return lhs.cmp(rhs) === 0;
112
- };
113
-
114
- function Point(curve, x, y, z, t) {
115
- Base.BasePoint.call(this, curve, 'projective');
116
- if (x === null && y === null && z === null) {
117
- this.x = this.curve.zero;
118
- this.y = this.curve.one;
119
- this.z = this.curve.one;
120
- this.t = this.curve.zero;
121
- this.zOne = true;
122
- } else {
123
- this.x = new BN(x, 16);
124
- this.y = new BN(y, 16);
125
- this.z = z ? new BN(z, 16) : this.curve.one;
126
- this.t = t && new BN(t, 16);
127
- if (!this.x.red)
128
- this.x = this.x.toRed(this.curve.red);
129
- if (!this.y.red)
130
- this.y = this.y.toRed(this.curve.red);
131
- if (!this.z.red)
132
- this.z = this.z.toRed(this.curve.red);
133
- if (this.t && !this.t.red)
134
- this.t = this.t.toRed(this.curve.red);
135
- this.zOne = this.z === this.curve.one;
136
-
137
- // Use extended coordinates
138
- if (this.curve.extended && !this.t) {
139
- this.t = this.x.redMul(this.y);
140
- if (!this.zOne)
141
- this.t = this.t.redMul(this.z.redInvm());
142
- }
143
- }
144
- }
145
- inherits(Point, Base.BasePoint);
146
-
147
- EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
148
- return Point.fromJSON(this, obj);
149
- };
150
-
151
- EdwardsCurve.prototype.point = function point(x, y, z, t) {
152
- return new Point(this, x, y, z, t);
153
- };
154
-
155
- Point.fromJSON = function fromJSON(curve, obj) {
156
- return new Point(curve, obj[0], obj[1], obj[2]);
157
- };
158
-
159
- Point.prototype.inspect = function inspect() {
160
- if (this.isInfinity())
161
- return '<EC Point Infinity>';
162
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
163
- ' y: ' + this.y.fromRed().toString(16, 2) +
164
- ' z: ' + this.z.fromRed().toString(16, 2) + '>';
165
- };
166
-
167
- Point.prototype.isInfinity = function isInfinity() {
168
- // XXX This code assumes that zero is always zero in red
169
- return this.x.cmpn(0) === 0 &&
170
- (this.y.cmp(this.z) === 0 ||
171
- (this.zOne && this.y.cmp(this.curve.c) === 0));
172
- };
173
-
174
- Point.prototype._extDbl = function _extDbl() {
175
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
176
- // #doubling-dbl-2008-hwcd
177
- // 4M + 4S
178
-
179
- // A = X1^2
180
- var a = this.x.redSqr();
181
- // B = Y1^2
182
- var b = this.y.redSqr();
183
- // C = 2 * Z1^2
184
- var c = this.z.redSqr();
185
- c = c.redIAdd(c);
186
- // D = a * A
187
- var d = this.curve._mulA(a);
188
- // E = (X1 + Y1)^2 - A - B
189
- var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
190
- // G = D + B
191
- var g = d.redAdd(b);
192
- // F = G - C
193
- var f = g.redSub(c);
194
- // H = D - B
195
- var h = d.redSub(b);
196
- // X3 = E * F
197
- var nx = e.redMul(f);
198
- // Y3 = G * H
199
- var ny = g.redMul(h);
200
- // T3 = E * H
201
- var nt = e.redMul(h);
202
- // Z3 = F * G
203
- var nz = f.redMul(g);
204
- return this.curve.point(nx, ny, nz, nt);
205
- };
206
-
207
- Point.prototype._projDbl = function _projDbl() {
208
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
209
- // #doubling-dbl-2008-bbjlp
210
- // #doubling-dbl-2007-bl
211
- // and others
212
- // Generally 3M + 4S or 2M + 4S
213
-
214
- // B = (X1 + Y1)^2
215
- var b = this.x.redAdd(this.y).redSqr();
216
- // C = X1^2
217
- var c = this.x.redSqr();
218
- // D = Y1^2
219
- var d = this.y.redSqr();
220
-
221
- var nx;
222
- var ny;
223
- var nz;
224
- if (this.curve.twisted) {
225
- // E = a * C
226
- var e = this.curve._mulA(c);
227
- // F = E + D
228
- var f = e.redAdd(d);
229
- if (this.zOne) {
230
- // X3 = (B - C - D) * (F - 2)
231
- nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
232
- // Y3 = F * (E - D)
233
- ny = f.redMul(e.redSub(d));
234
- // Z3 = F^2 - 2 * F
235
- nz = f.redSqr().redSub(f).redSub(f);
236
- } else {
237
- // H = Z1^2
238
- var h = this.z.redSqr();
239
- // J = F - 2 * H
240
- var j = f.redSub(h).redISub(h);
241
- // X3 = (B-C-D)*J
242
- nx = b.redSub(c).redISub(d).redMul(j);
243
- // Y3 = F * (E - D)
244
- ny = f.redMul(e.redSub(d));
245
- // Z3 = F * J
246
- nz = f.redMul(j);
247
- }
248
- } else {
249
- // E = C + D
250
- var e = c.redAdd(d);
251
- // H = (c * Z1)^2
252
- var h = this.curve._mulC(this.z).redSqr();
253
- // J = E - 2 * H
254
- var j = e.redSub(h).redSub(h);
255
- // X3 = c * (B - E) * J
256
- nx = this.curve._mulC(b.redISub(e)).redMul(j);
257
- // Y3 = c * E * (C - D)
258
- ny = this.curve._mulC(e).redMul(c.redISub(d));
259
- // Z3 = E * J
260
- nz = e.redMul(j);
261
- }
262
- return this.curve.point(nx, ny, nz);
263
- };
264
-
265
- Point.prototype.dbl = function dbl() {
266
- if (this.isInfinity())
267
- return this;
268
-
269
- // Double in extended coordinates
270
- if (this.curve.extended)
271
- return this._extDbl();
272
- else
273
- return this._projDbl();
274
- };
275
-
276
- Point.prototype._extAdd = function _extAdd(p) {
277
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
278
- // #addition-add-2008-hwcd-3
279
- // 8M
280
-
281
- // A = (Y1 - X1) * (Y2 - X2)
282
- var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
283
- // B = (Y1 + X1) * (Y2 + X2)
284
- var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
285
- // C = T1 * k * T2
286
- var c = this.t.redMul(this.curve.dd).redMul(p.t);
287
- // D = Z1 * 2 * Z2
288
- var d = this.z.redMul(p.z.redAdd(p.z));
289
- // E = B - A
290
- var e = b.redSub(a);
291
- // F = D - C
292
- var f = d.redSub(c);
293
- // G = D + C
294
- var g = d.redAdd(c);
295
- // H = B + A
296
- var h = b.redAdd(a);
297
- // X3 = E * F
298
- var nx = e.redMul(f);
299
- // Y3 = G * H
300
- var ny = g.redMul(h);
301
- // T3 = E * H
302
- var nt = e.redMul(h);
303
- // Z3 = F * G
304
- var nz = f.redMul(g);
305
- return this.curve.point(nx, ny, nz, nt);
306
- };
307
-
308
- Point.prototype._projAdd = function _projAdd(p) {
309
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
310
- // #addition-add-2008-bbjlp
311
- // #addition-add-2007-bl
312
- // 10M + 1S
313
-
314
- // A = Z1 * Z2
315
- var a = this.z.redMul(p.z);
316
- // B = A^2
317
- var b = a.redSqr();
318
- // C = X1 * X2
319
- var c = this.x.redMul(p.x);
320
- // D = Y1 * Y2
321
- var d = this.y.redMul(p.y);
322
- // E = d * C * D
323
- var e = this.curve.d.redMul(c).redMul(d);
324
- // F = B - E
325
- var f = b.redSub(e);
326
- // G = B + E
327
- var g = b.redAdd(e);
328
- // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
329
- var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
330
- var nx = a.redMul(f).redMul(tmp);
331
- var ny;
332
- var nz;
333
- if (this.curve.twisted) {
334
- // Y3 = A * G * (D - a * C)
335
- ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
336
- // Z3 = F * G
337
- nz = f.redMul(g);
338
- } else {
339
- // Y3 = A * G * (D - C)
340
- ny = a.redMul(g).redMul(d.redSub(c));
341
- // Z3 = c * F * G
342
- nz = this.curve._mulC(f).redMul(g);
343
- }
344
- return this.curve.point(nx, ny, nz);
345
- };
346
-
347
- Point.prototype.add = function add(p) {
348
- if (this.isInfinity())
349
- return p;
350
- if (p.isInfinity())
351
- return this;
352
-
353
- if (this.curve.extended)
354
- return this._extAdd(p);
355
- else
356
- return this._projAdd(p);
357
- };
358
-
359
- Point.prototype.mul = function mul(k) {
360
- if (this._hasDoubles(k))
361
- return this.curve._fixedNafMul(this, k);
362
- else
363
- return this.curve._wnafMul(this, k);
364
- };
365
-
366
- Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
367
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
368
- };
369
-
370
- Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
371
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
372
- };
373
-
374
- Point.prototype.normalize = function normalize() {
375
- if (this.zOne)
376
- return this;
377
-
378
- // Normalize coordinates
379
- var zi = this.z.redInvm();
380
- this.x = this.x.redMul(zi);
381
- this.y = this.y.redMul(zi);
382
- if (this.t)
383
- this.t = this.t.redMul(zi);
384
- this.z = this.curve.one;
385
- this.zOne = true;
386
- return this;
387
- };
388
-
389
- Point.prototype.neg = function neg() {
390
- return this.curve.point(this.x.redNeg(),
391
- this.y,
392
- this.z,
393
- this.t && this.t.redNeg());
394
- };
395
-
396
- Point.prototype.getX = function getX() {
397
- this.normalize();
398
- return this.x.fromRed();
399
- };
400
-
401
- Point.prototype.getY = function getY() {
402
- this.normalize();
403
- return this.y.fromRed();
404
- };
405
-
406
- Point.prototype.eq = function eq(other) {
407
- return this === other ||
408
- this.getX().cmp(other.getX()) === 0 &&
409
- this.getY().cmp(other.getY()) === 0;
410
- };
411
-
412
- Point.prototype.eqXToP = function eqXToP(x) {
413
- var rx = x.toRed(this.curve.red).redMul(this.z);
414
- if (this.x.cmp(rx) === 0)
415
- return true;
416
-
417
- var xc = x.clone();
418
- var t = this.curve.redN.redMul(this.z);
419
- for (;;) {
420
- xc.iadd(this.curve.n);
421
- if (xc.cmp(this.curve.p) >= 0)
422
- return false;
423
-
424
- rx.redIAdd(t);
425
- if (this.x.cmp(rx) === 0)
426
- return true;
427
- }
428
- };
429
-
430
- // Compatibility with BaseCurve
431
- Point.prototype.toP = Point.prototype.normalize;
432
- Point.prototype.mixedAdd = Point.prototype.add;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var curve = exports;
4
-
5
- curve.base = require('./base');
6
- curve.short = require('./short');
7
- curve.mont = require('./mont');
8
- curve.edwards = require('./edwards');