# Anonymous Access System with Limited Number of Uses in a Trustless Environment
## 6 Use Case in Detail  
As noted in the Introduction, a government bill could grant users (\(\mathcal{U}\)) earning below the minimum wage thirty free underground trips per month.  
In this use case, \(\mathcal{AP}\) could be an entity like a tax agency or bank, and \(\mathcal{SP}\) could be the underground service company. The scope \(S\) is defined as the string consisting of the first letter of the service, the number of the month, and the year in which the users are entitled to the service. \"U0123\" would be the scope for January 2023, \"U0223\" for February 2023, and so on.  
The steps for a given month are as follows:  
1. \(\mathcal{U}\) generates their keys \(sk_{\mathcal{U}}\) and \(pk_{\mathcal{U}}\) that could always be the same or that could be changed every month. This does not affect the protocol.
2. In January, \(\mathcal{U}\) obtains (using Formula (1)) the unique identifier \(id_{\mathcal{U}}\) for the scope \(S\) equal to \"U0123\".
3. \(\mathcal{U}\) refers then to \(\mathcal{AP}\) and identifies themselves, proving that in the previous month, it had income below the minimum wage, and obtains the \(\delta_{\mathcal{AP}}\) for the scope \"U0123\" that entitles them to thirty underground trips in January. \(\mathcal{AP}\) obtains \(\delta_{\mathcal{AP}}\) using Formula (2), binding the attribute to \(sk_{\mathcal{U}}\).
4. The \(\delta_{\mathcal{AP}}\) attribute is known by \(\mathcal{AP}\) that can associate it with a user to control whether it has already been given to them or not.
5. Before usage, \(\mathcal{U}\) blinds \(\delta_{\mathcal{AP}}\) and performs the calculations in Formula (2) to obtain the anonymous credentials from the scope \"M0103\" which entitles them to thirty underground trips during January 2023. These anonymous credentials are: \(\delta^{\prime}_{\mathcal{AP}}\), \(pk^{\prime}_{\mathcal{U}}\), \(pk^{\prime}_{\mathcal{AP}}\), \(P^{\prime}\), and \(C^{\prime}\).
6. To begin using trips, \(\mathcal{U}\) should obtain a counter. To do so, \(\mathcal{U}\) presents its anonymous credentials calculated in the previous step, \(id_{\mathcal{U}}\), and the proof of possession of their own private key. This proof is \(t_{i}\) and is calculated using Formula (8) with \(i\) equal to the number of trips, that is, \(t_{30}\). This proof can be checked with Formula (9) given the anonymous credentials and \(id_{\mathcal{U}}\). These checks are implemented in the Create method of the Smart Contract.
7. With this data, \(\mathcal{SP}\) calls the Create function of the Smart Contract to create a counter valid for thirty accesses, no more, no less.
8. Only \(\mathcal{U}\) can use this counter, using \(t_{i}\) each time, where \(i\) is the number of uses stored in the Smart Contract, along with \(id_{\mathcal{U}}\) and their public key. If \(\mathcal{U}\) keeps this \(t_{i}\)s secret, only they can consume the ticket each time. This prevents anyone who does not know the private key from incrementing the counter.
9. Once the ticket has been created, \(\mathcal{U}\) must calculate the \(t_{i}\) that corresponds to the current value of the counter and send it to \(\mathcal{SP}\) along with its \(id_{\mathcal{U}}\) to be able to use it. Checks of these values are implemented in the Consume method of the Smart Contract, and the counter should be less than or equal to the maximum number.
10. When \(\mathcal{SP}\) receives a request to consume a counter, it only needs to call the Consume method of the Smart Contract with the parameters of the request. If the execution is successful, it grants access to the underground service; otherwise, it should deny access to the service and revert the transaction. The problem could be:  
* \(t_{i}\) being incorrect
* an attempted fraud
* the ticket is sold out