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

chore: bcrypt cost adjustment #670

Merged
merged 1 commit into from
Mar 30, 2023
Merged

chore: bcrypt cost adjustment #670

merged 1 commit into from
Mar 30, 2023

Conversation

peter7891
Copy link
Contributor

In this PR, we reduce the bcrypt cost from 12 to 11.
@zivkovicmilos expressed concerns that CreateAccount was too slow.
It seems like this is safe to do. As far as i understand this refers to local storage.

@peter7891 peter7891 requested a review from a team as a code owner March 28, 2023 22:35
@moul
Copy link
Member

moul commented Mar 29, 2023

What's the impact on performance?

@moul
Copy link
Member

moul commented Mar 29, 2023

Do bcrypt's security measures have relevance to this situation? I'm more concerned about the potential risks of a weak PRNG than demonstrating proof of effort/work here.

@peter7891
Copy link
Contributor Author

@moul

Benchmarks with 12 cost

BenchmarkCreateAccount-8               4         257309375 ns/op
PASS
ok      github.com/gnolang/gno/pkgs/crypto/keys 10.182s

Benchmarks with 11 cost

BenchmarkCreateAccount-8               8         128997650 ns/op
PASS
ok      github.com/gnolang/gno/pkgs/crypto/keys 5.287s

Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

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

I support merging this issue as it is both redundant and disruptive to development.

I suggest that we open an issue to further discuss the security concerns. We should consider using a single round of bcrypt or switching to a simpler hashing function for this particular case. If that is not feasible, then let's determine the best default values and add comments to explain our decisions.

@moul moul changed the title bcrypt cost adjustment chore: bcrypt cost adjustment Mar 29, 2023
@peter7891 peter7891 merged commit e0c50ec into master Mar 30, 2023
@peter7891 peter7891 deleted the bcrypt branch March 30, 2023 12:24
grepsuzette added a commit to grepsuzette/gno that referenced this pull request Apr 1, 2023
This reverts e0c50ec (gnolang#670)
It breaks decoding of existing accounts.
For instance if you addpkg, it gives:

Enter password.
ciphertext decryption failed

Changing bcryptSecurityParameter = 12 (from 11) makes it work again.

Better change until we find a better solution.
moul-bot pushed a commit to moul/gno that referenced this pull request Apr 1, 2023
moul pushed a commit that referenced this pull request Apr 1, 2023
Co-authored-by: grepsuzette <grepsuzette@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants