DeGate
Product Feature
Search…
⌃K
Links

Account Structure

Users can access the DeGate protocol via the Ethereum wallet. First-time users are required to register for a DeGate account, this process links their DeGate account's authority together with their wallet address.
Account Nodes in the Entire Merkle Tree
Referring to the above diagram about the entire merkle tree diagram with the account nodes, it can be seen that each account's node contains a DeGate account which stores the wallet address (owner), asset public key (publicKeyX & publicKeyY), trading key (appKeyX, appKeyY), account nonce (nonce), trading key permissions (disableAppKeySpotTrade/Withdraw/TransferToOther), and the root data (balanceRoot, storageRoot). There can be up to 4^16 account nodes which means that the DeGate protocol can support approximately 4.2 billion accounts. Every DeGate account is assigned with an AccountID in sequence, starting from 0 and increasing by 1 each time. 0 and 1 are reserved so the first user AccountID will start from 2.
Assigning a short AccountID to represent a long wallet address helps save the cost to perform zero-knowledge proof. From a user standpoint, it is unnecessary to understand AccountID as they will only be utilizing their wallet to access and use DeGate to perform operations such as withdrawals and transfers.

Account Nonce and KeyNonce

There is also a Nonce in the account node of the merkle tree that is called "Account Nonce". Currently, there are 2 different concepts of nonce: Account Nonce and KeyNonce. The table below describes their differences:
Differences
Account Nonce
KeyNonce
Storage Location
Account node in merkle tree
Off-chain storage in DeGate node
Rules
Begin from 0, increment by 1 each time AccountUpdate or AppKeyUpdate is executed
Begins from 1, and increase by 1 with each reset
Verifer
The circuit
DeGate node,
Function
Prevent replaying transaction updates to the account's EdDSA keys and permissions. This is similar to how the nonce of ethereum transactions works.
Used to generate different EdDSA keys
What is the implication if DeGate nodes misplace the latest KeyNonce?
Each time a user unlocks their DeGate account, they will retrieve the latest KeyNonce from the DeGate node to generate the correct asset private key. If there is no KeyNonce, the user will perform signing from 1 onwards and compare with the key in the merkle tree's node, a match will indicate the latest KeyNonce is found. Therefore, losing the KeyNonce will not lead to loss or inaccessibility of the user's assets.

Account Assets

Asset Node under an Account Node
Each account will require assets before trading on DeGate can begin. Tokens can be either deposited from a wallet or transferred from other DeGate accounts. For deposits, all assets are stored in DeGate's smart contract and will be confirmed by zero-knowledge proof and updated to the respective DeGate account nodes and asset nodes in the merkle trees.
In other words, users cannot use their wallet funds directly with DeGate. They will have to deposit their assets to trade and withdraw their assets back to their wallet when done with trading. The need to deposit and withdraw may be a barriers to some users. However, in return, order placements and cancellations are free and instantaneous which is desirable for long-term and professional traders.
Some operations in DeGate require gas fees and will be paid from the account's assets.
On the protocol layer, any actions that deal with the account's assets will require a signed authorization from the wallet's private key and/or the asset private key. Users are responsible to make security precautions to safeguard these keys.