A good water supply and quality are the objectives of this module. A subsystem with pumps and tanks is modeled in the scenario. To govern the real system, the system uses the following rules. Water supply plans are optimized using optimization algorithms, knowledge reasoning, and other technologies based on real-time water level information [31]. At the start of the process, all pumps are turned off. After a certain interval, it checks the tank level. The first action is to check the tank level in which the system will switch on or off all pumps based on the results of this activity. It is an infinite loop that will only come to an end if anything outside of the model is done. We saw a considerable influence on the complexity of the imperative process during the modeling phase when any of the following simplifications are not applied. Even the same rules in the descriptive process do not affect the complexity of the process. Figure 4 depicts the framework for the suggested technique.
A smart city will be able to control its water supply using sensors controlled by the Corporation. A water dispatching strategy will be impacted by the source water in addition to quantity and quality. IoT devices in smart cities can detect problems with the pipeline, such as leaking, overflowing, or the supply of water, and send a message to the user's phone [32]. IoT devices are used to check for leaks in pipelines. Water flow for the drinking water and sour water tanks is also controlled by an IoT gadget. The blockchain receives water usage data in real-time from smart water meters at user ports. An automated charger with a power supply connected to the house is connected immediately to the IoT gadget.
Blockchain-based data analysis compares reservoir water levels with drought limits, and the results are stored on the blockchain [33]. A block of the node is also used to store the water quality data obtained from sensors. Blockchain is used to transmit the evaluation results after measuring the data against water quality objectives. An instantaneous transmission of the findings by a real-time monitoring system allows for the detection of water contamination problems. We can identify water contamination in its earliest phases thanks to our real-time data transmission from our water quality monitoring devices. To evaluate if permission has been exceeded, smart contracts match monitoring data from water abstraction permits with the quantity mentioned in the permits. Real-time data about water consumption is sent to the blockchain by the smart water meters at user ports [34].
5.1 Data Collection:
The system collects and encrypts the current water quality parameters at regular intervals from their associated sensors. The encrypted data is then saved on the Hyperledger Fabric blockchain network using its consensus algorithm and ledger structure. In addition to being trustworthy and transparent, Hyperledger Fabric also ensures that the collected data is tamper-proof and verified using its consensus algorithm. The use of encryption provides an additional layer of data protection, ensuring that the collected data is secure and confidential.
Inputs:
- WQ: a set of water quality parameters including pH, temperature, turbidity, and dissolved oxygen.
- s: a set of sensors used to collect the data, where
- xi: corresponds to the sensor used to collect parameter i in WQ.
Outputs:
- Encrypted data: a set of encrypted water quality data, where E(xi) corresponds to the encrypted value of the current value of parameter i in WQ.
Steps:
- Initialize the system and set up the sensors for data collection.
- At regular intervals, retrieve the current value of each parameter i in WQ from its corresponding sensor si.
- Encrypt each parameter value xi using a secure cryptographic algorithm, denoted as E(xi).
- Save the encrypted data E(xi) on the Hyperledger Fabric blockchain network for verification and storage.
- Repeat steps 2-4 at regular intervals to continuously monitor and collect water quality data.
Mathematical Formula:
Let WQ = {i1, i2, ..., in} be the set of water quality parameters that need to be monitored, and let s = {s1, s2, ..., sn} be the corresponding sensors used to collect the data.
For each parameter i in WQ, let xi be the current value of the parameter collected by its corresponding sensor si at time t. The encrypted value of xi is denoted as E(xi), which is calculated using a secure cryptographic algorithm.
At regular intervals, the system retrieves the current value of each parameter from its corresponding sensor and encrypts the values as follows:
For i = 1 to n: xi = si.get_value() # retrieve the current value of parameter i from its sensor E(xi) = encrypt(xi) # encrypt the value of parameter i using a secure cryptographic algorithm
The encrypted data E(xi) is then saved on the Hyperledger Fabric blockchain network for verification and storage.
Overall, the data collection algorithm ensures that water quality data is collected securely, accurately, and continuously, providing a foundation for the smart water quality management and distribution system using Hyperledger Fabric and IoT.
5.2 Data Verification:
The collected data is encrypted using a secure cryptographic algorithm before being saved on the Hyperledger Fabric blockchain network. The data is subsequently sent throughout a network of nodes that participate in the consensus method to verify and validate the transactions. In addition to the consensus algorithm, the Hyperledger Fabric ledger structure provides a transparent and auditable record of all transactions on the blockchain network. This allows for easy tracking and auditing of the collected data, further enhancing the system's transparency and trustworthiness.
To make sure that transactions are only added to the blockchain if they satisfy specific requirements, the Hyperledger Fabric consensus algorithm utilizes a technique known as endorsement policies. Transactions added to the blockchain are immutable, which means they cannot be altered or removed. This ensures the authenticity and integrity of the data, as any attempts to tamper with the data will be immediately detected and rejected by the consensus algorithm.
Overall, the suggested data verification approach in this work offers a very safe and dependable option for confirming the veracity and integrity of the data obtained, guaranteeing that the smart water quality management and distribution system is very dependable and open.
Input: Encrypted data D, endorsement policy EP, blockchain network BN
Output: Validated data V
Steps:
- Decrypting data D with a safe cryptographic technique yields the original data.
- To determine how many endorsements are necessary for a transaction to be declared genuine, consult the endorsement policy EP.
- Data that has been decrypted should be uploaded to the BN blockchain network.
- The transaction will be distributed over a network of nodes via the blockchain network BN.
- Transactions are examined by consensus algorithm nodes to see if they fulfill the endorsement policy EP.
- If the required number of endorsements is met, the transaction is added to the blockchain and becomes immutable.
- A validated data set (V) is the decrypted data that has been added to a blockchain network (BN).
Mathematical Formula:
V = Decrypt(D)
BN.SubmitTransaction(V)
ConsensusAlgorithm(BN)
if Endorsements >= EP:
BN.AddToBlockchain(V)
return V
else: return "Transaction invalid"
5.3 Data Storage:
The Hyperledger Fabric network ensures fault-tolerance and highly available data by maintaining copies of the blockchain on each node utilizing a consensus method to guarantee that all nodes concur on the blockchain's current state, it offers a high level of trust and transparency. The collected data is encrypted using a secure cryptographic algorithm before being saved on the blockchain network. The blockchain network provides a decentralized and tamper-proof database that is highly secure and transparent. Blockchains maintain data integrity and immutability and prohibit data from being changed or removed without authorization.
The blockchain network can be further secured by implementing access control mechanisms to restrict access to data stored on it. Data can only be accessed and modified by authorized parties, making the system more transparent and trustworthy.
Overall, the proposed method for data storage in this paper provides a highly secure and reliable solution for storing and managing the collected data, ensuring that the smart water quality management and distribution system is highly trustworthy and transparent.
Input: Data D, Hyperledger Fabric network BN
Output: Stored data SD
Steps:
- Encrypt the data D using a secure cryptographic algorithm.
- Create a transaction containing the encrypted data and submit it to the Hyperledger Fabric network BN.
- All network nodes receive the transaction.
- Nodes verify transactions and add them to their local blockchains if they are valid.
- As soon as a transaction is added to the blockchain, it becomes immutable and available to all nodes.
- The stored data SD is the encrypted data that has been added to the blockchain network BN.
Mathematical Formula:
SD = Encrypt(D)
BN.SubmitTransaction(SD)
ConsensusAlgorithm(BN)
if ValidTransaction:
BN.AddToBlockchain(SD)
return SD
else: return "Transaction invalid"
5.4 Smart Contract Execution:
Smart contracts are used to automate the water distribution process, based on demand and quality. The smart contract executes the water allocation process, ensuring that water resources are efficiently distributed to users. Smart contracts allow for the direct coding of the conditions of the parties' agreement. In the proposed system, smart contracts are used to automate various processes, such as water quality monitoring, distribution, and payment, while ensuring that all parties involved adhere to the pre-defined rules and conditions.
Hyperledger Fabric provides tamper-proof, transparent, and highly secure smart contracts that run on the blockchain network. The blockchain network allows for the automation of trust and verification in the system, as all parties can view and track the progress of the contracts, making the process more efficient and reliable.
In a smart contract, the execution triggers predefined actions, such as alerting a water treatment plant, triggering a distribution process, or processing a payment. As part of the proposed system, smart contracts are designed to automatically execute once predefined conditions are met, such as when water quality levels fall below a certain threshold.
To ensure the security and reliability of the system, the smart contracts are rigorously tested and audited before deployment, and access control mechanisms are implemented to restrict access to the contracts to only authorized parties.
Input:
- Pre-defined rules and conditions for water quality management and distribution
- Hyperledger Fabric blockchain network
Output:
- Automated execution of smart contracts for water quality management and distribution
Steps:
- The predefined conditions of smart contracts, such as when they should execute and what actions they should take, along with penalties should be assessed.
- Write the smart contracts in code, including the pre-defined rules and conditions.
- Test and audit the smart contracts to ensure they are functioning correctly and securely.
- Deploy the smart contracts to the Hyperledger Fabric blockchain network.
- Observe the network for events that trigger intelligent contracts, such as a decline in water quality or an overdue payment.
- Once triggered, the smart contracts execute automatically, initiating the pre-defined actions, such as alerting the water treatment plant, initiating the distribution process, or processing the payment.
- As smart contracts update on the blockchain network, all parties can track their progress and ensure that their actions are transparent and accountable.
- If any party fails to comply with the pre-defined rules and conditions, penalties are automatically applied, such as fines or suspension of service.
- Access control mechanisms are implemented to restrict access to the smart contracts to only authorized parties, ensuring the security and integrity of the system.
Mathematical Formulas:
- Smart Contract Code: SC = {rules, conditions, actions}
- Contract Trigger: T = {threshold, payment due}
- Smart Contract Execution: E(SC, T) = {actions taken}
- Smart Contract Status Update: S(SC) = {status}
- Penalty Application: P(SC, non-compliance) = {penalty}
- Access Control: AC(SC) = {authorized parties}
5.5 Access Control:
Using Hyperledger Fabric's access control mechanism, the system restricts unauthorized access to sensitive data and ensures that only authorized users have access to it.
Input:
- User ID: a unique identifier for each user
- Authentication credentials: such as a password or biometric identifier
- Access control policies: defined by the system administrator to enforce restrictions on data access and actions
- Encryption keys: used to encrypt and decrypt data
Output:
- Access is granted or denied based on the user's role, permissions, and privileges
Steps:
- Identification:
- The user provides their user ID to the system
- The system verifies the user ID against a list of authorized users
- Authentication:
- The user provides their authentication credentials to the system
- The system verifies the credentials against a stored record
- The user is verified and given access to the system if the credentials are legitimate.
- Authorization:
- The system verifies the user's role, permissions, and privileges based on their user ID
- The system checks the access control policies to determine if the user is authorized to perform the requested action
- If the user is authorized, the system grants access to the requested data or action
- Encryption:
- The system encrypts sensitive data both in transit and at rest using encryption keys
- Access to the encrypted data is controlled through key management mechanisms
- Audit Trails:
- The system logs all access attempts and actions
- Audit trails are reviewed and analyzed to detect and investigate security incidents or policy violations
Overall, the access control algorithm is designed to ensure that the system is secure and only authorized parties can access sensitive data and perform specific actions. Water quality management and distribution systems can be maintained in a secure way by enforcing access control policies and mechanisms.
5.5 Auditing:
The system logs all user activities, including data access and modification, using Hyperledger Fabric's audit mechanism. This ensures accountability and transparency, enabling system administrators to track all system activities.
Inputs:
- Requesting party identification (ID)
- Requesting party authentication credentials (creds)
- Resource ID (res_ID)
- Requested action (action)
Outputs:
- Access granted or denied (grant)
Steps:
- Verify that the requesting party has valid identification using the following formula:
- If ID = valid, then proceed to step 2
- Else, grant = denied and end
- Authenticate the requesting party using the following formula:
- If creds = valid, then proceed to step 3
- Else, grant = denied and end
- Determine if the requesting party is authorized to access the requested resource using the following formula:
- If action is authorized for res_ID, then grant = granted and end
- Else, grant = denied and end
- Encrypt the access decision using the following formula:
- Encrypt(grant, requesting party public key)
- Log the access request and decision using the following formula:
- Log(requesting party ID, res_ID, action, grant)
- End.