Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support :poly1305+chacha20 #68

Open
ysangkok opened this issue Jul 31, 2019 · 2 comments
Open

Feature request: Support :poly1305+chacha20 #68

ysangkok opened this issue Jul 31, 2019 · 2 comments

Comments

@ysangkok
Copy link

As specified in RFC 8439 and used in the Lightning Protocol (BOLT-08).

@ysangkok
Copy link
Author

ysangkok commented Aug 2, 2019

If you need this, you can use http://GITHUB.COM/lvh/caesium or (Java 11)

(defn javaenc [msg iv keyb]
  (let [mamboSpec (javax.crypto.spec.IvParameterSpec. iv)
         k4 (javax.crypto.spec.SecretKeySpec. keyb "ChaCha20")
         ci (doto (javax.crypto.Cipher/getInstance "ChaCha20-Poly1305")
                  (.init javax.crypto.Cipher/ENCRYPT_MODE k4 mamboSpec))]
       (->
         (.doFinal ci msg)
         (hexlify))))

IV is 12 bytes. Key is 32 bytes.

@niwinz
Copy link
Member

niwinz commented May 1, 2021

PR welcome ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants