Socket
Socket
Sign inDemoInstall

@ethersproject/signing-key

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/signing-key - npm Package Compare versions

Comparing version 6.0.0-beta.1 to 6.0.0-beta.2

README.md

2

lib/_version.d.ts

@@ -1,2 +0,2 @@

export declare const version = "@ethersproject/signing-key@6.0.0-beta.1";
export declare const version = "@ethersproject/signing-key@6.0.0-beta.2";
//# sourceMappingURL=_version.d.ts.map

@@ -1,2 +0,2 @@

export const version = "@ethersproject/signing-key@6.0.0-beta.1";
export const version = "@ethersproject/signing-key@6.0.0-beta.2";
//# sourceMappingURL=_version.js.map

@@ -0,3 +1,3 @@

import type { BytesLike } from "@ethersproject/bytes";
import type { Freezable, Frozen } from "@ethersproject/properties";
import type { BytesLike } from "@ethersproject/bytes";
import type { BigNumberish } from "@ethersproject/logger";

@@ -46,5 +46,4 @@ export declare type SignatureLike = Signature | string | {

static getNormalizedV(v: BigNumberish): 27 | 28;
static fromTransaction(r: string, s: string, _v: BigNumberish): Frozen<Signature>;
static from(sig: SignatureLike): Signature;
}
//# sourceMappingURL=signature.d.ts.map

@@ -13,4 +13,4 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

var _Signature_props;
import { concat, dataLength, hexlify, isHexString } from "@ethersproject/bytes";
import { getStore, setStore } from "@ethersproject/properties";
import { arrayify, concat, dataLength, hexlify, isHexString } from "@ethersproject/bytes";
import { logger } from "./logger.js";

