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

Improve performance initializing Mnemonics #13

Open
ccjernigan opened this issue Oct 21, 2021 · 0 comments
Open

Improve performance initializing Mnemonics #13

ccjernigan opened this issue Oct 21, 2021 · 0 comments

Comments

@ccjernigan
Copy link
Contributor

When Mnemonics is first touched, it performs an initialization of SecureRandom which is known to be slow.

While documenting this could be helpful, it doesn't give clients using this library a lot of options to work around it. That's because Mnemonics is an object, so initialization is effectively a JVM static initializer when means it runs as soon as something touches the object.

Possible alternative implementations:

  • Defer SecureRandom initialization until it is needed, giving clients better control over timing
  • Convert Mnemonics to a class, so that initialization happens during construction which allows clients better control over timing of the initialization
  • Create a companion object initializer. This could be a suspend function, allowing secure random injection into a private constructor for Mnemonics
  • ... There may be other options to consider as well
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

No branches or pull requests

1 participant