bip151: update to conform to spec.
This commit is contained in:
parent
8f8cf4fca6
commit
049be2086d
@ -23,7 +23,7 @@ var chachapoly = require('./chachapoly');
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var HKDF_SALT = new Buffer('bitcoinechd' /* ecHd (sic?) */, 'ascii');
|
var HKDF_SALT = new Buffer('bitcoinecdh', 'ascii');
|
||||||
var INFO_KEY1 = new Buffer('BitcoinK1', 'ascii');
|
var INFO_KEY1 = new Buffer('BitcoinK1', 'ascii');
|
||||||
var INFO_KEY2 = new Buffer('BitcoinK2', 'ascii');
|
var INFO_KEY2 = new Buffer('BitcoinK2', 'ascii');
|
||||||
var INFO_SID = new Buffer('BitcoinSessionID', 'ascii');
|
var INFO_SID = new Buffer('BitcoinSessionID', 'ascii');
|
||||||
@ -142,13 +142,22 @@ BIP151Stream.prototype.maybeRekey = function maybeRekey(data) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
BIP151Stream.prototype.rekey = function rekey() {
|
BIP151Stream.prototype.rekey = function rekey() {
|
||||||
|
var seed;
|
||||||
|
|
||||||
assert(this.prk, 'Cannot rekey before initialization.');
|
assert(this.prk, 'Cannot rekey before initialization.');
|
||||||
|
|
||||||
|
seed = new Buffer(64);
|
||||||
|
|
||||||
|
this.sid.copy(seed, 0);
|
||||||
|
|
||||||
|
this.k1.copy(seed, 32);
|
||||||
|
this.k1 = utils.hash256(seed);
|
||||||
|
|
||||||
|
this.k2.copy(seed, 32);
|
||||||
|
this.k2 = utils.hash256(seed);
|
||||||
|
|
||||||
// All state is reinitialized
|
// All state is reinitialized
|
||||||
// aside from the sequence number.
|
// aside from the sequence number.
|
||||||
this.k1 = utils.hash256(this.k1);
|
|
||||||
this.k2 = utils.hash256(this.k2);
|
|
||||||
|
|
||||||
this.chacha.init(this.k1, this.iv);
|
this.chacha.init(this.k1, this.iv);
|
||||||
this.aead.init(this.k2, this.iv);
|
this.aead.init(this.k2, this.iv);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user