donau.tex (12156B)
1 \section{Donau}\label{donau} 2 The Donau is written in C as it reuses parts of the codebase from the exchange 3 of GNU Taler (see section \ref{taler} for more information about GNU Taler). 4 The Donau has a similar architecture and uses 5 crypographic blinded signatures in a similar way as the exchange does. 6 7 \subsection{REST API} \label{rest_api} 8 The detailed REST API specification of the Donau backend is publicly available 9 under the following URL: \url{https://docs.taler.net/core/api-donau.html}. The 10 following are the main API endpoints: 11 12 \subsubsection{\texttt{/keys}} 13 The \texttt{GET /keys} request returns all valid donation unit public keys 14 offered by the Donau, as well as the Donau's current EdDSA public signing key. 15 Donation unit keys are used by the Donau to sign blinded messages for an issue 16 receipt request. The signing key is primarily used to create the donation 17 statement signature for the donor (see section 18 \ref{donor_requests_a_donation_statement_from_the_donau}). 19 20 The following is an example response of a \lstinline{curl 127.0.0.1:8080/keys} 21 command. Some parts of the following example responses are truncated (denoted by 22 the three dots '\texttt{...}') to make them more readable. 23 24 \begin{lstlisting} 25 { 26 "version": "0:0:0", 27 "base_url": "http://localhost:8080/", 28 "currency": "EUR", 29 "signkeys": [ 30 { 31 "stamp_start": { 32 "t_s": 1717069556 33 }, 34 "stamp_expire": { 35 "t_s": 1718279156 36 }, 37 "key": "CFV2PY8164E231XZSQK30K8R6CBQ..." 38 }, 39 { 40 ... 41 } 42 ], 43 "donation_units": [ 44 { 45 "donation_unit_pub": { 46 "cipher": "RSA", 47 "rsa_public_key": "020000YC7XK99S..." 48 }, 49 "year": 2024, 50 "lost": false, 51 "value": "EUR:5" 52 }, 53 { 54 "donation_unit_pub": { 55 "cipher": "CS", 56 "cs_public_key": "7SKRQGBSEPBG24..." 57 }, 58 "year": 2024, 59 "lost": false, 60 "value": "EUR:1" 61 }, 62 { 63 ... 64 } 65 ] 66 } 67 \end{lstlisting} 68 69 \subsubsection{\texttt{/charities}} 70 In order for a charity to be able to issue receipts by a specific Donau it must 71 be registered by this Donau. To do so the Donau provides an API to manage 72 charities. It is expected that only the Donau administrator can manage the 73 registered charities. 74 The charity itself should be able to request their issued donation receipt to 75 keep track of the set donation limit. 76 The response includes the maximum donation amount and the current donated 77 amount for the charity of the current year. 78 79 \begin{figure}[ht] 80 \includegraphics[width=1\textwidth]{donau_flow_register_charity} 81 \caption{The tax authority registers a new charity in the Donau}\label{fig:donau_flow_register_charity} 82 \end{figure} 83 84 The following is an example response of a 85 \lstinline{curl 127.0.0.1:8080/charities} command. 86 There is only one charity named 87 \texttt{example} registered with a donation limit of 10 euros. 88 89 \begin{lstlisting} 90 { 91 "charities": [ 92 { 93 "charity_pub": "ABETNXT9ZF606FRF3WD5...", 94 "url": "example.com", 95 "name": "example", 96 "max_per_year": "EUR:10", 97 "receipts_to_date": "EUR:0", 98 "current_year": 2024 99 } 100 ] 101 } 102 \end{lstlisting} 103 104 To insert a charity a \texttt{POST} request can be sent using 105 \lstinline{curl -d @charity.json -X POST http://127.0.0.1:8080/charities}. 106 107 \begin{lstlisting}[title=charity.json] 108 { 109 "charity_pub": "ABETNXT9ZF606FRF3WD5...", 110 "charity_name": "mycharity", 111 "charity_url": "mycharity.example.com", 112 "max_per_year": "EUR:1000", 113 "receipts_to_date": "EUR:0", 114 "current_year": 2024 115 } 116 \end{lstlisting} 117 118 The response consists of the charity ID generated by the database. 119 \begin{lstlisting} 120 { 121 "charity-id": 1 122 } 123 \end{lstlisting} 124 125 126 \subsubsection{\texttt{/batch-issue}} 127 Only recognized charities are allowed to issue receipts for their donors (see 128 section \ref{issuing_donation_receipts}). 129 A \texttt{POST} issue receipt request includes an array of \texttt{BKP}s. A 130 \texttt{BKP} consists of a \texttt{BUDI} and a hash of a public donation unit 131 key (see section \ref{notation_and_definitions}). 132 The charity signs the request with its own EdDSA private key. The 133 corresponding public key was given to the Donau in the registration process of 134 the charity. 135 After the Donau checked the signature from the charity it signs the 136 \texttt{BUDI}s with the corresponding donation unit private key. Before the 137 signatures are returned to the charity the Donau saves a hash of the request 138 and all donation unit signatures to make the request idempotent (see section 139 \ref{donau_database}). 140 141 \begin{figure}[ht] 142 \includegraphics[width=1\textwidth]{donau_flow_issue_receipt} 143 \caption{Flow of the issue receipt process} \label{fig:donau_flow_issue_receipt} 144 \end{figure} 145 146 The following is an example response of a \\ 147 \lstinline{curl -d @issue.json -X POST http://127.0.0.1:8080/batch-issue/1} 148 request. The number at the end of the URL is the charity ID. 149 150 \begin{lstlisting}[title=issue.json] 151 { 152 "budikeypairs": [ 153 { 154 "h_donaton_unit_pub": "130C2KDHTAFDQFB8XED...", 155 "blinded_udi": { 156 "cipher": "RSA", 157 "rsa_blinded_identifier": "AXPTEE24W28S9XN..." 158 } 159 } 160 ], 161 "charity_sig": "JEJ0QMDXD416XKSK1SG0DETJEH...", 162 "year": 2024 163 } 164 \end{lstlisting} 165 166 \begin{lstlisting} 167 { 168 "blind_signatures": [ 169 { 170 "blinded_signature": { 171 "cipher": "RSA", 172 "blinded_rsa_signature": "16XHNWSCDRVKHF..." 173 } 174 } 175 ], 176 "issued_amount: "EUR:15" 177 } 178 \end{lstlisting} 179 180 \subsubsection{\texttt{/batch-submit}} 181 The batch-submit route is used by the donor to summarize their donation 182 receipts into one donation statement EdDSA signature. 183 The request is composed of the donation receipt (see section 184 \ref{notation_and_definitions}), the corresponding year and the hash of the 185 salted tax ID. 186 When processing the request the Donau checks the validity of the donation 187 receipts and searches after more saved donation receipts made in the requested 188 year. The EdDSA signature over the total amount of the value of the donation 189 units of all donation receipts of the year, the hash of the salted tax ID and 190 the year forms the donation statement. The donation statement and the receipts 191 are stored in the Donau database (see section \ref{donau_database}). 192 193 \subsubsection{\texttt{/donation-statement}} 194 The donation statement will not be returned after a submit request, a 195 donation statement get request can be made for a specified year and tax ID. 196 197 \begin{figure}[ht] 198 \includegraphics[width=1\textwidth]{donau_flow_submit_receipt} 199 \caption{Donor requests a donation statement from the Donau} \label{fig:donau_flow_submit_receipt} 200 \end{figure} 201 202 The following is an example of a \\ 203 \lstinline{curl -d @submit.json -X POST http://127.0.0.1:8080/batch-submit} 204 request. If successful, the Donau returns the \texttt{HTTP 201} status code 205 with an empty response. 206 207 \begin{lstlisting}[title=submit.json] 208 { 209 "h_donor_tax_id": "N2NYR2SFNGZSS388R2SB0VK...", 210 "donation_year": 2024, 211 "donation_receipts": [ 212 { 213 "h_donaton_unit_pub": "130C2KDHTAFDQFB8X...", 214 "nonce": "JEQC39G", 215 "donation_unit_sig": 216 { 217 "cipher": "RSA", 218 "rsa_signature": "GQBXPNE4JT5W53T3CVP6E..." 219 } 220 } 221 ] 222 } 223 \end{lstlisting} 224 225 The following is an example response of a \\ 226 \lstinline{curl http://127.0.0.1:8080/donation-statement/2024/N2NYR2SFNGZSS388R2SB...} \\ 227 request. 228 229 The last parameter of the URL is the salted hash of the donor tax ID. 230 231 \begin{lstlisting} 232 { 233 "total": "EUR:15", 234 "donation_statement": "C1JVDP25AR001W5AHMAZ...", 235 "donau_pub": "63f62b7901311c2187bfcde6304d1..." 236 } 237 \end{lstlisting} 238 \subsection{Donau client} 239 The REST client removes some of the complexity of sending requests to the Donau 240 Server. It converts request parameters into JSON and parses JSON responses into 241 a usable C format. What the exact queries are and how they look like is already 242 described in chapter \label{rest_api}. 243 244 \subsection{Donau database}\label{donau_database} 245 The Donau database contains five tables as shown in figure 246 \ref{fig:db_physical_model}. The \texttt{donation\_units} and 247 \texttt{donau\_sign\_keys} table store the keys necessary for signing and 248 creating donation receipts. Donation receipts that are issued to be signed by 249 the donau are stored in the \texttt{receipts\_issued} table while the receipts 250 that are already signed are stored in the \texttt{receipts\_submitted} table. 251 The \texttt{history} table keeps the donation records of the past years. 252 253 \begin{figure}[ht] 254 \includegraphics[width=1\textwidth]{db_physical_model} 255 \caption{Donau database model (generated by \url{https://dbdiagram.io/})} \label{fig:db_physical_model} 256 \end{figure} 257 \subsubsection{charities} 258 Each registered charity has an entry in this table. There may be a donation 259 limit imposed by local law which prevents further donations if the limit is 260 reached. 261 262 \begin{itemize} 263 \item \texttt{charity\_id:} Unique ID generated by the database. 264 \item \texttt{charity\_pub:} Charity EdDSA public key 265 \item \texttt{charity\_name:} Name of the charity 266 \item \texttt{charity\_url:} Charity URL 267 \item \texttt{max\_per\_year:} The annual donation limit according to local law. 268 \item \texttt{receipts\_to\_date:} The current amount of donations in the current year. Reset to 0 when incrementing the \texttt{current\_year}. 269 \item \texttt{current\_year:} Current year 270 \end{itemize} 271 272 \subsubsection{donation\_units} 273 Table containing all the valid donation units the Donau knows about. 274 \begin{itemize} 275 \item \texttt{donation\_unit\_serial:} Unique ID generated by the database. 276 \item \texttt{h\_donation\_unit\_pub:} Hash value of the donation unit public key \texttt{donation\_unit\_pub} 277 \item \texttt{donation\_unit\_pub:} The donation unit public key. Is either an RSA or CS public key. 278 \item \texttt{validity\_year:} The year, for which the donation unit is valid. 279 \item \texttt{value:} The amount and currency that this donation unit represents. 280 \end{itemize} 281 282 \subsubsection{donau\_sign\_keys} 283 Contains all Donau EdDSA signing keys. 284 \begin{itemize} 285 \item \texttt{dsk\_serial:} Unique ID generated by the database. 286 \item \texttt{donau\_pub:} Donau EdDSA public key. 287 \item \texttt{valid\_from:} Year the signing key becomes valid. 288 \item \texttt{expire\_sign:} Year the signing key becomes invalid. 289 \item \texttt{expire\_legal:} Year the signing key legally expires. 290 \end{itemize} 291 292 \subsubsection{receipts\_issued} 293 Contains all issued donation receipts sent to the Donau. 294 \begin{itemize} 295 \item \texttt{receipt\_id:} Unique ID generated by the database. 296 \item \texttt{blinded\_sig:} Array of blinded signatures. These are the \texttt{BKP}'s the Donau blind signed. 297 \item \texttt{charity\_id:} The ID of the charity that received the donation. 298 \item \texttt{receipt\_hash:} Hash value over all the blinded donation receipt received plus the hash of the donation units public key. 299 \item \texttt{amount:} The amount and currency this donation receipt contains. 300 \end{itemize} 301 302 \subsubsection{receipts\_submitted} 303 Contains all submitted donation receipts sent to the Donor. By storing the 304 signature \texttt{donation\_unit\_sig}, the idempotentcy of the API is kept in 305 case the private key is replaced. 306 \begin{itemize} 307 \item \texttt{receipt\_id:} Unique ID generated by the database. 308 \item \texttt{h\_tax\_number:} The hash of the tax number and salt. 309 \item \texttt{nonce:} The nonce used in the \texttt{Unique Donor Identifier} 310 \item \texttt{donation\_unit\_pub:} Reference to public key used to sign. 311 \item \texttt{donation\_unit\_sig:} The unblinded signature the Donau made. 312 \item \texttt{donation\_year:} The year the donation was made. 313 \end{itemize} 314 315 \subsubsection{history} 316 History of the yearly donations for each charity. This data provides a record 317 of donations each year. It could also provide valuable information that could 318 be used in statistics to analyze general donations over the year. 319 \begin{itemize} 320 \item \texttt{charity\_id:} Unique ID generated by the database. 321 \item \texttt{final\_amount:} The final amount that was donated to the charity 322 \item \texttt{donation\_year:} The year in which the donations where made. 323 \end{itemize} 324