Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

micro-eth-signer

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micro-eth-signer - npm Package Compare versions

Comparing version 0.4.2 to 0.4.7

4

index.d.ts

@@ -76,5 +76,5 @@ /*! micro-eth-signer - MIT License (c) Paul Miller (paulmillr.com) */

get hash(): string;
sign(privateKey: string | Uint8Array): Promise<Transaction>;
recoverSenderPublicKey(): string | undefined;
sign(privateKey: string | Uint8Array, extraEntropy?: boolean): Promise<Transaction>;
recoverSenderPublicKey(): Uint8Array | undefined;
}
export {};

@@ -5,6 +5,6 @@ "use strict";

exports.Transaction = exports.Address = exports.strip0x = exports.add0x = exports.TRANSACTION_TYPES = exports.CHAIN_TYPES = void 0;
const sha3_1 = require("@noble/hashes/lib/sha3");
const utils_1 = require("@noble/hashes/lib/utils");
const sha3_1 = require("@noble/hashes/sha3");
const utils_1 = require("@noble/hashes/utils");
const secp256k1 = require("@noble/secp256k1");
const rlp = require("micro-rlp");
const rlp_1 = require("rlp");
exports.CHAIN_TYPES = { mainnet: 1, ropsten: 3, rinkeby: 4, goerli: 5, kovan: 42 };

@@ -77,3 +77,3 @@ exports.TRANSACTION_TYPES = { legacy: 0, eip2930: 1, eip1559: 2 };

if (value instanceof Uint8Array)
value = add0x(utils_1.bytesToHex(value));
value = add0x((0, utils_1.bytesToHex)(value));
if (field === 'yParity' && typeof value === 'boolean')

@@ -97,3 +97,3 @@ value = value ? '0x1' : '0x0';

if (value instanceof Uint8Array)
value = utils_1.bytesToHex(value);
value = (0, utils_1.bytesToHex)(value);
if (typeof value !== 'string')

@@ -215,3 +215,3 @@ throw new TypeError(`Invalid type for field ${field}`);

const tNum = exports.TRANSACTION_TYPES[type];
return (tNum ? `0x0${tNum}` : '0x') + utils_1.bytesToHex(rlp.encode(normalized));
return (tNum ? `0x0${tNum}` : '0x') + (0, utils_1.bytesToHex)(rlp_1.default.encode(normalized));
}

@@ -231,3 +231,3 @@ exports.Address = {

const pub = len === 65 ? key : secp256k1.Point.fromHex(key).toRawBytes(false);
const addr = utils_1.bytesToHex(sha3_1.keccak_256(pub.slice(1, 65))).slice(24);
const addr = (0, utils_1.bytesToHex)((0, sha3_1.keccak_256)(pub.slice(1, 65))).slice(24);
return exports.Address.checksum(addr);

@@ -239,3 +239,3 @@ },

throw new Error('Invalid address, must have 40 chars');
const hash = strip0x(utils_1.bytesToHex(sha3_1.keccak_256(addr)));
const hash = strip0x((0, utils_1.bytesToHex)((0, sha3_1.keccak_256)(addr)));
let checksummed = '';

@@ -257,3 +257,3 @@ for (let i = 0; i < addr.length; i++) {

return true;
const hash = utils_1.bytesToHex(sha3_1.keccak_256(addr.toLowerCase()));
const hash = (0, utils_1.bytesToHex)((0, sha3_1.keccak_256)(addr.toLowerCase()));
for (let i = 0; i < 40; i++) {

@@ -278,3 +278,3 @@ const nth = Number.parseInt(hash[i], 16);

else if (data instanceof Uint8Array) {
norm = utils_1.bytesToHex(data);
norm = (0, utils_1.bytesToHex)(data);
}

@@ -301,3 +301,3 @@ else if (Array.isArray(data) || (typeof data === 'object' && data != null)) {

this.type = type;
const ui8a = rlp.decode(txData);
const ui8a = rlp_1.default.decode(txData);
this.raw = ui8a.reduce((res, value, i) => {

@@ -388,6 +388,6 @@ const name = TypeToFields[type][i];

}
let encoded = rlp.encode(values);
let encoded = rlp_1.default.encode(values);
if (this.type !== 'legacy')
encoded = new Uint8Array([exports.TRANSACTION_TYPES[this.type], ...Array.from(encoded)]);
return utils_1.bytesToHex(sha3_1.keccak_256(encoded));
return (0, utils_1.bytesToHex)((0, sha3_1.keccak_256)(encoded));
}

@@ -399,3 +399,3 @@ get hash() {

}
async sign(privateKey) {
async sign(privateKey, extraEntropy = false) {
if (this.isSigned)

@@ -407,3 +407,3 @@ throw new Error('Expected unsigned transaction');

recovered: true,
canonical: true,
extraEntropy: extraEntropy === false ? undefined : true
});

@@ -423,6 +423,7 @@ const signature = secp256k1.Signature.fromHex(hex);

const [r, s] = [this.raw.r, this.raw.s].map((n) => hexToNumber(n));
if (this.hardfork !== 'chainstart' && s && s > secp256k1.CURVE.n / 2n) {
const sig = new secp256k1.Signature(r, s);
if (this.hardfork !== 'chainstart' && sig.hasHighS()) {
throw new Error('Invalid signature: s is invalid');
}
const signature = new secp256k1.Signature(r, s).toHex();
const signature = sig.toHex();
const v = Number(hexToNumber(this.type === 'legacy' ? this.raw.v : this.raw.yParity));

@@ -429,0 +430,0 @@ const chainId = Number(this.raw.chainId);

{
"name": "micro-eth-signer",
"version": "0.4.2",
"version": "0.4.7",
"description": "Create, sign and validate Ethereum transactions & addresses with minimum deps. Supports London & Berlin txs",

@@ -43,5 +43,5 @@ "main": "index.js",

"dependencies": {
"@noble/hashes": "^0.4.1",
"@noble/secp256k1": "^1.3.0",
"micro-rlp": "2.2.9"
"@noble/hashes": "~1.0.0",
"@noble/secp256k1": "~1.5.2",
"rlp": "3.0.0"
},

@@ -54,4 +54,4 @@ "devDependencies": {

"rollup": "^2.42.4",
"typescript": "^4.2.3"
"typescript": "^4.5.3"
}
}
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