This is what I've been thinking lately for our system. This is the meat of a solid project and I think it's not hacker-proof but at least very difficult to compromise unless they access all the parts at once in which case we're doomed.
First we identify two user roles in the process, traders and investors:
When trader registers:
- We create account T1 with two signers (threshold 2), our main account M1 and their new account T1
- We provide trader with secret key and we don't store it anywhere. All txs must be initiated by trader.
- When user trades they sign T1 on browser then submit to server, we sign M1 and submit to network T1+M1
- Nobody is aware of T1 signature except trader so account can never be hacked on client or server side.
When investor registers:
- We create account I1 with three signers (threshold 2), our main account X1, validator server V1 account, and their new account I1
- When trader trades T1, we sign M1 and submit trade to Stellar network as explained before
- Then we create one operation for each follower, sign X1 and submit tx to validator server V1 with ID:T1:TX
- Validator server V1 can only process accounts that have been signed by us X1
- Validator on signing request must ask for original transaction from T1 to verify it has been signed and submitted
- We may pass a batch with all trades signed X1 and properly identified.
- Validator can process txs in 100 ops batch (if that many followers) or process individually if they fail.
Validator server V1 can also process withdrawals and closing accounts once I1+X1+Y1 have been signed initiated by I1 only and signed by I1+X1.
* Our main accounts M1 (trading) and X1 (investing) are different to keep processes isolated.
Thoughts?