title: pubToAddress method from ethereumjs-util throws AssertionError: false == true
body: <p>I have the following code on nodejs:
      var keythereum = require('keythereum');
      var crypto = require("crypto");
      var eccrypto = require("eccrypto");
      var pubToAddress = require("ethereumjs-util").pubToAddress;
      var ecdsa = new (require("elliptic").ec)("secp256k1");</p>
  
  <pre><code>// A new random 32-byte private key. 
  var privateKey = crypto.randomBytes(32);
  
  // console.log(privateKey);
  // &lt;Buffer 06 79 35 4c 5e dd a2 1d b3 cf 70 8d e7 92 06 50 a7 f3 a3 88 3c e0 8c 57 3a 45 7c 53 d1 71 46 a5&gt;
  
  // Corresponding uncompressed (65-byte) public key. 
  var publicKey = eccrypto.getPublic(privateKey);
  
  console.log(publicKey);
  // &lt;Buffer 04 fa c7 15 ed c6 41 86 1e 18 fb e8 8d 6c e4 f7 75 1e d6 13 d9 b1 b5 f9 ba dc bc c6 48 1b c7 06 cb 28 4d b8 71 e6 74 75 5b e1 9e 49 15 07 76 80 21 3e ... &gt;
  
  var address = pubToAddress(publicKey).toString("hex");
  </code></pre>
  
  <p>While executing last line of code:</p>
  
  <pre><code>var address = pubToAddress(publicKey).toString("hex");
  </code></pre>
  
  <p>It throws an assertion error like this:</p>
  
  <pre><code>AssertionError: false == true
      at exports.pubToAddress.exports.publicToAddress (/myHomeDir/node_modules/ethereumjs-util/index.js:323:3)
      at repl:1:15
      at realRunInThisContextScript (vm.js:22:35)
      at sigintHandlersWrap (vm.js:98:12)
      at ContextifyScript.Script.runInThisContext (vm.js:24:12)
      at REPLServer.defaultEval (repl.js:346:29)
      at bound (domain.js:280:14)
      at REPLServer.runBound [as eval] (domain.js:293:12)
      at REPLServer.onLine (repl.js:544:10)
      at emitOne (events.js:101:20)
  </code></pre>
  
  <p>Found out that the assertion that fails is this one:</p>
  
  <pre><code>/**
   * Returns the ethereum address of a given public key.
   * Accepts "Ethereum public keys" and SEC1 encoded keys.
   * @param {Buffer} pubKey The two points of an uncompressed key, unless sanitize is enabled
   * @param {Boolean} [sanitize=false] Accept public keys in other formats
   * @return {Buffer}
   */
  exports.pubToAddress = exports.publicToAddress = function (pubKey, sanitize) {
    pubKey = exports.toBuffer(pubKey)
    if (sanitize &amp;&amp; (pubKey.length !== 64)) {
      pubKey = secp256k1.publicKeyConvert(pubKey, false).slice(1)
    }
    assert(pubKey.length === 64)
    // Only take the lower 160bits of the hash
    return exports.sha3(pubKey).slice(-20)
  }
  </code></pre>
  
  <p>Should I just remove first byte  (04) from address?</p>
  
  <p>This piece of code is based on <a href="https://github.com/ethereumjs/keythereum/blob/master/test/keys.js" rel="nofollow noreferrer">https://github.com/ethereumjs/keythereum/blob/master/test/keys.js</a> trying to create an Ethereum private key and getting its corresponding public key and address. It fails at the final step. Any hint about what is going on would be very helpful. Thx!</p>