 
   A map of the secret seed and public-key is returned."
   ([]
-   (let [pk (byte-array publickeybytes)
-         sk (byte-array secretkeybytes)]
-     (.crypto_sign_keypair b/sodium pk sk)
-     {:public pk
-      :secret sk}))
+   (let [pk (bb/alloc publickeybytes)
+         sk (bb/alloc secretkeybytes)]
+     (b/✨ sign-keypair pk sk)
+     {:public pk :secret sk}))
   ([seed]
-   (let [pk (byte-array publickeybytes)
-         sk (byte-array secretkeybytes)]
-     (.crypto_sign_seed_keypair b/sodium pk sk seed)
-     {:public pk
-      :secret sk})))
+   (let [pk (bb/alloc publickeybytes)
+         sk (bb/alloc secretkeybytes)
+         seed (bb/->indirect-byte-buf seed)]
+     (b/✨ sign-seed-keypair pk sk seed)
+     {:public pk :secret sk})))
 
 (def ^:deprecated generate-signing-keys
   "Deprecated alias for [[keypair!]]."

  message. When given a valid signature, returns nil. When given an
  invalid signed message or signature, raises RuntimeException."
  ([pk sm]
   (let [smlen (buflen sm)
         m (byte-array (- smlen bytes))
         res (.crypto_sign_open b/sodium m nil sm smlen pk)]
     (if (zero? res)
       m
       (throw (RuntimeException. "Signature validation failed")))))
  ([pk msg sig]
   (let [mlen (buflen msg)
         res (.crypto_sign_verify_detached b/sodium sig msg mlen pk)]
     (when-not (zero? res)
       (throw (RuntimeException. "Signature validation failed"))))))

(ns caesium.crypto.sign
  (:refer-clojure :exclude [bytes])
  (:require [caesium.binding :as b]
            [caesium.byte-bufs :as bb]))

(b/defconsts [bytes seedbytes publickeybytes secretkeybytes primitive])

