   bytes at the front.
 
   The return value is a mutable byte array."
-  [n]
-  (let [unpadded (.toByteArray (biginteger n))
-        bytelen (alength unpadded)
-        output (byte-array noncebytes)]
-    (System/arraycopy unpadded 0 output (- noncebytes bytelen) bytelen)
-    output))
+  (partial u/n->bytes noncebytes))

  [key nonce ciphertext]
  (secretbox-open-easy ciphertext nonce key))

(defn int->nonce
  "Turns an integer into a byte array, suitable as a nonce.

  The resulting byte-array is in big-endian order: it starts with the most

(ns caesium.crypto.secretbox
  "Bindings to the secretbox secret-key authenticated encryption scheme."
  (:require [caesium.binding :refer [sodium defconsts]]
            [caesium.utils :as u]))

(defconsts [keybytes noncebytes macbytes primitive])

