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

Use built-in PBKDF2 implementation #295

Merged
merged 9 commits into from
Jul 19, 2022
Merged

Use built-in PBKDF2 implementation #295

merged 9 commits into from
Jul 19, 2022

Conversation

prichodko
Copy link
Collaborator

@prichodko prichodko commented Jul 8, 2022

PBKDF2 is used for generating symmetric keys for the community and every chat for the community.

In a community with ~25 chats, the generation of keys using the PBKDF2 vanilla implementation from ethereum-cryptography took ~10-50 seconds. After migrating for built-in browser implementation it now only takes ~1 second and utilizes multiple threads.

See @felicio's comment for detailed comparison.

@felicio felicio marked this pull request as ready for review July 18, 2022 10:20
@@ -4,12 +4,28 @@ import { defineConfig } from 'vite'

import { dependencies } from './package.json'

import type { Alias } from 'vite'

const isTest = process.env.NODE_ENV === 'test'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do it the same, but I remember reading this from their docs:

Use process.env.VITEST or mode property on defineConfig (will be set to test if not overridden) to conditionally apply different configuration in vite.config.ts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx 👍, done.

@felicio
Copy link
Collaborator

felicio commented Jul 19, 2022

add video comparing both implementations

@prichodko I don't have the video recording, but at the beginning I took the following perf recording:

Before using window.crypto.subtle for ~25 chats it took:

  • Node.js (~5s)
  • Safari (~50s)
  • Chrome (~10s)
  • Safari Technology Preview (~50s)
  • and blocked main thread

Pasted Graphic 1

Pasted Graphic 2

After:

  • Safari Technology Preview (~1s)
  • and used other threads

Pasted Graphic 3

Let me know if you'd like the exports of those perf recording too.

@prichodko prichodko merged commit 1f567e1 into main Jul 19, 2022
@prichodko prichodko deleted the feat/use-native-pbkdf2 branch July 19, 2022 15:45
felicio added a commit to felicio/status-web that referenced this pull request May 15, 2023
* add pbkdf2 browser implementation

* use webcrypto in pbkdf2

* rename pbkdf2 file

* use pbkdf2

* add changeset

* revert rename

* remove browser field from package.json

* use `resolve.alias` for pbkdf2 if test

* use `mode` in vite.config.ts

Co-authored-by: Felicio Mununga <felicio@users.noreply.github.com>
This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants