     (bb/->bytes m)))
 
 (defn ^:private xchacha20poly1305-ietf-keygen-to-buf! [k]
-  (b/call! xchacha20poly1305-keybytes k))
-
-(defn xchacha20poly1305-ietf-keygen []
+  (b/call! xchacha20poly1305-ietf-keygen k))
+
+(defn xchacha20poly1305-ietf-keygen
   "Generates a new random key."
+  []
   (let [k (bb/alloc xchacha20poly1305-ietf-keybytes)]
-    (chacha20poly1305-keygen-to-buf! k)
+    (xchacha20poly1305-ietf-keygen-to-buf! k)
     k))
 
 (defn new-xchacha20poly1305-ietf-nonce


(defn ^:private xchacha20poly1305-ietf-decrypt-detached-to-buf!
  [m nsec c mac ad npub k]
  (b/call! xchacha20poly1305-ietf-decrypt-detached m nsec c mac ad npub k)
  c)

(defn xchacha20poly1305-ietf-decrypt-detached
  [c mac ad npub k]


(defn ^:private chacha20poly1305-ietf-decrypt-to-buf!
  [m nsec c ad npub k]
  (let [res (b/call! chacha20poly1305-ietf-decrypt m nsec c ad npub k)]
    (if (zero? res)
      c
      (throw (RuntimeException. "Ciphertext verification failed")))))

(defn chacha20poly1305-ietf-decrypt
  [c ad npub k]
