brontide: modify key rotation to match test vectors in spec

This commit modifies our key rotation slightly to match the test
vectors within the BOLT08 specifications. Before this commit, we were
rotating one message before the rest of the implementers. This
implementation divergence was possibly due to the section of the spec
describing the rotations being a bit ambiguous.

A future PR to the lightning-rfc repo will make the spec more explicit
to avoid situations like this in the future.
This commit is contained in:
Olaoluwa Osuntokun 2017-01-09 19:12:28 -08:00
parent efa7059ac3
commit bc885f5f27
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

View File

@ -87,7 +87,7 @@ func (c *cipherState) Encrypt(associatedData, cipherText, plainText []byte) []by
defer func() {
c.nonce++
if c.nonce > keyRotationInterval {
if c.nonce == keyRotationInterval {
c.rotateKey()
}
}()
@ -105,7 +105,7 @@ func (c *cipherState) Decrypt(associatedData, plainText, cipherText []byte) ([]b
defer func() {
c.nonce++
if c.nonce > keyRotationInterval {
if c.nonce == keyRotationInterval {
c.rotateKey()
}
}()