*3.2. Location-Based Service Selection*

The user electronics readings are maintained at di fferent locations of the county on di fferent servers. Each geographic region reading is stored on separate servers located in di fferent geographic regions. The user can view generated bills and make paymen<sup>t</sup> of bills through the cloud services. Upon creating a request, the cloud platform selects the respective service, according to the location of data or the server where the data is stored. To provide a more complete, and reliable service, the selection is made in a more strategic way where the time complexity should be minimized. The range of services is based on the location of the data, and then the user communicates with the selected service. The cloud managemen<sup>t</sup> console makes the selection, and once the service is selected, then the user request is transferred to the service chosen (see Algorithm 2).

### **Algorithm 2:** Location-Based Service Selection

LBSS(UserId Uid, UserLocation Uloc) Output: Selected cloud service CS. **Step1:** Read user-id Uid. **Step2:** Read user location Uloc. **Step3:** Read service details SD, service History Sh. **Step4:** Select available services according to the location Uloc. Ss = N i=1 Mx(sh) × (Sd(Uloc)) N = number of available services. Mx = Minimum frequency of service Sh = service history **Step5:** Return SS.

### *3.3. Hash Function for Key Generation*

The cloud user is assigned a secure key using which the user is identified and authenticated. The generation of the secret key is a dynamic process which is initiated for each reading, and the key is destroyed when the user completes the task. The key generation mechanism uses a hash function where the parameter of the hashing function also is changed when the existing or other users enter the system the next time. The selection of parameters and functions will also be adjusted according to the region of the user to provide more security and to avoid guessing attacks (see Algorithm 3).

**Algorithm 3:** Hashing Function for Key Generation Intake: Locations loc, Schemes S. Outcome: Secret key SecK. Read location details LD from the database. Compute Nl = Number of locations from Ld. Nl = sizeof(LD). Generate Random Number Rn. Rn = *f*(*x*) = ∅(1, <sup>S</sup>). Selected Scheme SeS = S(Rn). If (SeS %2) = 0 then Generate Secret Key SecK. Initialize SecK = 8i=1 SecK(i) = 0).// initialize the key to the size of 8 bit and set all bit to 0. //Set the bit 1,2 = for region 1,2,3 //Set the bit 3,4 = for scheme 1-Feb no, 2-ams no, 3-Mona //Set bit 5 and 6 = for the value - //Set the bit 7,8 with meter no User region ur = select the region of the user. Select a random number for the addressing scheme RanS. If(RanS = 1) Ms = Select a Fibonacci number within ur. Ms = *f*(*x*) = ® ∩ (- Fibanacci ∈ (1, UR)) Else if (RanS = 2) Ms = select a amstrong number within ur. Ms = *f*(*x*) = ® ∩ (- Amstrong ∈ (1, UR)) Else Ms = select a manorama number within ur. Ms = *f*(*x*) = ® ∩ (- Manorama ∈ (1, UR)) **End** Construct sk = {Ur,RanS,NS,Mr}. Else Create a Secret Key SecK. Initialize SecK = 16 i=1 SecK(i) = 0).// initialize the key to the size of 16 bit and set all bit to 0. //Set the bit 1 to,4 = for region 1,2,3 //Set the bit 5 to 8 = for scheme 1-Feb no, 2-ams no, 3-Mona //Set bit 9 to12 = for the value - //Set the bit 13 to 16 with meter no User region ur = select the region of the user. Select a random number for the addressing scheme RanS. If(RanS = 1) Ms = Select a Fibonacci number within ur. Ms = *f*(*x*) = ® ∩ (- Fibanacci ∈ (1, UR)) Else if (RanS = 2) Ms = select a amstrong number within ur. Ms = *f*(*x*) = ® ∩ (- Amstrong ∈ (1, UR)) Else Ms = select a manorama number within ur. Ms = *f*(*x*) = ® ∩ (- Manorama ∈ (1, UR)) **End** Construct SecK = {Ur,RanS,NS,Mr}. **End** Return SecK.
