How to use the ethereumjs-util.publicToAddress 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 invisible-college / democracy / packages / aztec-lib / src / mintFunc.js View on Github external
const erc20Token = await deployed( 'TestERC20', { deployID: `deploy${tradeSymbol}` } )
  console.log('ERC20 Token Address ', erc20Token.address)
  const token = await deployed( 'ZkAssetTradeable', { deployID: `deploy${tradeSymbol}` } )
  LOGGER.info('Trade Symbol '           , tradeSymbol)
  LOGGER.info('ZkMintableAsset Address ', token.address)
  LOGGER.info('Deployer Address '       , deployerAddress)
  LOGGER.info('Mintee address'          , minteeAddress)
  LOGGER.info('Mintee public key'       , minteePublicKey)
  LOGGER.info('Mintee amount'           , minteeAmount)
  LOGGER.info('mintFromZero'            , mintFromZero)
  
  assert( minteeAmount.gte(0), 'Mintee amount must be greater than or equal to zero.' )
  assert( minteePublicKey.startsWith('0x04'), 'AZTEC public keys must start with 0x04' )
  const derivedAddress =
    util.toChecksumAddress(
      util.publicToAddress('0x' + minteePublicKey.slice(4)).toString('hex'))
  assert.equal(derivedAddress, minteeAddress,
    `Mintee address from pubKey was ${derivedAddress} instead of ${minteeAddress}`)

  const baseKey =`zkNotes/${chainId}/${minteeAddress}/${token.address}`
  const mintKey =`zkMintedTotals/${chainId}/${deployerAddress}/${token.address}`
  LOGGER.info(`Mint Key ${mintKey}`)

  const minteeNote = await aztec.note.create(minteePublicKey, minteeAmount)
  LOGGER.info(`Created new mintee note ${minteeNote.noteHash}`)

  let oldTotalNote, oldTotalNoteHash, mintedFromZero
  try { 
    if (mintFromZero) { throw new Error('Minting from zero.') }
    const oldTotalNoteRaw = await bm.inputter(mintKey)
    LOGGER.info('oldTotalNoteRaw', oldTotalNoteRaw)
    oldTotalNoteHash = oldTotalNoteRaw.get('zkNoteHash')
github MyEtherWallet / MyEtherWallet / src / wallets / hardware / trezor / trezorWallet.js View on Github external
_getAddressForWallet(wallet) {
    if (typeof wallet.pubKey === 'undefined') {
      return '0x' + ethUtil.privateToAddress(wallet.privKey).toString('hex');
    }
    return '0x' + ethUtil.publicToAddress(wallet.pubKey, true).toString('hex');
  }
github decentralized-identity / element / packages / element-lib / src / crypto / MnemonicKeySystem.js View on Github external
const publicKeyToAddress = (pubKey) => {
  const addr = ethUtil.publicToAddress(Buffer.from(pubKey, 'hex')).toString('hex');
  const address = ethUtil.toChecksumAddress(addr);
  return address;
};
github brave / ethereum-remote-client / app / scripts / lib / trezorKeyring.js View on Github external
_addressFromId (pathBase, i) {
    const dkey = this.hdk.derive(`${pathBase}/${i}`)
    const address = ethUtil
      .publicToAddress(dkey.publicKey, true)
      .toString('hex')
    return ethUtil.toChecksumAddress(address)
  }
github ethereumjs / ethereumjs-vm / lib / evm / precompiles / 01-ecrecover.ts View on Github external
const r = data.slice(64, 96)
  const s = data.slice(96, 128)

  let publicKey
  try {
    publicKey = ecrecover(msgHash, new BN(v).toNumber(), r, s)
  } catch (e) {
    return {
      gasUsed,
      returnValue: Buffer.alloc(0),
    }
  }

  return {
    gasUsed,
    returnValue: setLengthLeft(publicToAddress(publicKey), 32),
  }
}
github MyEtherWallet / MyEtherWallet / src / wallets / software / mnemonic / mnemonicWallet_old.js View on Github external
_getAddress (wallet) {
    if (typeof wallet.pubKey === 'undefined') {
      return '0x' + ethUtil.privateToAddress(wallet.privKey).toString('hex')
    } else {
      return '0x' + ethUtil.publicToAddress(wallet.pubKey, true).toString('hex')
    }
  }
github zachd / ethereum-identity-research / app / javascripts / app.js View on Github external
function verifyAttribute(attribute, RPCsig) {
  var hash = ethUtils.sha3(attribute);
  var sig = ethUtils.fromRpcSig(RPCsig);
  var pubkey = ethUtils.ecrecover(hash, sig.v, sig.r, sig.s);
  return '0x' + ethUtils.publicToAddress(pubkey).toString('hex');
}
github MyEtherWallet / MyEtherWallet / src / wallets / WalletInterface.js View on Github external
getAddress() {
    if (this.isAddress) return this.publicKey;
    return publicToAddress(this.publicKey, true);
  }
github MyEtherWallet / MyEtherWallet / src / helpers / Wallet / Wallet.js View on Github external
Wallet.prototype.getAddress = function () {
  if (typeof this.pubKey === 'undefined') {
    return util.privateToAddress(this.privKey)
  } else {
    return util.publicToAddress(this.pubKey, true)
  }
}