Cipher

data class Cipher(val cryptography: Cryptography, val key: CipherKey? = null, val nonce: Nonce = Nonce.zero)(source)

Encompasses all Noise protocol cipher state required to encrypt and decrypt data.

Note that as per Noise revision 34 § 5.1, [key] may be uninitialized. In this case [encrypt] and [decrypt] are identity functions over the plaintext and ciphertext.

Encryption and decryption throw if incrementing [nonce] results in its maximum value: it means too many messages have been exchanged. Too many is a lot indeed: 2^64-1.

Constructors

Link copied to clipboard
constructor(cryptography: Cryptography, key: CipherKey? = null, nonce: Nonce = Nonce.zero)

Properties

Link copied to clipboard
Link copied to clipboard
val key: CipherKey? = null
Link copied to clipboard

Functions

Link copied to clipboard
fun decrypt(associatedData: AssociatedData, ciphertext: Ciphertext): State<Cipher, Plaintext>?
Link copied to clipboard
fun encrypt(associatedData: AssociatedData, plaintext: Plaintext): State<Cipher, Ciphertext>