diff --git a/dist/es/calculate-contract-address.js b/dist/es/calculate-contract-address.js index 2250c12..9f9ee56 100644 --- a/dist/es/calculate-contract-address.js +++ b/dist/es/calculate-contract-address.js @@ -1,6 +1,6 @@ import { generateAddress, toChecksumAddress, toBuffer } from 'ethereumjs-util'; import { addLeading0x } from './util'; -export default function calculateContractAddress(creatorAddress, nonce) { +export function calculateContractAddress(creatorAddress, nonce) { var addressBuffer = generateAddress(toBuffer(addLeading0x(creatorAddress)), toBuffer(nonce)); var address = addressBuffer.toString('hex'); return toChecksumAddress(addLeading0x(address)); diff --git a/dist/es/create-identity.js b/dist/es/create-identity.js index d8780c5..6d2a292 100644 --- a/dist/es/create-identity.js +++ b/dist/es/create-identity.js @@ -27,7 +27,7 @@ export function createPrivateKey(entropy) { * private-, public-Key and address * @param {Buffer?} entropy if provided, will use that as single random-source */ -export default function createIdentity(entropy) { +export function createIdentity(entropy) { var privateKey = createPrivateKey(entropy); var wallet = new Wallet(privateKey); var identity = { diff --git a/dist/es/decrypt-with-private-key.js b/dist/es/decrypt-with-private-key.js index ace43b1..68afa11 100644 --- a/dist/es/decrypt-with-private-key.js +++ b/dist/es/decrypt-with-private-key.js @@ -1,7 +1,7 @@ import { decrypt } from 'eccrypto'; import { parse } from './cipher'; import { removeLeading0x } from './util'; -export default function decryptWithPrivateKey(privateKey, encrypted) { +export function decryptWithPrivateKey(privateKey, encrypted) { encrypted = parse(encrypted); // remove trailing '0x' from privateKey diff --git a/dist/es/encrypt-with-public-key.js b/dist/es/encrypt-with-public-key.js index 085d266..3c7041a 100644 --- a/dist/es/encrypt-with-public-key.js +++ b/dist/es/encrypt-with-public-key.js @@ -1,6 +1,6 @@ import { encrypt } from 'eccrypto'; import { decompress } from './public-key'; -export default function encryptWithPublicKey(publicKey, message, opts) { +export function encryptWithPublicKey(publicKey, message, opts) { // ensure its an uncompressed publicKey publicKey = decompress(publicKey); diff --git a/dist/es/index.js b/dist/es/index.js index a01779b..17ede46 100644 --- a/dist/es/index.js +++ b/dist/es/index.js @@ -1,15 +1,15 @@ -import createIdentity from './create-identity'; +import { createIdentity } from './create-identity'; import * as publicKey from './public-key'; -import decryptWithPrivateKey from './decrypt-with-private-key'; -import encryptWithPublicKey from './encrypt-with-public-key'; +import { decryptWithPrivateKey } from './decrypt-with-private-key'; +import { encryptWithPublicKey } from './encrypt-with-public-key'; import * as cipher from './cipher'; -import publicKeyByPrivateKey from './public-key-by-private-key'; -import recover from './recover'; -import recoverPublicKey from './recover-public-key'; -import sign from './sign'; -import signTransaction from './sign-transaction'; -import txDataByCompiled from './tx-data-by-compiled'; -import calculateContractAddress from './calculate-contract-address'; +import { publicKeyByPrivateKey } from './public-key-by-private-key'; +import { recover } from './recover'; +import { recoverPublicKey } from './recover-public-key'; +import { sign } from './sign'; +import { signTransaction } from './sign-transaction'; +import { txDataByCompiled } from './tx-data-by-compiled'; +import { calculateContractAddress } from './calculate-contract-address'; import * as hash from './hash'; import * as hex from './hex'; import * as vrs from './vrs'; diff --git a/dist/es/public-key-by-private-key.js b/dist/es/public-key-by-private-key.js index 8d8decd..d036ada 100644 --- a/dist/es/public-key-by-private-key.js +++ b/dist/es/public-key-by-private-key.js @@ -7,7 +7,7 @@ import { addLeading0x } from './util'; * where 04 has stripped from left * @returns {string} */ -export default function publicKeyOfPrivateKey(privateKey) { +export function publicKeyByPrivateKey(privateKey) { privateKey = addLeading0x(privateKey); var publicKeyBuffer = privateToPublic(toBuffer(privateKey)); return publicKeyBuffer.toString('hex'); diff --git a/dist/es/recover-public-key.js b/dist/es/recover-public-key.js index fc80e4e..28c3015 100644 --- a/dist/es/recover-public-key.js +++ b/dist/es/recover-public-key.js @@ -7,7 +7,7 @@ import { removeLeading0x, hexToUnit8Array, uint8ArrayToHex } from './util'; * @param {string} hash * @return {string} publicKey */ -export default function recoverPublicKey(signature, hash) { +export function recoverPublicKey(signature, hash) { signature = removeLeading0x(signature); // split into v-value and sig diff --git a/dist/es/recover.js b/dist/es/recover.js index 2b4a616..04c8e73 100644 --- a/dist/es/recover.js +++ b/dist/es/recover.js @@ -1,4 +1,4 @@ -import recoverPublicKey from './recover-public-key'; +import { recoverPublicKey } from './recover-public-key'; import { toAddress as addressByPublicKey } from './public-key'; /** @@ -7,7 +7,7 @@ import { toAddress as addressByPublicKey } from './public-key'; * @param {string} hash * @return {string} address */ -export default function recover(sigString, hash) { +export function recover(sigString, hash) { var pubkey = recoverPublicKey(sigString, hash); var address = addressByPublicKey(pubkey); return address; diff --git a/dist/es/sign-transaction.js b/dist/es/sign-transaction.js index 0a94f47..49aa370 100644 --- a/dist/es/sign-transaction.js +++ b/dist/es/sign-transaction.js @@ -1,7 +1,7 @@ import { Transaction } from '@ethereumjs/tx'; -import publicKeyByPrivateKey from './public-key-by-private-key'; +import { publicKeyByPrivateKey } from './public-key-by-private-key'; import { toAddress as addressByPublicKey } from './public-key'; -export default function signTransaction(rawTx, privateKey) { +export function signTransaction(rawTx, privateKey) { var txOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; // check if privateKey->address matches rawTx.from var publicKey = publicKeyByPrivateKey(privateKey); diff --git a/dist/es/sign.js b/dist/es/sign.js index 3c82472..14964f8 100644 --- a/dist/es/sign.js +++ b/dist/es/sign.js @@ -8,7 +8,7 @@ import { addLeading0x, removeLeading0x } from './util'; * @param {string} hash * @return {string} hexString */ -export default function sign(privateKey, hash) { +export function sign(privateKey, hash) { hash = addLeading0x(hash); if (hash.length !== 66) throw new Error('EthCrypto.sign(): Can only sign hashes, given: ' + hash); var sigObj = secp256k1_sign(new Uint8Array(Buffer.from(removeLeading0x(hash), 'hex')), new Uint8Array(Buffer.from(removeLeading0x(privateKey), 'hex'))); diff --git a/dist/es/tx-data-by-compiled.js b/dist/es/tx-data-by-compiled.js index 7207b16..e65ba0a 100644 --- a/dist/es/tx-data-by-compiled.js +++ b/dist/es/tx-data-by-compiled.js @@ -1,6 +1,6 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; import { ContractFactory } from 'ethers'; -export default function txDataByCompiled(abi, bytecode, args) { +export function txDataByCompiled(abi, bytecode, args) { // solc returns a string which is often passed instead of the json if (typeof abi === 'string') abi = JSON.parse(abi); diff --git a/dist/lib/calculate-contract-address.js b/dist/lib/calculate-contract-address.js index dd87d7b..9a889ff 100644 --- a/dist/lib/calculate-contract-address.js +++ b/dist/lib/calculate-contract-address.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = calculateContractAddress; +exports.calculateContractAddress = calculateContractAddress; var _ethereumjsUtil = require("ethereumjs-util"); var _util = require("./util"); function calculateContractAddress(creatorAddress, nonce) { diff --git a/dist/lib/create-identity.js b/dist/lib/create-identity.js index ccbbb23..420ce09 100644 --- a/dist/lib/create-identity.js +++ b/dist/lib/create-identity.js @@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); +exports.createIdentity = createIdentity; exports.createPrivateKey = createPrivateKey; -exports["default"] = createIdentity; var _ethers = require("ethers"); var _ethereumjsUtil = require("ethereumjs-util"); var MIN_ENTROPY_SIZE = 128; diff --git a/dist/lib/decrypt-with-private-key.js b/dist/lib/decrypt-with-private-key.js index 68655f0..065df13 100644 --- a/dist/lib/decrypt-with-private-key.js +++ b/dist/lib/decrypt-with-private-key.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = decryptWithPrivateKey; +exports.decryptWithPrivateKey = decryptWithPrivateKey; var _eccrypto = require("eccrypto"); var _cipher = require("./cipher"); var _util = require("./util"); diff --git a/dist/lib/encrypt-with-public-key.js b/dist/lib/encrypt-with-public-key.js index f1ff2e3..197d103 100644 --- a/dist/lib/encrypt-with-public-key.js +++ b/dist/lib/encrypt-with-public-key.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = encryptWithPublicKey; +exports.encryptWithPublicKey = encryptWithPublicKey; var _eccrypto = require("eccrypto"); var _publicKey = require("./public-key"); function encryptWithPublicKey(publicKey, message, opts) { diff --git a/dist/lib/index.js b/dist/lib/index.js index 8c8d410..89f8d7c 100644 --- a/dist/lib/index.js +++ b/dist/lib/index.js @@ -1,6 +1,5 @@ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true @@ -8,81 +7,81 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "calculateContractAddress", { enumerable: true, get: function get() { - return _calculateContractAddress["default"]; + return _calculateContractAddress.calculateContractAddress; } }); exports.cipher = void 0; Object.defineProperty(exports, "createIdentity", { enumerable: true, get: function get() { - return _createIdentity["default"]; + return _createIdentity.createIdentity; } }); Object.defineProperty(exports, "decryptWithPrivateKey", { enumerable: true, get: function get() { - return _decryptWithPrivateKey["default"]; + return _decryptWithPrivateKey.decryptWithPrivateKey; } }); exports["default"] = void 0; Object.defineProperty(exports, "encryptWithPublicKey", { enumerable: true, get: function get() { - return _encryptWithPublicKey["default"]; + return _encryptWithPublicKey.encryptWithPublicKey; } }); exports.publicKey = exports.hex = exports.hash = void 0; Object.defineProperty(exports, "publicKeyByPrivateKey", { enumerable: true, get: function get() { - return _publicKeyByPrivateKey["default"]; + return _publicKeyByPrivateKey.publicKeyByPrivateKey; } }); Object.defineProperty(exports, "recover", { enumerable: true, get: function get() { - return _recover["default"]; + return _recover.recover; } }); Object.defineProperty(exports, "recoverPublicKey", { enumerable: true, get: function get() { - return _recoverPublicKey["default"]; + return _recoverPublicKey.recoverPublicKey; } }); Object.defineProperty(exports, "sign", { enumerable: true, get: function get() { - return _sign["default"]; + return _sign.sign; } }); Object.defineProperty(exports, "signTransaction", { enumerable: true, get: function get() { - return _signTransaction["default"]; + return _signTransaction.signTransaction; } }); Object.defineProperty(exports, "txDataByCompiled", { enumerable: true, get: function get() { - return _txDataByCompiled["default"]; + return _txDataByCompiled.txDataByCompiled; } }); exports.vrs = exports.util = void 0; -var _createIdentity = _interopRequireDefault(require("./create-identity")); +var _createIdentity = require("./create-identity"); var publicKey = _interopRequireWildcard(require("./public-key")); exports.publicKey = publicKey; -var _decryptWithPrivateKey = _interopRequireDefault(require("./decrypt-with-private-key")); -var _encryptWithPublicKey = _interopRequireDefault(require("./encrypt-with-public-key")); +var _decryptWithPrivateKey = require("./decrypt-with-private-key"); +var _encryptWithPublicKey = require("./encrypt-with-public-key"); var cipher = _interopRequireWildcard(require("./cipher")); exports.cipher = cipher; -var _publicKeyByPrivateKey = _interopRequireDefault(require("./public-key-by-private-key")); -var _recover = _interopRequireDefault(require("./recover")); -var _recoverPublicKey = _interopRequireDefault(require("./recover-public-key")); -var _sign = _interopRequireDefault(require("./sign")); -var _signTransaction = _interopRequireDefault(require("./sign-transaction")); -var _txDataByCompiled = _interopRequireDefault(require("./tx-data-by-compiled")); -var _calculateContractAddress = _interopRequireDefault(require("./calculate-contract-address")); +var _publicKeyByPrivateKey = require("./public-key-by-private-key"); +var _recover = require("./recover"); +var _recoverPublicKey = require("./recover-public-key"); +var _sign = require("./sign"); +var _signTransaction = require("./sign-transaction"); +var _txDataByCompiled = require("./tx-data-by-compiled"); +var _calculateContractAddress = require("./calculate-contract-address"); var hash = _interopRequireWildcard(require("./hash")); exports.hash = hash; var hex = _interopRequireWildcard(require("./hex")); @@ -94,18 +93,18 @@ exports.util = util; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } var _default = { - createIdentity: _createIdentity["default"], + createIdentity: _createIdentity.createIdentity, publicKey: publicKey, - decryptWithPrivateKey: _decryptWithPrivateKey["default"], - encryptWithPublicKey: _encryptWithPublicKey["default"], + decryptWithPrivateKey: _decryptWithPrivateKey.decryptWithPrivateKey, + encryptWithPublicKey: _encryptWithPublicKey.encryptWithPublicKey, cipher: cipher, - publicKeyByPrivateKey: _publicKeyByPrivateKey["default"], - recover: _recover["default"], - recoverPublicKey: _recoverPublicKey["default"], - sign: _sign["default"], - signTransaction: _signTransaction["default"], - txDataByCompiled: _txDataByCompiled["default"], - calculateContractAddress: _calculateContractAddress["default"], + publicKeyByPrivateKey: _publicKeyByPrivateKey.publicKeyByPrivateKey, + recover: _recover.recover, + recoverPublicKey: _recoverPublicKey.recoverPublicKey, + sign: _sign.sign, + signTransaction: _signTransaction.signTransaction, + txDataByCompiled: _txDataByCompiled.txDataByCompiled, + calculateContractAddress: _calculateContractAddress.calculateContractAddress, hash: hash, hex: hex, vrs: vrs, diff --git a/dist/lib/public-key-by-private-key.js b/dist/lib/public-key-by-private-key.js index 391c65d..4480b07 100644 --- a/dist/lib/public-key-by-private-key.js +++ b/dist/lib/public-key-by-private-key.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = publicKeyOfPrivateKey; +exports.publicKeyByPrivateKey = publicKeyByPrivateKey; var _ethereumjsUtil = require("ethereumjs-util"); var _util = require("./util"); /** @@ -12,7 +12,7 @@ var _util = require("./util"); * where 04 has stripped from left * @returns {string} */ -function publicKeyOfPrivateKey(privateKey) { +function publicKeyByPrivateKey(privateKey) { privateKey = (0, _util.addLeading0x)(privateKey); var publicKeyBuffer = (0, _ethereumjsUtil.privateToPublic)((0, _ethereumjsUtil.toBuffer)(privateKey)); return publicKeyBuffer.toString('hex'); diff --git a/dist/lib/recover-public-key.js b/dist/lib/recover-public-key.js index f33b0b8..6e49d2e 100644 --- a/dist/lib/recover-public-key.js +++ b/dist/lib/recover-public-key.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = recoverPublicKey; +exports.recoverPublicKey = recoverPublicKey; var _secp256k = require("secp256k1"); var _util = require("./util"); /** diff --git a/dist/lib/recover.js b/dist/lib/recover.js index 571ebac..04ed62a 100644 --- a/dist/lib/recover.js +++ b/dist/lib/recover.js @@ -1,11 +1,10 @@ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = recover; -var _recoverPublicKey = _interopRequireDefault(require("./recover-public-key")); +exports.recover = recover; +var _recoverPublicKey = require("./recover-public-key"); var _publicKey = require("./public-key"); /** * returns the adress with which the messageHash was signed @@ -14,7 +13,7 @@ var _publicKey = require("./public-key"); * @return {string} address */ function recover(sigString, hash) { - var pubkey = (0, _recoverPublicKey["default"])(sigString, hash); + var pubkey = (0, _recoverPublicKey.recoverPublicKey)(sigString, hash); var address = (0, _publicKey.toAddress)(pubkey); return address; } \ No newline at end of file diff --git a/dist/lib/sign-transaction.js b/dist/lib/sign-transaction.js index 4c5708c..aefaa10 100644 --- a/dist/lib/sign-transaction.js +++ b/dist/lib/sign-transaction.js @@ -1,17 +1,16 @@ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = signTransaction; +exports.signTransaction = signTransaction; var _tx = require("@ethereumjs/tx"); -var _publicKeyByPrivateKey = _interopRequireDefault(require("./public-key-by-private-key")); +var _publicKeyByPrivateKey = require("./public-key-by-private-key"); var _publicKey = require("./public-key"); function signTransaction(rawTx, privateKey) { var txOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; // check if privateKey->address matches rawTx.from - var publicKey = (0, _publicKeyByPrivateKey["default"])(privateKey); + var publicKey = (0, _publicKeyByPrivateKey.publicKeyByPrivateKey)(privateKey); var address = (0, _publicKey.toAddress)(publicKey); if (address != rawTx.from) throw new Error('EthCrypto.signTransaction(): rawTx.from does not match the address of the privateKey'); var privateKeyBuffer = Buffer.from(privateKey.replace(/^.{2}/g, ''), 'hex'); diff --git a/dist/lib/sign.js b/dist/lib/sign.js index d25545c..0f7f06e 100644 --- a/dist/lib/sign.js +++ b/dist/lib/sign.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = sign; +exports.sign = sign; var _secp256k = require("secp256k1"); var _util = require("./util"); /** diff --git a/dist/lib/tx-data-by-compiled.js b/dist/lib/tx-data-by-compiled.js index ef66acf..cc97985 100644 --- a/dist/lib/tx-data-by-compiled.js +++ b/dist/lib/tx-data-by-compiled.js @@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = txDataByCompiled; +exports.txDataByCompiled = txDataByCompiled; var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); var _ethers = require("ethers"); function txDataByCompiled(abi, bytecode, args) { diff --git a/package.json b/package.json index 769166e..4e2de04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eth-crypto", - "version": "2.5.0", + "version": "2.6.0", "description": "Cryptographic functions for ethereum and how to use them with web3 and solidity", "keywords": [ "ethereum", diff --git a/perf.txt b/perf.txt deleted file mode 100644 index 30eaf0b..0000000 --- a/perf.txt +++ /dev/null @@ -1,3 +0,0 @@ -=== build size -BEFORE: 140000 -AFTER: 123499