From f837317ffd69b65af922d369cae455fa1c88afe8 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 26 Jul 2016 23:39:21 -0700 Subject: [PATCH] bip151: fix aead aad etm. --- lib/bcoin/bip151.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bcoin/bip151.js b/lib/bcoin/bip151.js index f9226c73..a5ea0bea 100644 --- a/lib/bcoin/bip151.js +++ b/lib/bcoin/bip151.js @@ -202,8 +202,9 @@ BIP151Stream.prototype.getPublicKey = function getPublicKey() { BIP151Stream.prototype.encryptSize = function encryptSize(size) { var data = new Buffer(4); data.writeUInt32LE(size, 0, true); + this.chacha.encrypt(data); this.aead.aad(data); - return this.chacha.encrypt(data); + return data; }; /** @@ -214,8 +215,8 @@ BIP151Stream.prototype.encryptSize = function encryptSize(size) { BIP151Stream.prototype.decryptSize = function decryptSize(data) { data = data.slice(0, 4); - this.chacha.encrypt(data); this.aead.aad(data); + this.chacha.encrypt(data); return data.readUInt32LE(0, true); };