finitefields 0.0.11 → 0.0.12

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/ellipticcurves.ts CHANGED
@@ -189,6 +189,24 @@ interface Ipoint {
189
189
  constructor: Function;
190
190
  }
191
191
 
192
+ (Array as any).prototype.origToString = Array.prototype.toString;
193
+ Array.prototype.toString = function(this:Maybe<Point>): string {
194
+ let p:Point;
195
+ let x:bigint;
196
+ let y:bigint;
197
+
198
+ if (!empty(this)) {
199
+ if (!(typeof this === 'object') && ('∞' in this[0]))
200
+ return (this as any).origToString();
201
+ p = fold(this);
202
+ [x,y] = [p.x,p.y];
203
+
204
+ return `(${x},${y})`;
205
+ }
206
+ else
207
+ return '∞';
208
+ }
209
+
192
210
  class Point implements Ipoint {
193
211
  public 'x':bigint;
194
212
  public 'y':bigint;
@@ -207,7 +225,7 @@ class Point implements Ipoint {
207
225
  default:
208
226
  return fail();
209
227
  }
210
-
228
+
211
229
  return this;
212
230
  }
213
231
  }
package/main.ts CHANGED
@@ -42,20 +42,21 @@ curve = new ecℤp(field, birch17());
42
42
  // process.exit(0);
43
43
  // p = undefined as any;
44
44
 
45
+ log(['Adding point (5,1) to itself:']);
45
46
  mp = curve.p;
46
47
  mq = curve.q;
47
- log(curve.p);
48
+ log('n=0', mp.toString());
48
49
 
49
50
  // mp = curve.add(curve.p, curve.q);
50
51
  // mp = curve.q;
51
52
 
52
53
  q = fold(mq);
53
54
  p = fold(curve.p);
54
- for (n=0n; n<22n; n++) {
55
+ for (n=1n; n<23n; n++) {
55
56
  mp = curve.add(mp, mq);
56
- log(mp);
57
+ log('n='+n.toString(), mp.toString());
57
58
  }
58
- log(mp);
59
+ log('n='+n.toString(), mp.toString());
59
60
 
60
61
  export { Polynomial,Util,PrimeField,ecℤp,Point };
61
62
  export { p256,empty,fold,just,nothing };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "finitefields",
3
3
  "type": "module",
4
- "version": "0.0.11",
4
+ "version": "0.0.12",
5
5
  "description": "Galois/Finite field crypto and raw elliptic curves",
6
6
  "main": "main.js",
7
7
  "scripts": {