Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Why do we need this feature? What are we trying to accomplish?
The current process for retrieving a public key (via schnorr_public_key or ecdsa_public_key) takes approximately 9 seconds each time a user requests an address. By storing public keys in a static variable, I want to improve performance and minimize cycle burn rate in the canister. It can serve as a good example for developers.
Requirements
What requirements are necessary to consider this problem solved?
Public keys should be stored in a static variable, allowing retrieval without calling the key generation functions every time.
Considered Solutions
What solutions were considered?
thread_local storage with static variables that do persist across calls, but not across updates.
Recommended Solution
What solution are you recommending? Why?
Storing public keys in a static variable with HashMap for different derivation_paths
Considerations
What impact will this change have on security, performance, users (e.g. breaking changes) or the team (e.g. maintenance costs)?
This solution will significantly improve performance and lower cycle burn rate