diff --git a/lib/bcoin/bip151.js b/lib/bcoin/bip151.js index 40348ba4..cf5b4201 100644 --- a/lib/bcoin/bip151.js +++ b/lib/bcoin/bip151.js @@ -85,7 +85,7 @@ BIP151Stream.prototype.maybeRekey = function maybeRekey(data) { if (now >= this.lastRekey + 10 || this.processed >= this.highWaterMark) { - this.lastRekey = utils.now(); + this.lastRekey = now; this.processed = 0; this.emit('rekey'); this.rekey(); @@ -349,13 +349,11 @@ BIP151.prototype.encinit = function encinit(data) { var cipher = p.readU8(); assert(!this.initReceived, 'Already initialized.'); + this.initReceived = true; + assert(cipher === this.output.cipher, 'Cipher mismatch.'); this.output.init(publicKey); - - this.initReceived = true; - - return this; }; BIP151.prototype.toEncack = function toEncack(writer) {