   "Bindings to the secretbox secret-key authenticated encryption scheme."
   (:require [caesium.binding :as b]
             [caesium.util :as u]
-            [caesium.byte-bufs :refer [buflen]])
+            [caesium.byte-bufs :as bb])
   (:import [java.nio ByteBuffer]))
 
 (b/defconsts [keybytes noncebytes macbytes primitive])

  You only want this to manage the output byte buffer yourself. Otherwise,
  you want [[secretbox-easy]]."
  [c m n k]
  (b/✨ easy m n k))

(defn secretbox-easy
  "Encrypt with `crypto_secretbox_easy`.

  automatically prepend the required `ZERO_BYTES` NUL bytes, verify
  that the encryption succeeded, and strip them from the returned
  ciphertext."
  [m n k]
  (let [c (bb/alloc (+ macbytes (bb/buflen m)))]
    (secretbox-easy-to-buf!
     c
     (bb/->indirect-byte-buf m)
     (bb/->indirect-byte-buf n)
     (bb/->indirect-byte-buf k))
    (bb/->bytes c)))

(defn secretbox-open-easy-to-buf!
  "Decrypt with `crypto_secretbox_open_easy` into the given byte array.

  All arguments must be `java.nio.ByteBuffer`.

  You only want this to manage the output byte array yourself. Otherwise,
  you want [[secretbox-open-easy]]."
  [m c n k]
  (let [res (b/✨ open-easy m c n k)]
    (if (= res 0)
      m
      (throw (RuntimeException. "Ciphertext verification failed")))))

(defn secretbox-open-easy