@@ -44,3 +44,3 @@ // Constants

}
else if (arrayify(value)[0] & 0x80) {
else if (logger.getBytes(value)[0] & 0x80) {
logger.throwArgumentError("non-canonical s", "value", value);

@@ -82,3 +82,3 @@ }

// The EIP-2098 compact representation
const yParityAndS = arrayify(this.s);
const yParityAndS = logger.getBytes(this.s);
if (this.yParity) {

@@ -99,9 +99,7 @@ yParityAndS[0] |= 0x80;

clone() {
if (getStore(__classPrivateFieldGet(this, _Signature_props, "f"), "networkV")) {
logger.throwError("cannot clone EIP-155 signatures", "UNSUPPORTED_OPERATION", {
operation: "clone"
});
const clone = new Signature(_guard, this.r, this.s, this.v);
if (this.networkV) {
setStore(__classPrivateFieldGet(clone, _Signature_props, "f"), "networkV", this.networkV);
}
const { r, s, v } = __classPrivateFieldGet(this, _Signature_props, "f");
return new Signature(_guard, r, s, v);
return clone;
}

@@ -116,7 +114,7 @@ freeze() {

toJSON() {
const { r, s, v, networkV } = this;
const networkV = this.networkV;
return {
_type: "signature",
networkV: ((networkV != null) ? networkV.toString() : null),
r, s, v,
r: this.r, s: this.s, v: this.v,
};

@@ -156,8 +154,2 @@ }

}
static fromTransaction(r, s, _v) {
const v = logger.getBigInt(_v, "v");
const sig = Signature.from({ r, s, v });
setStore(__classPrivateFieldGet(sig, _Signature_props, "f"), "networkV", v);
return sig.freeze();
}
static from(sig) {

@@ -200,3 +192,3 @@ const throwError = (message) => {

const s = (function (s, yParityAndS) {
if (s) {
if (s != null) {
if (!isHexString(s, 32)) {

@@ -207,7 +199,7 @@ throwError("invalid s");

}
if (yParityAndS) {
if (yParityAndS != null) {
if (!isHexString(yParityAndS, 32)) {
throwError("invalid yParityAndS");
}
const bytes = arrayify(yParityAndS);
const bytes = logger.getBytes(yParityAndS);
bytes[0] &= 0x7f;

@@ -218,28 +210,33 @@ return hexlify(bytes);

})(sig.s, sig.yParityAndS);
if (arrayify(s)[0] & 0x80) {
if (logger.getBytes(s)[0] & 0x80) {
throwError("non-canonical s");
}
// Get v; by any means necessary (we check consistency below)
const v = (function (v, yParityAndS, yParity) {
if (v) {
return Signature.getNormalizedV(v);
const { networkV, v } = (function (_v, yParityAndS, yParity) {
if (_v != null) {
const v = logger.getBigInt(_v);
return {
networkV: ((v >= BN_35) ? v : undefined),
v: Signature.getNormalizedV(v)
};
}
if (yParityAndS) {
if (yParityAndS != null) {
if (!isHexString(yParityAndS, 32)) {
throwError("invalid yParityAndS");
}
return ((arrayify(yParityAndS)[0] & 0x80) ? 28 : 27);
return { v: ((logger.getBytes(yParityAndS)[0] & 0x80) ? 28 : 27) };
}
if (yParity) {
if (yParity != null) {
switch (yParity) {
case 0: return 27;
case 1: return 28;
case 0: return { v: 27 };
case 1: return { v: 28 };
}
return throwError("invalid yParity");
}
//if (chainId) { return BigNumber.from(chainId).and(1).sub(27); } // @TODO: check this
return throwError("missing v");
})(sig.v, sig.yParityAndS, sig.yParity);
// @TODO: add chainId support
const result = new Signature(_guard, r, s, v);
if (networkV) {
setStore(__classPrivateFieldGet(result, _Signature_props, "f"), "networkV", networkV);
}
// If multiple of v, yParity, yParityAndS we given, check they match

@@ -252,4 +249,2 @@ if ("yParity" in sig && sig.yParity !== result.yParity) {

}
//if (sig.chainId && sig.chainId !== result.chainId) {
//}
return result;

@@ -256,0 +251,0 @@ }

@@ -19,3 +19,3 @@ {

"ethereum": "donations.ethers.eth",
"gitHead": "77f691b3bc3a6387a5184ec9b1779faab4bcb30d",
"gitHead": "4fcde0967317451fac6cec6addba8258f98c14b5",
"keywords": [

@@ -41,6 +41,6 @@ "Ethereum",

"sideEffects": false,
"tarballHash": "0x1e018e6c270e54aabd3b8ec6bda5d5214afa5db34a1f33456f4a2f1c81f129c9",
"tarballHash": "0x1f4cae8944fb490ad2b8681a54f5dd709d4a69e760f2c32c57ab62241780bc75",
"type": "module",
"types": "./lib/index.d.ts",
"version": "6.0.0-beta.1"
"version": "6.0.0-beta.2"
}

@@ -1,1 +0,1 @@

export const version = "@ethersproject/signing-key@6.0.0-beta.1";
export const version = "@ethersproject/signing-key@6.0.0-beta.2";

@@ -0,15 +1,11 @@

import { concat, dataLength, hexlify, isHexString } from "@ethersproject/bytes";
import { getStore, setStore } from "@ethersproject/properties";
//import type { BigNumberish } from "@ethersproject/bignumber";
import type { Freezable, Frozen } from "@ethersproject/properties";
import { logger } from "./logger.js";
import { arrayify, concat, dataLength, hexlify, isHexString } from "@ethersproject/bytes";
import type { BytesLike } from "@ethersproject/bytes";
import type { Freezable, Frozen } from "@ethersproject/properties";
import type { BigNumberish } from "@ethersproject/logger";
import { logger } from "./logger.js";
// Constants

@@ -28,16 +24,7 @@ const BN_0 = BigInt(0);

v: BigNumberish;
//chainId?: BigNumberish;
yParity?: 0 | 1;
yParityAndS?: string;
//} | {
// r: string;
// s: string;
// //chainId: BigNumberish;
// v?: BigNumberish;
// yParity?: 0 | 1
// yParityAndS?: string;
} | {
r: string;
yParityAndS: string;
//chainId?: BigNumberish;
yParity?: 0 | 1;

@@ -50,3 +37,2 @@ s?: string;

yParity: 0 | 1;
//chainId?: BigNumberish;
v?: BigNumberish;

@@ -76,3 +62,3 @@ yParityAndS?: string;

logger.throwArgumentError("invalid r", "value", value);
} else if (arrayify(value)[0] & 0x80) {
} else if (logger.getBytes(value)[0] & 0x80) {
logger.throwArgumentError("non-canonical s", "value", value);

@@ -112,3 +98,3 @@ }

// The EIP-2098 compact representation
const yParityAndS = arrayify(this.s);
const yParityAndS = logger.getBytes(this.s);
if (this.yParity) { yParityAndS[0] |= 0x80; }

@@ -136,9 +122,5 @@ return hexlify(yParityAndS);

clone(): Signature {
if (getStore(this.#props, "networkV")) {
logger.throwError("cannot clone EIP-155 signatures", "UNSUPPORTED_OPERATION", {
operation: "clone"
});
}
const { r, s, v } = this.#props;
return new Signature(_guard, r, s, v);
const clone = new Signature(_guard, this.r, this.s, this.v);
if (this.networkV) { setStore(clone.#props, "networkV", this.networkV); }
return clone;
}

@@ -156,7 +138,7 @@

toJSON(): any {
const { r, s, v, networkV } = this;
const networkV = this.networkV;
return {
_type: "signature",
networkV: ((networkV != null) ? networkV.toString(): null),
r, s, v,
r: this.r, s: this.s, v: this.v,
};

@@ -198,9 +180,2 @@ }

static fromTransaction(r: string, s: string, _v: BigNumberish): Frozen<Signature> {
const v = logger.getBigInt(_v, "v");
const sig = Signature.from({ r, s, v });
setStore(sig.#props, "networkV", v);
return sig.freeze();
}
static from(sig: SignatureLike): Signature {

@@ -221,3 +196,3 @@ const throwError = (message: string) => {

if (dataLength(sig) !== 65) {
if (dataLength(sig) !== 65) {
const r = hexlify(sig.slice(0, 32));

@@ -242,37 +217,46 @@ const s = bytes.slice(32, 64);

const s = (function(s?: string, yParityAndS?: string) {
if (s) {
if (s != null) {
if (!isHexString(s, 32)) { throwError("invalid s"); }
return s;
}
if (yParityAndS) {
if (yParityAndS != null) {
if (!isHexString(yParityAndS, 32)) { throwError("invalid yParityAndS"); }
const bytes = arrayify(yParityAndS);
const bytes = logger.getBytes(yParityAndS);
bytes[0] &= 0x7f;
return hexlify(bytes);
}
return throwError("missing s");
})(sig.s, sig.yParityAndS);
if (arrayify(s)[0] & 0x80) { throwError("non-canonical s"); }
if (logger.getBytes(s)[0] & 0x80) { throwError("non-canonical s"); }
// Get v; by any means necessary (we check consistency below)
const v = (function(v?: BigNumberish, yParityAndS?: string, yParity?: number) {
if (v) { return Signature.getNormalizedV(v); }
if (yParityAndS) {
const { networkV, v } = (function(_v?: BigNumberish, yParityAndS?: string, yParity?: number): { networkV?: bigint, v: 27 | 28 } {
if (_v != null) {
const v = logger.getBigInt(_v);
return {
networkV: ((v >= BN_35) ? v: undefined),
v: Signature.getNormalizedV(v)
};
}
if (yParityAndS != null) {
if (!isHexString(yParityAndS, 32)) { throwError("invalid yParityAndS"); }
return ((arrayify(yParityAndS)[0] & 0x80) ? 28: 27);
return { v: ((logger.getBytes(yParityAndS)[0] & 0x80) ? 28: 27) };
}
if (yParity) {
if (yParity != null) {
switch (yParity) {
case 0: return 27;
case 1: return 28;
case 0: return { v: 27 };
case 1: return { v: 28 };
}
return throwError("invalid yParity");
}
//if (chainId) { return BigNumber.from(chainId).and(1).sub(27); } // @TODO: check this
return throwError("missing v");
})(sig.v, sig.yParityAndS, sig.yParity);
// @TODO: add chainId support
const result = new Signature(_guard, r, s, v);
if (networkV) { setStore(result.#props, "networkV", networkV); }

@@ -286,5 +270,2 @@ // If multiple of v, yParity, yParityAndS we given, check they match

//if (sig.chainId && sig.chainId !== result.chainId) {
//}
return result;

@@ -291,0 +272,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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