parent
ff746f02e1
commit
da252e34e1
@ -1,3 +1,2 @@ |
||||
var EthCrypto = require('./index.js'); |
||||
|
||||
window['EthCrypto'] = EthCrypto; |
@ -1,22 +1,23 @@ |
||||
import { ecdsaRecover } from 'secp256k1'; |
||||
import { removeLeading0x, hexToUnit8Array, uint8ArrayToHex } from './util'; |
||||
|
||||
/** |
||||
* returns the publicKey for the privateKey with which the messageHash was signed |
||||
* @param {string} signature |
||||
* @param {string} hash |
||||
* @return {string} publicKey |
||||
*/ |
||||
|
||||
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; |
||||
} |
@ -1,5 +1,4 @@ |
||||
"use strict"; |
||||
|
||||
var EthCrypto = require('./index.js'); |
||||
|
||||
window['EthCrypto'] = EthCrypto; |
@ -1,20 +1,17 @@ |
||||
"use strict"; |
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
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); |
||||
var deployTransaction = factory.getDeployTransaction.apply(factory, (0, _toConsumableArray2["default"])(args)); |
||||
return deployTransaction.data; |
||||
|
Loading…
Reference in new issue