Replies: 5 comments 2 replies
-
I could be wrong, but we can maybe keep the |
Beta Was this translation helpful? Give feedback.
-
|
To comment on a couple of the assumptions:
The Rust client does not generate nor store keypairs anywhere. In terms of the actual
As implied above, this should mostly already be the case. |
Beta Was this translation helpful? Give feedback.
-
|
I think there's some confusion so I'd like to be pretty specific. The A Stateless signature would look like: This forces clients to implement a keystore like here in the rust client or here in the web client.
Because it's Generic, you can of course implement any keystore you want to use but every client implementation is going to have to make some decisions about what that keystore looks like. What @dagarcia7 and I are advocating is that the Client implementation shouldn't have to care about how keys are stored. In the Web Client, this leads to some complication. Sometimes as a DApp developer, a default solution like IndexedDB is sufficient. In the case of a wallet chrome extension, we have to be extremely specific of how these keys are stored and exposed. We can't run a full client in a service worker as the service worker is blocking and we never want to expose private keys to the content scripts which is where the client has to run. Ideally, we'd be able to have small stateless parts of the SDK like generating keys or signatures and run those in the service worker. What this ends up looking like right now is that we have to implement a different keystore just for the Miden Wallet which will be extremely opinionated. Anyone who has a slightly different opinion about where private keys are stored will need to fork the Web Client and reimplement their own keystore. I see this is a challenge when someone wants to create a Mobile Client or use the keychain or create a NodeJS client. Having a Generic keystore lets implement anything you could want or you could make it stateless and then users don't have to fork code and reimplement clients in order to use it. |
Beta Was this translation helpful? Give feedback.
-
I think I'm not fully understanding the proposal, but the stated benefits is exactly what we are trying to achieve with Basically, the intent of the And the problem, again, is that it doesn't quite work in the context of the WebClient because Assuming the above is correct (and let me know if it isn't), this is a broader problem that we are trying to solve (and hopefully, will solve in the next few weeks) by making requests emitted by the VM to be |
Beta Was this translation helpful? Give feedback.
-
|
We really appreciate the clarification. We can modify We'll create an issue to address this as well as create a standalone: That we will use in the service worker. Thanks for clearing this up. We now have a much better understanding. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi team,
After looking to implement #908, I realized there's a lot of room for improvement in the way the web and rust clients handle user keys. I'd like to propose we investigate what it takes to move from our current stateful key management model to a stateless approach for both the Miden rust and web clients. This change would simplify interfaces, improve separation of concerns, and enhance security posture by delegating key management to downstream consumers (wallets, dApps, etc.).
Current State
Today, both the Rust and web clients:
For example:
When a transaction is triggered in the web client, it has to call fetch and cache an account for the synchronous
get_signaturecall to be able to get the signing key.This pattern adds complexity to seemingly simple operations like signMessage, which would either:
Stateless Proposal
Under a stateless model, the clients would:
sendTransaction,getSignature,signMessage, etc.In this model:
get_signature(public_key)becomes obsolete; instead, the signing logic would operate on a provided private key or signature directly.Benefits
Security: Removes assumption that the client can securely store keys; encourages explicit encryption/storage flows.
Simplicity: Eliminates the need for caching accounts, global key state, or indirection in interfaces.
Flexibility: Supports integration with a wider range of key management flows (e.g., hardware wallets, passphrase-based encryption, external keystores).
Testability: Stateless APIs are easier to test in isolation without requiring mock storage/state.
Conclusion
I know this is a big ask, but I'm hopeful that because there are not too many places where
get_signatureis called, that it should be in the realm of possibility to at least make this part of the client stateless. I believe if we are able to achieve this, I'd feel much better security-wise (at least from the client's perspective), but this would also help untangle the responsibility of key management and make a clear cut between what apps are responsible for and what the client is responsible for. This would in turn help simplify the APIs from the web client perspective and put the onus on the consumers as to how they want to use the keys they generate. Finally, if we wanted, we could even include utilities to aid users likeencryptSecretKeyWithPassphrase, or things like that to simplify their key handling, but that would be further down the line.I could also be way off the mark and not be considering something or have something wrong with what I have above 😅
In any case, let me know what y'all think!
Beta Was this translation helpful? Give feedback.
All reactions