antontutoveanu / crystals-kyber-javascript

JavaScript implementation of CRYSTALS-KYBER (version 3) post-quantum key exchange algorithm.
MIT License
110 stars 22 forks source link

KeyGen512 is not defined on browser #11

Open sebmeister2077 opened 1 year ago

sebmeister2077 commented 1 year ago

I have a problem on the client side and can't seem to use the package. I am using Qwik and whenever i import the library i get this error

image

ghost commented 1 year ago

I'm not familiar with Qwik, but to get this working in a Vite project I had to pop open node modules, cut out the portion of the code I needed (basically KeyGen768, Encrypt768, etc., and the related helper functions). Then I had to add packages that were missing from the client side. Specifically, a package for SHA/SHAKE and a package for buffer. Also, I had to export each of the functions so that I could import them properly. As far as I can tell, this package seems to be designed to run in a server side node environment, so you'll have to adapt it.

It's hard to say what your specific issue is without any code, but hopefully this gives you some insight. If you can show me some code, I may be able to help more.

sebmeister2077 commented 1 year ago

Thank you for your reply. Sounds like a lot of trouble, but i found this new package that came out a few days ago and used it on my front end. https://www.npmjs.com/package/crystals-kyber-js

ghost commented 1 year ago

Yes, it was a lot of work. Glad you found something that works for you and thanks for the link to the other package. Looks interesting.