How to use the ethereumjs-util.privateToAddress function in ethereumjs-util

To help you get started, we’ve selected a few ethereumjs-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github monerium / smart-contracts / test / 3-mintable-controller.js View on Github external
contract('MintableController', accounts => {

  if (web3.version.network <= 100) return;

  const owner = accounts[0];
  const system = accounts[9];
  let controller;

  beforeEach("setup mintable controller", async () => { 
    controller = await MintableController.deployed();
    await controller.addSystemAccount(system);
  });

  const key = Buffer.from("23f2ee33c522046e80b67e96ceb84a05b60b9434b0ee2e3ae4b1311b9f5dcc46", "hex");
  const address = `0x${EthUtil.privateToAddress(key).toString("hex")}`;

  it("should start with zero tokens", async () => {
    const supply = await controller.totalSupply();
    assert.equal(supply.valueOf(), 0, "initial supply is not 0");  
  });

  it("should fail to mint 666 new tokens from non-system account", async () => {
    await truffleAssert.reverts(
      controller.mintTo_withCaller(accounts[0], accounts[0], 666, {from: accounts[0]})
    );
  });

  it("should fail to burnFrom 888 new tokens from non-system account", async () => {
    const wallet = wallets["trust wallet"];
    const balance0 = await controller.balanceOf(wallet.address);
    await controller.mintTo_withCaller(system, wallet.address, 888, {from: system});
github ethers-io / ethers.js / tests / make-tests / make-transactions.js View on Github external
function addTransaction(privateKey, name, transaction, signature) {
    var rawTransaction = new ethereumTx(transaction);

    transaction.chainId = 5;
    var rawTransactionEip155 = new ethereumTx(transaction);
    delete transaction['chainId'];

console.log(rawTransaction, rawTransaction.serialize().toString('hex'));
console.log(rawTransactionEip155, rawTransactionEip155.serialize().toString('hex'));
console.log(rawTransactionEip155.serialize().toString('hex') === rawTransaction.serialize().toString('hex'));
console.log('------');

    var test = {
        accountAddress: '0x' + ethereumUtil.privateToAddress(privateKey).toString('hex'),
        name: name,
        privateKey: '0x' + privateKey.toString('hex'),
        unsignedTransaction: '0x' + rawTransaction.serializeUnsigned().toString('hex'),
        unsignedTransactionChainId5: '0x' + rawTransactionEip155.serializeUnsigned().toString('hex'),
    }

    rawTransaction.sign(privateKey);
    test.signedTransaction = '0x' + rawTransaction.serialize().toString('hex');

    rawTransactionEip155.sign(privateKey);
    test.signedTransactionChainId5 = '0x' + rawTransactionEip155.serialize().toString('hex');

    for (var k in transaction) {
        test[k] = transaction[k];
    }
github merklejerk / send-tokens / test / tests.js View on Github external
function randomAccount() {
	const key = crypto.randomBytes(32);
	const address = ethjs.toChecksumAddress(
		ethjs.bufferToHex(ethjs.privateToAddress(key)));
	return {
		key: ethjs.bufferToHex(key),
		address: address
	};
}
github austintgriffith / eth.build / src / nodes / Crypto / KeyPair.js View on Github external
Web3KeyPair.prototype.onPropertyChanged = async function(name, value){
  this.properties[name] = value;

  try{

    if(this.properties.privateKey){
      //console.log("PK this.properties.privateKey")
      this.publicKey = "0x"+EthUtil.privateToPublic(this.properties.privateKey).toString('hex')
      this.address = "0x"+EthUtil.privateToAddress(this.properties.privateKey).toString('hex')
    }else{
      //console.log("NO this.properties.privateKey")
    }

  }catch(e){
    console.error(e)
  }

  return true;
};
github realcodywburns / TokenMint / src / lib / wallet.js View on Github external
Wallet.generate = function(icapDirect) {
    if (icapDirect) {
        while (true) {
            var privKey = ethUtil.crypto.randomBytes(32)
            if (ethUtil.privateToAddress(privKey)[0] === 0) {
                return new Wallet(privKey)
            }
        }
    } else {
        return new Wallet(ethUtil.crypto.randomBytes(32))
    }
}
Wallet.prototype.getPrivateKey = function() {
github MuzikaFoundation / muzika-platform / projects / studio-renderer / src / modules / wallet / services / wallet-storage.service.ts View on Github external
return currentState.findIndex(key => {
      return ethUtil.bufferToHex(ethUtil.privateToAddress(ethUtil.toBuffer(key))) === address.toLowerCase();
    }) !== -1;
  }
github MyEtherWallet / MyEtherWallet / src / wallets / software / mnemonic / mnemonicWallet_old.js View on Github external
deriveAddress (wallet) {
    if (typeof wallet.pubKey === 'undefined') {
      return ethUtil.privateToAddress(wallet.privKey).toString('hex')
    } else {
      return ethUtil.publicToAddress(wallet.pubKey, true).toString('hex')
    }
  }
github MyEtherWallet / MyEtherWallet / src / helpers / Wallet / Wallet.js View on Github external
Wallet.generate = function (icapDirect) {
  if (icapDirect) {
    while (true) {
      const privKey = crypto.randomBytes(32)
      if (util.privateToAddress(privKey)[0] === 0) {
        return new Wallet(privKey)
      }
    }
  } else {
    return new Wallet(crypto.randomBytes(32))
  }
}
github drunken005 / ethereum-offline-sign / lib / index.js View on Github external
EtherSigner.prototype.getAddress = function () {
    let privateKey = Buffer.from(this.privateKey, 'hex');
    return '0x' + EthereumUtil.privateToAddress(privateKey).toString('hex');
};
github blockmason / lndr-mobile / packages / lndr / engine / index.ts View on Github external
createUserFromCredentials(mnemonicInstance, hashedPassword) {

    const mnemonic = mnemonicInstance.toString()
    const privateKey = mnemonicInstance.toHDPrivateKey()
    const privateKeyBuffer = privateKey.privateKey.toBuffer()
    const ethAddress = ethUtil.privateToAddress(privateKeyBuffer)
    const address = ethAddress.toString('hex')

    return new User(
      mnemonic,
      hashedPassword,
      privateKey,
      privateKeyBuffer,
      ethAddress,
      address
    )
  }