Improve built code

pull/548/head
Yannick Huard 3 years ago
parent a6e4463c8c
commit 5eb1f540c2
  1. 5
      dist/es/create-identity.js
  2. 8
      dist/lib/create-identity.js
  3. 5
      src/create-identity.js

@ -1,4 +1,3 @@
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import { ethers } from 'ethers';
import { stripHexPrefix } from 'ethereumjs-util';
var MIN_ENTROPY_SIZE = 128;
@ -16,7 +15,7 @@ export function createPrivateKey(entropy) {
var outerHex = keccak256(entropy);
return outerHex;
} else {
var innerHex = keccak256(ethers.utils.concat([].concat(_toConsumableArray(ethers.utils.randomBytes(32)), _toConsumableArray(ethers.utils.randomBytes(32)))));
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);
@ -35,8 +34,8 @@ export default function createIdentity(entropy) {
var wallet = new ethers.Wallet(privateKey);
var identity = {
privateKey: privateKey,
publicKey: stripHexPrefix(wallet.publicKey).slice(2),
// remove trailing '0x04'
publicKey: stripHexPrefix(wallet.publicKey).slice(2),
address: wallet.address
};
return identity;

@ -1,15 +1,11 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createPrivateKey = createPrivateKey;
exports["default"] = createIdentity;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _ethers = require("ethers");
var _ethereumjsUtil = require("ethereumjs-util");
@ -29,7 +25,7 @@ function createPrivateKey(entropy) {
var outerHex = keccak256(entropy);
return outerHex;
} else {
var innerHex = keccak256(_ethers.ethers.utils.concat([].concat((0, _toConsumableArray2["default"])(_ethers.ethers.utils.randomBytes(32)), (0, _toConsumableArray2["default"])(_ethers.ethers.utils.randomBytes(32)))));
var innerHex = keccak256(_ethers.ethers.utils.concat([_ethers.ethers.utils.randomBytes(32), _ethers.ethers.utils.randomBytes(32)]));
var middleHex = _ethers.ethers.utils.concat([_ethers.ethers.utils.concat([_ethers.ethers.utils.randomBytes(32), innerHex]), _ethers.ethers.utils.randomBytes(32)]);
@ -50,8 +46,8 @@ function createIdentity(entropy) {
var wallet = new _ethers.ethers.Wallet(privateKey);
var identity = {
privateKey: privateKey,
publicKey: (0, _ethereumjsUtil.stripHexPrefix)(wallet.publicKey).slice(2),
// remove trailing '0x04'
publicKey: (0, _ethereumjsUtil.stripHexPrefix)(wallet.publicKey).slice(2),
address: wallet.address
};
return identity;

@ -19,7 +19,7 @@ export function createPrivateKey(entropy) {
const outerHex = keccak256(entropy);
return outerHex;
} else {
const innerHex = keccak256(ethers.utils.concat([...ethers.utils.randomBytes(32), ...ethers.utils.randomBytes(32)]));
const innerHex = keccak256(ethers.utils.concat([ethers.utils.randomBytes(32), ethers.utils.randomBytes(32)]));
const middleHex = ethers.utils.concat([ethers.utils.concat([ethers.utils.randomBytes(32), innerHex]), ethers.utils.randomBytes(32)]);
const outerHex = keccak256(middleHex);
return outerHex;
@ -36,7 +36,8 @@ export default function createIdentity(entropy) {
const wallet = new ethers.Wallet(privateKey);
const identity = {
privateKey: privateKey,
publicKey: stripHexPrefix(wallet.publicKey).slice(2), // remove trailing '0x04'
// remove trailing '0x04'
publicKey: stripHexPrefix(wallet.publicKey).slice(2),
address: wallet.address,
};
return identity;

Loading…
Cancel
Save