package tezos-crypto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type key
val keybytes : int

Size of the secret key

val tagbytes : int

Size of the message authentication tag

val unsafe_of_bytes : Stdlib.Bytes.t -> key
  • raises Invalid_argument

    if argument is not keybytes bytes long

val blit_of_bytes : Stdlib.Bytes.t -> int -> key
  • raises Invalid_argument

    if argument is not keybytes bytes long

val genkey : unit -> key

genkey () generates a secretbox key.

val secretbox : key:key -> nonce:Stdlib.Bytes.t -> msg:Stdlib.Bytes.t -> cmsg:Stdlib.Bytes.t -> unit

secretbox key nonce msg cmsg encrypts and authenticates the data in msg using key and nonce and outputs the authentication tag and the ciphertext in one buffer cmsg. For this reason, csmg needs to be tagbytes longer than msg.

val secretbox_open : key:key -> nonce:Stdlib.Bytes.t -> cmsg:Stdlib.Bytes.t -> msg:Stdlib.Bytes.t -> bool

secretbox_open key nonce cmsg msg verifies and decrypts cmsg using key and nonce and outputs the plaintext in msg. As above, msg is expected to be tagbytes shorter than cmsg. Returns true if operation has succeeded, false otherwise.

OCaml

Innovation. Community. Security.