diff options
Diffstat (limited to 'src/mint/mint.h')
-rw-r--r-- | src/mint/mint.h | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/src/mint/mint.h b/src/mint/mint.h new file mode 100644 index 000000000..5adce03c6 --- /dev/null +++ b/src/mint/mint.h | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | (C) 2014 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file taler_mint.h | ||
19 | * @brief Common functionality for the mint | ||
20 | * @author Florian Dold | ||
21 | * @author Benedikt Mueller | ||
22 | */ | ||
23 | |||
24 | #ifndef _MINT_H | ||
25 | #define _MINT_H | ||
26 | |||
27 | #include <gnunet/gnunet_util_lib.h> | ||
28 | #include <gnunet/gnunet_common.h> | ||
29 | #include <libpq-fe.h> | ||
30 | #include "taler_util.h" | ||
31 | #include "taler_rsa.h" | ||
32 | |||
33 | #define DIR_SIGNKEYS "signkeys" | ||
34 | #define DIR_DENOMKEYS "denomkeys" | ||
35 | |||
36 | |||
37 | GNUNET_NETWORK_STRUCT_BEGIN | ||
38 | |||
39 | |||
40 | /** | ||
41 | * FIXME | ||
42 | */ | ||
43 | struct TALER_MINT_SignKeyIssue | ||
44 | { | ||
45 | struct GNUNET_CRYPTO_EddsaPrivateKey signkey_priv; | ||
46 | struct GNUNET_CRYPTO_EddsaSignature signature; | ||
47 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
48 | struct GNUNET_CRYPTO_EddsaPublicKey master_pub; | ||
49 | struct GNUNET_TIME_AbsoluteNBO start; | ||
50 | struct GNUNET_TIME_AbsoluteNBO expire; | ||
51 | struct GNUNET_CRYPTO_EddsaPublicKey signkey_pub; | ||
52 | }; | ||
53 | |||
54 | struct TALER_MINT_DenomKeyIssue | ||
55 | { | ||
56 | /** | ||
57 | * The private key of the denomination. Will be NULL if the private key is | ||
58 | * not available. | ||
59 | */ | ||
60 | struct TALER_RSA_PrivateKey *denom_priv; | ||
61 | struct GNUNET_CRYPTO_EddsaSignature signature; | ||
62 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
63 | struct GNUNET_CRYPTO_EddsaPublicKey master; | ||
64 | struct GNUNET_TIME_AbsoluteNBO start; | ||
65 | struct GNUNET_TIME_AbsoluteNBO expire_withdraw; | ||
66 | struct GNUNET_TIME_AbsoluteNBO expire_spend; | ||
67 | struct TALER_RSA_PublicKeyBinaryEncoded denom_pub; | ||
68 | struct TALER_AmountNBO value; | ||
69 | struct TALER_AmountNBO fee_withdraw; | ||
70 | struct TALER_AmountNBO fee_deposit; | ||
71 | struct TALER_AmountNBO fee_refresh; | ||
72 | }; | ||
73 | |||
74 | struct RefreshMeltSignatureBody | ||
75 | { | ||
76 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
77 | struct GNUNET_HashCode melt_hash; | ||
78 | }; | ||
79 | |||
80 | struct RefreshCommitSignatureBody | ||
81 | { | ||
82 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
83 | struct GNUNET_HashCode commit_hash; | ||
84 | }; | ||
85 | |||
86 | struct RefreshCommitResponseSignatureBody | ||
87 | { | ||
88 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
89 | uint16_t noreveal_index; | ||
90 | }; | ||
91 | |||
92 | struct RefreshMeltResponseSignatureBody | ||
93 | { | ||
94 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
95 | struct GNUNET_HashCode melt_response_hash; | ||
96 | }; | ||
97 | |||
98 | |||
99 | struct RefreshMeltConfirmSignRequestBody | ||
100 | { | ||
101 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
102 | struct GNUNET_CRYPTO_EddsaPublicKey session_pub; | ||
103 | }; | ||
104 | |||
105 | |||
106 | GNUNET_NETWORK_STRUCT_END | ||
107 | |||
108 | |||
109 | |||
110 | /** | ||
111 | * Iterator for sign keys. | ||
112 | * | ||
113 | * @param cls closure | ||
114 | * @param ski the sign key issue | ||
115 | * @return #GNUNET_OK to continue to iterate, | ||
116 | * #GNUNET_NO to stop iteration with no error, | ||
117 | * #GNUNET_SYSERR to abort iteration with error! | ||
118 | */ | ||
119 | typedef int (*TALER_MINT_SignkeyIterator)(void *cls, | ||
120 | const struct TALER_MINT_SignKeyIssue *ski); | ||
121 | |||
122 | /** | ||
123 | * Iterator for denomination keys. | ||
124 | * | ||
125 | * @param cls closure | ||
126 | * @param dki the denomination key issue | ||
127 | * @param alias coin alias | ||
128 | * @return #GNUNET_OK to continue to iterate, | ||
129 | * #GNUNET_NO to stop iteration with no error, | ||
130 | * #GNUNET_SYSERR to abort iteration with error! | ||
131 | */ | ||
132 | typedef int (*TALER_MINT_DenomkeyIterator)(void *cls, | ||
133 | const char *alias, | ||
134 | const struct TALER_MINT_DenomKeyIssue *dki); | ||
135 | |||
136 | |||
137 | |||
138 | /** | ||
139 | * FIXME | ||
140 | */ | ||
141 | int | ||
142 | TALER_MINT_signkeys_iterate (const char *mint_base_dir, | ||
143 | TALER_MINT_SignkeyIterator it, void *cls); | ||
144 | |||
145 | |||
146 | /** | ||
147 | * FIXME | ||
148 | */ | ||
149 | int | ||
150 | TALER_MINT_denomkeys_iterate (const char *mint_base_dir, | ||
151 | TALER_MINT_DenomkeyIterator it, void *cls); | ||
152 | |||
153 | |||
154 | /** | ||
155 | * Exports a denomination key to the given file | ||
156 | * | ||
157 | * @param filename the file where to write the denomination key | ||
158 | * @param dki the denomination key | ||
159 | * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure. | ||
160 | */ | ||
161 | int | ||
162 | TALER_MINT_write_denom_key (const char *filename, | ||
163 | const struct TALER_MINT_DenomKeyIssue *dki); | ||
164 | |||
165 | |||
166 | /** | ||
167 | * Import a denomination key from the given file | ||
168 | * | ||
169 | * @param filename the file to import the key from | ||
170 | * @param dki pointer to return the imported denomination key | ||
171 | * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure | ||
172 | */ | ||
173 | int | ||
174 | TALER_MINT_read_denom_key (const char *filename, | ||
175 | struct TALER_MINT_DenomKeyIssue *dki); | ||
176 | |||
177 | |||
178 | /** | ||
179 | * Load the configuration for the mint in the given | ||
180 | * directory. | ||
181 | * | ||
182 | * @param mint_base_dir the mint's base directory | ||
183 | * @return the mint configuratin, or NULL on error | ||
184 | */ | ||
185 | struct GNUNET_CONFIGURATION_Handle * | ||
186 | TALER_MINT_config_load (const char *mint_base_dir); | ||
187 | |||
188 | |||
189 | int | ||
190 | TALER_TALER_DB_extract_amount (PGresult *result, unsigned int row, | ||
191 | int indices[3], struct TALER_Amount *denom); | ||
192 | |||
193 | int | ||
194 | TALER_TALER_DB_extract_amount_nbo (PGresult *result, unsigned int row, | ||
195 | int indices[3], struct TALER_AmountNBO *denom_nbo); | ||
196 | |||
197 | #endif /* _MINT_H */ | ||
198 | |||