# DSVN: A Flexible and Secure Data-Sharing Model for VANET Based on Blockchain
## 4 System Design
### ORCP-ABE Algorithm  
The ORCP-ABE algorithm consists of the following algorithms. * Initialization \((\lambda,U)\to PK,MSK,DPK,DSK\): The algorithm takes security parameters \(\lambda\) and system attribute set \(U\) as input. Algorithm constructs a bilinear mapping \(e:\mathbb{G}_{0}\times\mathbb{G}_{0}\rightarrow\mathbb{G}_{T}\). Where \(\mathbb{G}_{0}\) and \(\mathbb{G}_{T}\) are two bilinear groups of prime of order \(p\). \(g\) is the generator of the cyclic group \(\mathbb{G}_{0}\). Then algorithm randomly selects the index value \(t_{i}\) for each attribute \(att_{i}\in U\). Finally, algorithm randomly selects two numbers \(a\), \(\beta\), then calculates system key pair \(MSK\), \(PK\), and data key pair \(DSK\), \(DPK\): \[MSK=\left(\beta,g^{a}\right),PK=\left(g,e(g,g)^{a},h\right)\] (3) \[DSK=\left\{t_{i}|1\leq i\leq n\right\},DPK=\left\{T_{i}=g^{t_{i}}|1\leq i \leq n\right\}\] where \(a\), \(\beta\), \(t_{i}\in Z_{p}^{*}\), \(h=g^{\beta}\), and \(n\) is the number of attributes in \(U\) (note: The system public key \(PK\) and the data public key \(DPK\) are publicly accessible);
* Key generation \((id,S,MSK)\to SK_{id}\): The algorithm takes user number \(id\), attribute set \(S\) and system private key \(MSK\) as input. Algorithm randomly selects \(uid\), \(USK\), calculates user private key \(SK_{id}\) and user attribute encryption information \(kek\). For each attribute \(att_{i}\in S\), algorithm calculates node intersection \(V_{j}\) and judges whether \(V_{j}\) is empty. If \(V_{j}=\varnothing\), algorithm stop the calculation, else calculates user attribute group encryption information \(KEk\):  
Figure 4: System flow. \[ \begin{split} SK_{id}&=\left(D=g^{\frac{u+i\,ail}{B}},D^{ \prime}=g^{util-USK},USK\right),\\ kek&=\left\{att_{i},kek_{i}=g^{t_{i}-uid-USK}\right\}_{att _{i}\in S^{\prime}}\\ KEK&=\left\{KEK_{i}=(kek_{i})^{\frac{1}{t_{i}}}=g^{ \frac{t_{i}-uid-USK}{t_{i}}}\right\}_{att_{i}\in S}\end{split}  \tag{4}\]  
where \(uid,USK\in Z_{p}^{*},V_{j}=Path(u_{i})\cap Mincs(G_{j})\) and \(\theta_{j}\) is the value in node \(V_{j}\) (note: The system private key \(MSK\) is not visible and is only accessed through calls during the user registration phase);
* Access tree generation \((T,U)\to T^{*}\): The algorithm takes access structure \(T\) and the system attribute set \(U\) as input. First, algorithm classifies \(att_{i}\to L_{j}\) and assigns weights \(w\) for each attribute \(att_{i}\in U\). Then, algorithm replaces each attribute in \(T\) with the corresponding category weight pairs \(L_{j}:w\). Finally, algorithm constructs attribute-weighted tree \(T^{*}\);
* Pre-encryption \((M,T^{*})\to CT\): The algorithm takes the message \(M\) and attribute-weighted tree \(T*\) as input. First, algorithm generates a randomly univariate polynomial \(Q_{mode}(x)[\)\(]\) or each tree node. The secret value of node _node_ is \(Q_{mode}(0)\). Then, algorithm calculates pre-encrypted ciphertext \(CT\): \[CT=\left(T^{*},\widetilde{C}=Me(g,g)^{as},C=h^{s},\forall y\in Y:C_{y}^{\prime }=g^{Q_{y}(0)}\right)\] (5) where \(s\) is the secret value of root node, \(y\) is a leaf node of \(T^{*}\), and \(Y\) is leaf node set;
* Encryption \((CT,G)\to CT^{\prime},Hdr\): The algorithm takes attribute-weighted tree \(T\), pre-encrypted ciphertext \(CT\) and access structure attribute set \(G\) as input. Algorithm randomly selects \(k_{y}\), and calculates \(CT^{\prime}\): \[ \begin{split} CT^{\prime}&=\left(T^{*}, \widetilde{C}=Me(g,g)^{as},C=h^{s},\forall y\in Y:C_{y}^{\prime}=g^{Q_{Y}(0)}.g^{k_{y}}\right),\\ Hdr&=\left\{v_{j},E\left(k_{y}\right)=g^{k_{y}\theta_ {j}/I_{i}}\right\}_{v_{j}\in Mincs(G_{i})}\end{split}