Comment on page
Onboarding & Wallets
Starknet, a Layer 2 solution, incorporates separate public/private keys from your Ethereum keys. To interact with Paradex on Starknet, here's a simplified overview:
- 1.Key Generation: visit the Paradex UI running in your browser. When you sign the Onboarding transactions, it will deterministically generate your private Starknet keys based on a signature from your Ethereum L1 signature. Any Ethereum wallet that supports deterministic signing is supported. Importantly, this process ensures that you can regenerate your Starknet keys using the same Ethereum key/pair and seed phrase. Rest assured, your Starknet keys are never transmitted to servers or any external location; they remain securely stored in your browser.
- 2.Transaction Signing: Your private Starknet key is employed to sign any transactions you authorize on Layer 2. The UI running on your machine automatically performs these signatures when required.
- 3.Wallet Integration: Starknet's technology is being increasingly adopted by various wallets, including Argent, Braavos etc. with more integrations on the horizon. Wallet integration facilitates storing your private Starknet key directly within the wallet itself, offering enhanced security compared to browser storage.
Wallet Compatibility: Please note that as of now, smart contract wallets like Argent are not compatible with Paradex.
Our solution was to allow our customers to operate on Starknet while only having to care about their Ethereum wallet, which they are already familiar with. We did not want users to have to manage a separate Starknet wallet, but instead be able to use a wallet they are comfortable with, such as MetaMask. This reduces complexity, as they would have to manage an Ethereum wallet anyway in order to interact with Starknet.
MetaMask was our wallet of choice that would allow us to provide a simple experience to our users.
Remember that in order to make changes to the blockchain, the transaction doing so must be signed by a private key and that private key must belong to the user and to the user only.
So how do we generate the same private key to the same user over and over?
I'll answer that with a question: What's the one thing that a MetaMask user can do that we can verify that only they and no one else have done?
The answer: A signature!
Why a signature?
- 1.It's based off of the user's private key on Ethereum, which in turn is based off of the recovery phrase provided to them by MetaMask, which we know can be used to recreate the wallet on a different device, therefore allowing the same private key to sign on different devices.
- 2.Only the user is capable of generating that signature given that they are (presumably) the only holder of that private key.
But it's not just any signature.
We need the user to be able to generate the exact same signature over and over otherwise, again, they will lose their funds. The way we do that is by always asking the user to sign the same thing every time.
There we have it: some bytes that only the user themself can generate repeatedly in any device that they choose to use.
This is where some slightly advanced cryptography comes in.
Converting arbitrary inputs into a private key is done with a KDF or Key Derivation Function. The KDF takes the input and does a series of transformations to it in order to convert it to a key in a deterministic way.
Of course we relied on the StarkWare team as the cryptography specialists to provide us with the KDF that would do what we needed in a secure way.
Finally, this gave us the key (no pun intended) to allow our users to interact with Starknet by only having a MetaMask wallet.
You must be asking yourself how secure is this private key, right?
It's as secure as the user's computer. The private key never leaves RAM and is sandboxed to the browser tab running the app. That means that only our app has access to it, only on the user's machine and only while it's running. It's not stored anywhere else and is never sent in a request. The moment the app closed the private key goes away.
In order to be able to not ask the user to authenticate again when reopening the app we have to store something. As you may have guessed we DON'T store the private key. Instead, we store a signature made with the user's Startknet private key. That signature is reused in our servers in order to authenticate the user for a longer period of time, but it expires after a few days to limit its exposure in case it's leaked.