# A Blockchain-Based Protocol for Fair Delivery for Receips
## 5 Certified Delivery Protocol
By the same method as that of Step 2, this step generates an on-chain transaction (\(tx_{publishA}\)) that is signed with the private key of \(A\), which is related to the public blockchain address @\(A\):  
\[tx_{publishA}=publish(id,k)\]  
where \(k\) contains the cryptographic parameters required by the recipient to retrieve \(K\) and decrypt the content in accordance with the selected cryptographic scheme (see Section 7.2 for more details). Once the smart contract receives this message, it verifies its contents. If the deadline \(t_{d}\) has not yet expired, the received transaction is signed by \(B\), the provided \(id\) matches, and there is already an entry stored for the identifier \(id\) with the state accepted, then the smart contract modifies the execution status to delivered, stores the received information as evidence of publication and triggers a blockchain event that contains this evidence. Otherwise, the smart contract does not execute any action, so it ignores the incoming request. When \(B\) is notified of the blockchain event, they can check the correctness of its contents, and if the contents are correct, they can recover \(K\) from the data provided in \(k\) (according to the cryptographic scheme used by \(A\) in Step 3 to protect \(K\)). Once \(K\) is available, it can be used to decrypt the delivered document (\(M=D_{K}(C)\)). Notably, if the sender fails to execute Step 3 before \(t_{d}\) expires, the delivery is not completed successfully. Nevertheless, this does not compromise fairness for either participant. If the protocol ends successfully, both participants have the following evidence:  
* \(A\) receives \(B\)'s acknowledgment of receipt, which was published on the blockchain as a result of executing the \(accept\) function. This evidence indicates that \(B\) wanted to receive the document linked to \(C\). Additionally, \(A\) possesses a blockchain transaction confirming the publication of the decryption key (signed with the private key associated with their blockchain address @\(A\)). Consequently, they can demonstrate that the key \(K\) corresponds to the key accessible to \(B\), confirming that \(B\) was able to access the document contents promptly. * \(B\) possesses \(C\) and \(k\); hence, they also possess \(K\), which enables them to access the document. In addition, \(B\) has the signature from Step 1 and the blockchain transaction generated by the \(publish\) function (duly signed by the private key bound to the blockchain address @\(A\)). If \(B\) cannot decrypt the document with the key \(K\) (\(A\) provided an incorrect key), they can demonstrate to any relevant party that they were unable to access the document content, implying that \(A\) was dishonest. Get status.The two parties can always determine the status of the document delivery process by executing a read-only action. This action incurs no blockchain transaction costs, as it simply queries the smart contract for the delivery status identified by \(id\), so the smart contract answers with undefined, accepted or delivered according to the state of the specified delivery.