Socket
Socket
Sign inDemoInstall

@tkey/common-types

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tkey/common-types - npm Package Compare versions

Comparing version 13.0.0-alpha.0 to 13.0.0-alpha.1

30

dist/commonTypes.cjs.js

@@ -198,2 +198,6 @@ /******/ (() => { // webpackBootstrap

}
static fromScalar(s, ec) {
const p = ec.g.mul(s);
return Point.fromElliptic(p);
}

@@ -216,2 +220,5 @@ /**

static fromElliptic(p) {
if (p.isInfinity()) {
return new Point(null, null);
}
return new Point(p.getX(), p.getY());

@@ -224,5 +231,10 @@ }

static fromSEC1(ec, encodedPoint) {
// "elliptic"@6.5.4 can't decode identity.
if (encodedPoint.length === 2 && encodedPoint === "00") {
const identity = ec.g.mul(new (external_bn_js_default())(0));
return Point.fromElliptic(identity);
}
const key = ec.keyFromPublic(encodedPoint, "hex");
const pt = key.getPublic();
return new Point(pt.getX(), pt.getY());
return Point.fromElliptic(pt);
}

@@ -253,2 +265,5 @@

toEllipticPoint(ec) {
if (this.isIdentity()) {
return ec.g.mul(new (external_bn_js_default())(0));
}
const keyPair = ec.keyFromPublic({

@@ -269,2 +284,6 @@ x: this.x.toString("hex"),

let compressed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
// "elliptic"@6.5.4 can't encode identity.
if (this.isIdentity()) {
return Buffer.from("00", "hex");
}
const p = this.toEllipticPoint(ec);

@@ -279,2 +298,11 @@ return Buffer.from(p.encode("hex", compressed), "hex");

}
isIdentity() {
return this.x === null && this.y === null;
}
equals(p) {
if (this.isIdentity()) {
return p.isIdentity();
}
return this.x.eq(p.x) && this.y.eq(p.y);
}
}

@@ -281,0 +309,0 @@ /* harmony default export */ const base_Point = (Point);

@@ -99,2 +99,6 @@ import { encrypt as encrypt$1, decrypt as decrypt$1, generatePrivate, getPublic } from '@toruslabs/eccrypto';

}
static fromScalar(s, ec) {
const p = ec.g.mul(s);
return Point.fromElliptic(p);
}

@@ -117,2 +121,5 @@ /**

static fromElliptic(p) {
if (p.isInfinity()) {
return new Point(null, null);
}
return new Point(p.getX(), p.getY());

@@ -125,5 +132,10 @@ }

static fromSEC1(ec, encodedPoint) {
// "elliptic"@6.5.4 can't decode identity.
if (encodedPoint.length === 2 && encodedPoint === "00") {
const identity = ec.g.mul(new BN(0));
return Point.fromElliptic(identity);
}
const key = ec.keyFromPublic(encodedPoint, "hex");
const pt = key.getPublic();
return new Point(pt.getX(), pt.getY());
return Point.fromElliptic(pt);
}

@@ -154,2 +166,5 @@

toEllipticPoint(ec) {
if (this.isIdentity()) {
return ec.g.mul(new BN(0));
}
const keyPair = ec.keyFromPublic({

@@ -170,2 +185,6 @@ x: this.x.toString("hex"),

let compressed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
// "elliptic"@6.5.4 can't encode identity.
if (this.isIdentity()) {
return Buffer.from("00", "hex");
}
const p = this.toEllipticPoint(ec);

@@ -180,2 +199,11 @@ return Buffer.from(p.encode("hex", compressed), "hex");

}
isIdentity() {
return this.x === null && this.y === null;
}
equals(p) {
if (this.isIdentity()) {
return p.isIdentity();
}
return this.x.eq(p.x) && this.y.eq(p.y);
}
}

@@ -182,0 +210,0 @@

7

dist/types/base/Point.d.ts

@@ -5,5 +5,6 @@ /// <reference types="node" />

declare class Point implements IPoint {
x: BN;
y: BN;
x: BN | null;
y: BN | null;
constructor(x: BNString, y: BNString);
static fromScalar(s: BN, ec: EllipticCurve): Point;
/**

@@ -34,3 +35,5 @@ * @deprecated Use `fromSEC1` instead.

toJSON(): StringifiedType;
isIdentity(): boolean;
equals(p: Point): boolean;
}
export default Point;

@@ -29,4 +29,4 @@ /// <reference types="node" />

export interface IPoint extends ISerializable {
x: BN;
y: BN;
x: BN | null;
y: BN | null;
encode(enc: string, params?: unknown): Buffer;

@@ -33,0 +33,0 @@ }

{
"name": "@tkey/common-types",
"version": "13.0.0-alpha.0",
"version": "13.0.0-alpha.1",
"description": "TKey common types",

@@ -70,3 +70,3 @@ "author": "Torus Labs",

},
"gitHead": "822dd90e9f0880112bb91ce65a380f65e8c79080"
"gitHead": "18a461142685936f9dda868a9b3bda34522caf61"
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc