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

Add custom argon2 Wasm implementation #907

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

webmaster128
Copy link
Member

@webmaster128 webmaster128 commented Oct 19, 2021

An attempt to replace Argon2 from libsodium.js with the argon2 crate.

Local benchmarks show this makes things significantly slower:

This PR (argon2 crate):

    5.1 Argon2id
      ✓ works for 1 MiB memory and opsLimit = 5 (0.177 sec)
      ✓ works for 8 MiB memory and opsLimit = 2 (0.531 sec)
      ✓ works for 10 MiB memory and opsLimit = 1 (0.368 sec)
      ✓ works for different output lengths (0.338 sec)
      ✓ throw for invalid salt lengths (0.001 sec)
      
main (libsodium.js):

    5.1 Argon2id
      ✓ works for 1 MiB memory and opsLimit = 5 (0.06 sec)
      ✓ works for 8 MiB memory and opsLimit = 2 (0.186 sec)
      ✓ works for 10 MiB memory and opsLimit = 1 (0.115 sec)
      ✓ works for different output lengths (0.116 sec)
      ✓ throw for invalid salt lengths (0 sec)

In CI

This PR (argon2 crate):

➤ YN0000: [@cosmjs/crypto]:     5.1 Argon2id
➤ YN0000: [@cosmjs/crypto]:       ✓ works for 1 MiB memory and opsLimit = 5 (0.302 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ works for 8 MiB memory and opsLimit = 2 (1 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ works for 10 MiB memory and opsLimit = 1 (0.668 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ works for different output lengths (0.622 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ throw for invalid salt lengths (0.001 sec)
      
main (libsodium.js):

➤ YN0000: [@cosmjs/crypto]:     5.1 Argon2id
➤ YN0000: [@cosmjs/crypto]:       ✓ works for 1 MiB memory and opsLimit = 5 (0.084 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ works for 8 MiB memory and opsLimit = 2 (0.279 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ works for 10 MiB memory and opsLimit = 1 (0.167 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ works for different output lengths (0.288 sec)
➤ YN0000: [@cosmjs/crypto]:       ✓ throw for invalid salt lengths (0.002 sec)

@webmaster128 webmaster128 mentioned this pull request Oct 19, 2021
@webmaster128
Copy link
Member Author

With the latest Rust compiler the results are even now:

main (libsodium.js):

    5.1 Argon2id
      ✓ works for 1 MiB memory and opsLimit = 5 (0.031 sec)
      ✓ works for 8 MiB memory and opsLimit = 2 (0.092 sec)
      ✓ works for 10 MiB memory and opsLimit = 1 (0.057 sec)
      ✓ works for different output lengths (0.058 sec)
      ✓ throw for invalid salt lengths (0 sec)


This PR (argon2 crate):

    5.1 Argon2id
      ✓ works for 1 MiB memory and opsLimit = 5 (0.03 sec)
      ✓ works for 8 MiB memory and opsLimit = 2 (0.094 sec)
      ✓ works for 10 MiB memory and opsLimit = 1 (0.059 sec)
      ✓ works for different output lengths (0.057 sec)
      ✓ throw for invalid salt lengths (0.001 sec)

@o-az
Copy link

o-az commented May 3, 2024

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