lvh / caesium

Modern cryptography (libsodium/NaCl) for Clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bindings for Ed25519 to Curve25519

davidwalker opened this issue · comments

I was going to add bindings for the ed25519 to curve25519 key conversion functions (https://download.libsodium.org/doc/advanced/ed25519-curve25519.html). Is that something you'd be happy to take a pull request for?

If so maybe you can help me with an error I'm getting:

clojure.lang.Compiler$CompilerException: java.lang.IllegalArgumentException: More than one matching method found: crypto_sign_ed25519_pk_to_curve25519, compiling:(.../caesium/src/caesium/crypto/sign/ed25519.clj:16:5)

in binding.clj I've added:

    [^int crypto_sign_ed25519_pk_to_curve25519
     [^bytes ^{Pinned {}} curve25519_pk
      ^bytes ^{Pinned {}} ed25519_pk]]

then to call it

    (b/call! crypto_sign_ed25519_pk_to_curve25519
             (bb/->indirect-byte-buf curve_pk)
             (bb/->indirect-byte-buf pk))

Any idea what I'm doing wrong?

I think I've figured out my problem, the name of the arguments used for the call! macro must match the name of the parameter in the binding.

commented

Yep, that is correct -- that's how it maps the arguments to the C arguments (it could do it positionally, but that seems brittle), which it needs to do in order to add the appropriate type annotations.

Thanks for working on this!