diff --git a/src/handshakes/abstract-handshake.ts b/src/handshakes/abstract-handshake.ts index 576957b..1f9675e 100644 --- a/src/handshakes/abstract-handshake.ts +++ b/src/handshakes/abstract-handshake.ts @@ -23,7 +23,7 @@ export abstract class AbstractHandshake { public decryptWithAd (cs: CipherState, ad: Uint8Array, ciphertext: Uint8Array): {plaintext: bytes, valid: boolean} { const { plaintext, valid } = this.decrypt(cs.k, cs.n, ad, ciphertext) - cs.n.increment() + if (valid) cs.n.increment() return { plaintext, valid } }