## 4 Key Management Framework (KMF)  
In this section, the definitions, common abbreviations, and KMS for the AMI system are explained. Abbreviations specifies a set of abbreviations and their meanings for use in the KMS. Based on the key graph concept [20], an AMI system's key management architecture is created. This is conducted in order to manage all three distinct forms of message transmission. As shown in Figure 2, KMF can be defined as:  
\[\text{KMF}=(\text{U,K,R}) \tag{1}\]  
where:  
\(\text{U}=\{\text{u}_{1},\text{u}_{2},\ldots,\text{u}_{n}\}\) This is a set that is finite and non-empty and represents NXs within the AMI system. \(\text{K}=\{\text{k}_{0},\text{k}_{1},\ldots,\text{k}_{n},\text{kg}_{1},\text{ kg}_{2},\text{kg}_{m}\}\). This is a set that is finite and non-empty, where \(\{\text{k}_{1},\text{k}_{2},\ldots,\text{k}_{n}\}\) represents the keys of NXs. \(\{\text{gk1},\text{gk2},\ldots,\text{gkm}\}\). \"k\" represents the group keys of demand response projects, and \"k\" is the root key of the key hierarchy. R: The user-key relation is a binary relation between U and K, denoted as \(\text{Rk}\subset\text{U}\times\text{K}\). It indicates that user u knows key k if and only if (u, k) is present in R.  
In addition to this, a function is connected to the set, and its definition is as follows in (2):  
\[\text{\emph{userset}}(k)=\{u|(u,k)\in R\} \tag{2}\]  
For example, of the AMI, the KMF shown in Figure 3 might be expressed in (3), (4), and (5), for instance:  
\[U=\{u_{1},u_{2},\ u_{3}\} \tag{3}\]  
\[K=\{k_{0},k_{1},k_{2},k_{3}\}\cup\{gk_{1},gk_{2}\} \tag{4}\]  
\[R=\left\{ \begin{matrix}(u_{1},k_{0}),\ (u_{1},k_{1}),(u_{1},gk_{1}),\\ (u_{2},k_{0}),\ (u_{2},k_{2}),(u_{2},gk_{1}),(u_{2},gk_{2}),\\ (u_{3},k_{0}),(u_{3},k_{3}),(u_{3},gk_{2})\end{matrix} ,\right\} \tag{5}\]  
Figure 2: The U, K, and R for KMF. The set user set identifies the users involved in DR project \(1(\text{gk}_{1})=\{u_{1},u_{2}\}\), while the users participating in DR project 2 are denoted by the set user set (\((\text{gk}_{2})=\{u_{2},u_{3}\}\). For the broadcast mode, the KMF uses the group keys, and the root key \(k_{0}\). \([\text{gk}_{1},\text{gk}_{2},\dots,\text{gk}_{m}]\) are the keys for the multicast mode in several DR project groups \([\text{k}_{1},\text{k}_{2},\dots,\text{k}_{n}\;]\) are for each MS and each SX in unicast mode. The core of key management is these keys, so it is important to outline the procedures for their creation, distribution, and periodic refreshment. In addition, in order to authenticate and verify messages, as well as encrypt and decrypt them, session keys are required throughout the communication process. As a result, the procedures used to create, distribute, and renew session keys must be carefully designed while considering the amount of traffic on the network and the computing power of SXs. In order to provide a concise introduction to the KMS, the MS is denoted by the symbol \(u_{0}\). First, the keys of KMF and the extra value for creating session keys are created by \(u_{0}\) via the use of certain key servers. After that, the keys are disseminated to SXs. The initialization procedure is shown in Figure 4, which is then followed by explanations in further depth. Figure 4: Initial keys and their additional value to distribute to SXs. Figure 3: An instance of the key management framework. **Step 1:** The first b-bit keys for each SX project group and each DR project group are formed after the initial construction of the key \(\mathsf{u}_{0}\). \[k_{i}=Kgen\left(1^{b}\right)\,,\ i=0,1,2,\ldots,n\] \[gk_{j}=Kgen\left(1^{b}\right)\,,\ j=0,1,2,\ldots,m\] \[Count_{i}=Random(b)\,,\ i=0,1,2,\ldots,n\] \[GCount_{j}=Random(b),j=0,1,2,\ldots,m\]  
**Step 2:** The initial keys are distributed, as well as the extra value.