eth-crypto
Advanced tools
Comparing version 2.3.0 to 2.4.0
var EthCrypto = require('./index.js'); | ||
window['EthCrypto'] = EthCrypto; |
import { compress, decompress } from './public-key'; | ||
export function stringify(cipher) { | ||
if (typeof cipher === 'string') return cipher; // use compressed key because it's smaller | ||
if (typeof cipher === 'string') return cipher; | ||
// use compressed key because it's smaller | ||
var compressedKey = compress(cipher.ephemPublicKey); | ||
var ret = Buffer.concat([Buffer.from(cipher.iv, 'hex'), // 16bit | ||
Buffer.from(compressedKey, 'hex'), // 33bit | ||
Buffer.from(cipher.mac, 'hex'), // 32bit | ||
var ret = Buffer.concat([Buffer.from(cipher.iv, 'hex'), | ||
// 16bit | ||
Buffer.from(compressedKey, 'hex'), | ||
// 33bit | ||
Buffer.from(cipher.mac, 'hex'), | ||
// 32bit | ||
Buffer.from(cipher.ciphertext, 'hex') // var bit | ||
]); | ||
return ret.toString('hex'); | ||
@@ -21,6 +26,7 @@ } | ||
ciphertext: buf.toString('hex', 81, buf.length) | ||
}; // decompress publicKey | ||
}; | ||
// decompress publicKey | ||
ret.ephemPublicKey = '04' + decompress(ret.ephemPublicKey); | ||
return ret; | ||
} |
@@ -5,2 +5,3 @@ import { utils as ethersUtils, Wallet } from 'ethers'; | ||
var keccak256 = ethersUtils.keccak256; | ||
/** | ||
@@ -11,3 +12,2 @@ * create a privateKey from the given entropy or a new one | ||
*/ | ||
export function createPrivateKey(entropy) { | ||
@@ -22,8 +22,7 @@ if (entropy) { | ||
var middleHex = ethersUtils.concat([ethersUtils.concat([ethersUtils.randomBytes(32), innerHex]), ethersUtils.randomBytes(32)]); | ||
var _outerHex = keccak256(middleHex); | ||
return _outerHex; | ||
} | ||
} | ||
/** | ||
@@ -34,3 +33,2 @@ * creates a new object with | ||
*/ | ||
export default function createIdentity(entropy) { | ||
@@ -37,0 +35,0 @@ var privateKey = createPrivateKey(entropy); |
@@ -5,4 +5,5 @@ import { decrypt } from 'eccrypto'; | ||
export default function decryptWithPrivateKey(privateKey, encrypted) { | ||
encrypted = parse(encrypted); // remove trailing '0x' from privateKey | ||
encrypted = parse(encrypted); | ||
// remove trailing '0x' from privateKey | ||
var twoStripped = removeLeading0x(privateKey); | ||
@@ -9,0 +10,0 @@ var encryptedBuffer = { |
@@ -5,4 +5,5 @@ import { encrypt } from 'eccrypto'; | ||
// ensure its an uncompressed publicKey | ||
publicKey = decompress(publicKey); // re-add the compression-flag | ||
publicKey = decompress(publicKey); | ||
// re-add the compression-flag | ||
var pubString = '04' + publicKey; | ||
@@ -9,0 +10,0 @@ return encrypt(Buffer.from(pubString, 'hex'), Buffer.from(message), opts ? opts : {}).then(function (encryptedBuffers) { |
@@ -5,3 +5,2 @@ import { utils as ethersUtils } from 'ethers'; | ||
var values = []; | ||
if (!Array.isArray(params)) { | ||
@@ -16,5 +15,4 @@ types.push('string'); | ||
} | ||
return ethersUtils.solidityKeccak256(types, values); | ||
} | ||
export var SIGN_PREFIX = '\x19Ethereum Signed Message:\n32'; |
@@ -6,10 +6,11 @@ /** | ||
*/ | ||
import { removeLeading0x, addLeading0x } from './util'; | ||
export function compress(hex) { | ||
var base64 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
hex = removeLeading0x(hex); // if base64:true, we use our own function because it results in a smaller output | ||
hex = removeLeading0x(hex); | ||
// if base64:true, we use our own function because it results in a smaller output | ||
if (base64 === true) return Buffer.from(hex, 'hex').toString('base64'); | ||
var string = ''; | ||
while (hex.length % 4 != 0) { | ||
@@ -19,3 +20,2 @@ // we need it to be multiple of 4 | ||
} | ||
for (var i = 0; i < hex.length; i += 4) { | ||
@@ -25,3 +25,2 @@ // get char from ascii code which goes from 0 to 65536 | ||
} | ||
return string; | ||
@@ -31,3 +30,2 @@ } | ||
var base64 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
// if base64:true, we use our own function because it results in a smaller output | ||
@@ -38,5 +36,3 @@ if (base64 === true) { | ||
} | ||
var hex = ''; | ||
for (var i = 0; i < compressedString.length; i++) { | ||
@@ -46,5 +42,4 @@ // get character ascii code and convert to hexa string, adding necessary 0s | ||
} | ||
hex = hex.toLowerCase(); | ||
return addLeading0x(hex); | ||
} |
import { privateToPublic, toBuffer } from 'ethereumjs-util'; | ||
import { addLeading0x } from './util'; | ||
/** | ||
@@ -9,3 +10,2 @@ * Generate publicKey from the privateKey. | ||
*/ | ||
export default function publicKeyOfPrivateKey(privateKey) { | ||
@@ -12,0 +12,0 @@ privateKey = addLeading0x(privateKey); |
@@ -14,7 +14,9 @@ import { publicKeyConvert } from 'secp256k1'; | ||
if (testBuffer.length === 64) startsWith02Or03 = '04' + startsWith02Or03; | ||
var decompressed = uint8ArrayToHex(publicKeyConvert(hexToUnit8Array(startsWith02Or03), false)); // remove trailing 04 | ||
var decompressed = uint8ArrayToHex(publicKeyConvert(hexToUnit8Array(startsWith02Or03), false)); | ||
// remove trailing 04 | ||
decompressed = decompressed.substring(2); | ||
return decompressed; | ||
} | ||
/** | ||
@@ -25,3 +27,2 @@ * generates the ethereum-adress of the publicKey | ||
*/ | ||
export function toAddress(publicKey) { | ||
@@ -28,0 +29,0 @@ // normalize key |
import { ecdsaRecover } from 'secp256k1'; | ||
import { removeLeading0x, hexToUnit8Array, uint8ArrayToHex } from './util'; | ||
/** | ||
@@ -9,15 +10,15 @@ * returns the publicKey for the privateKey with which the messageHash was signed | ||
*/ | ||
export default function recoverPublicKey(signature, hash) { | ||
signature = removeLeading0x(signature); // split into v-value and sig | ||
signature = removeLeading0x(signature); | ||
// split into v-value and sig | ||
var sigOnly = signature.substring(0, signature.length - 2); // all but last 2 chars | ||
var vValue = signature.slice(-2); // last 2 chars | ||
var recoveryNumber = vValue === '1c' ? 1 : 0; | ||
var pubKey = uint8ArrayToHex(ecdsaRecover(hexToUnit8Array(sigOnly), recoveryNumber, hexToUnit8Array(removeLeading0x(hash)), false)); // remove trailing '04' | ||
var pubKey = uint8ArrayToHex(ecdsaRecover(hexToUnit8Array(sigOnly), recoveryNumber, hexToUnit8Array(removeLeading0x(hash)), false)); | ||
// remove trailing '04' | ||
pubKey = pubKey.slice(2); | ||
return pubKey; | ||
} |
import recoverPublicKey from './recover-public-key'; | ||
import { toAddress as addressByPublicKey } from './public-key'; | ||
/** | ||
@@ -9,3 +10,2 @@ * returns the adress with which the messageHash was signed | ||
*/ | ||
export default function recover(sigString, hash) { | ||
@@ -12,0 +12,0 @@ var pubkey = recoverPublicKey(sigString, hash); |
import { ecdsaSign as secp256k1_sign } from 'secp256k1'; | ||
import { addLeading0x, removeLeading0x } from './util'; | ||
/** | ||
@@ -10,3 +11,2 @@ * signs the given message | ||
*/ | ||
export default function sign(privateKey, hash) { | ||
@@ -13,0 +13,0 @@ hash = addLeading0x(hash); |
@@ -5,4 +5,5 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
// solc returns a string which is often passed instead of the json | ||
if (typeof abi === 'string') abi = JSON.parse(abi); // Construct a Contract Factory | ||
if (typeof abi === 'string') abi = JSON.parse(abi); | ||
// Construct a Contract Factory | ||
var factory = new ContractFactory(abi, '0x' + bytecode); | ||
@@ -9,0 +10,0 @@ var deployTransaction = factory.getDeployTransaction.apply(factory, _toConsumableArray(args)); |
@@ -7,3 +7,2 @@ import { utils as ethersUtils } from 'ethers'; | ||
*/ | ||
export function fromString(hexString) { | ||
@@ -18,2 +17,3 @@ var arr = ethersUtils.splitSignature(hexString); | ||
} | ||
/** | ||
@@ -24,5 +24,4 @@ * merge signature-parts to one string | ||
*/ | ||
export function toString(sig) { | ||
return ethersUtils.joinSignature(sig); | ||
} |
"use strict"; | ||
var EthCrypto = require('./index.js'); | ||
window['EthCrypto'] = EthCrypto; |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports["default"] = calculateContractAddress; | ||
var _ethereumjsUtil = require("ethereumjs-util"); | ||
var _util = require("./util"); | ||
function calculateContractAddress(creatorAddress, nonce) { | ||
@@ -14,0 +11,0 @@ var addressBuffer = (0, _ethereumjsUtil.generateAddress)((0, _ethereumjsUtil.toBuffer)((0, _util.addLeading0x)(creatorAddress)), (0, _ethereumjsUtil.toBuffer)(nonce)); |
@@ -8,17 +8,19 @@ "use strict"; | ||
exports.stringify = stringify; | ||
var _publicKey = require("./public-key"); | ||
function stringify(cipher) { | ||
if (typeof cipher === 'string') return cipher; // use compressed key because it's smaller | ||
if (typeof cipher === 'string') return cipher; | ||
// use compressed key because it's smaller | ||
var compressedKey = (0, _publicKey.compress)(cipher.ephemPublicKey); | ||
var ret = Buffer.concat([Buffer.from(cipher.iv, 'hex'), // 16bit | ||
Buffer.from(compressedKey, 'hex'), // 33bit | ||
Buffer.from(cipher.mac, 'hex'), // 32bit | ||
var ret = Buffer.concat([Buffer.from(cipher.iv, 'hex'), | ||
// 16bit | ||
Buffer.from(compressedKey, 'hex'), | ||
// 33bit | ||
Buffer.from(cipher.mac, 'hex'), | ||
// 32bit | ||
Buffer.from(cipher.ciphertext, 'hex') // var bit | ||
]); | ||
return ret.toString('hex'); | ||
} | ||
function parse(str) { | ||
@@ -32,6 +34,7 @@ if (typeof str !== 'string') return str; | ||
ciphertext: buf.toString('hex', 81, buf.length) | ||
}; // decompress publicKey | ||
}; | ||
// decompress publicKey | ||
ret.ephemPublicKey = '04' + (0, _publicKey.decompress)(ret.ephemPublicKey); | ||
return ret; | ||
} |
@@ -8,9 +8,7 @@ "use strict"; | ||
exports["default"] = createIdentity; | ||
var _ethers = require("ethers"); | ||
var _ethereumjsUtil = require("ethereumjs-util"); | ||
var MIN_ENTROPY_SIZE = 128; | ||
var keccak256 = _ethers.utils.keccak256; | ||
/** | ||
@@ -21,3 +19,2 @@ * create a privateKey from the given entropy or a new one | ||
*/ | ||
function createPrivateKey(entropy) { | ||
@@ -31,10 +28,8 @@ if (entropy) { | ||
var innerHex = keccak256(_ethers.utils.concat([_ethers.utils.randomBytes(32), _ethers.utils.randomBytes(32)])); | ||
var middleHex = _ethers.utils.concat([_ethers.utils.concat([_ethers.utils.randomBytes(32), innerHex]), _ethers.utils.randomBytes(32)]); | ||
var _outerHex = keccak256(middleHex); | ||
return _outerHex; | ||
} | ||
} | ||
/** | ||
@@ -45,4 +40,2 @@ * creates a new object with | ||
*/ | ||
function createIdentity(entropy) { | ||
@@ -49,0 +42,0 @@ var privateKey = createPrivateKey(entropy); |
@@ -7,12 +7,9 @@ "use strict"; | ||
exports["default"] = decryptWithPrivateKey; | ||
var _eccrypto = require("eccrypto"); | ||
var _cipher = require("./cipher"); | ||
var _util = require("./util"); | ||
function decryptWithPrivateKey(privateKey, encrypted) { | ||
encrypted = (0, _cipher.parse)(encrypted); // remove trailing '0x' from privateKey | ||
encrypted = (0, _cipher.parse)(encrypted); | ||
// remove trailing '0x' from privateKey | ||
var twoStripped = (0, _util.removeLeading0x)(privateKey); | ||
@@ -19,0 +16,0 @@ var encryptedBuffer = { |
@@ -7,11 +7,9 @@ "use strict"; | ||
exports["default"] = encryptWithPublicKey; | ||
var _eccrypto = require("eccrypto"); | ||
var _publicKey = require("./public-key"); | ||
function encryptWithPublicKey(publicKey, message, opts) { | ||
// ensure its an uncompressed publicKey | ||
publicKey = (0, _publicKey.decompress)(publicKey); // re-add the compression-flag | ||
publicKey = (0, _publicKey.decompress)(publicKey); | ||
// re-add the compression-flag | ||
var pubString = '04' + publicKey; | ||
@@ -18,0 +16,0 @@ return (0, _eccrypto.encrypt)(Buffer.from(pubString, 'hex'), Buffer.from(message), opts ? opts : {}).then(function (encryptedBuffers) { |
@@ -8,9 +8,6 @@ "use strict"; | ||
exports.keccak256 = keccak256; | ||
var _ethers = require("ethers"); | ||
function keccak256(params) { | ||
var types = []; | ||
var values = []; | ||
if (!Array.isArray(params)) { | ||
@@ -25,7 +22,5 @@ types.push('string'); | ||
} | ||
return _ethers.utils.solidityKeccak256(types, values); | ||
} | ||
var SIGN_PREFIX = '\x19Ethereum Signed Message:\n32'; | ||
exports.SIGN_PREFIX = SIGN_PREFIX; |
@@ -8,5 +8,3 @@ "use strict"; | ||
exports.decompress = decompress; | ||
var _util = require("./util"); | ||
/** | ||
@@ -17,9 +15,10 @@ * compress/decompress hex-strings to utf16 or base64 | ||
*/ | ||
function compress(hex) { | ||
var base64 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
hex = (0, _util.removeLeading0x)(hex); // if base64:true, we use our own function because it results in a smaller output | ||
hex = (0, _util.removeLeading0x)(hex); | ||
// if base64:true, we use our own function because it results in a smaller output | ||
if (base64 === true) return Buffer.from(hex, 'hex').toString('base64'); | ||
var string = ''; | ||
while (hex.length % 4 != 0) { | ||
@@ -29,3 +28,2 @@ // we need it to be multiple of 4 | ||
} | ||
for (var i = 0; i < hex.length; i += 4) { | ||
@@ -35,9 +33,6 @@ // get char from ascii code which goes from 0 to 65536 | ||
} | ||
return string; | ||
} | ||
function decompress(compressedString) { | ||
var base64 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
// if base64:true, we use our own function because it results in a smaller output | ||
@@ -48,5 +43,3 @@ if (base64 === true) { | ||
} | ||
var hex = ''; | ||
for (var i = 0; i < compressedString.length; i++) { | ||
@@ -56,5 +49,4 @@ // get character ascii code and convert to hexa string, adding necessary 0s | ||
} | ||
hex = hex.toLowerCase(); | ||
return (0, _util.addLeading0x)(hex); | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -74,51 +72,26 @@ value: true | ||
exports.vrs = exports.util = void 0; | ||
var _createIdentity = _interopRequireDefault(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 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 hash = _interopRequireWildcard(require("./hash")); | ||
exports.hash = hash; | ||
var hex = _interopRequireWildcard(require("./hex")); | ||
exports.hex = hex; | ||
var vrs = _interopRequireWildcard(require("./vrs")); | ||
exports.vrs = vrs; | ||
var util = _interopRequireWildcard(require("./util")); | ||
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 = { | ||
@@ -125,0 +98,0 @@ createIdentity: _createIdentity["default"], |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports["default"] = publicKeyOfPrivateKey; | ||
var _ethereumjsUtil = require("ethereumjs-util"); | ||
var _util = require("./util"); | ||
/** | ||
@@ -14,0 +11,0 @@ * Generate publicKey from the privateKey. |
@@ -9,9 +9,5 @@ "use strict"; | ||
exports.toAddress = toAddress; | ||
var _secp256k = require("secp256k1"); | ||
var _ethereumjsUtil = require("ethereumjs-util"); | ||
var _util = require("./util"); | ||
function compress(startsWith04) { | ||
@@ -23,3 +19,2 @@ // add trailing 04 if not done before | ||
} | ||
function decompress(startsWith02Or03) { | ||
@@ -29,7 +24,9 @@ // if already decompressed an not has trailing 04 | ||
if (testBuffer.length === 64) startsWith02Or03 = '04' + startsWith02Or03; | ||
var decompressed = (0, _util.uint8ArrayToHex)((0, _secp256k.publicKeyConvert)((0, _util.hexToUnit8Array)(startsWith02Or03), false)); // remove trailing 04 | ||
var decompressed = (0, _util.uint8ArrayToHex)((0, _secp256k.publicKeyConvert)((0, _util.hexToUnit8Array)(startsWith02Or03), false)); | ||
// remove trailing 04 | ||
decompressed = decompressed.substring(2); | ||
return decompressed; | ||
} | ||
/** | ||
@@ -40,4 +37,2 @@ * generates the ethereum-adress of the publicKey | ||
*/ | ||
function toAddress(publicKey) { | ||
@@ -44,0 +39,0 @@ // normalize key |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports["default"] = recoverPublicKey; | ||
var _secp256k = require("secp256k1"); | ||
var _util = require("./util"); | ||
/** | ||
@@ -20,13 +17,14 @@ * returns the publicKey for the privateKey with which the messageHash was signed | ||
function recoverPublicKey(signature, hash) { | ||
signature = (0, _util.removeLeading0x)(signature); // split into v-value and sig | ||
signature = (0, _util.removeLeading0x)(signature); | ||
// split into v-value and sig | ||
var sigOnly = signature.substring(0, signature.length - 2); // all but last 2 chars | ||
var vValue = signature.slice(-2); // last 2 chars | ||
var recoveryNumber = vValue === '1c' ? 1 : 0; | ||
var pubKey = (0, _util.uint8ArrayToHex)((0, _secp256k.ecdsaRecover)((0, _util.hexToUnit8Array)(sigOnly), recoveryNumber, (0, _util.hexToUnit8Array)((0, _util.removeLeading0x)(hash)), false)); // remove trailing '04' | ||
var pubKey = (0, _util.uint8ArrayToHex)((0, _secp256k.ecdsaRecover)((0, _util.hexToUnit8Array)(sigOnly), recoveryNumber, (0, _util.hexToUnit8Array)((0, _util.removeLeading0x)(hash)), false)); | ||
// remove trailing '04' | ||
pubKey = pubKey.slice(2); | ||
return pubKey; | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,7 +8,4 @@ value: true | ||
exports["default"] = recover; | ||
var _recoverPublicKey = _interopRequireDefault(require("./recover-public-key")); | ||
var _publicKey = require("./public-key"); | ||
/** | ||
@@ -16,0 +12,0 @@ * returns the adress with which the messageHash was signed |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,9 +8,5 @@ value: true | ||
exports["default"] = signTransaction; | ||
var _tx = require("@ethereumjs/tx"); | ||
var _publicKeyByPrivateKey = _interopRequireDefault(require("./public-key-by-private-key")); | ||
var _publicKey = require("./public-key"); | ||
function signTransaction(rawTx, privateKey) { | ||
@@ -24,5 +19,3 @@ var txOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var privateKeyBuffer = Buffer.from(privateKey.replace(/^.{2}/g, ''), 'hex'); | ||
var tx = _tx.Transaction.fromTxData(rawTx, txOptions); | ||
var signedTx = tx.sign(privateKeyBuffer); | ||
@@ -29,0 +22,0 @@ var serializedTx = signedTx.serialize().toString('hex'); |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports["default"] = sign; | ||
var _secp256k = require("secp256k1"); | ||
var _util = require("./util"); | ||
/** | ||
@@ -14,0 +11,0 @@ * signs the given message |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,11 +8,9 @@ value: true | ||
exports["default"] = txDataByCompiled; | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _ethers = require("ethers"); | ||
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); // Construct a Contract Factory | ||
if (typeof abi === 'string') abi = JSON.parse(abi); | ||
// Construct a Contract Factory | ||
var factory = new _ethers.ContractFactory(abi, '0x' + bytecode); | ||
@@ -20,0 +17,0 @@ var deployTransaction = factory.getDeployTransaction.apply(factory, (0, _toConsumableArray2["default"])(args)); |
@@ -10,17 +10,13 @@ "use strict"; | ||
exports.uint8ArrayToHex = uint8ArrayToHex; | ||
function removeLeading0x(str) { | ||
if (str.startsWith('0x')) return str.substring(2);else return str; | ||
} | ||
function addLeading0x(str) { | ||
if (!str.startsWith('0x')) return '0x' + str;else return str; | ||
} | ||
function uint8ArrayToHex(arr) { | ||
return Buffer.from(arr).toString('hex'); | ||
} | ||
function hexToUnit8Array(str) { | ||
return new Uint8Array(Buffer.from(str, 'hex')); | ||
} |
@@ -8,5 +8,3 @@ "use strict"; | ||
exports.toString = toString; | ||
var _ethers = require("ethers"); | ||
/** | ||
@@ -19,3 +17,2 @@ * split signature-hex into parts | ||
var arr = _ethers.utils.splitSignature(hexString); | ||
return { | ||
@@ -28,2 +25,3 @@ // convert "v" to hex | ||
} | ||
/** | ||
@@ -34,6 +32,4 @@ * merge signature-parts to one string | ||
*/ | ||
function toString(sig) { | ||
return _ethers.utils.joinSignature(sig); | ||
} |
{ | ||
"name": "eth-crypto", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Cryptographic functions for ethereum and how to use them with web3 and solidity", | ||
@@ -46,2 +46,3 @@ "keywords": [ | ||
"author": "pubkey", | ||
"funding": "https://github.com/sponsors/pubkey", | ||
"license": "MIT", | ||
@@ -53,12 +54,12 @@ "bugs": { | ||
"devDependencies": { | ||
"@babel/cli": "7.17.6", | ||
"@babel/core": "7.17.9", | ||
"@babel/plugin-transform-runtime": "7.17.0", | ||
"@babel/preset-env": "7.16.11", | ||
"@babel/cli": "7.19.3", | ||
"@babel/core": "7.19.6", | ||
"@babel/plugin-transform-runtime": "7.19.6", | ||
"@babel/preset-env": "7.19.4", | ||
"assert": "2.0.0", | ||
"async-test-util": "2.0.0", | ||
"babel-loader": "8.2.5", | ||
"bn.js": "5.2.0", | ||
"bn.js": "5.2.1", | ||
"browserify": "17.0.0", | ||
"concurrently": "7.1.0", | ||
"concurrently": "7.5.0", | ||
"convert-hrtime": "5.0.0", | ||
@@ -73,3 +74,3 @@ "cross-env": "7.0.3", | ||
"js-sha3": "0.8.0", | ||
"karma": "6.3.19", | ||
"karma": "6.4.1", | ||
"karma-babel-preprocessor": "8.0.2", | ||
@@ -91,19 +92,19 @@ "karma-browserify": "8.1.0", | ||
"terser-webpack-plugin": "4.2.3", | ||
"ts-node": "10.7.0", | ||
"typescript": "4.6.3", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.8.4", | ||
"uglify-es": "3.3.9", | ||
"web3": "1.7.3", | ||
"web3": "1.8.0", | ||
"webpack": "4.41.5", | ||
"webpack-bundle-analyzer": "4.5.0", | ||
"webpack-cli": "4.9.2" | ||
"webpack-bundle-analyzer": "4.7.0", | ||
"webpack-cli": "4.10.0" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "7.17.9", | ||
"@ethereumjs/tx": "3.5.1", | ||
"@types/bn.js": "5.1.0", | ||
"@babel/runtime": "7.19.4", | ||
"@ethereumjs/tx": "3.5.2", | ||
"@types/bn.js": "5.1.1", | ||
"eccrypto": "1.1.6", | ||
"ethereumjs-util": "7.1.4", | ||
"ethers": "5.6.4", | ||
"ethereumjs-util": "7.1.5", | ||
"ethers": "5.7.2", | ||
"secp256k1": "4.0.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1409
71013
+ Added@babel/runtime@7.19.4(transitive)
+ Added@ethereumjs/tx@3.5.2(transitive)
+ Added@ethersproject/abi@5.7.0(transitive)
+ Added@ethersproject/abstract-provider@5.7.0(transitive)
+ Added@ethersproject/abstract-signer@5.7.0(transitive)
+ Added@ethersproject/address@5.7.0(transitive)
+ Added@ethersproject/base64@5.7.0(transitive)
+ Added@ethersproject/basex@5.7.0(transitive)
+ Added@ethersproject/bignumber@5.7.0(transitive)
+ Added@ethersproject/bytes@5.7.0(transitive)
+ Added@ethersproject/constants@5.7.0(transitive)
+ Added@ethersproject/contracts@5.7.0(transitive)
+ Added@ethersproject/hash@5.7.0(transitive)
+ Added@ethersproject/hdnode@5.7.0(transitive)
+ Added@ethersproject/json-wallets@5.7.0(transitive)
+ Added@ethersproject/keccak256@5.7.0(transitive)
+ Added@ethersproject/logger@5.7.0(transitive)
+ Added@ethersproject/networks@5.7.1(transitive)
+ Added@ethersproject/pbkdf2@5.7.0(transitive)
+ Added@ethersproject/properties@5.7.0(transitive)
+ Added@ethersproject/providers@5.7.2(transitive)
+ Added@ethersproject/random@5.7.0(transitive)
+ Added@ethersproject/rlp@5.7.0(transitive)
+ Added@ethersproject/sha2@5.7.0(transitive)
+ Added@ethersproject/signing-key@5.7.0(transitive)
+ Added@ethersproject/solidity@5.7.0(transitive)
+ Added@ethersproject/strings@5.7.0(transitive)
+ Added@ethersproject/transactions@5.7.0(transitive)
+ Added@ethersproject/units@5.7.0(transitive)
+ Added@ethersproject/wallet@5.7.0(transitive)
+ Added@ethersproject/web@5.7.1(transitive)
+ Added@ethersproject/wordlists@5.7.0(transitive)
+ Added@types/bn.js@5.1.1(transitive)
+ Addedethers@5.7.2(transitive)
- Removed@babel/runtime@7.17.9(transitive)
- Removed@ethereumjs/tx@3.5.1(transitive)
- Removed@ethersproject/abi@5.6.1(transitive)
- Removed@ethersproject/abstract-provider@5.6.0(transitive)
- Removed@ethersproject/abstract-signer@5.6.0(transitive)
- Removed@ethersproject/address@5.6.0(transitive)
- Removed@ethersproject/base64@5.6.0(transitive)
- Removed@ethersproject/basex@5.6.0(transitive)
- Removed@ethersproject/bignumber@5.6.0(transitive)
- Removed@ethersproject/bytes@5.6.1(transitive)
- Removed@ethersproject/constants@5.6.0(transitive)
- Removed@ethersproject/contracts@5.6.0(transitive)
- Removed@ethersproject/hash@5.6.0(transitive)
- Removed@ethersproject/hdnode@5.6.0(transitive)
- Removed@ethersproject/json-wallets@5.6.0(transitive)
- Removed@ethersproject/keccak256@5.6.0(transitive)
- Removed@ethersproject/logger@5.6.0(transitive)
- Removed@ethersproject/networks@5.6.2(transitive)
- Removed@ethersproject/pbkdf2@5.6.0(transitive)
- Removed@ethersproject/properties@5.6.0(transitive)
- Removed@ethersproject/providers@5.6.4(transitive)
- Removed@ethersproject/random@5.6.0(transitive)
- Removed@ethersproject/rlp@5.6.0(transitive)
- Removed@ethersproject/sha2@5.6.0(transitive)
- Removed@ethersproject/signing-key@5.6.0(transitive)
- Removed@ethersproject/solidity@5.6.0(transitive)
- Removed@ethersproject/strings@5.6.0(transitive)
- Removed@ethersproject/transactions@5.6.0(transitive)
- Removed@ethersproject/units@5.6.0(transitive)
- Removed@ethersproject/wallet@5.6.0(transitive)
- Removed@ethersproject/web@5.6.0(transitive)
- Removed@ethersproject/wordlists@5.6.0(transitive)
- Removed@types/bn.js@5.1.0(transitive)
- Removedethereumjs-util@7.1.4(transitive)
- Removedethers@5.6.4(transitive)
Updated@babel/runtime@7.19.4
Updated@ethereumjs/tx@3.5.2
Updated@types/bn.js@5.1.1
Updatedethereumjs-util@7.1.5
Updatedethers@5.7.2