Real-time Cryptocurrency Trading: Leveraging Trusted Hardware
Glossary
Term DefinitionsBlockchainA distributed ledger maintained by multiple processing devices that contains transaction data recorded in chronological order.Smart ContractA program stored on a blockchain that automatically executes when preset conditions are met.Trusted Execution Environment (TEE)A secure area in a processor that provides an isolated execution environment for code and data.Intel SGXIntel Software Guard Extensions, a technology that provides hardware protection for user-level code, creating a trusted execution environment.Remote AttestationA process that allows one device to verify the state of software on another device, such as proving that code is running in an SGX enclave.FrontrunningA behavior in which an attacker seeks to profit by executing a transaction ahead of other traders.Atomic Cross-Chain SettlementA mechanism that ensures that transactions involving multiple blockchains are either all successful or all failed.TimelockA mechanism that restricts transactions to a specific time or block height before they can take effect.Colored CoinsA scheme for creating tokens representing other assets on an existing blockchain (such as Bitcoin).ERC-20A smart contract standard for creating and issuing tokens on the Ethereum blockchain.Paxos ProtocolAn algorithm used in distributed systems to reach consensus, such as determining which server is the leader. Short Answer Questions
Briefly describe how Intel SGX protects data and code security for a real-time cryptocurrency trading platform.
Intel SGX protects data and code security by creating an isolated execution environment called an enclave in the CPU. The enclave uses hardware mechanisms to protect the code and data inside it from attacks from other software (including the operating system) on the same host, even if the attacker has physical access.
Explain what "front-running" attacks mean in cryptocurrency trading and how Girlfriend prevents such attacks.
In cryptocurrency trading, front-running refers to the act of an attacker using known transaction information to execute a trade ahead of other traders to profit. Girlfriend prevents such attacks by storing trade orders in a secure SGX enclave, ensuring that trades are only executed when all necessary conditions are met and the trade is irreversible.
Explain what "atomic cross-chain settlement" means and give an example of how Girlfriend achieves this goal.
Atomic cross-chain settlement refers to transactions involving multiple blockchains that either all succeed or all fail, ensuring that all participants receive a fair result. For example, if Alice uses Bitcoin to trade Litecoin with Bob, Girlfriend will create two transactions: one to transfer Bitcoin on the Bitcoin blockchain and another to transfer Litecoin on the Litecoin blockchain. Girlfriend uses mechanisms such as time locks and conditional scripts to ensure that the two transactions are either completed at the same time or fail at the same time, preventing either party from suffering losses during the transaction.
Describe how Girlfriend uses the "time lock" mechanism to protect user funds.
Girlfriend maintains a UTXO (unspent transaction output) for each user, which can be spent in one of two ways: signed by the exchange's private key, or signed by the user's private key after a certain time. This mechanism allows users to recover their funds when the exchange fails or is unavailable.
Explain the concept of "colored coins" and give examples of how Girlfriend supports asset transactions based on colored coins.
Colored coins are a scheme for creating tokens representing other assets on an existing blockchain (such as Bitcoin). Girlfriend can support asset transactions based on colored coins by identifying predefined types of colored coins in deposit transactions. For example, if a colored coin represents USD, Girlfriend can allow users to transact with that colored coin just like any other supported cryptocurrency.
Describe how Girlfriend leverages hardware random number generators and other mechanisms to ensure the security of key generation.
Girlfriend uses multiple sources of randomness to generate keys, including: SGX's hardware random number generator (RDRAND), the hash of the most recent blockchain block, OS-provided randomness (/dev/random), and the SGX trusted clock. Combining these sources of randomness increases entropy and reduces the likelihood that an attacker can guess or extract the key.
Explain how Girlfriend leverages multi-party computation (MPC) to improve security.
Girlfriend can use multi-party computation (MPC) to decentralize key management and prevent single points of failure. For example, you can use MPC to split a private key into multiple parts and distribute it to multiple servers. Only when a certain number of servers cooperate can the private key be used for signing or decryption operations.
Describe how Girlfriend ensures that service availability is maintained even when some servers are unavailable.
Girlfriend uses the Paxos protocol or other consensus mechanisms to reach consensus among multiple servers and select a leader server. If the leader server fails, other servers can take over and continue to provide services. In addition, Girlfriend also uses a time lock mechanism to ensure that users can recover their funds even if the exchange is unavailable.
What mechanisms does Girlfriend use to prevent "Eclipse Attack"?
Girlfriend prevents eclipse attacks through the following mechanisms:
Maintaining a queue of blockchain headers: Girlfriend maintains a queue containing the latest blockchain headers inside the enclave and periodically verifies these block headers to ensure their validity.
Use hard-coded difficulty parameters: Girlfriend hard-codes the current PoW difficulty parameters into the enclave code to prevent attackers from using low-difficulty blockchains to deceive the enclave.
Remote proof: Users can verify whether the Girlfriend enclave has the latest blockchain data through the remote proof mechanism and reject transactions if inconsistencies are found.
Multi-server consensus: Girlfriend uses a multi-server consensus mechanism to verify deposit transactions and ensure that at least half of the servers confirm the validity of the transaction to prevent a single server from being controlled by an attacker.
An example of how Girlfriend supports tokenizing Bitcoin and using it on the Ethereum blockchain.
Girlfriend can create a token called tBTC that is pegged 1:1 to Bitcoin. Users can deposit Bitcoin into Girlfriend's reserve address and receive an equal amount of tBTC tokens. These tBTC tokens can circulate and trade freely on the Ethereum blockchain and be used in smart contracts and other decentralized applications. When a user wants to redeem tBTC back to Bitcoin, they can send tBTC to Girlfriend's designated address, and Girlfriend will send the same amount of Bitcoin to the user's address. To ensure security, Girlfriend uses an atomic cross-chain settlement mechanism to handle the exchange between tBTC and Bitcoin.