# Portable Smart Spectrometer Integrated with Blockchain and Big Data Technology
## 5 Blockchain System
### Transaction Process  
A transaction is a carrier of information to be exchanged in a blockchain. Figures 10 and 11 show how the PSS-1.0 processes measured data and uploads it to the blockchain network as a transaction:  
1. After the PSS-1.0 measures the spectrum, it connects to the smart device via Bluetooth.
2. The user selects an item type and the smart device downloads a spectral analysis model according to the item type.
3. After measuring the spectrum, the user can set the PSS-1.0 to save the measured data to local storage or upload it to share it.
4. If upload is selected, the PSS-1.0 obtains the timestamp through the smart device.
5. The PSS-1.0 hashes the item type, measured data, and timestamp with SHA512 to obtain a hash value.
6. The PSS-1.0 signs the hash value with the private key stored in flash and packs the hash value, the item type, measured data, timestamp, signature, and system ID into packet 1.
7. The PSS-1.0 sends packet 1 to the smart device via Bluetooth.  
Figure 9: Blockchain system architecture.  
The smart device sends the packet 1 as a proposal to the peers to which the PSS-1.0 belongs (e.g., the peers of the organization that produces, purchases, uses or represents this PSS-1.0.).
9. The above peers receive the proposal, verify the signature using the public key corresponding to the system ID, and check the data format.
10. If the verification is passed and the data format is correct, the peers save the data in the big data management system according to Table 1, then provide endorsements and send them to the smart device. If the verification fails, the data cannot be recorded into the blockchain.
11. The smart device receives the endorsements, checks their legitimacy, and sends the hash value, signature, item type, timestamp, system ID, and endorsements to the orderer nodes of the blockchain network as a transaction for recording. The orderer nodes sort and package transactions into a block and send it to all peers. After peers update the ledger status according to the transactions in the block, the blockchain completes the record of the relevant data.  
To encourage individual users to upload data, the organization that records the spectral data may reward the account based on the record of the uploaded data.  
The data requester can select the required data through the item type, timestamp, or system ID recorded in the blockchain network, and request data from the data recorder through the hash value.  
Figure 11: Steps to upload data to and request data from the data recorder in the blockchain system.  
Figure 10: Method of portable smart spectrometer processing measured data.  
The data recorder can query the data based on the hash value through the big data management system and provide the corresponding data to the requester. The requester can authenticate the authenticity of the data by calculating the hash value of the data. These operations are also recorded as transactions on the blockchain so that data recorders can charge accordingly. Because no device stores the private key except the PSS-1.0 itself, no data recorder can change the data without being discovered. Real data guarantees the feasibility of data reuse and increases the value of the data.