How things work
I have a Factory contract, FContract.
FContract can be called by a user as many times as they want, creating instances of, let's call it, contractA. Thus, they're able to own as many contract instances of contractA, deployed by FContract, as they want.
Every instance of contractA can store distinct keys. Some keys are for this, some keys are for that, and some other keys are for signing purposes. So, inside the contract the user stores the sha3 of the public key that they created.
The user creates keys through the frontend (keys are not created by the contracts!). For example, the routine that the user calls to create keys, follows these steps (I found this on another project):
- Produce some randomHex(32) through web3.utils.randomHex(32)
- Concat 0's to the end of the produced hex, so it is == 67 digits
- set publicKey = web3.eth.accounts.privateKeyToAccount(privateKeyWithConcat).address
- set producedKey = web3.eth.utils.sha3(publicKey)
The issue & What I want to achieve
I want the users to be able to sign messages with the keys that they produced. They will choose one of the "signing keys" and then sign the message.
But the issue is that I do not have any idea on how to store (or retrieve) the private key.
Am I losing something?
Also, why hashing the public key by using sha3? What are the benefits of it? I can't really think of any, while storing the hashed public key instead of the real public key, uses much more space.
**Contracts interactions are done with Metamask
Edit: The only possible solution I can think of is that the user will have to "write down somewhere" the produced private key and, at the phase of signing, the system will ask him to provide it with it. But is this the only feasible solution?