# A Time Bank System Design on the Basis of Hyperledger Fabric Blockchain
## 4 The Proposed Time Bank System
### Phase 3: Grading System  
_(1) An Overview:_ Generally, a grading system is used to collect all grades associated with a specific member before showing the average grade to him or her. However, most of the participants in a time bank may be neighbors in the same community or live in geographic close-by regions; therefore, directly revealing every individual's grade will cause disharmony. Hence, in our system, every single grade is hidden, and only the average grade is released. The period of average grade releasing is, of course, defined as another system parameter. For example, it is proper to reveal the average grade of an SP once five individual grades are received. When it comes to hiding a plaintext, the most common way is to use a cryptographic encryption scheme. However, our grading function needs to calculate the average of a certain amount of ciphertexts as a functional return. Fortunately, there is a system facing a similar problem to us, which is the E-voting system. Comparing to those E-voting systems [16; 17; 18; 19], our grading system has a significant difference, that is, our private key must never be revealed. This is because an E-voting system is a one-time process such that all the keys will be re-generated if another run of the election is held. However, in our grading system, the key pair cannot be changed every time the average grade is calculated and revealed. In other words, the private key adopted in the grading system should never be released. Due to the above-mentioned reasons, our grading system was designed to be a semi-decentralized system, that is, as outlined in Section 2.2, there is a TTP joined in this system but there are some restrictions on its functionality. This third-party entity is called the grade manager and is responsible for generating storing and concealing the encryption key. The grading system and the grade manager are detailed in the subsections below. _(2) The Processes of Our Grading System:_ The full mark is defined as 5.0 in the grading system. In addition, the grade is separated into two types, provide-grade and receive-grade, since people receive grades when they are either SP or SR. In our grading system, users have to conduct the encryption process before submitting their grades to the ledger. That is, the encryption is done in an off-chain phase. As for the encryption process, the asymmetric encryption scheme is selected since the encryption and decryption are executed by different parties. In this work, the well-known asymmetric encryption scheme RSA [20] is adopted. The steps of the grade submission and average grade calculation, as illustrated in Figure 6, are explained below. 1. Firstly, both users (SP and SR) encrypt their plain grades with _public-key_ 1, and the encrypted results are respectively defined as _ciphertext-1a_ and _ciphertext-1b_. Users have to keep these ciphertexts as their commitment for system checking later. 2. Then, the users encrypt _ciphertext-1a_ and _ciphertext-1b_ with _public-key_ 2, and the results are denoted as _ciphertext-2a_ and _ciphertext-2b_. Users submit _ciphertext-2a_ and _ciphertext-2b_ to the ledger so as to hide the real grade value. 3. The grade manager periodically accesses the grading peer to query those encrypted grade data such as _ciphertext-2a_ and _ciphertext-2b_. Since the grade manager owns the _private-key 1_ and _private-key 2_, they can firstly decrypt the _ciphertext-2a_ back to _ciphertext-1a with private-key 2_ and then decrypt the result again with _private-key_ 1 to get the plain grade data. When the grade manager collects five plain grade data of someone, they can calculate the average grade for that person. * Finally, the grade manager submits the average grade and the ciphertexts which are obtained by decrypting the encrypted data on the ledger with _private-key_ 2. These ciphertexts, such as _ciphertext_- 1\(a\), are regarded as the \"commitments\" of the grade data decryption.