Module Noalloc.Detached
The detached interface uses 2 separate buffers for the ciphertext and the message authentication tag. This allows users to encrypt and decrypt data in-place, by passing the same buffer for both plaintext and ciphertext.
Buffers have the following size requirements:
tag: 16 bytespk,sk,ck: 32 bytesn: 24 bytes
Box
One-shot interface
val box : pt:bytes -> n:bytes -> pk:bytes -> sk:bytes -> ct:bytes -> tag:bytes -> boolbox pt n pk sk ct tagauthenticates and encrypts plaintextptusing public keypk, secret keysk, and noncenand writes the ciphertext inctand the message authentication tag intag. Returns true if successful.
val box_open : ct:bytes -> tag:bytes -> n:bytes -> pk:bytes -> sk:bytes -> pt:bytes -> boolbox_open ct tag n pk sk ptattempts to verify and decrypt ciphertextctand message authentication tagtagusing public keypk, secret keysk, and noncenand if successful writes the plaintext inptand returns true.
Precomputation interface
The shared key ck is obtained using NaCl.box_beforenm or NaCl.Noalloc.box_beforenm.