dajiaji / hpke-js

A Hybrid Public Key Encryption (HPKE) module built on top of Web Cryptography API.
https://dajiaji.github.io/hpke-js/docs
MIT License
63 stars 9 forks source link

Question about the JS module size #221

Closed Zhiyi-Zhang closed 1 year ago

Zhiyi-Zhang commented 1 year ago

We have been using hpke-js in our library. We found the hpke-js library is big in size. Do you have some numbers for the size of the JS module?

image
Zhiyi-Zhang commented 1 year ago

The large size can also be caused by some of our internal tools that didn't successfully compress/optimize the JS files so I want to get some insights from you.

dajiaji commented 1 year ago

I think one of the issues is the use of external libraries to support ciphersuites that are not covered by the Web Cryptography API. Currently, I'm refactoring the code to use only the Web Cryptography API and create a core module that is independent of external dependencies. Additionally, we are separating the cryptographic suites that rely on external libraries into extension modules outside the core.

If you do not use x25519/x448 or chacha20, you only need to use @hpke/core, which significantly reduces the size. Please refer to the following for more information.

There may be other issues with package generation as well. The npm package's support for esm/cjs dual compatibility could be affecting something. I'll also look into it on my end.