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:
parent
efa7059ac3
commit
bc885f5f27
@ -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()
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user