diff --git a/src/main/kotlin/cryptography/Nonce.kt b/src/main/kotlin/cryptography/Nonce.kt index f055292..b77b9f5 100644 --- a/src/main/kotlin/cryptography/Nonce.kt +++ b/src/main/kotlin/cryptography/Nonce.kt @@ -9,7 +9,7 @@ value class Nonce(val value: ULong) { val bytes: ByteArray get() = SIZE.byteArray { (value shr (it * Byte.SIZE_BITS)).toByte() } - fun increment(): Nonce? = if (value == ULong.MAX_VALUE) null else Nonce(value + 1uL) + fun increment(): Nonce? = if (value >= ULong.MAX_VALUE - 2uL) null else Nonce(value + 1uL) companion object {