# A Blockchain-Based Framework to Enhance Anonymous Services with Accountability Guarantees
## 3 Actors and Notation  
Our solution involves four actors:  
* The user \(U\): they require access to an anonymous service offered by a service provider \(SP\). * The service provider \(SP\): it offers the anonymous service to \(U\). \(U\) interacts with \(SP\) through a pseudonym username \(user_{U}\) not linkable to thereal identity \(ID_{U}\) of \(U\). * The identity gateway \(IG\): it does not know \(ID_{U}\), but acts as a gateway between an identity provider who knows \(ID_{U}\) and the Ethereum network. In principle, it may be included directly in the identity provider. Regardless, we keep it as a separated entity in order to not require technological changes in the identity provider and maintain it as compliant with the eIDAS regulation [35]. * The linkage agency \(LA\): it is a third independent party that, after receiving an order by a court, is able, through the collaboration of \(IG\) and \(SP\), to link the real identity \(ID_{U}\) with the username \(user_{U}\). As discussed in Section 1 and shown in Section 7, the collaboration of just two out of \(IG\), \(SP\), and \(LA\) is not enough to associate \(ID_{U}\) with \(user_{U}\), and all three parties have to be involved. During the interaction between \(U\) and \(SP\), some information is generated and associated with \(user_{U}\) (since \(SP\) does not know the real identity \(ID_{U}\)). We denote by \(I_{U}\) such account information. For example, if \(SP\) is an anonymous social network, \(I_{U}\) is represented by the private messages exchanged between \(U\) and other users, the messages posted by \(U\), the \"likes\" released by \(U\), and so on. Like almost all of the web services, \(I_{U}\) is maintained server-side by \(SP\). Observe that the access to \(I_{U}\) is what the user has to recover in case of a loss of credentials. An association among EOAs (see Section 2) and actors is established. Specifically, \(U\) owns two Ethereum addresses \(Add_{1}^{U}\) and \(Add_{2}^{U}\). \(SP\) owns the Ethereum address \(Add^{SP}\). \(IG\) owns the Ethereum address \(Add^{IG}\). Finally, \(LA\) owns the Ethereum address \(Add^{LA}\). Observe that \(Add^{U}_{I}\) and \(Add^{U}_{2}\) are pseudonyms of \(U\) not linkable between them or with \(ID_{U}\). \(Add^{SP}\), \(Add^{IG}\), and \(Add^{LA}\) are made publicly available by \(SP\), \(IG\), and \(LA\), respectively. As we will see in Section 4, our proposal is based on a challenge-response mechanism implemented by the smart contract reported in Listing 1. A number of instances of such a smart contract are deployed by \(SP\), \(IG\), and \(LA\). ```
1 contractSmartContract{
2 addressprivateowner;
3 mapping(address=>string)publicstateMap;
4 mapping(address=>bytes32)challengeMap;
5
6 modifierisOwner(){
7 require(msg.sender-owner,\"Callerisnotowner\");
8-;
9}
10 constructor(){
11 owner=msg.sender;
12}
13}
14
15 functionsetChallenge(addressuser,bytes32 challenge)publicisOwner{
16 stateMap[user]=\"ToConfirm\";
17 challengeMap[user]=challenge;
18}
19 functionsolveChallenge(bytes32 solution)public{
20 addresssender=msg.sender;
21 if(compareStrings(stateMap[sender],\"ToConfirm\")){
22 bytes32 challenge=challengeMap[sender];
23 if(kecack256(abi.encode(solution))==challenge){
24 stateMap[sender]=\"Confirmed\";
25}
26}
27}
28 functioncompareStrings(stringmemorya,stringmemoryb)publicview
29 returns(bool){
30 return(kecack256(abi.encodePacked((a)))==
31 kecack256(abi.encodePacked((b))));
32}
33}
34}
35}
```  
**Listing 1**Smart contract implementing a challenge-response mechanism. Specifically, \(SP\) deploys two instances \(C^{SP}_{1}\) and \(C^{SP}_{2}\) with Ethereum addresses \(Add^{C^{SP}}_{1}\) and \(Add^{C^{SP}_{2}}\), respectively. \(C^{SP}_{1}\) is used by \(U\) during the registration phase with \(SP\). It allows \(SP\) to associate the Ethereum address \(Add^{U}_{2}\) with \(user_{U}\). Clearly, this operation is performed by \(SP\) without knowing the real identity \(ID_{U}\) of \(U\). Moreover, \(user_{U}\) is not publicly disclosed.