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

Alternative export API for optimized delivery #4

Open
benoneal opened this issue Jun 11, 2019 · 1 comment
Open

Alternative export API for optimized delivery #4

benoneal opened this issue Jun 11, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@benoneal
Copy link

Just found this library, and I think you guys have nailed the problem that is isomorphic crypto, and the approach appears really well researched and developed. In the interest of optimising real-world application use and making it a bit more user-friendly, I've got some suggestions:

For most projects I've worked on, only one, possibly two crypto methods are required. For these projects, modern tree-shaking build systems can optimise application code by removing unused code paths.

Unfortunately, right now Enigma's module pattern appears to prevent that, as destructured imports (import {AES} from '@cubbit/enigma) aren't valid, and import Enigma means bundling the entire library, even though the vast majority of that code will never be used.

On a related note, the new Enigma.AES().init({key}).then(aes => aes.encrypt(message)) API seems unnecessarily unwieldy. Surely static async methods such as AES.encrypt(message, key) should be possible?

Otherwise I'd hazard that most people, like me, will have to write our own convenience wrappers around that API.

But the tree-shaking thing is more important, as it's not possible to address in userland, and some applications (like ours!) are very sensitive to the size of our script payloads.

@alessiopcc alessiopcc added the enhancement New feature or request label Jun 16, 2019
@alessiopcc
Copy link
Member

Thanks for suggestions. We will try to address it in the next version.
We can improve imports to better support tree shaking, I think we need to refactor the init phase to do it.

Regarding the encrypt method, yes it's unwieldy but it is due to the WebCrypto implementation. We started with a single static method but then we noticed bad performance encrypting multiple times with the same key because of the WebCrypto importKey. We can add back the static method and let the choice to users.

@alessiopcc alessiopcc self-assigned this Jun 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants