1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
|
/*
This file is part of TALER
Copyright (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file include/taler_crypto_lib.h
* @brief taler-specific crypto functions
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff <christian@grothoff.org>
* @author Özgür Kesim <oec-taler@kesim.org>
*/
#if ! defined (__TALER_UTIL_LIB_H_INSIDE__)
#error "Only <taler_util.h> can be included directly."
#endif
#ifndef TALER_CRYPTO_LIB_H
#define TALER_CRYPTO_LIB_H
#include <gnunet/gnunet_util_lib.h>
#include "taler_error_codes.h"
#include <gcrypt.h>
#include <jansson.h>
/**
* Maximum number of coins we allow per operation.
*/
#define TALER_MAX_FRESH_COINS 256
/**
* Cut-and-choose size for refreshing. Client looses the gamble (of
* unaccountable transfers) with probability 1/TALER_CNC_KAPPA. Refresh cost
* increases linearly with TALER_CNC_KAPPA, and 3 is sufficient up to a
* income/sales tax of 66% of total transaction value. As there is
* no good reason to change this security parameter, we declare it
* fixed and part of the protocol.
*/
#define TALER_CNC_KAPPA 3
#define TALER_CNC_KAPPA_MINUS_ONE_STR "2"
/* ****************** Coin crypto primitives ************* */
GNUNET_NETWORK_STRUCT_BEGIN
/**
* @brief Type of public keys for Taler security modules (software or hardware).
* Note that there are usually at least two security modules (RSA and EdDSA),
* each with its own private key.
*/
struct TALER_SecurityModulePublicKeyP
{
/**
* Taler uses EdDSA for security modules.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Set of the public keys of the security modules
*/
struct TALER_SecurityModulePublicKeySetP
{
/**
* Public key of the RSA security module
*/
struct TALER_SecurityModulePublicKeyP rsa;
/**
* Public key of the CS security module
*/
struct TALER_SecurityModulePublicKeyP cs;
/**
* Public key of the eddsa security module
*/
struct TALER_SecurityModulePublicKeyP eddsa;
};
/**
* @brief Type of private keys for Taler security modules (software or hardware).
*/
struct TALER_SecurityModulePrivateKeyP
{
/**
* Taler uses EdDSA for security modules.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures used for Taler security modules (software or hardware).
*/
struct TALER_SecurityModuleSignatureP
{
/**
* Taler uses EdDSA for security modules.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* @brief Type of public keys for Taler reserves.
*/
struct TALER_ReservePublicKeyP
{
/**
* Taler uses EdDSA for reserves.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of private keys for Taler reserves.
*/
struct TALER_ReservePrivateKeyP
{
/**
* Taler uses EdDSA for reserves.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures used with Taler reserves.
*/
struct TALER_ReserveSignatureP
{
/**
* Taler uses EdDSA for reserves.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* (Symmetric) key used to encrypt KYC attribute data in the database.
*/
struct TALER_AttributeKeyP
{
/**
* Actual key material.
*/
struct GNUNET_HashCode key;
};
/**
* @brief Type of public keys to for merchant authorizations.
* Merchants can issue refunds using the corresponding
* private key.
*/
struct TALER_MerchantPublicKeyP
{
/**
* Taler uses EdDSA for merchants.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of private keys for merchant authorizations.
* Merchants can issue refunds using the corresponding
* private key.
*/
struct TALER_MerchantPrivateKeyP
{
/**
* Taler uses EdDSA for merchants.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures made by merchants.
*/
struct TALER_MerchantSignatureP
{
/**
* Taler uses EdDSA for merchants.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_sig;
};
/**
* @brief Type of transfer public keys used during refresh
* operations.
*/
struct TALER_TransferPublicKeyP
{
/**
* Taler uses ECDHE for transfer keys.
*/
struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_pub;
};
/**
* @brief Type of transfer private keys used during refresh
* operations.
*/
struct TALER_TransferPrivateKeyP
{
/**
* Taler uses ECDHE for melting session keys.
*/
struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_priv;
};
/**
* @brief Type of public keys used for contract
* encryption.
*/
struct TALER_ContractDiffiePublicP
{
/**
* Taler uses ECDHE for contract encryption.
*/
struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_pub;
};
/**
* @brief Type of private keys used for contract
* encryption.
*/
struct TALER_ContractDiffiePrivateP
{
/**
* Taler uses ECDHE for contract encryption.
*/
struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_priv;
};
/**
* @brief Type of online public keys used by the exchange to sign
* messages.
*/
struct TALER_ExchangePublicKeyP
{
/**
* Taler uses EdDSA for online exchange message signing.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of online public keys used by the exchange to
* sign messages.
*/
struct TALER_ExchangePrivateKeyP
{
/**
* Taler uses EdDSA for online signatures sessions.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures used by the exchange to sign messages online.
*/
struct TALER_ExchangeSignatureP
{
/**
* Taler uses EdDSA for online signatures sessions.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* @brief Type of the offline master public key used by the exchange.
*/
struct TALER_MasterPublicKeyP
{
/**
* Taler uses EdDSA for the long-term offline master key.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of the offline master public keys used by the exchange.
*/
struct TALER_MasterPrivateKeyP
{
/**
* Taler uses EdDSA for the long-term offline master key.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures by the offline master public key used by the exchange.
*/
struct TALER_MasterSignatureP
{
/**
* Taler uses EdDSA for the long-term offline master key.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* @brief Type of the private key used by the auditor.
*/
struct TALER_AuditorPrivateKeyP
{
/**
* Taler uses EdDSA for the auditor's signing key.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of the public key used by the auditor.
*/
struct TALER_AuditorPublicKeyP
{
/**
* Taler uses EdDSA for the auditor's signing key.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of signatures used by the auditor.
*/
struct TALER_AuditorSignatureP
{
/**
* Taler uses EdDSA signatures for auditors.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_sig;
};
/**
* @brief Type of public keys for Taler coins. The same key material is used
* for EdDSA and ECDHE operations.
*/
struct TALER_CoinSpendPublicKeyP
{
/**
* Taler uses EdDSA for coins when signing deposit requests.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of private keys for Taler coins. The same key material is used
* for EdDSA and ECDHE operations.
*/
struct TALER_CoinSpendPrivateKeyP
{
/**
* Taler uses EdDSA for coins when signing deposit requests.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures made with Taler coins.
*/
struct TALER_CoinSpendSignatureP
{
/**
* Taler uses EdDSA for coins.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* @brief Type of private keys for age commitment in coins.
*/
struct TALER_AgeCommitmentPrivateKeyP
{
#ifdef AGE_RESTRICTION_WITH_ECDSA
/**
* Taler uses EcDSA for coins when signing age verification attestation.
*/
struct GNUNET_CRYPTO_EcdsaPrivateKey priv;
#else
/**
* Taler uses Edx25519 for coins when signing age verification attestation.
*/
struct GNUNET_CRYPTO_Edx25519PrivateKey priv;
#endif
};
/**
* @brief Type of public keys for age commitment in coins.
*/
struct TALER_AgeCommitmentPublicKeyP
{
#ifdef AGE_RESTRICTION_WITH_ECDSA
/**
* Taler uses EcDSA for coins when signing age verification attestation.
*/
struct GNUNET_CRYPTO_EcdsaPublicKey pub;
#else
/**
* Taler uses Edx25519 for coins when signing age verification attestation.
*/
struct GNUNET_CRYPTO_Edx25519PublicKey pub;
#endif
};
/*
* @brief Hash to represent the commitment to n*kappa blinded keys during a
* age-withdrawal. It is the running SHA512 hash over the hashes of the blinded
* envelopes of n*kappa coins.
*/
struct TALER_AgeWithdrawCommitmentHashP
{
struct GNUNET_HashCode hash;
};
/**
* @brief Type of online public keys used by the wallet to establish a purse and the associated contract meta data.
*/
struct TALER_PurseContractPublicKeyP
{
/**
* Taler uses EdDSA for purse message signing.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of online private keys used by the wallet to
* bind a purse to a particular contract (and other meta data).
*/
struct TALER_PurseContractPrivateKeyP
{
/**
* Taler uses EdDSA for online signatures sessions.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures used by the wallet to sign purse creation messages online.
*/
struct TALER_PurseContractSignatureP
{
/**
* Taler uses EdDSA for online signatures sessions.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* @brief Type of online public keys used by the wallet to
* sign a merge of a purse into an account.
*/
struct TALER_PurseMergePublicKeyP
{
/**
* Taler uses EdDSA for purse message signing.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of online private keys used by the wallet to
* sign a merge of a purse into an account.
*/
struct TALER_PurseMergePrivateKeyP
{
/**
* Taler uses EdDSA for online signatures sessions.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures used by the wallet to sign purse merge requests online.
*/
struct TALER_PurseMergeSignatureP
{
/**
* Taler uses EdDSA for online signatures sessions.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* @brief Type of online public keys used by AML officers.
*/
struct TALER_AmlOfficerPublicKeyP
{
/**
* Taler uses EdDSA for AML decision signing.
*/
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
};
/**
* @brief Type of online private keys used to identify
* AML officers.
*/
struct TALER_AmlOfficerPrivateKeyP
{
/**
* Taler uses EdDSA for AML decision signing.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
};
/**
* @brief Type of signatures used by AML officers.
*/
struct TALER_AmlOfficerSignatureP
{
/**
* Taler uses EdDSA for AML decision signing.
*/
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
/**
* Possible AML decision states.
*/
enum TALER_AmlDecisionState
{
/**
* All AML requirements are currently satisfied.
*/
TALER_AML_NORMAL = 0,
/**
* An AML investigation is pending.
*/
TALER_AML_PENDING = 1,
/**
* An AML decision has concluded that the funds must be frozen.
*/
TALER_AML_FROZEN = 2
};
/**
* Possible algorithms for confirmation code generation.
*/
enum TALER_MerchantConfirmationAlgorithm
{
/**
* No purchase confirmation.
*/
TALER_MCA_NONE = 0,
/**
* Purchase confirmation without payment
*/
TALER_MCA_WITHOUT_PRICE = 1,
/**
* Purchase confirmation with payment
*/
TALER_MCA_WITH_PRICE = 2
};
/**
* @brief Type of blinding keys for Taler.
* must be 32 bytes (DB)
*/
union TALER_DenominationBlindingKeyP
{
/**
* Clause Schnorr Signatures have 2 blinding secrets, each containing two unpredictable values. (must be 32 bytes)
*/
struct GNUNET_CRYPTO_CsNonce nonce;
/**
* Taler uses RSA for blind signatures.
*/
struct GNUNET_CRYPTO_RsaBlindingKeySecret rsa_bks;
};
/**
* Commitment value for the refresh protocol.
* See #TALER_refresh_get_commitment().
*/
struct TALER_RefreshCommitmentP
{
/**
* The commitment is a hash code.
*/
struct GNUNET_HashCode session_hash;
};
/**
* Symmetric key we use to encrypt KYC attributes
* in our database.
*/
struct TALER_AttributeEncryptionKeyP
{
/**
* The key is a hash code.
*/
struct GNUNET_HashCode hash;
};
/**
* Token used for access control to the merchant's unclaimed
* orders.
*/
struct TALER_ClaimTokenP
{
/**
* The token is a 128-bit UUID.
*/
struct GNUNET_Uuid token;
};
/**
* Salt used to hash a merchant's payto:// URI to
* compute the "h_wire" (say for deposit requests).
*/
struct TALER_WireSaltP
{
/**
* Actual 128-bit salt value.
*/
uint32_t salt[4];
};
/**
* Hash used to represent an CS public key. Does not include age
* restrictions and is ONLY for CS. Used ONLY for interactions with the CS
* security module.
*/
struct TALER_CsPubHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Hash used to represent an RSA public key. Does not include age
* restrictions and is ONLY for RSA. Used ONLY for interactions with the RSA
* security module.
*/
struct TALER_RsaPubHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Master key material for the deriviation of
* private coins and blinding factors during
* withdraw or refresh.
*/
struct TALER_PlanchetMasterSecretP
{
/**
* Key material.
*/
uint32_t key_data[8];
};
/**
* Master key material for the deriviation of
* private coins and blinding factors.
*/
struct TALER_RefreshMasterSecretP
{
/**
* Key material.
*/
uint32_t key_data[8];
};
/**
* Hash used to represent a denomination public key
* and associated age restrictions (if any).
*/
struct TALER_DenominationHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Hash used to represent the private part
* of a contract between merchant and consumer.
*/
struct TALER_PrivateContractHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Hash used to represent the policy extension to a deposit
*/
struct TALER_ExtensionPolicyHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Hash used to represent the salted hash of a
* merchant's bank account.
*/
struct TALER_MerchantWireHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Hash used to represent the unsalted hash of a
* payto:// URI representing a bank account.
*/
struct TALER_PaytoHashP
{
/**
* Actual hash value.
*/
struct GNUNET_ShortHashCode hash;
};
/**
* Hash used to represent a commitment to a blinded
* coin, i.e. the hash of the envelope.
*/
struct TALER_BlindedCoinHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Hash used to represent the hash of the public
* key of a coin (without blinding).
*/
struct TALER_CoinPubHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* @brief Value that uniquely identifies a reward.
*/
struct TALER_RewardIdentifierP
{
/**
* The tip identifier is a SHA-512 hash code.
*/
struct GNUNET_HashCode hash;
};
/**
* @brief Value that uniquely identifies a tip pick up operation.
*/
struct TALER_PickupIdentifierP
{
/**
* The pickup identifier is a SHA-512 hash code.
*/
struct GNUNET_HashCode hash;
};
/**
* @brief Salted hash over the JSON object representing the manifests of
* extensions.
*/
struct TALER_ExtensionManifestsHashP
{
/**
* Actual hash value.
*/
struct GNUNET_HashCode hash;
};
/**
* Set of the fees applying to a denomination.
*/
struct TALER_DenomFeeSetNBOP
{
/**
* The fee the exchange charges when a coin of this type is withdrawn.
* (can be zero).
*/
struct TALER_AmountNBO withdraw;
/**
* The fee the exchange charges when a coin of this type is deposited.
* (can be zero).
*/
struct TALER_AmountNBO deposit;
/**
* The fee the exchange charges when a coin of this type is refreshed.
* (can be zero).
*/
struct TALER_AmountNBO refresh;
/**
* The fee the exchange charges when a coin of this type is refunded.
* (can be zero). Note that refund fees are charged to the customer;
* if a refund is given, the deposit fee is also refunded.
*/
struct TALER_AmountNBO refund;
};
/**
* Set of the fees applying for a given
* time-range and wire method.
*/
struct TALER_WireFeeSetNBOP
{
/**
* The fee the exchange charges for wiring funds
* to a merchant.
*/
struct TALER_AmountNBO wire;
/**
* The fee the exchange charges for closing a reserve
* and wiring the funds back to the origin account.
*/
struct TALER_AmountNBO closing;
};
/**
* Set of the fees applying globally for a given
* time-range.
*/
struct TALER_GlobalFeeSetNBOP
{
/**
* The fee the exchange charges for returning the history of a reserve or
* account.
*/
struct TALER_AmountNBO history;
/**
* The fee the exchange charges for keeping an account or reserve open for a
* year.
*/
struct TALER_AmountNBO account;
/**
* The fee the exchange charges if a purse is abandoned and this was not
* covered by the account limit.
*/
struct TALER_AmountNBO purse;
};
GNUNET_NETWORK_STRUCT_END
/**
* @brief Builds POS confirmation token to verify payment.
*
* @param pos_key encoded key for verification payment
* @param pos_alg algorithm to compute the payment verification
* @param total of the order paid
* @param ts is the time given
* @return POS token on success, NULL otherwise
*/
char *
TALER_build_pos_confirmation (const char *pos_key,
enum TALER_MerchantConfirmationAlgorithm pos_alg,
const struct TALER_Amount *total,
struct GNUNET_TIME_Timestamp ts);
/**
* Set of the fees applying to a denomination.
*/
struct TALER_DenomFeeSet
{
/**
* The fee the exchange charges when a coin of this type is withdrawn.
* (can be zero).
*/
struct TALER_Amount withdraw;
/**
* The fee the exchange charges when a coin of this type is deposited.
* (can be zero).
*/
struct TALER_Amount deposit;
/**
* The fee the exchange charges when a coin of this type is refreshed.
* (can be zero).
*/
struct TALER_Amount refresh;
/**
* The fee the exchange charges when a coin of this type is refunded.
* (can be zero). Note that refund fees are charged to the customer;
* if a refund is given, the deposit fee is also refunded.
*/
struct TALER_Amount refund;
};
/**
* Set of the fees applying for a given time-range and wire method.
*/
struct TALER_WireFeeSet
{
/**
* The fee the exchange charges for wiring funds to a merchant.
*/
struct TALER_Amount wire;
/**
* The fee the exchange charges for closing a reserve
* and wiring the funds back to the origin account.
*/
struct TALER_Amount closing;
};
/**
* Set of the fees applying globally for a given
* time-range.
*/
struct TALER_GlobalFeeSet
{
/**
* The fee the exchange charges for returning the
* history of a reserve or account.
*/
struct TALER_Amount history;
/**
* The fee the exchange charges for keeping
* an account or reserve open for a year.
*/
struct TALER_Amount account;
/**
* The fee the exchange charges if a purse
* is abandoned and this was not covered by
* the account limit.
*/
struct TALER_Amount purse;
};
/**
* Convert fee set from host to network byte order.
*
* @param[out] nbo where to write the result
* @param fees fee set to convert
*/
void
TALER_denom_fee_set_hton (struct TALER_DenomFeeSetNBOP *nbo,
const struct TALER_DenomFeeSet *fees);
/**
* Convert fee set from network to host network byte order.
*
* @param[out] fees where to write the result
* @param nbo fee set to convert
*/
void
TALER_denom_fee_set_ntoh (struct TALER_DenomFeeSet *fees,
const struct TALER_DenomFeeSetNBOP *nbo);
/**
* Convert global fee set from host to network byte order.
*
* @param[out] nbo where to write the result
* @param fees fee set to convert
*/
void
TALER_global_fee_set_hton (struct TALER_GlobalFeeSetNBOP *nbo,
const struct TALER_GlobalFeeSet *fees);
/**
* Convert global fee set from network to host network byte order.
*
* @param[out] fees where to write the result
* @param nbo fee set to convert
*/
void
TALER_global_fee_set_ntoh (struct TALER_GlobalFeeSet *fees,
const struct TALER_GlobalFeeSetNBOP *nbo);
/**
* Compare global fee sets.
*
* @param f1 first set to compare
* @param f2 second set to compare
* @return 0 if sets are equal
*/
int
TALER_global_fee_set_cmp (const struct TALER_GlobalFeeSet *f1,
const struct TALER_GlobalFeeSet *f2);
/**
* Convert wire fee set from host to network byte order.
*
* @param[out] nbo where to write the result
* @param fees fee set to convert
*/
void
TALER_wire_fee_set_hton (struct TALER_WireFeeSetNBOP *nbo,
const struct TALER_WireFeeSet *fees);
/**
* Convert wire fee set from network to host network byte order.
*
* @param[out] fees where to write the result
* @param nbo fee set to convert
*/
void
TALER_wire_fee_set_ntoh (struct TALER_WireFeeSet *fees,
const struct TALER_WireFeeSetNBOP *nbo);
/**
* Compare wire fee sets.
*
* @param f1 first set to compare
* @param f2 second set to compare
* @return 0 if sets are equal
*/
int
TALER_wire_fee_set_cmp (const struct TALER_WireFeeSet *f1,
const struct TALER_WireFeeSet *f2);
/**
* Hash @a rsa.
*
* @param rsa key to hash
* @param[out] h_rsa where to write the result
*/
void
TALER_rsa_pub_hash (const struct GNUNET_CRYPTO_RsaPublicKey *rsa,
struct TALER_RsaPubHashP *h_rsa);
/**
* Hash @a cs.
*
* @param cs key to hash
* @param[out] h_cs where to write the result
*/
void
TALER_cs_pub_hash (const struct GNUNET_CRYPTO_CsPublicKey *cs,
struct TALER_CsPubHashP *h_cs);
/**
* Types of public keys used for denominations in Taler.
* FIXME: rename to BlindCipher
*/
enum TALER_DenominationCipher
{
/**
* Invalid type of signature.
*/
TALER_DENOMINATION_INVALID = 0,
/**
* RSA blind signature.
*/
TALER_DENOMINATION_RSA = 1,
/**
* Clause Blind Schnorr signature.
*/
TALER_DENOMINATION_CS = 2
};
/**
* @brief Type of (unblinded) coin signatures for Taler.
* FIXME: rename to BlindSignature
*/
struct TALER_DenominationSignature
{
/**
* Type of the signature.
*/
enum TALER_DenominationCipher cipher;
/**
* Details, depending on @e cipher.
*/
union
{
/**
* If we use #TALER_DENOMINATION_CS in @a cipher.
*/
struct GNUNET_CRYPTO_CsSignature cs_signature;
/**
* If we use #TALER_DENOMINATION_RSA in @a cipher.
*/
struct GNUNET_CRYPTO_RsaSignature *rsa_signature;
} details;
};
/**
* The Sign Answer for Clause Blind Schnorr signature.
* The sign operation returns a parameter @param b and the signature
* scalar @param s_scalar.
*/
struct TALER_BlindedDenominationCsSignAnswer
{
/**
* To make ROS problem harder, the signer chooses an unpredictable b and only calculates signature of c_b
*/
unsigned int b;
/**
* The blinded s scalar calculated from c_b
*/
struct GNUNET_CRYPTO_CsBlindS s_scalar;
};
/**
* @brief Type for *blinded* denomination signatures for Taler.
* Must be unblinded before it becomes valid.
* FIXME: rename to BlindedSignature
*/
struct TALER_BlindedDenominationSignature
{
/**
* Type of the signature.
*/
enum TALER_DenominationCipher cipher;
/**
* Details, depending on @e cipher.
*/
union
{
/**
* If we use #TALER_DENOMINATION_CS in @a cipher.
* At this point only the blinded s scalar is used.
* The final signature consisting of r,s is built after unblinding.
*/
struct TALER_BlindedDenominationCsSignAnswer blinded_cs_answer;
/**
* If we use #TALER_DENOMINATION_RSA in @a cipher.
*/
struct GNUNET_CRYPTO_RsaSignature *blinded_rsa_signature;
} details;
};
/* *************** Age Restriction *********************************** */
/*
* @brief Type of a list of age groups, represented as bit mask.
*
* The bits set in the mask mark the edges at the beginning of a next age
* group. F.e. for the age groups
* 0-7, 8-9, 10-11, 12-13, 14-15, 16-17, 18-21, 21-*
* the following bits are set:
*
* 31 24 16 8 0
* | | | | |
* oooooooo oo1oo1o1 o1o1o1o1 ooooooo1
*
* A value of 0 means that the exchange does not support the extension for
* age-restriction.
*
* For a non-0 age mask, the 0th bit always must be set, otherwise the age
* mask is considered invalid.
*/
struct TALER_AgeMask
{
uint32_t bits;
};
/**
* @brief Age commitment of a coin.
*/
struct TALER_AgeCommitmentHash
{
/**
* The commitment is a SHA-256 hash code.
*/
struct GNUNET_ShortHashCode shash;
};
/**
* @brief Signature of an age with the private key for the corresponding age group of an age commitment.
*/
struct TALER_AgeAttestation
{
#ifdef AGE_RESTRICTION_WITH_ECDSA
struct GNUNET_CRYPTO_EcdsaSignature signature;
#else
struct GNUNET_CRYPTO_Edx25519Signature signature;
#endif
};
#define TALER_AgeCommitmentHash_isNullOrZero(ph) ((NULL == ph) || \
GNUNET_is_zero (ph))
/**
* @brief Type of public signing keys for verifying blindly signed coins.
* FIXME: rename to BlindPublicKey
*/
struct TALER_DenominationPublicKey
{
/**
* Type of the public key.
*/
enum TALER_DenominationCipher cipher;
/**
* Age restriction mask used for the key.
*/
struct TALER_AgeMask age_mask;
/**
* Details, depending on @e cipher.
*/
union
{
/**
* If we use #TALER_DENOMINATION_CS in @a cipher.
*/
struct GNUNET_CRYPTO_CsPublicKey cs_public_key;
/**
* If we use #TALER_DENOMINATION_RSA in @a cipher.
*/
struct GNUNET_CRYPTO_RsaPublicKey *rsa_public_key;
} details;
};
/**
* @brief Type of private signing keys for blind signing of coins.
* FIXME: rename to BlindPrivateKey
*/
struct TALER_DenominationPrivateKey
{
/**
* Type of the public key.
*/
enum TALER_DenominationCipher cipher;
/**
* Details, depending on @e cipher.
*/
union
{
/**
* If we use #TALER_DENOMINATION_CS in @a cipher.
*/
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key;
/**
* If we use #TALER_DENOMINATION_RSA in @a cipher.
*/
struct GNUNET_CRYPTO_RsaPrivateKey *rsa_private_key;
} details;
};
/**
* @brief RSA Parameters to create blinded signature
*
* FIXME: rename to BlindedMessage or so???
*/
struct TALER_BlindedRsaPlanchet
{
/**
* Blinded message to be signed
* Note: is malloc()'ed!
*/
void *blinded_msg;
/**
* Size of the @e blinded_msg to be signed.
*/
size_t blinded_msg_size;
};
/**
* Withdraw nonce for CS denominations
*/
struct TALER_CsNonce
{
/**
* 32 bit nonce to include in withdrawals when using CS.
*/
struct GNUNET_CRYPTO_CsNonce nonce;
};
/**
* @brief CS Parameters to create blinded signature
*/
struct TALER_BlindedCsPlanchet
{
/**
* The Clause Schnorr c_0 and c_1 containing the blinded message
*/
struct GNUNET_CRYPTO_CsC c[2];
/**
* Public nonce.
*/
struct TALER_CsNonce nonce;
};
/**
* @brief Type including Parameters to create blinded signature
* FIXME: rename to BlindedXXX
*/
struct TALER_BlindedPlanchet
{
/**
* Type of the sign blinded message
*/
enum TALER_DenominationCipher cipher;
/**
* Details, depending on @e cipher.
*/
union
{
/**
* If we use #TALER_DENOMINATION_CS in @a cipher.
*/
struct TALER_BlindedCsPlanchet cs_blinded_planchet;
/**
* If we use #TALER_DENOMINATION_RSA in @a cipher.
*/
struct TALER_BlindedRsaPlanchet rsa_blinded_planchet;
} details;
};
/**
* Pair of Public R values for Cs denominations
*/
struct TALER_DenominationCSPublicRPairP
{
struct GNUNET_CRYPTO_CsRPublic r_pub[2];
};
/**
* Secret r for Cs denominations
*/
struct TALER_DenominationCSPrivateRPairP
{
struct GNUNET_CRYPTO_CsRSecret r[2];
};
/**
* @brief Public information about a coin (including the public key
* of the coin, the denomination key and the signature with
* the denomination key).
*/
struct TALER_CoinPublicInfo
{
/**
* The coin's public key.
*/
struct TALER_CoinSpendPublicKeyP coin_pub;
/**
* Hash of the public key representing the denomination of the coin that is
* being deposited.
*/
struct TALER_DenominationHashP denom_pub_hash;
/**
* Hash of the age commitment. If no age commitment was provided, it must be
* set to all zeroes.
*/
struct TALER_AgeCommitmentHash h_age_commitment;
/**
* True, if age commitment is not applicable.
*/
bool no_age_commitment;
/**
* (Unblinded) signature over @e coin_pub with @e denom_pub,
* which demonstrates that the coin is valid.
*/
struct TALER_DenominationSignature denom_sig;
};
/**
* Details for one of the /deposit operations that the
* exchange combined into a single wire transfer.
*/
struct TALER_TrackTransferDetails
{
/**
* Hash of the proposal data.
*/
struct TALER_PrivateContractHashP h_contract_terms;
/**
* Which coin was deposited?
*/
struct TALER_CoinSpendPublicKeyP coin_pub;
/**
* Value of the deposit (including fee).
*/
struct TALER_Amount coin_value;
/**
* Fee charged by the exchange for the deposit.
*/
struct TALER_Amount coin_fee;
};
/**
* @brief Type of algorithm specific Values for withdrawal
* FIXME: rename to BlindedInputValues or so???
*/
struct TALER_ExchangeWithdrawValues
{
/**
* Type of the signature.
*/
enum TALER_DenominationCipher cipher;
/**
* Details, depending on @e cipher.
*/
union
{
/**
* If we use #TALER_DENOMINATION_CS in @a cipher.
*/
struct TALER_DenominationCSPublicRPairP cs_values;
} details;
};
/**
* Free internals of @a denom_pub, but not @a denom_pub itself.
*
* @param[in] denom_pub key to free
*/
void
TALER_denom_pub_free (struct TALER_DenominationPublicKey *denom_pub);
/**
* Create private key for a Taler coin.
* @param ps planchet secret to derive coin priv key
* @param alg_values includes algorithm specific values
* @param[out] coin_priv private key to initialize
*/
void
TALER_planchet_setup_coin_priv (
const struct TALER_PlanchetMasterSecretP *ps,
const struct TALER_ExchangeWithdrawValues *alg_values,
struct TALER_CoinSpendPrivateKeyP *coin_priv);
/**
* @brief Method to derive withdraw /csr nonce
*
* @param ps planchet secrets of the coin
* @param[out] nonce withdraw nonce included in the request to generate R_0 and R_1
*/
void
TALER_cs_withdraw_nonce_derive (
const struct TALER_PlanchetMasterSecretP *ps,
struct TALER_CsNonce *nonce);
/**
* @brief Method to derive /csr nonce
* to be used during refresh/melt operation.
*
* @param rms secret input for the refresh operation
* @param idx index of the fresh coin
* @param[out] nonce set to nonce included in the request to generate R_0 and R_1
*/
void
TALER_cs_refresh_nonce_derive (
const struct TALER_RefreshMasterSecretP *rms,
uint32_t idx,
struct TALER_CsNonce *nonce);
/**
* Initialize denomination public-private key pair.
*
* For #TALER_DENOMINATION_RSA, an additional "unsigned int"
* argument with the number of bits for 'n' (e.g. 2048) must
* be passed.
*
* @param[out] denom_priv where to write the private key
* @param[out] denom_pub where to write the public key
* @param cipher which type of cipher to use
* @param ... RSA key size (eg. 2048/3072/4096)
* @return #GNUNET_OK on success, #GNUNET_NO if parameters were invalid
*/
enum GNUNET_GenericReturnValue
TALER_denom_priv_create (struct TALER_DenominationPrivateKey *denom_priv,
struct TALER_DenominationPublicKey *denom_pub,
enum TALER_DenominationCipher cipher,
...);
/**
* Free internals of @a denom_priv, but not @a denom_priv itself.
*
* @param[in] denom_priv key to free
*/
void
TALER_denom_priv_free (struct TALER_DenominationPrivateKey *denom_priv);
/**
* Free internals of @a denom_sig, but not @a denom_sig itself.
*
* @param[in] denom_sig signature to free
*/
void
TALER_denom_sig_free (struct TALER_DenominationSignature *denom_sig);
/**
* Blind coin for blind signing with @a dk using blinding secret @a coin_bks.
*
* NOTE: As a particular oddity, the @a blinded_planchet is only partially
* initialized by this function in the case of CS-denominations. Here, the
* 'nonce' must be initialized separately!
*
* @param dk denomination public key to blind for
* @param coin_bks blinding secret to use
* @param age_commitment_hash hash of the age commitment to be used for the coin. NULL if no commitment is made.
* @param coin_pub public key of the coin to blind
* @param alg_values algorithm specific values to blind the planchet
* @param[out] c_hash resulting hashed coin
* @param[out] blinded_planchet planchet data to initialize
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
const union TALER_DenominationBlindingKeyP *coin_bks,
const struct TALER_AgeCommitmentHash *age_commitment_hash,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_ExchangeWithdrawValues *alg_values,
struct TALER_CoinPubHashP *c_hash,
struct TALER_BlindedPlanchet *blinded_planchet);
/**
* Create blinded signature.
*
* @param[out] denom_sig where to write the signature
* @param denom_priv private key to use for signing
* @param for_melt true to use the HKDF for melt
* @param blinded_planchet the planchet already blinded
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig,
const struct TALER_DenominationPrivateKey *denom_priv,
bool for_melt,
const struct TALER_BlindedPlanchet *blinded_planchet);
/**
* Unblind blinded signature.
*
* @param[out] denom_sig where to write the unblinded signature
* @param bdenom_sig the blinded signature
* @param bks blinding secret to use
* @param c_hash hash of the coin's public key for verification of the signature
* @param alg_values algorithm specific values
* @param denom_pub public key used for signing
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
TALER_denom_sig_unblind (
struct TALER_DenominationSignature *denom_sig,
const struct TALER_BlindedDenominationSignature *bdenom_sig,
const union TALER_DenominationBlindingKeyP *bks,
const struct TALER_CoinPubHashP *c_hash,
const struct TALER_ExchangeWithdrawValues *alg_values,
const struct TALER_DenominationPublicKey *denom_pub);
/**
* Free internals of @a denom_sig, but not @a denom_sig itself.
*
* @param[in] denom_sig signature to free
*/
void
TALER_blinded_denom_sig_free (
struct TALER_BlindedDenominationSignature *denom_sig);
/**
* Compute the hash of the given @a denom_pub.
*
* @param denom_pub public key to hash
* @param[out] denom_hash resulting hash value
*/
void
TALER_denom_pub_hash (const struct TALER_DenominationPublicKey *denom_pub,
struct TALER_DenominationHashP *denom_hash);
/**
* Make a (deep) copy of the given @a denom_src to
* @a denom_dst.
*
* @param[out] denom_dst target to copy to
* @param denom_src public key to copy
*/
void
TALER_denom_pub_deep_copy (struct TALER_DenominationPublicKey *denom_dst,
const struct TALER_DenominationPublicKey *denom_src);
/**
* Make a (deep) copy of the given @a denom_src to
* @a denom_dst.
*
* @param[out] denom_dst target to copy to
* @param denom_src public key to copy
*/
void
TALER_denom_sig_deep_copy (struct TALER_DenominationSignature *denom_dst,
const struct TALER_DenominationSignature *denom_src);
/**
* Make a (deep) copy of the given @a denom_src to
* @a denom_dst.
*
* @param[out] denom_dst target to copy to
* @param denom_src public key to copy
*/
void
TALER_blinded_denom_sig_deep_copy (
struct TALER_BlindedDenominationSignature *denom_dst,
const struct TALER_BlindedDenominationSignature *denom_src);
/**
* Compare two denomination public keys.
*
* @param denom1 first key
* @param denom2 second key
* @return 0 if the keys are equal, otherwise -1 or 1
*/
int
TALER_denom_pub_cmp (const struct TALER_DenominationPublicKey *denom1,
const struct TALER_DenominationPublicKey *denom2);
/**
* Compare two denomination signatures.
*
* @param sig1 first signature
* @param sig2 second signature
* @return 0 if the keys are equal, otherwise -1 or 1
*/
int
TALER_denom_sig_cmp (const struct TALER_DenominationSignature *sig1,
const struct TALER_DenominationSignature *sig2);
/**
* Compare two blinded denomination signatures.
*
* @param sig1 first signature
* @param sig2 second signature
* @return 0 if the keys are equal, otherwise -1 or 1
*/
int
TALER_blinded_denom_sig_cmp (
const struct TALER_BlindedDenominationSignature *sig1,
const struct TALER_BlindedDenominationSignature *sig2);
/**
* Compare two blinded planchets.
*
* @param bp1 first blinded planchet
* @param bp2 second blinded planchet
* @return 0 if the keys are equal, otherwise -1 or 1
*/
int
TALER_blinded_planchet_cmp (
const struct TALER_BlindedPlanchet *bp1,
const struct TALER_BlindedPlanchet *bp2);
/**
* Obtain denomination public key from a denomination private key.
*
* @param denom_priv private key to convert
* @param age_mask age mask to be applied
* @param[out] denom_pub where to return the public key
*/
void
TALER_denom_priv_to_pub (const struct TALER_DenominationPrivateKey *denom_priv,
const struct TALER_AgeMask age_mask,
struct TALER_DenominationPublicKey *denom_pub);
/**
* Verify signature made with a denomination public key
* over a coin.
*
* @param denom_pub public denomination key
* @param denom_sig signature made with the private key
* @param c_hash hash over the coin
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_denom_pub_verify (const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_DenominationSignature *denom_sig,
const struct TALER_CoinPubHashP *c_hash);
/**
* Encrypts KYC attributes for storage in the database.
*
* @param key encryption key to use
* @param attr set of attributes to encrypt
* @param[out] enc_attr encrypted attribute data
* @param[out] enc_attr_size number of bytes in @a enc_attr
*/
void
TALER_CRYPTO_kyc_attributes_encrypt (
const struct TALER_AttributeEncryptionKeyP *key,
const json_t *attr,
void **enc_attr,
size_t *enc_attr_size);
/**
* Encrypts KYC attributes for storage in the database.
*
* @param key encryption key to use
* @param enc_attr encrypted attribute data
* @param enc_attr_size number of bytes in @a enc_attr
* @return set of decrypted attributes, NULL on failure
*/
json_t *
TALER_CRYPTO_kyc_attributes_decrypt (
const struct TALER_AttributeEncryptionKeyP *key,
const void *enc_attr,
size_t enc_attr_size);
/**
* Takes a set of KYC attributes and extracts key
* data that we use to detect similar / duplicate
* entries in the database.
*
* @param attr set of KYC attributes
* @param[out] kyc_prox set to the proximity hash
*/
void
TALER_CRYPTO_attributes_to_kyc_prox (
const json_t *attr,
struct GNUNET_ShortHashCode *kyc_prox);
/**
* Check if a coin is valid; that is, whether the denomination key exists,
* is not expired, and the signature is correct.
*
* @param coin_public_info the coin public info to check for validity
* @param denom_pub denomination key, must match @a coin_public_info's `denom_pub_hash`
* @return #GNUNET_YES if the coin is valid,
* #GNUNET_NO if it is invalid
* #GNUNET_SYSERR if an internal error occurred
*/
enum GNUNET_GenericReturnValue
TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info,
const struct TALER_DenominationPublicKey *denom_pub);
/**
* Compute the hash of a blinded coin.
*
* @param blinded_planchet blinded planchet
* @param denom_hash hash of the denomination publick key
* @param[out] bch where to write the hash
* @return #GNUNET_OK when successful, #GNUNET_SYSERR if an internal error occurred
*/
enum GNUNET_GenericReturnValue
TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
const struct TALER_DenominationHashP *denom_hash,
struct TALER_BlindedCoinHashP *bch);
/**
* Compute the hash of a coin.
*
* @param coin_pub public key of the coin
* @param age_commitment_hash hash of the age commitment vector. NULL, if no age commitment was set
* @param[out] coin_h where to write the hash
*/
void
TALER_coin_pub_hash (const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_AgeCommitmentHash *age_commitment_hash,
struct TALER_CoinPubHashP *coin_h);
/**
* Compute the hash of a payto URI.
*
* @param payto URI to hash
* @param[out] h_payto where to write the hash
*/
void
TALER_payto_hash (const char *payto,
struct TALER_PaytoHashP *h_payto);
/**
* Details about a planchet that the customer wants to obtain
* a withdrawal authorization. This is the information that
* will need to be sent to the exchange to obtain the blind
* signature required to turn a planchet into a coin.
*/
struct TALER_PlanchetDetail
{
/**
* Hash of the denomination public key.
*/
struct TALER_DenominationHashP denom_pub_hash;
/**
* The blinded planchet
*/
struct TALER_BlindedPlanchet blinded_planchet;
};
/**
* Information about a (fresh) coin, returned from the API when we
* finished creating a coin. Note that @e sig needs to be freed
* using the appropriate code.
*/
struct TALER_FreshCoin
{
/**
* The exchange's signature over the coin's public key.
*/
struct TALER_DenominationSignature sig;
/**
* The coin's private key.
*/
struct TALER_CoinSpendPrivateKeyP coin_priv;
/**
* Optional hash of an age commitment bound to this coin, maybe NULL.
*/
const struct TALER_AgeCommitmentHash *h_age_commitment;
};
GNUNET_NETWORK_STRUCT_BEGIN
/**
* @brief Secret used to decrypt the key to decrypt link secrets.
*/
struct TALER_TransferSecretP
{
/**
* Secret used to derive private inputs for refreshed coins.
* Must be (currently) a hash as this is what
* GNUNET_CRYPTO_ecc_ecdh() returns to us.
*/
struct GNUNET_HashCode key;
};
/**
* Length of the raw value in the Taler wire transfer identifier
* (in binary representation).
*/
#define TALER_BANK_TRANSFER_IDENTIFIER_LEN 32
/**
* #TALER_BANK_TRANSFER_IDENTIFIER_LEN as a string.
*/
#define TALER_BANK_TRANSFER_IDENTIFIER_LEN_STR "32"
/**
* Raw value of a wire transfer subjects, without the checksum.
*/
struct TALER_WireTransferIdentifierRawP
{
/**
* Raw value. Note that typical payment systems (SEPA, ACH) support
* at least two lines of 27 ASCII characters to encode a transaction
* subject or "details", for a total of 54 characters. (The payment
* system protocols often support more lines, but the forms presented
* to customers are usually limited to 54 characters.)
*
* With a Base32-encoding of 5 bit per character, this gives us 270
* bits or (rounded down) 33 bytes. So we use the first 32 bytes to
* encode the actual value (i.e. a 256-bit / 32-byte public key or
* a hash code), and the last byte for a minimalistic checksum.
*/
uint8_t raw[TALER_BANK_TRANSFER_IDENTIFIER_LEN];
};
/**
* Raw value of a wire transfer subject for a wad.
*/
struct TALER_WadIdentifierP
{
/**
* Wad identifier, in binary encoding.
*/
uint8_t raw[24];
};
/**
* Binary information encoded in Crockford's Base32 in wire transfer
* subjects of transfers from Taler to a merchant. The actual value
* is chosen by the exchange and has no particular semantics, other than
* being unique so that the exchange can lookup details about the wire
* transfer when needed.
*/
struct TALER_WireTransferIdentifierP
{
/**
* Raw value.
*/
struct TALER_WireTransferIdentifierRawP raw;
/**
* Checksum using CRC8 over the @e raw data.
*/
uint8_t crc8;
};
GNUNET_NETWORK_STRUCT_END
/**
* Setup information for a fresh coin, deriving the coin planchet secrets from
* which we will later derive the private key and the blinding factor. The
* planchet secrets derivation is based on the @a secret_seed with a KDF
* salted by the @a coin_num_salt.
*
* @param secret_seed seed to use for KDF to derive coin keys
* @param coin_num_salt number of the coin to include in KDF
* @param[out] ps value to initialize
*/
void
TALER_transfer_secret_to_planchet_secret (
const struct TALER_TransferSecretP *secret_seed,
uint32_t coin_num_salt,
struct TALER_PlanchetMasterSecretP *ps);
/**
* Derive the @a coin_num transfer private key @a tpriv from a refresh from
* the @a rms seed and the @a old_coin_pub of the refresh operation. The
* transfer private key derivation is based on the @a ps with a KDF salted by
* the @a coin_num.
*
* @param rms seed to use for KDF to derive transfer keys
* @param old_coin_priv private key of the old coin
* @param cnc_num cut and choose number to include in KDF
* @param[out] tpriv value to initialize
*/
void
TALER_planchet_secret_to_transfer_priv (
const struct TALER_RefreshMasterSecretP *rms,
const struct TALER_CoinSpendPrivateKeyP *old_coin_priv,
uint32_t cnc_num,
struct TALER_TransferPrivateKeyP *tpriv);
/**
* Setup secret seed information for fresh coins to be
* withdrawn.
*
* @param[out] ps value to initialize
*/
void
TALER_planchet_master_setup_random (
struct TALER_PlanchetMasterSecretP *ps);
/**
* Setup secret seed for fresh coins to be refreshed.
*
* @param[out] rms value to initialize
*/
void
TALER_refresh_master_setup_random (
struct TALER_RefreshMasterSecretP *rms);
/**
* Create a blinding secret @a bks given the client's @a ps and the alg_values
* from the exchange.
*
* @param ps secret to derive blindings from
* @param alg_values withdraw values containing cipher and additional CS values
* @param[out] bks blinding secrets
*/
void
TALER_planchet_blinding_secret_create (
const struct TALER_PlanchetMasterSecretP *ps,
const struct TALER_ExchangeWithdrawValues *alg_values,
union TALER_DenominationBlindingKeyP *bks);
/**
* Prepare a planchet for withdrawal. Creates and blinds a coin.
*
* @param dk denomination key for the coin to be created
* @param alg_values algorithm specific values
* @param bks blinding secrets
* @param coin_priv coin private key
* @param ach hash of age commitment to bind to this coin, maybe NULL
* @param[out] c_hash set to the hash of the public key of the coin (needed later)
* @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup() and
* other withdraw operations, `pd->blinded_planchet.cipher` will be set
* to cipher from @a dk
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
const struct TALER_ExchangeWithdrawValues *alg_values,
const union TALER_DenominationBlindingKeyP *bks,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
const struct TALER_AgeCommitmentHash *ach,
struct TALER_CoinPubHashP *c_hash,
struct TALER_PlanchetDetail *pd);
/**
* Frees blinded message inside blinded planchet depending on `blinded_planchet->cipher`.
* Does not free the @a blinded_planchet itself!
*
* @param[in] blinded_planchet blinded planchet
*/
void
TALER_blinded_planchet_free (struct TALER_BlindedPlanchet *blinded_planchet);
/**
* Frees blinded message inside planchet detail @a pd.
*
* @param[in] pd planchet detail to free
*/
void
TALER_planchet_detail_free (struct TALER_PlanchetDetail *pd);
/**
* Obtain a coin from the planchet's secrets and the blind signature
* of the exchange.
*
* @param dk denomination key, must match what was given to #TALER_planchet_prepare()
* @param blind_sig blind signature from the exchange
* @param bks blinding key secret
* @param coin_priv private key of the coin
* @param ach hash of age commitment that is bound to this coin, maybe NULL
* @param c_hash hash of the coin's public key for verification of the signature
* @param alg_values values obtained from the exchange for the withdrawal
* @param[out] coin set to the details of the fresh coin
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
TALER_planchet_to_coin (
const struct TALER_DenominationPublicKey *dk,
const struct TALER_BlindedDenominationSignature *blind_sig,
const union TALER_DenominationBlindingKeyP *bks,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
const struct TALER_AgeCommitmentHash *ach,
const struct TALER_CoinPubHashP *c_hash,
const struct TALER_ExchangeWithdrawValues *alg_values,
struct TALER_FreshCoin *coin);
/**
* Add the hash of the @a bp (in some canonicalized form)
* to the @a hash_context.
*
* @param bp blinded planchet to hash
* @param[in,out] hash_context hash context to use
*/
void
TALER_blinded_planchet_hash_ (const struct TALER_BlindedPlanchet *bp,
struct GNUNET_HashContext *hash_context);
/**
* Given the coin and the transfer private keys, compute the
* transfer secret. (Technically, we only need one of the two
* private keys, but the caller currently trivially only has
* the two private keys, so we derive one of the public keys
* internally to this function.)
*
* @param coin_priv coin key
* @param trans_priv transfer private key
* @param[out] ts computed transfer secret
*/
void
TALER_link_derive_transfer_secret (
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
const struct TALER_TransferPrivateKeyP *trans_priv,
struct TALER_TransferSecretP *ts);
/**
* Decrypt the shared @a secret from the information in the
* @a trans_priv and @a coin_pub.
*
* @param trans_priv transfer private key
* @param coin_pub coin public key
* @param[out] transfer_secret set to the shared secret
*/
void
TALER_link_reveal_transfer_secret (
const struct TALER_TransferPrivateKeyP *trans_priv,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_TransferSecretP *transfer_secret);
/**
* Decrypt the shared @a secret from the information in the
* @a trans_priv and @a coin_pub.
*
* @param trans_pub transfer private key
* @param coin_priv coin public key
* @param[out] transfer_secret set to the shared secret
*/
void
TALER_link_recover_transfer_secret (
const struct TALER_TransferPublicKeyP *trans_pub,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_TransferSecretP *transfer_secret);
/**
* Information about a coin to be created during a refresh operation.
*/
struct TALER_RefreshCoinData
{
/**
* The denomination's public key.
*/
const struct TALER_DenominationPublicKey *dk;
/**
* The blinded planchet (details depend on cipher).
*/
struct TALER_BlindedPlanchet blinded_planchet;
};
/**
* One of the #TALER_CNC_KAPPA commitments.
*/
struct TALER_RefreshCommitmentEntry
{
/**
* Transfer public key of this commitment.
*/
struct TALER_TransferPublicKeyP transfer_pub;
/**
* Array of @e num_new_coins new coins to be created.
*/
struct TALER_RefreshCoinData *new_coins;
};
/**
* Compute the commitment for a /refresh/melt operation from
* the respective public inputs.
*
* @param[out] rc set to the value the wallet must commit to
* @param kappa number of transfer public keys involved (must be #TALER_CNC_KAPPA)
* @param rms refresh master secret to include, can be NULL!
* @param num_new_coins number of new coins to be created
* @param rcs array of @a kappa commitments
* @param coin_pub public key of the coin to be melted
* @param amount_with_fee amount to be melted, including fee
*/
void
TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
uint32_t kappa,
const struct TALER_RefreshMasterSecretP *rms,
uint32_t num_new_coins,
const struct TALER_RefreshCommitmentEntry *rcs,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee);
/**
* Encrypt contract for transmission to a party that will
* merge it into a reserve.
*
* @param purse_pub public key of the purse
* @param contract_priv private key of the contract
* @param merge_priv merge capability to include
* @param contract_terms contract terms to encrypt
* @param[out] econtract set to encrypted contract
* @param[out] econtract_size set to number of bytes in @a econtract
*/
void
TALER_CRYPTO_contract_encrypt_for_merge (
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_ContractDiffiePrivateP *contract_priv,
const struct TALER_PurseMergePrivateKeyP *merge_priv,
const json_t *contract_terms,
void **econtract,
size_t *econtract_size);
/**
* Decrypt contract for the party that will
* merge it into a reserve.
*
* @param purse_pub public key of the purse
* @param contract_priv private key of the contract
* @param econtract encrypted contract
* @param econtract_size number of bytes in @a econtract
* @param[out] merge_priv set to merge capability
* @return decrypted contract terms, or NULL on failure
*/
json_t *
TALER_CRYPTO_contract_decrypt_for_merge (
const struct TALER_ContractDiffiePrivateP *contract_priv,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const void *econtract,
size_t econtract_size,
struct TALER_PurseMergePrivateKeyP *merge_priv);
/**
* Encrypt contract for transmission to a party that will
* pay for it.
*
* @param purse_pub public key of the purse
* @param contract_priv private key of the contract
* @param contract_terms contract terms to encrypt
* @param[out] econtract set to encrypted contract
* @param[out] econtract_size set to number of bytes in @a econtract
*/
void
TALER_CRYPTO_contract_encrypt_for_deposit (
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_ContractDiffiePrivateP *contract_priv,
const json_t *contract_terms,
void **econtract,
size_t *econtract_size);
/**
* Decrypt contract for the party that will pay for it.
*
* @param contract_priv private key of the contract
* @param econtract encrypted contract
* @param econtract_size number of bytes in @a econtract
* @return decrypted contract terms, or NULL on failure
*/
json_t *
TALER_CRYPTO_contract_decrypt_for_deposit (
const struct TALER_ContractDiffiePrivateP *contract_priv,
const void *econtract,
size_t econtract_size);
/* **************** AML officer signatures **************** */
/**
* Sign AML query. Simple authentication, doesn't actually
* sign anything.
*
* @param officer_priv private key of AML officer
* @param[out] officer_sig where to write the signature
*/
void
TALER_officer_aml_query_sign (
const struct TALER_AmlOfficerPrivateKeyP *officer_priv,
struct TALER_AmlOfficerSignatureP *officer_sig);
/**
* Verify AML query authorization.
*
* @param officer_pub public key of AML officer
* @param officer_sig signature to verify
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_officer_aml_query_verify (
const struct TALER_AmlOfficerPublicKeyP *officer_pub,
const struct TALER_AmlOfficerSignatureP *officer_sig);
/**
* Sign AML decision.
*
* @param justification human-readable justification
* @param decision_time when was the decision made
* @param new_threshold at what monthly amount threshold
* should a revision be triggered
* @param h_payto payto URI hash of the account the
* decision is about
* @param new_state updated AML state
* @param kyc_requirements additional KYC requirements to
* impose, can be NULL
* @param officer_priv private key of AML officer
* @param[out] officer_sig where to write the signature
*/
void
TALER_officer_aml_decision_sign (
const char *justification,
struct GNUNET_TIME_Timestamp decision_time,
const struct TALER_Amount *new_threshold,
const struct TALER_PaytoHashP *h_payto,
enum TALER_AmlDecisionState new_state,
const json_t *kyc_requirements,
const struct TALER_AmlOfficerPrivateKeyP *officer_priv,
struct TALER_AmlOfficerSignatureP *officer_sig);
/**
* Verify AML decision.
*
* @param justification human-readable justification
* @param decision_time when was the decision made
* @param new_threshold at what monthly amount threshold
* should a revision be triggered
* @param h_payto payto URI hash of the account the
* decision is about
* @param new_state updated AML state
* @param kyc_requirements additional KYC requirements to
* impose, can be NULL
* @param officer_pub public key of AML officer
* @param officer_sig signature to verify
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_officer_aml_decision_verify (
const char *justification,
struct GNUNET_TIME_Timestamp decision_time,
const struct TALER_Amount *new_threshold,
const struct TALER_PaytoHashP *h_payto,
enum TALER_AmlDecisionState new_state,
const json_t *kyc_requirements,
const struct TALER_AmlOfficerPublicKeyP *officer_pub,
const struct TALER_AmlOfficerSignatureP *officer_sig);
/* **************** Helper-based RSA operations **************** */
/**
* Handle for talking to an Denomination key signing helper.
*/
struct TALER_CRYPTO_RsaDenominationHelper;
/**
* Function called with information about available keys for signing. Usually
* only called once per key upon connect. Also called again in case a key is
* being revoked, in that case with an @a end_time of zero.
*
* @param cls closure
* @param section_name name of the denomination type in the configuration;
* NULL if the key has been revoked or purged
* @param start_time when does the key become available for signing;
* zero if the key has been revoked or purged
* @param validity_duration how long does the key remain available for signing;
* zero if the key has been revoked or purged
* @param h_rsa hash of the RSA @a denom_pub that is available (or was purged)
* @param denom_pub the public key itself, NULL if the key was revoked or purged
* @param sm_pub public key of the security module, NULL if the key was revoked or purged
* @param sm_sig signature from the security module, NULL if the key was revoked or purged
* The signature was already verified against @a sm_pub.
*/
typedef void
(*TALER_CRYPTO_RsaDenominationKeyStatusCallback)(
void *cls,
const char *section_name,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Relative validity_duration,
const struct TALER_RsaPubHashP *h_rsa,
const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_SecurityModulePublicKeyP *sm_pub,
const struct TALER_SecurityModuleSignatureP *sm_sig);
/**
* Initiate connection to an denomination key helper.
*
* @param cfg configuration to use
* @param dkc function to call with key information
* @param dkc_cls closure for @a dkc
* @return NULL on error (such as bad @a cfg).
*/
struct TALER_CRYPTO_RsaDenominationHelper *
TALER_CRYPTO_helper_rsa_connect (
const struct GNUNET_CONFIGURATION_Handle *cfg,
TALER_CRYPTO_RsaDenominationKeyStatusCallback dkc,
void *dkc_cls);
/**
* Function to call to 'poll' for updates to the available key material.
* Should be called whenever it is important that the key material status is
* current, like when handling a "/keys" request. This function basically
* briefly checks if there are messages from the helper announcing changes to
* denomination keys.
*
* @param dh helper process connection
*/
void
TALER_CRYPTO_helper_rsa_poll (struct TALER_CRYPTO_RsaDenominationHelper *dh);
/**
* Information needed for an RSA signature request.
*/
struct TALER_CRYPTO_RsaSignRequest
{
/**
* Hash of the RSA public key.
*/
const struct TALER_RsaPubHashP *h_rsa;
/**
* Message to be (blindly) signed.
*/
const void *msg;
/**
* Number of bytes in @e msg.
*/
size_t msg_size;
};
/**
* Request helper @a dh to sign message in @a rsr using the public key
* corresponding to the key in @a rsr.
*
* This operation will block until the signature has been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* @param dh helper process connection
* @param rsr details about the requested signature
* @param[out] bs set to the blind signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_CRYPTO_helper_rsa_sign (
struct TALER_CRYPTO_RsaDenominationHelper *dh,
const struct TALER_CRYPTO_RsaSignRequest *rsr,
struct TALER_BlindedDenominationSignature *bs);
/**
* Request helper @a dh to batch sign messages in @a rsrs using the public key
* corresponding to the keys in @a rsrs.
*
* This operation will block until all the signatures have been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* Note that in case of errors, the @a bss array may still have been partially
* filled with signatures, which in this case must be freed by the caller
* (this is in contrast to the #TALER_CRYPTO_helper_rsa_sign() API which never
* returns any signatures if there was an error).
*
* @param dh helper process connection
* @param rsrs array with details about the requested signatures
* @param rsrs_length length of the @a rsrs array
* @param[out] bss array set to the blind signatures, must be of length @a rsrs_length!
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_CRYPTO_helper_rsa_batch_sign (
struct TALER_CRYPTO_RsaDenominationHelper *dh,
const struct TALER_CRYPTO_RsaSignRequest *rsrs,
unsigned int rsrs_length,
struct TALER_BlindedDenominationSignature *bss);
/**
* Ask the helper to revoke the public key associated with @a h_denom_pub.
* Will cause the helper to tell all clients that the key is now unavailable,
* and to create a replacement key.
*
* This operation will block until the revocation request has been
* transmitted. Should this process receive a signal (that is not ignored)
* while the operation is pending, the operation may fail. If the key is
* unknown, this function will also appear to have succeeded. To be sure that
* the revocation worked, clients must watch the denomination key status
* callback.
*
* @param dh helper to process connection
* @param h_rsa hash of the RSA public key to revoke
*/
void
TALER_CRYPTO_helper_rsa_revoke (
struct TALER_CRYPTO_RsaDenominationHelper *dh,
const struct TALER_RsaPubHashP *h_rsa);
/**
* Close connection to @a dh.
*
* @param[in] dh connection to close
*/
void
TALER_CRYPTO_helper_rsa_disconnect (
struct TALER_CRYPTO_RsaDenominationHelper *dh);
/* **************** Helper-based CS operations **************** */
/**
* Handle for talking to an Denomination key signing helper.
*/
struct TALER_CRYPTO_CsDenominationHelper;
/**
* Function called with information about available keys for signing. Usually
* only called once per key upon connect. Also called again in case a key is
* being revoked, in that case with an @a end_time of zero.
*
* @param cls closure
* @param section_name name of the denomination type in the configuration;
* NULL if the key has been revoked or purged
* @param start_time when does the key become available for signing;
* zero if the key has been revoked or purged
* @param validity_duration how long does the key remain available for signing;
* zero if the key has been revoked or purged
* @param h_cs hash of the CS @a denom_pub that is available (or was purged)
* @param denom_pub the public key itself, NULL if the key was revoked or purged
* @param sm_pub public key of the security module, NULL if the key was revoked or purged
* @param sm_sig signature from the security module, NULL if the key was revoked or purged
* The signature was already verified against @a sm_pub.
*/
typedef void
(*TALER_CRYPTO_CsDenominationKeyStatusCallback)(
void *cls,
const char *section_name,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Relative validity_duration,
const struct TALER_CsPubHashP *h_cs,
const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_SecurityModulePublicKeyP *sm_pub,
const struct TALER_SecurityModuleSignatureP *sm_sig);
/**
* Initiate connection to an denomination key helper.
*
* @param cfg configuration to use
* @param dkc function to call with key information
* @param dkc_cls closure for @a dkc
* @return NULL on error (such as bad @a cfg).
*/
struct TALER_CRYPTO_CsDenominationHelper *
TALER_CRYPTO_helper_cs_connect (
const struct GNUNET_CONFIGURATION_Handle *cfg,
TALER_CRYPTO_CsDenominationKeyStatusCallback dkc,
void *dkc_cls);
/**
* Function to call to 'poll' for updates to the available key material.
* Should be called whenever it is important that the key material status is
* current, like when handling a "/keys" request. This function basically
* briefly checks if there are messages from the helper announcing changes to
* denomination keys.
*
* @param dh helper process connection
*/
void
TALER_CRYPTO_helper_cs_poll (struct TALER_CRYPTO_CsDenominationHelper *dh);
/**
* Information about what we should sign over.
*/
struct TALER_CRYPTO_CsSignRequest
{
/**
* Hash of the CS public key to use to sign.
*/
const struct TALER_CsPubHashP *h_cs;
/**
* Blinded planchet containing c and the nonce.
*/
const struct TALER_BlindedCsPlanchet *blinded_planchet;
};
/**
* Request helper @a dh to sign @a req.
*
* This operation will block until the signature has been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* @param dh helper process connection
* @param req information about the key to sign with and the value to sign
* @param for_melt true if for melt operation
* @param[out] bs set to the blind signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_CRYPTO_helper_cs_sign (
struct TALER_CRYPTO_CsDenominationHelper *dh,
const struct TALER_CRYPTO_CsSignRequest *req,
bool for_melt,
struct TALER_BlindedDenominationSignature *bs);
/**
* Request helper @a dh to sign batch of @a reqs requests.
*
* This operation will block until the signature has been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* @param dh helper process connection
* @param reqs information about the keys to sign with and the values to sign
* @param reqs_length length of the @a reqs array
* @param for_melt true if this is for a melt operation
* @param[out] bss array set to the blind signatures, must be of length @a reqs_length!
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_CRYPTO_helper_cs_batch_sign (
struct TALER_CRYPTO_CsDenominationHelper *dh,
const struct TALER_CRYPTO_CsSignRequest *reqs,
unsigned int reqs_length,
bool for_melt,
struct TALER_BlindedDenominationSignature *bss);
/**
* Ask the helper to revoke the public key associated with @a h_cs.
* Will cause the helper to tell all clients that the key is now unavailable,
* and to create a replacement key.
*
* This operation will block until the revocation request has been
* transmitted. Should this process receive a signal (that is not ignored)
* while the operation is pending, the operation may fail. If the key is
* unknown, this function will also appear to have succeeded. To be sure that
* the revocation worked, clients must watch the denomination key status
* callback.
*
* @param dh helper to process connection
* @param h_cs hash of the CS public key to revoke
*/
void
TALER_CRYPTO_helper_cs_revoke (
struct TALER_CRYPTO_CsDenominationHelper *dh,
const struct TALER_CsPubHashP *h_cs);
/**
* Information about what we should derive for.
*/
struct TALER_CRYPTO_CsDeriveRequest
{
/**
* Hash of the CS public key to use to sign.
*/
const struct TALER_CsPubHashP *h_cs;
/**
* Nonce to use.
*/
const struct TALER_CsNonce *nonce;
};
/**
* Ask the helper to derive R using the information
* from @a cdr.
*
* This operation will block until the R has been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* @param dh helper to process connection
* @param cdr derivation input data
* @param for_melt true if this is for a melt operation
* @param[out] crp set to the pair of R values
* @return set to the error code (or #TALER_EC_NONE on success)
*/
enum TALER_ErrorCode
TALER_CRYPTO_helper_cs_r_derive (
struct TALER_CRYPTO_CsDenominationHelper *dh,
const struct TALER_CRYPTO_CsDeriveRequest *cdr,
bool for_melt,
struct TALER_DenominationCSPublicRPairP *crp);
/**
* Ask the helper to derive R using the information from @a cdrs.
*
* This operation will block until the R has been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* @param dh helper to process connection
* @param cdrs array with derivation input data
* @param cdrs_length length of the @a cdrs array
* @param for_melt true if this is for a melt operation
* @param[out] crps array set to the pair of R values, must be of length @a cdrs_length
* @return set to the error code (or #TALER_EC_NONE on success)
*/
enum TALER_ErrorCode
TALER_CRYPTO_helper_cs_r_batch_derive (
struct TALER_CRYPTO_CsDenominationHelper *dh,
const struct TALER_CRYPTO_CsDeriveRequest *cdrs,
unsigned int cdrs_length,
bool for_melt,
struct TALER_DenominationCSPublicRPairP *crps);
/**
* Close connection to @a dh.
*
* @param[in] dh connection to close
*/
void
TALER_CRYPTO_helper_cs_disconnect (
struct TALER_CRYPTO_CsDenominationHelper *dh);
/**
* Handle for talking to an online key signing helper.
*/
struct TALER_CRYPTO_ExchangeSignHelper;
/**
* Function called with information about available keys for signing. Usually
* only called once per key upon connect. Also called again in case a key is
* being revoked, in that case with an @a end_time of zero.
*
* @param cls closure
* @param start_time when does the key become available for signing;
* zero if the key has been revoked or purged
* @param validity_duration how long does the key remain available for signing;
* zero if the key has been revoked or purged
* @param exchange_pub the public key itself, NULL if the key was revoked or purged
* @param sm_pub public key of the security module, NULL if the key was revoked or purged
* @param sm_sig signature from the security module, NULL if the key was revoked or purged
* The signature was already verified against @a sm_pub.
*/
typedef void
(*TALER_CRYPTO_ExchangeKeyStatusCallback)(
void *cls,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Relative validity_duration,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const struct TALER_SecurityModulePublicKeyP *sm_pub,
const struct TALER_SecurityModuleSignatureP *sm_sig);
/**
* Initiate connection to an online signing key helper.
*
* @param cfg configuration to use
* @param ekc function to call with key information
* @param ekc_cls closure for @a ekc
* @return NULL on error (such as bad @a cfg).
*/
struct TALER_CRYPTO_ExchangeSignHelper *
TALER_CRYPTO_helper_esign_connect (
const struct GNUNET_CONFIGURATION_Handle *cfg,
TALER_CRYPTO_ExchangeKeyStatusCallback ekc,
void *ekc_cls);
/**
* Function to call to 'poll' for updates to the available key material.
* Should be called whenever it is important that the key material status is
* current, like when handling a "/keys" request. This function basically
* briefly checks if there are messages from the helper announcing changes to
* exchange online signing keys.
*
* @param esh helper process connection
*/
void
TALER_CRYPTO_helper_esign_poll (struct TALER_CRYPTO_ExchangeSignHelper *esh);
/**
* Request helper @a esh to sign @a msg using the current online
* signing key.
*
* This operation will block until the signature has been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* @param esh helper process connection
* @param purpose message to sign (must extend beyond the purpose)
* @param[out] exchange_pub set to the public key used for the signature upon success
* @param[out] exchange_sig set to the signature upon success
* @return the error code (or #TALER_EC_NONE on success)
*/
enum TALER_ErrorCode
TALER_CRYPTO_helper_esign_sign_ (
struct TALER_CRYPTO_ExchangeSignHelper *esh,
const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
struct TALER_ExchangePublicKeyP *exchange_pub,
struct TALER_ExchangeSignatureP *exchange_sig);
/**
* Request helper @a esh to sign @a msg using the current online
* signing key.
*
* This operation will block until the signature has been obtained. Should
* this process receive a signal (that is not ignored) while the operation is
* pending, the operation will fail. Note that the helper may still believe
* that it created the signature. Thus, signals may result in a small
* differences in the signature counters. Retrying in this case may work.
*
* @param esh helper process connection
* @param ps message to sign (MUST begin with a purpose)
* @param[out] epub set to the public key used for the signature upon success
* @param[out] esig set to the signature upon success
* @return the error code (or #TALER_EC_NONE on success)
*/
#define TALER_CRYPTO_helper_esign_sign(esh,ps,epub,esig) ( \
/* check size is set correctly */ \
GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)), \
/* check 'ps' begins with the purpose */ \
GNUNET_static_assert (((void*) (ps)) == \
((void*) &(ps)->purpose)), \
TALER_CRYPTO_helper_esign_sign_ (esh, \
&(ps)->purpose, \
epub, \
esig) )
/**
* Ask the helper to revoke the public key @a exchange_pub .
* Will cause the helper to tell all clients that the key is now unavailable,
* and to create a replacement key.
*
* This operation will block until the revocation request has been
* transmitted. Should this process receive a signal (that is not ignored)
* while the operation is pending, the operation may fail. If the key is
* unknown, this function will also appear to have succeeded. To be sure that
* the revocation worked, clients must watch the signing key status callback.
*
* @param esh helper to process connection
* @param exchange_pub the public key to revoke
*/
void
TALER_CRYPTO_helper_esign_revoke (
struct TALER_CRYPTO_ExchangeSignHelper *esh,
const struct TALER_ExchangePublicKeyP *exchange_pub);
/**
* Close connection to @a esh.
*
* @param[in] esh connection to close
*/
void
TALER_CRYPTO_helper_esign_disconnect (
struct TALER_CRYPTO_ExchangeSignHelper *esh);
/* ********************* wallet signing ************************** */
/**
* Sign a request to create a purse.
*
* @param purse_expiration when should the purse expire
* @param h_contract_terms contract the two parties agree on
* @param merge_pub public key defining the merge capability
* @param min_age age restriction to apply for deposits into the purse
* @param amount total amount in the purse (including fees)
* @param purse_priv key identifying the purse
* @param[out] purse_sig resulting signature
*/
void
TALER_wallet_purse_create_sign (
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_PurseMergePublicKeyP *merge_pub,
uint32_t min_age,
const struct TALER_Amount *amount,
const struct TALER_PurseContractPrivateKeyP *purse_priv,
struct TALER_PurseContractSignatureP *purse_sig);
/**
* Verify a purse creation request.
*
* @param purse_expiration when should the purse expire
* @param h_contract_terms contract the two parties agree on
* @param merge_pub public key defining the merge capability
* @param min_age age restriction to apply for deposits into the purse
* @param amount total amount in the purse (including fees)
* @param purse_pub purse’s public key
* @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_CREATE
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_purse_create_verify (
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_PurseMergePublicKeyP *merge_pub,
uint32_t min_age,
const struct TALER_Amount *amount,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PurseContractSignatureP *purse_sig);
/**
* Sign a request to delete a purse.
*
* @param purse_priv key identifying the purse
* @param[out] purse_sig resulting signature
*/
void
TALER_wallet_purse_delete_sign (
const struct TALER_PurseContractPrivateKeyP *purse_priv,
struct TALER_PurseContractSignatureP *purse_sig);
/**
* Verify a purse deletion request.
*
* @param purse_pub purse’s public key
* @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_DELETE
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_purse_delete_verify (
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PurseContractSignatureP *purse_sig);
/**
* Sign a request to upload an encrypted contract.
*
* @param econtract encrypted contract
* @param econtract_size number of bytes in @a econtract
* @param contract_pub public key for the DH-encryption
* @param purse_priv key identifying the purse
* @param[out] purse_sig resulting signature
*/
void
TALER_wallet_econtract_upload_sign (
const void *econtract,
size_t econtract_size,
const struct TALER_ContractDiffiePublicP *contract_pub,
const struct TALER_PurseContractPrivateKeyP *purse_priv,
struct TALER_PurseContractSignatureP *purse_sig);
/**
* Verify a signature over encrypted contract.
*
* @param econtract encrypted contract
* @param econtract_size number of bytes in @a econtract
* @param contract_pub public key for the DH-encryption
* @param purse_pub purse’s public key
* @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_CREATE
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_econtract_upload_verify (
const void *econtract,
size_t econtract_size,
const struct TALER_ContractDiffiePublicP *contract_pub,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PurseContractSignatureP *purse_sig);
/**
* Verify a signature over encrypted contract.
*
* @param h_econtract hashed encrypted contract
* @param contract_pub public key for the DH-encryption
* @param purse_pub purse’s public key
* @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_CREATE
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_econtract_upload_verify2 (
const struct GNUNET_HashCode *h_econtract,
const struct TALER_ContractDiffiePublicP *contract_pub,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PurseContractSignatureP *purse_sig);
/**
* Sign a request to inquire about a purse's status.
*
* @param purse_priv key identifying the purse
* @param[out] purse_sig resulting signature
*/
void
TALER_wallet_purse_status_sign (
const struct TALER_PurseContractPrivateKeyP *purse_priv,
struct TALER_PurseContractSignatureP *purse_sig);
/**
* Verify a purse status request signature.
*
* @param purse_pub purse’s public key
* @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_STATUS
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_purse_status_verify (
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PurseContractSignatureP *purse_sig);
/**
* Sign a request to deposit a coin into a purse.
*
* @param exchange_base_url URL of the exchange hosting the purse
* @param purse_pub purse’s public key
* @param amount amount of the coin's value to transfer to the purse
* @param h_denom_pub hash of the coin's denomination
* @param h_age_commitment hash of the coin's age commitment
* @param coin_priv key identifying the coin to be deposited
* @param[out] coin_sig resulting signature
*/
void
TALER_wallet_purse_deposit_sign (
const char *exchange_base_url,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_Amount *amount,
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify a purse deposit request.
*
* @param exchange_base_url URL of the exchange hosting the purse
* @param purse_pub purse’s public key
* @param amount amount of the coin's value to transfer to the purse
* @param h_denom_pub hash of the coin's denomination
* @param h_age_commitment hash of the coin's age commitment
* @param coin_pub key identifying the coin that is being deposited
* @param[out] coin_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_purse_deposit_verify (
const char *exchange_base_url,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_Amount *amount,
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Sign a request by a purse to merge it into an account.
*
* @param reserve_uri identifies the location of the reserve
* @param merge_timestamp time when the merge happened
* @param purse_pub key identifying the purse
* @param merge_priv key identifying the merge capability
* @param[out] merge_sig resulting signature
*/
void
TALER_wallet_purse_merge_sign (
const char *reserve_uri,
struct GNUNET_TIME_Timestamp merge_timestamp,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PurseMergePrivateKeyP *merge_priv,
struct TALER_PurseMergeSignatureP *merge_sig);
/**
* Verify a purse merge request.
*
* @param reserve_uri identifies the location of the reserve
* @param merge_timestamp time when the merge happened
* @param purse_pub public key of the purse to merge
* @param merge_pub public key of the merge capability
* @param merge_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_MERGE
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_purse_merge_verify (
const char *reserve_uri,
struct GNUNET_TIME_Timestamp merge_timestamp,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PurseMergePublicKeyP *merge_pub,
const struct TALER_PurseMergeSignatureP *merge_sig);
/**
* Flags for a merge signature.
*/
enum TALER_WalletAccountMergeFlags
{
/**
* A mode must be set. None is not a legal mode!
*/
TALER_WAMF_MODE_NONE = 0,
/**
* We are merging a fully paid-up purse into a reserve.
*/
TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE = 1,
/**
* We are creating a fresh purse, from the contingent
* of free purses that our account brings.
*/
TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA = 2,
/**
* The account owner is willing to pay the purse_fee for the purse to be
* created from the account balance.
*/
TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE = 3,
/**
* Bitmask to AND the full flags with to get the mode.
*/
TALER_WAMF_MERGE_MODE_MASK = 3
};
/**
* Sign a request by an account to merge a purse.
*
* @param merge_timestamp time when the merge happened
* @param purse_pub public key of the purse to merge
* @param purse_expiration when should the purse expire
* @param h_contract_terms contract the two parties agree on
* @param amount total amount in the purse (including fees)
* @param purse_fee purse fee the reserve will pay,
* only used if @a flags is #TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE
* @param min_age age restriction to apply for deposits into the purse
* @param flags flags for the operation
* @param reserve_priv key identifying the reserve
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_account_merge_sign (
struct GNUNET_TIME_Timestamp merge_timestamp,
const struct TALER_PurseContractPublicKeyP *purse_pub,
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_Amount *amount,
const struct TALER_Amount *purse_fee,
uint32_t min_age,
enum TALER_WalletAccountMergeFlags flags,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify an account's request to merge a purse.
*
* @param merge_timestamp time when the merge happened
* @param purse_pub public key of the purse to merge
* @param purse_expiration when should the purse expire
* @param h_contract_terms contract the two parties agree on
* @param amount total amount in the purse (including fees)
* @param purse_fee purse fee the reserve will pay,
* only used if @a flags is #TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE
* @param min_age age restriction to apply for deposits into the purse
* @param flags flags for the operation
* @param reserve_pub account’s public key
* @param reserve_sig the signature made with purpose #TALER_SIGNATURE_WALLET_ACCOUNT_MERGE
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_account_merge_verify (
struct GNUNET_TIME_Timestamp merge_timestamp,
const struct TALER_PurseContractPublicKeyP *purse_pub,
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_Amount *amount,
const struct TALER_Amount *purse_fee,
uint32_t min_age,
enum TALER_WalletAccountMergeFlags flags,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Sign a request to keep a reserve open.
*
* @param reserve_payment how much to pay from the
* reserve's own balance for opening the reserve
* @param request_timestamp when was the request created
* @param reserve_expiration desired expiration time for the reserve
* @param purse_limit minimum number of purses the client
* wants to have concurrently open for this reserve
* @param reserve_priv key identifying the reserve
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_reserve_open_sign (
const struct TALER_Amount *reserve_payment,
struct GNUNET_TIME_Timestamp request_timestamp,
struct GNUNET_TIME_Timestamp reserve_expiration,
uint32_t purse_limit,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify a request to keep a reserve open.
*
* @param reserve_payment how much to pay from the
* reserve's own balance for opening the reserve
* @param request_timestamp when was the request created
* @param reserve_expiration desired expiration time for the reserve
* @param purse_limit minimum number of purses the client
* wants to have concurrently open for this reserve
* @param reserve_pub key identifying the reserve
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_open_verify (
const struct TALER_Amount *reserve_payment,
struct GNUNET_TIME_Timestamp request_timestamp,
struct GNUNET_TIME_Timestamp reserve_expiration,
uint32_t purse_limit,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Sign to deposit coin to pay for keeping a reserve open.
*
* @param coin_contribution how much the coin should contribute
* @param reserve_sig signature over the reserve open operation
* @param coin_priv private key of the coin
* @param[out] coin_sig signature by the coin
*/
void
TALER_wallet_reserve_open_deposit_sign (
const struct TALER_Amount *coin_contribution,
const struct TALER_ReserveSignatureP *reserve_sig,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify signature that deposits coin to pay for keeping a reserve open.
*
* @param coin_contribution how much the coin should contribute
* @param reserve_sig signature over the reserve open operation
* @param coin_pub public key of the coin
* @param coin_sig signature by the coin
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_open_deposit_verify (
const struct TALER_Amount *coin_contribution,
const struct TALER_ReserveSignatureP *reserve_sig,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Sign a request to close a reserve.
*
* @param request_timestamp when was the request created
* @param h_payto where to send the funds (NULL allowed to send
* to origin of the reserve)
* @param reserve_priv key identifying the reserve
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_reserve_close_sign (
struct GNUNET_TIME_Timestamp request_timestamp,
const struct TALER_PaytoHashP *h_payto,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify wallet request to close an account.
*
* @param request_timestamp when was the request created
* @param h_payto where to send the funds (NULL/all zeros
* allowed to send to origin of the reserve)
* @param reserve_pub account’s public key
* @param reserve_sig the signature made with purpose #TALER_SIGNATURE_WALLET_RESERVE_CLOSE
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_close_verify (
struct GNUNET_TIME_Timestamp request_timestamp,
const struct TALER_PaytoHashP *h_payto,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Sign a request by a wallet to perform a KYC check.
*
* @param reserve_priv key identifying the wallet/account
* @param balance_threshold the balance threshold the wallet is about to cross
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_account_setup_sign (
const struct TALER_ReservePrivateKeyP *reserve_priv,
const struct TALER_Amount *balance_threshold,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify account setup request.
*
* @param reserve_pub reserve the setup request was for
* @param balance_threshold the balance threshold the wallet is about to cross
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_account_setup_verify (
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *balance_threshold,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Sign request to the exchange to confirm certain
* @a details about the owner of a reserve.
*
* @param request_timestamp when was the request created
* @param details which attributes are requested
* @param reserve_priv private key of the reserve
* @param[out] reserve_sig where to store the signature
*/
void
TALER_wallet_reserve_attest_request_sign (
struct GNUNET_TIME_Timestamp request_timestamp,
const json_t *details,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify request to the exchange to confirm certain
* @a details about the owner of a reserve.
*
* @param request_timestamp when was the request created
* @param details which attributes are requested
* @param reserve_pub public key of the reserve
* @param reserve_sig where to store the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_attest_request_verify (
struct GNUNET_TIME_Timestamp request_timestamp,
const json_t *details,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Sign a deposit permission. Function for wallets.
*
* @param amount the amount to be deposited
* @param deposit_fee the deposit fee we expect to pay
* @param h_wire hash of the merchant’s account details
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange)
* @param wallet_data_hash hash over wallet inputs into the contract (maybe NULL)
* @param h_age_commitment hash over the age commitment, if applicable to the denomination (maybe NULL)
* @param h_policy hash over the policy extension
* @param h_denom_pub hash of the coin denomination's public key
* @param coin_priv coin’s private key
* @param wallet_timestamp timestamp when the contract was finalized, must not be too far in the future
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
* @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline
* @param[out] coin_sig set to the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT
*/
void
TALER_wallet_deposit_sign (
const struct TALER_Amount *amount,
const struct TALER_Amount *deposit_fee,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct GNUNET_HashCode *wallet_data_hash,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_ExtensionPolicyHashP *h_policy,
const struct TALER_DenominationHashP *h_denom_pub,
struct GNUNET_TIME_Timestamp wallet_timestamp,
const struct TALER_MerchantPublicKeyP *merchant_pub,
struct GNUNET_TIME_Timestamp refund_deadline,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify a deposit permission.
*
* @param amount the amount to be deposited
* @param deposit_fee the deposit fee we expect to pay
* @param h_wire hash of the merchant’s account details
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange)
* @param wallet_data_hash hash over wallet inputs into the contract (maybe NULL)
* @param h_age_commitment hash over the age commitment (maybe all zeroes, if not applicable to the denomination)
* @param h_policy hash over the policy extension
* @param h_denom_pub hash of the coin denomination's public key
* @param wallet_timestamp timestamp when the contract was finalized, must not be too far in the future
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
* @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline
* @param coin_pub coin’s public key
* @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_deposit_verify (
const struct TALER_Amount *amount,
const struct TALER_Amount *deposit_fee,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct GNUNET_HashCode *wallet_data_hash,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_ExtensionPolicyHashP *h_policy,
const struct TALER_DenominationHashP *h_denom_pub,
struct GNUNET_TIME_Timestamp wallet_timestamp,
const struct TALER_MerchantPublicKeyP *merchant_pub,
struct GNUNET_TIME_Timestamp refund_deadline,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Sign a melt request.
*
* @param amount_with_fee the amount to be melted (with fee)
* @param melt_fee the melt fee we expect to pay
* @param rc refresh session we are committed to
* @param h_denom_pub hash of the coin denomination's public key
* @param h_age_commitment hash of the age commitment (may be NULL)
* @param coin_priv coin’s private key
* @param[out] coin_sig set to the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_MELT
*/
void
TALER_wallet_melt_sign (
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *melt_fee,
const struct TALER_RefreshCommitmentP *rc,
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify a melt request.
*
* @param amount_with_fee the amount to be melted (with fee)
* @param melt_fee the melt fee we expect to pay
* @param rc refresh session we are committed to
* @param h_denom_pub hash of the coin denomination's public key
* @param h_age_commitment hash of the age commitment (may be NULL)
* @param coin_pub coin’s public key
* @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_MELT
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_melt_verify (
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *melt_fee,
const struct TALER_RefreshCommitmentP *rc,
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_AgeCommitmentHash *h_age_commitment,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Sign link data.
*
* @param h_denom_pub hash of the denomiantion public key of the new coin
* @param transfer_pub transfer public key
* @param bch blinded coin hash
* @param old_coin_priv private key to sign with
* @param[out] coin_sig resulting signature
*/
void
TALER_wallet_link_sign (
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_TransferPublicKeyP *transfer_pub,
const struct TALER_BlindedCoinHashP *bch,
const struct TALER_CoinSpendPrivateKeyP *old_coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify link signature.
*
* @param h_denom_pub hash of the denomiantion public key of the new coin
* @param transfer_pub transfer public key
* @param h_coin_ev hash of the coin envelope
* @param old_coin_pub old coin key that the link signature is for
* @param coin_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_link_verify (
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_TransferPublicKeyP *transfer_pub,
const struct TALER_BlindedCoinHashP *h_coin_ev,
const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Sign withdraw request.
*
* @param h_denom_pub hash of the denomiantion public key of the coin to withdraw
* @param amount_with_fee amount to debit the reserve for
* @param bch blinded coin hash
* @param reserve_priv private key to sign with
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_withdraw_sign (
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_BlindedCoinHashP *bch,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify withdraw request.
*
* @param h_denom_pub hash of the denomiantion public key of the coin to withdraw
* @param amount_with_fee amount to debit the reserve for
* @param bch blinded coin hash
* @param reserve_pub public key of the reserve
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_withdraw_verify (
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_BlindedCoinHashP *bch,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Sign age-withdraw request.
*
* @param h_commitment hash over all n*kappa blinded coins in the commitment for the age-withdraw
* @param amount_with_fee amount to debit the reserve for
* @param mask the mask that defines the age groups
* @param max_age maximum age from which the age group is derived, that the withdrawn coins must be restricted to.
* @param reserve_priv private key to sign with
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_age_withdraw_sign (
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
const struct TALER_Amount *amount_with_fee,
const struct TALER_AgeMask *mask,
uint8_t max_age,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify an age-withdraw request.
*
* @param h_commitment hash all n*kappa blinded coins in the commitment for the age-withdraw
* @param amount_with_fee amount to debit the reserve for
* @param mask the mask that defines the age groups
* @param max_age maximum age from which the age group is derived, that the withdrawn coins must be restricted to.
* @param reserve_pub public key of the reserve
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_age_withdraw_verify (
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
const struct TALER_Amount *amount_with_fee,
const struct TALER_AgeMask *mask,
uint8_t max_age,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify exchange melt confirmation.
*
* @param rc refresh session this is about
* @param noreveal_index gamma value chosen by the exchange
* @param exchange_pub public signing key used
* @param exchange_sig signature to check
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_melt_confirmation_verify (
const struct TALER_RefreshCommitmentP *rc,
uint32_t noreveal_index,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const struct TALER_ExchangeSignatureP *exchange_sig);
/**
* Verify recoup signature.
*
* @param h_denom_pub hash of the denomiantion public key of the coin
* @param coin_bks blinding factor used when withdrawing the coin
* @param coin_pub coin key of the coin to be recouped
* @param coin_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_recoup_verify (
const struct TALER_DenominationHashP *h_denom_pub,
const union TALER_DenominationBlindingKeyP *coin_bks,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Create recoup signature.
*
* @param h_denom_pub hash of the denomiantion public key of the coin
* @param coin_bks blinding factor used when withdrawing the coin
* @param coin_priv coin key of the coin to be recouped
* @param[out] coin_sig resulting signature
*/
void
TALER_wallet_recoup_sign (
const struct TALER_DenominationHashP *h_denom_pub,
const union TALER_DenominationBlindingKeyP *coin_bks,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify recoup-refresh signature.
*
* @param h_denom_pub hash of the denomiantion public key of the coin
* @param coin_bks blinding factor used when withdrawing the coin
* @param coin_pub coin key of the coin to be recouped
* @param coin_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_recoup_refresh_verify (
const struct TALER_DenominationHashP *h_denom_pub,
const union TALER_DenominationBlindingKeyP *coin_bks,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Create recoup-refresh signature.
*
* @param h_denom_pub hash of the denomiantion public key of the coin
* @param coin_bks blinding factor used when withdrawing the coin
* @param coin_priv coin key of the coin to be recouped
* @param[out] coin_sig resulting signature
*/
void
TALER_wallet_recoup_refresh_sign (
const struct TALER_DenominationHashP *h_denom_pub,
const union TALER_DenominationBlindingKeyP *coin_bks,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify reserve history request signature.
*
* @param start_off start of the requested range
* @param reserve_pub reserve the history request was for
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_history_verify (
uint64_t start_off,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Create reserve status request signature.
*
* @param start_off start of the requested range
* @param reserve_priv private key of the reserve the history request is for
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_reserve_history_sign (
uint64_t start_off,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify coin history request signature.
*
* @param start_off start of the requested range
* @param coin_pub coin the history request was for
* @param coin_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_coin_history_verify (
uint64_t start_off,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Create coin status request signature.
*
* @param start_off start of the requested range
* @param coin_priv private key of the coin the history request is for
* @param[out] coin_sig resulting signature
*/
void
TALER_wallet_coin_history_sign (
uint64_t start_off,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct TALER_CoinSpendSignatureP *coin_sig);
/* ********************* merchant signing ************************** */
/**
* Create merchant signature approving a refund.
*
* @param coin_pub coin to be refunded
* @param h_contract_terms contract to be refunded
* @param rtransaction_id unique ID for this (partial) refund
* @param amount amount to be refunded
* @param merchant_priv private key to sign with
* @param[out] merchant_sig where to write the signature
*/
void
TALER_merchant_refund_sign (
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
uint64_t rtransaction_id,
const struct TALER_Amount *amount,
const struct TALER_MerchantPrivateKeyP *merchant_priv,
struct TALER_MerchantSignatureP *merchant_sig);
/**
* Verify merchant signature approving a refund.
*
* @param coin_pub coin to be refunded
* @param h_contract_terms contract to be refunded
* @param rtransaction_id unique ID for this (partial) refund
* @param amount amount to be refunded
* @param merchant_pub public key of the merchant
* @param merchant_sig signature to verify
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_merchant_refund_verify (
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
uint64_t rtransaction_id,
const struct TALER_Amount *amount,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantSignatureP *merchant_sig);
/* ********************* exchange deposit signing ************************* */
/**
* Sign a deposit.
*
* @param h_contract_terms hash of contract terms
* @param h_wire hash of the merchant account details
* @param coin_pub coin to be deposited
* @param merchant_priv private key to sign with
* @param[out] merchant_sig where to write the signature
*/
void
TALER_merchant_deposit_sign (
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_MerchantPrivateKeyP *merchant_priv,
struct TALER_MerchantSignatureP *merchant_sig);
/**
* Verify a deposit.
*
* @param merchant merchant public key
* @param coin_pub public key of the deposited coin
* @param h_contract_terms hash of contract terms
* @param h_wire hash of the merchant account details
* @param merchant_sig signature of the merchant
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_merchant_deposit_verify (
const struct TALER_MerchantPublicKeyP *merchant,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_MerchantSignatureP *merchant_sig);
/* ********************* exchange online signing ************************** */
/**
* Signature of a function that signs the message in @a purpose with the
* exchange's signing key.
*
* The @a purpose data is the beginning of the data of which the signature is
* to be created. The `size` field in @a purpose must correctly indicate the
* number of bytes of the data structure, including its header. *
* @param purpose the message to sign
* @param[out] pub set to the current public signing key of the exchange
* @param[out] sig signature over purpose using current signing key
* @return #TALER_EC_NONE on success
*/
typedef enum TALER_ErrorCode
(*TALER_ExchangeSignCallback)(
const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Signature of a function that signs the message in @a purpose with the
* exchange's signing key.
*
* The @a purpose data is the beginning of the data of which the signature is
* to be created. The `size` field in @a purpose must correctly indicate the
* number of bytes of the data structure, including its header. *
* @param cls closure
* @param purpose the message to sign
* @param[out] pub set to the current public signing key of the exchange
* @param[out] sig signature over purpose using current signing key
* @return #TALER_EC_NONE on success
*/
typedef enum TALER_ErrorCode
(*TALER_ExchangeSignCallback2)(
void *cls,
const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Create deposit confirmation signature.
*
* @param scb function to call to create the signature
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange)
* @param h_wire hash of the merchant’s account details
* @param h_policy hash over the policy extension, can be NULL
* @param exchange_timestamp timestamp when the contract was finalized, must not be too far off
* @param wire_deadline date until which the exchange should wire the funds
* @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline
* @param total_without_fee the total amount to be deposited after fees over all coins
* @param num_coins length of @a coin_sigs array
* @param coin_sigs signatures of the deposited coins
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_deposit_confirmation_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_ExtensionPolicyHashP *h_policy,
struct GNUNET_TIME_Timestamp exchange_timestamp,
struct GNUNET_TIME_Timestamp wire_deadline,
struct GNUNET_TIME_Timestamp refund_deadline,
const struct TALER_Amount *total_without_fee,
unsigned int num_coins,
const struct TALER_CoinSpendSignatureP *coin_sigs[static num_coins],
const struct TALER_MerchantPublicKeyP *merchant_pub,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify deposit confirmation signature.
*
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange)
* @param h_wire hash of the merchant’s account details
* @param h_policy hash over the policy extension, can be NULL
* @param exchange_timestamp timestamp when the contract was finalized, must not be too far off
* @param wire_deadline date until which the exchange should wire the funds
* @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline
* @param total_without_fee the total amount to be deposited after fees over all coins
* @param num_coins length of @a coin_sigs array
* @param coin_sigs signatures of the deposited coins
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_deposit_confirmation_verify (
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_ExtensionPolicyHashP *h_policy,
struct GNUNET_TIME_Timestamp exchange_timestamp,
struct GNUNET_TIME_Timestamp wire_deadline,
struct GNUNET_TIME_Timestamp refund_deadline,
const struct TALER_Amount *total_without_fee,
unsigned int num_coins,
const struct TALER_CoinSpendSignatureP *coin_sigs[static num_coins],
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create refund confirmation signature.
*
* @param scb function to call to create the signature
* @param h_contract_terms hash of contract being refunded
* @param coin_pub public key of the coin receiving the refund
* @param merchant public key of the merchant that granted the refund
* @param rtransaction_id refund transaction ID used by the merchant
* @param refund_amount amount refunded
* @param[out] pub where to write the exchange public key
* @param[out] sig where to write the exchange signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_refund_confirmation_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_MerchantPublicKeyP *merchant,
uint64_t rtransaction_id,
const struct TALER_Amount *refund_amount,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify refund confirmation signature.
*
* @param h_contract_terms hash of contract being refunded
* @param coin_pub public key of the coin receiving the refund
* @param merchant public key of the merchant that granted the refund
* @param rtransaction_id refund transaction ID used by the merchant
* @param refund_amount amount refunded
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_refund_confirmation_verify (
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_MerchantPublicKeyP *merchant,
uint64_t rtransaction_id,
const struct TALER_Amount *refund_amount,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create refresh melt confirmation signature.
*
* @param scb function to call to create the signature
* @param rc refresh commitment that identifies the melt operation
* @param noreveal_index gamma cut-and-choose value chosen by the exchange
* @param[out] pub where to write the exchange public key
* @param[out] sig where to write the exchange signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_melt_confirmation_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_RefreshCommitmentP *rc,
uint32_t noreveal_index,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify refresh melt confirmation signature.
*
* @param rc refresh commitment that identifies the melt operation
* @param noreveal_index gamma cut-and-choose value chosen by the exchange
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_melt_confirmation_verify (
const struct TALER_RefreshCommitmentP *rc,
uint32_t noreveal_index,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create exchange purse refund confirmation signature.
*
* @param scb function to call to create the signature
* @param amount_without_fee refunded amount
* @param refund_fee refund fee charged
* @param coin_pub coin that was refunded
* @param purse_pub public key of the expired purse
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_purse_refund_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_Amount *amount_without_fee,
const struct TALER_Amount *refund_fee,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_PurseContractPublicKeyP *purse_pub,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify signature of exchange affirming purse refund
* from purse expiration.
*
* @param amount_without_fee refunded amount
* @param refund_fee refund fee charged
* @param coin_pub coin that was refunded
* @param purse_pub public key of the expired purse
* @param pub public key to verify signature against
* @param sig signature to verify
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_purse_refund_verify (
const struct TALER_Amount *amount_without_fee,
const struct TALER_Amount *refund_fee,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create exchange key set signature.
*
* @param scb function to call to create the signature
* @param cls closure for @a scb
* @param timestamp time when the key set was issued
* @param hc hash over all the keys
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_key_set_sign (
TALER_ExchangeSignCallback2 scb,
void *cls,
struct GNUNET_TIME_Timestamp timestamp,
const struct GNUNET_HashCode *hc,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify key set signature.
*
* @param timestamp time when the key set was issued
* @param hc hash over all the keys
* @param pub public key to verify signature against
* @param sig signature to verify
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_key_set_verify (
struct GNUNET_TIME_Timestamp timestamp,
const struct GNUNET_HashCode *hc,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create account KYC setup success signature.
*
* @param scb function to call to create the signature
* @param h_payto target of the KYC account
* @param kyc JSON data describing which KYC checks
* were satisfied
* @param timestamp time when the KYC was confirmed
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_account_setup_success_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_PaytoHashP *h_payto,
const json_t *kyc,
struct GNUNET_TIME_Timestamp timestamp,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify account KYC setup success signature.
*
* @param h_payto target of the KYC account
* @param kyc JSON data describing which KYC checks
* were satisfied
* @param timestamp time when the KYC was confirmed
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_account_setup_success_verify (
const struct TALER_PaytoHashP *h_payto,
const json_t *kyc,
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Hash normalized @a j JSON object or array and
* store the result in @a hc.
*
* @param j JSON to hash
* @param[out] hc where to write the hash
*/
void
TALER_json_hash (const json_t *j,
struct GNUNET_HashCode *hc);
/**
* Update the @a hash_context in the computation of the
* h_details for a wire status signature.
*
* @param[in,out] hash_context context to update
* @param h_contract_terms hash of the contract
* @param execution_time when was the wire transfer initiated
* @param coin_pub deposited coin
* @param deposit_value contribution of the coin
* @param deposit_fee how high was the deposit fee
*/
void
TALER_exchange_online_wire_deposit_append (
struct GNUNET_HashContext *hash_context,
const struct TALER_PrivateContractHashP *h_contract_terms,
struct GNUNET_TIME_Timestamp execution_time,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *deposit_value,
const struct TALER_Amount *deposit_fee);
/**
* Create wire deposit signature.
*
* @param scb function to call to create the signature
* @param total amount the merchant was credited
* @param wire_fee fee charged by the exchange for the wire transfer
* @param merchant_pub which merchant was credited
* @param payto payto://-URI of the merchant account
* @param h_details hash over the aggregation details
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_wire_deposit_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_Amount *total,
const struct TALER_Amount *wire_fee,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const char *payto,
const struct GNUNET_HashCode *h_details,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify wire deposit signature.
*
* @param total amount the merchant was credited
* @param wire_fee fee charged by the exchange for the wire transfer
* @param merchant_pub which merchant was credited
* @param h_payto hash of the payto://-URI of the merchant account
* @param h_details hash over the aggregation details
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_wire_deposit_verify (
const struct TALER_Amount *total,
const struct TALER_Amount *wire_fee,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_PaytoHashP *h_payto,
const struct GNUNET_HashCode *h_details,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create wire confirmation signature.
*
* @param scb function to call to create the signature
* @param h_wire hash of the merchant's account
* @param h_contract_terms hash of the contract
* @param wtid wire transfer this deposit was aggregated into
* @param coin_pub public key of the deposited coin
* @param execution_time when was wire transfer initiated
* @param coin_contribution what was @a coin_pub's contribution to the wire transfer
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_confirm_wire_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct GNUNET_TIME_Timestamp execution_time,
const struct TALER_Amount *coin_contribution,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify confirm wire signature.
*
* @param h_wire hash of the merchant's account
* @param h_contract_terms hash of the contract
* @param wtid wire transfer this deposit was aggregated into
* @param coin_pub public key of the deposited coin
* @param execution_time when was wire transfer initiated
* @param coin_contribution what was @a coin_pub's contribution to the wire transfer
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_confirm_wire_verify (
const struct TALER_MerchantWireHashP *h_wire,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct GNUNET_TIME_Timestamp execution_time,
const struct TALER_Amount *coin_contribution,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create confirm recoup signature.
*
* @param scb function to call to create the signature
* @param timestamp when was the recoup done
* @param recoup_amount how much was recouped
* @param coin_pub coin that was recouped
* @param reserve_pub reserve that was credited
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_confirm_recoup_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_Amount *recoup_amount,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_ReservePublicKeyP *reserve_pub,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify confirm recoup signature.
*
* @param timestamp when was the recoup done
* @param recoup_amount how much was recouped
* @param coin_pub coin that was recouped
* @param reserve_pub reserve that was credited
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_confirm_recoup_verify (
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_Amount *recoup_amount,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create confirm recoup refresh signature.
*
* @param scb function to call to create the signature
* @param timestamp when was the recoup done
* @param recoup_amount how much was recouped
* @param coin_pub coin that was recouped
* @param old_coin_pub old coin that was credited
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_confirm_recoup_refresh_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_Amount *recoup_amount,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify confirm recoup refresh signature.
*
* @param timestamp when was the recoup done
* @param recoup_amount how much was recouped
* @param coin_pub coin that was recouped
* @param old_coin_pub old coin that was credited
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_confirm_recoup_refresh_verify (
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_Amount *recoup_amount,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create denomination unknown signature.
*
* @param scb function to call to create the signature
* @param timestamp when was the error created
* @param h_denom_pub hash of denomination that is unknown
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_denomination_unknown_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_DenominationHashP *h_denom_pub,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify denomination unknown signature.
*
* @param timestamp when was the error created
* @param h_denom_pub hash of denomination that is unknown
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_denomination_unknown_verify (
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create denomination expired signature.
*
* @param scb function to call to create the signature
* @param timestamp when was the error created
* @param h_denom_pub hash of denomination that is expired
* @param op character string describing the operation for which
* the denomination is expired
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_denomination_expired_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_DenominationHashP *h_denom_pub,
const char *op,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify denomination expired signature.
*
* @param timestamp when was the error created
* @param h_denom_pub hash of denomination that is expired
* @param op character string describing the operation for which
* the denomination is expired
* @param pub where to write the public key
* @param sig where to write the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_denomination_expired_verify (
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_DenominationHashP *h_denom_pub,
const char *op,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create reserve closure signature.
*
* @param scb function to call to create the signature
* @param timestamp time when the reserve was closed
* @param closing_amount amount left in the reserve
* @param closing_fee closing fee charged
* @param payto target of the wire transfer
* @param wtid wire transfer subject used
* @param reserve_pub public key of the closed reserve
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_reserve_closed_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_Amount *closing_amount,
const struct TALER_Amount *closing_fee,
const char *payto,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_ReservePublicKeyP *reserve_pub,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify reserve closure signature.
*
* @param timestamp time when the reserve was closed
* @param closing_amount amount left in the reserve
* @param closing_fee closing fee charged
* @param payto target of the wire transfer
* @param wtid wire transfer subject used
* @param reserve_pub public key of the closed reserve
* @param pub the public key of the exchange to check against
* @param sig the signature to check
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_reserve_closed_verify (
struct GNUNET_TIME_Timestamp timestamp,
const struct TALER_Amount *closing_amount,
const struct TALER_Amount *closing_fee,
const char *payto,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Create signature by exchange affirming that a reserve
* has had certain attributes verified via KYC.
*
* @param scb function to call to create the signature
* @param attest_timestamp our time
* @param expiration_time when does the KYC data expire
* @param reserve_pub for which reserve are attributes attested
* @param attributes JSON object with attributes being attested to
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_reserve_attest_details_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp attest_timestamp,
struct GNUNET_TIME_Timestamp expiration_time,
const struct TALER_ReservePublicKeyP *reserve_pub,
const json_t *attributes,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify signature by exchange affirming that a reserve
* has had certain attributes verified via KYC.
*
* @param attest_timestamp our time
* @param expiration_time when does the KYC data expire
* @param reserve_pub for which reserve are attributes attested
* @param attributes JSON object with attributes being attested to
* @param pub exchange public key
* @param sig exchange signature to verify
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_reserve_attest_details_verify (
struct GNUNET_TIME_Timestamp attest_timestamp,
struct GNUNET_TIME_Timestamp expiration_time,
const struct TALER_ReservePublicKeyP *reserve_pub,
const json_t *attributes,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Create signature by exchange affirming that a purse was created.
*
* @param scb function to call to create the signature
* @param exchange_time our time
* @param purse_expiration when will the purse expire
* @param amount_without_fee total amount to be put into the purse (without deposit fees)
* @param total_deposited total currently in the purse
* @param purse_pub public key of the purse
* @param h_contract_terms hash of the contract for the purse
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_purse_created_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp exchange_time,
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_Amount *amount_without_fee,
const struct TALER_Amount *total_deposited,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify exchange signature about a purse creation and balance.
*
* @param exchange_time our time
* @param purse_expiration when will the purse expire
* @param amount_without_fee total amount to be put into the purse (without deposit fees)
* @param total_deposited total currently in the purse
* @param purse_pub public key of the purse
* @param h_contract_terms hash of the contract for the purse
* @param pub the public key of the exchange to check against
* @param sig the signature to check
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_purse_created_verify (
struct GNUNET_TIME_Timestamp exchange_time,
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_Amount *amount_without_fee,
const struct TALER_Amount *total_deposited,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Sign affirmation that a purse was merged.
*
* @param scb function to call to create the signature
* @param exchange_time our time
* @param purse_expiration when does the purse expire
* @param amount_without_fee total amount that should be in the purse without deposit fees
* @param purse_pub public key of the purse
* @param h_contract_terms hash of the contract of the purse
* @param reserve_pub reserve the purse will be merged into
* @param exchange_url exchange at which the @a reserve_pub lives
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_purse_merged_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp exchange_time,
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_Amount *amount_without_fee,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_ReservePublicKeyP *reserve_pub,
const char *exchange_url,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify affirmation that a purse will be merged.
*
* @param exchange_time our time
* @param purse_expiration when does the purse expire
* @param amount_without_fee total amount that should be in the purse without deposit fees
* @param purse_pub public key of the purse
* @param h_contract_terms hash of the contract of the purse
* @param reserve_pub reserve the purse will be merged into
* @param exchange_url exchange at which the @a reserve_pub lives
* @param pub the public key of the exchange to check against
* @param sig the signature to check
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_purse_merged_verify (
struct GNUNET_TIME_Timestamp exchange_time,
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_Amount *amount_without_fee,
const struct TALER_PurseContractPublicKeyP *purse_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_ReservePublicKeyP *reserve_pub,
const char *exchange_url,
const struct TALER_ExchangePublicKeyP *pub,
const struct TALER_ExchangeSignatureP *sig);
/**
* Sign information about the status of a purse.
*
* @param scb function to call to create the signature
* @param merge_timestamp when was the purse merged (can be never)
* @param deposit_timestamp when was the purse fully paid up (can be never)
* @param balance current balance of the purse
* @param[out] pub where to write the public key
* @param[out] sig where to write the signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_purse_status_sign (
TALER_ExchangeSignCallback scb,
struct GNUNET_TIME_Timestamp merge_timestamp,
struct GNUNET_TIME_Timestamp deposit_timestamp,
const struct TALER_Amount *balance,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verify signature over information about the status of a purse.
*
* @param merge_timestamp when was the purse merged (can be never)
* @param deposit_timestamp when was the purse fully paid up (can be never)
* @param balance current balance of the purse
* @param exchange_pub the public key of the exchange to check against
* @param exchange_sig the signature to check
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_purse_status_verify (
struct GNUNET_TIME_Timestamp merge_timestamp,
struct GNUNET_TIME_Timestamp deposit_timestamp,
const struct TALER_Amount *balance,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const struct TALER_ExchangeSignatureP *exchange_sig);
/**
* Create age-withdraw confirmation signature.
*
* @param scb function to call to create the signature
* @param h_commitment age-withdraw commitment that identifies the n*kappa blinded coins
* @param noreveal_index gamma cut-and-choose value chosen by the exchange
* @param[out] pub where to write the exchange public key
* @param[out] sig where to write the exchange signature
* @return #TALER_EC_NONE on success
*/
enum TALER_ErrorCode
TALER_exchange_online_age_withdraw_confirmation_sign (
TALER_ExchangeSignCallback scb,
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
uint32_t noreveal_index,
struct TALER_ExchangePublicKeyP *pub,
struct TALER_ExchangeSignatureP *sig);
/**
* Verfiy an exchange age-withdraw confirmation
*
* @param h_commitment Commitment over all n*kappa coin candidates from the original request to age-withdraw
* @param noreveal_index The index returned by the exchange
* @param exchange_pub The public key used for signing
* @param exchange_sig The signature from the exchange
*/
enum GNUNET_GenericReturnValue
TALER_exchange_online_age_withdraw_confirmation_verify (
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
uint32_t noreveal_index,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const struct TALER_ExchangeSignatureP *exchange_sig);
/* ********************* offline signing ************************** */
/**
* Create AML officer status change signature.
*
* @param officer_pub public key of the AML officer
* @param officer_name name of the officer
* @param change_date when to affect the status change
* @param is_active true to enable the officer
* @param read_only true to only allow read-only access
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_aml_officer_status_sign (
const struct TALER_AmlOfficerPublicKeyP *officer_pub,
const char *officer_name,
struct GNUNET_TIME_Timestamp change_date,
bool is_active,
bool read_only,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify AML officer status change signature.
*
* @param officer_pub public key of the AML officer
* @param officer_name name of the officer
* @param change_date when to affect the status change
* @param is_active true to enable the officer
* @param read_only true to only allow read-only access
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_aml_officer_status_verify (
const struct TALER_AmlOfficerPublicKeyP *officer_pub,
const char *officer_name,
struct GNUNET_TIME_Timestamp change_date,
bool is_active,
bool read_only,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create auditor addition signature.
*
* @param auditor_pub public key of the auditor
* @param auditor_url URL of the auditor
* @param start_date when to enable the auditor (for replay detection)
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_auditor_add_sign (
const struct TALER_AuditorPublicKeyP *auditor_pub,
const char *auditor_url,
struct GNUNET_TIME_Timestamp start_date,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify auditor add signature.
*
* @param auditor_pub public key of the auditor
* @param auditor_url URL of the auditor
* @param start_date when to enable the auditor (for replay detection)
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_auditor_add_verify (
const struct TALER_AuditorPublicKeyP *auditor_pub,
const char *auditor_url,
struct GNUNET_TIME_Timestamp start_date,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create auditor deletion signature.
*
* @param auditor_pub public key of the auditor
* @param end_date when to disable the auditor (for replay detection)
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_auditor_del_sign (
const struct TALER_AuditorPublicKeyP *auditor_pub,
struct GNUNET_TIME_Timestamp end_date,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify auditor del signature.
*
* @param auditor_pub public key of the auditor
* @param end_date when to disable the auditor (for replay detection)
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_auditor_del_verify (
const struct TALER_AuditorPublicKeyP *auditor_pub,
struct GNUNET_TIME_Timestamp end_date,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create denomination revocation signature.
*
* @param h_denom_pub hash of public denomination key to revoke
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_denomination_revoke_sign (
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify denomination revocation signature.
*
* @param h_denom_pub hash of public denomination key to revoke
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_denomination_revoke_verify (
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create signkey revocation signature.
*
* @param exchange_pub public signing key to revoke
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_signkey_revoke_sign (
const struct TALER_ExchangePublicKeyP *exchange_pub,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify signkey revocation signature.
*
* @param exchange_pub public signkey key to revoke
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_signkey_revoke_verify (
const struct TALER_ExchangePublicKeyP *exchange_pub,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create signkey validity signature.
*
* @param exchange_pub public signing key to validate
* @param start_sign starting point of validity for signing
* @param end_sign end point (exclusive) for validity for signing
* @param end_legal legal end point of signature validity
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_signkey_validity_sign (
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Timestamp end_sign,
struct GNUNET_TIME_Timestamp end_legal,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify signkey validitity signature.
*
* @param exchange_pub public signkey key to validate
* @param start_sign starting point of validity for signing
* @param end_sign end point (exclusive) for validity for signing
* @param end_legal legal end point of signature validity
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_signkey_validity_verify (
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Timestamp end_sign,
struct GNUNET_TIME_Timestamp end_legal,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create denomination key validity signature.
*
* @param h_denom_pub hash of the denomination's public key
* @param stamp_start when does the exchange begin signing with this key
* @param stamp_expire_withdraw when does the exchange end signing with this key
* @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key
* @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key
* @param coin_value what is the value of coins signed with this key
* @param fees fees for this denomination
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_denom_validity_sign (
const struct TALER_DenominationHashP *h_denom_pub,
struct GNUNET_TIME_Timestamp stamp_start,
struct GNUNET_TIME_Timestamp stamp_expire_withdraw,
struct GNUNET_TIME_Timestamp stamp_expire_deposit,
struct GNUNET_TIME_Timestamp stamp_expire_legal,
const struct TALER_Amount *coin_value,
const struct TALER_DenomFeeSet *fees,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify denomination key validity signature.
*
* @param h_denom_pub hash of the denomination's public key
* @param stamp_start when does the exchange begin signing with this key
* @param stamp_expire_withdraw when does the exchange end signing with this key
* @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key
* @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key
* @param coin_value what is the value of coins signed with this key
* @param fees fees for this denomination
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_denom_validity_verify (
const struct TALER_DenominationHashP *h_denom_pub,
struct GNUNET_TIME_Timestamp stamp_start,
struct GNUNET_TIME_Timestamp stamp_expire_withdraw,
struct GNUNET_TIME_Timestamp stamp_expire_deposit,
struct GNUNET_TIME_Timestamp stamp_expire_legal,
const struct TALER_Amount *coin_value,
const struct TALER_DenomFeeSet *fees,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create offline signature about an exchange's partners.
*
* @param partner_pub master public key of the partner
* @param start_date validity period start
* @param end_date validity period end
* @param wad_frequency how often will we do wad transfers to this partner
* @param wad_fee what is the wad fee to this partner
* @param partner_base_url what is the base URL of the @a partner_pub exchange
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_partner_details_sign (
const struct TALER_MasterPublicKeyP *partner_pub,
struct GNUNET_TIME_Timestamp start_date,
struct GNUNET_TIME_Timestamp end_date,
struct GNUNET_TIME_Relative wad_frequency,
const struct TALER_Amount *wad_fee,
const char *partner_base_url,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify signature about an exchange's partners.
*
* @param partner_pub master public key of the partner
* @param start_date validity period start
* @param end_date validity period end
* @param wad_frequency how often will we do wad transfers to this partner
* @param wad_fee what is the wad fee to this partner
* @param partner_base_url what is the base URL of the @a partner_pub exchange
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_partner_details_verify (
const struct TALER_MasterPublicKeyP *partner_pub,
struct GNUNET_TIME_Timestamp start_date,
struct GNUNET_TIME_Timestamp end_date,
struct GNUNET_TIME_Relative wad_frequency,
const struct TALER_Amount *wad_fee,
const char *partner_base_url,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create offline signature about wiring profits to a
* regular non-escrowed account of the exchange.
*
* @param wtid (random) wire transfer ID to be used
* @param date when was the profit drain approved (not exact time of execution)
* @param amount how much should be wired
* @param account_section configuration section of the
* exchange specifying the account to be debited
* @param payto_uri target account to be credited
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_profit_drain_sign (
const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Timestamp date,
const struct TALER_Amount *amount,
const char *account_section,
const char *payto_uri,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify offline signature about wiring profits to a
* regular non-escrowed account of the exchange.
*
* @param wtid (random) wire transfer ID to be used
* @param date when was the profit drain approved (not exact time of execution)
* @param amount how much should be wired
* @param account_section configuration section of the
* exchange specifying the account to be debited
* @param payto_uri target account to be credited
* @param master_pub public key to verify signature against
* @param master_sig the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_profit_drain_verify (
const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Timestamp date,
const struct TALER_Amount *amount,
const char *account_section,
const char *payto_uri,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create security module EdDSA signature.
*
* @param exchange_pub public signing key to validate
* @param start_sign starting point of validity for signing
* @param duration how long will the key be in use
* @param secm_priv security module key to sign with
* @param[out] secm_sig where to write the signature
*/
void
TALER_exchange_secmod_eddsa_sign (
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Relative duration,
const struct TALER_SecurityModulePrivateKeyP *secm_priv,
struct TALER_SecurityModuleSignatureP *secm_sig);
/**
* Verify security module EdDSA signature.
*
* @param exchange_pub public signing key to validate
* @param start_sign starting point of validity for signing
* @param duration how long will the key be in use
* @param secm_pub public key to verify against
* @param secm_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_secmod_eddsa_verify (
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Relative duration,
const struct TALER_SecurityModulePublicKeyP *secm_pub,
const struct TALER_SecurityModuleSignatureP *secm_sig);
/**
* Create security module denomination signature.
*
* @param h_rsa hash of the RSA public key to sign
* @param section_name name of the section in the configuration
* @param start_sign starting point of validity for signing
* @param duration how long will the key be in use
* @param secm_priv security module key to sign with
* @param[out] secm_sig where to write the signature
*/
void
TALER_exchange_secmod_rsa_sign (
const struct TALER_RsaPubHashP *h_rsa,
const char *section_name,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Relative duration,
const struct TALER_SecurityModulePrivateKeyP *secm_priv,
struct TALER_SecurityModuleSignatureP *secm_sig);
/**
* Verify security module denomination signature.
*
* @param h_rsa hash of the public key to validate
* @param section_name name of the section in the configuration
* @param start_sign starting point of validity for signing
* @param duration how long will the key be in use
* @param secm_pub public key to verify against
* @param secm_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_secmod_rsa_verify (
const struct TALER_RsaPubHashP *h_rsa,
const char *section_name,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Relative duration,
const struct TALER_SecurityModulePublicKeyP *secm_pub,
const struct TALER_SecurityModuleSignatureP *secm_sig);
/**
* Create security module denomination signature.
*
* @param h_cs hash of the CS public key to sign
* @param section_name name of the section in the configuration
* @param start_sign starting point of validity for signing
* @param duration how long will the key be in use
* @param secm_priv security module key to sign with
* @param[out] secm_sig where to write the signature
*/
void
TALER_exchange_secmod_cs_sign (
const struct TALER_CsPubHashP *h_cs,
const char *section_name,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Relative duration,
const struct TALER_SecurityModulePrivateKeyP *secm_priv,
struct TALER_SecurityModuleSignatureP *secm_sig);
/**
* Verify security module denomination signature.
*
* @param h_cs hash of the public key to validate
* @param section_name name of the section in the configuration
* @param start_sign starting point of validity for signing
* @param duration how long will the key be in use
* @param secm_pub public key to verify against
* @param secm_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_secmod_cs_verify (
const struct TALER_CsPubHashP *h_cs,
const char *section_name,
struct GNUNET_TIME_Timestamp start_sign,
struct GNUNET_TIME_Relative duration,
const struct TALER_SecurityModulePublicKeyP *secm_pub,
const struct TALER_SecurityModuleSignatureP *secm_sig);
/**
* Create denomination key validity signature by the auditor.
*
* @param auditor_url BASE URL of the auditor's API
* @param h_denom_pub hash of the denomination's public key
* @param master_pub master public key of the exchange
* @param stamp_start when does the exchange begin signing with this key
* @param stamp_expire_withdraw when does the exchange end signing with this key
* @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key
* @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key
* @param coin_value what is the value of coins signed with this key
* @param fees fees the exchange charges for this denomination
* @param auditor_priv private key to sign with
* @param[out] auditor_sig where to write the signature
*/
void
TALER_auditor_denom_validity_sign (
const char *auditor_url,
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_MasterPublicKeyP *master_pub,
struct GNUNET_TIME_Timestamp stamp_start,
struct GNUNET_TIME_Timestamp stamp_expire_withdraw,
struct GNUNET_TIME_Timestamp stamp_expire_deposit,
struct GNUNET_TIME_Timestamp stamp_expire_legal,
const struct TALER_Amount *coin_value,
const struct TALER_DenomFeeSet *fees,
const struct TALER_AuditorPrivateKeyP *auditor_priv,
struct TALER_AuditorSignatureP *auditor_sig);
/**
* Verify denomination key validity signature from auditor.
*
* @param auditor_url BASE URL of the auditor's API
* @param h_denom_pub hash of the denomination's public key
* @param master_pub master public key of the exchange
* @param stamp_start when does the exchange begin signing with this key
* @param stamp_expire_withdraw when does the exchange end signing with this key
* @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key
* @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key
* @param coin_value what is the value of coins signed with this key
* @param fees fees the exchange charges for this denomination
* @param auditor_pub public key to verify against
* @param auditor_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_auditor_denom_validity_verify (
const char *auditor_url,
const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_MasterPublicKeyP *master_pub,
struct GNUNET_TIME_Timestamp stamp_start,
struct GNUNET_TIME_Timestamp stamp_expire_withdraw,
struct GNUNET_TIME_Timestamp stamp_expire_deposit,
struct GNUNET_TIME_Timestamp stamp_expire_legal,
const struct TALER_Amount *coin_value,
const struct TALER_DenomFeeSet *fees,
const struct TALER_AuditorPublicKeyP *auditor_pub,
const struct TALER_AuditorSignatureP *auditor_sig);
/* **************** /wire account offline signing **************** */
/**
* Create wire fee signature.
*
* @param payment_method the payment method
* @param start_time when do the fees start to apply
* @param end_time when do the fees start to apply
* @param fees the wire fees
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_wire_fee_sign (
const char *payment_method,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_WireFeeSet *fees,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify wire fee signature.
*
* @param payment_method the payment method
* @param start_time when do the fees start to apply
* @param end_time when do the fees start to apply
* @param fees the wire fees
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_wire_fee_verify (
const char *payment_method,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_WireFeeSet *fees,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create global fees signature.
*
* @param start_time when do the fees start to apply
* @param end_time when do the fees start to apply
* @param fees the global fees
* @param purse_timeout how long do unmerged purses stay around
* @param history_expiration how long do we keep the history of an account
* @param purse_account_limit how many concurrent purses are free per account holder
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_global_fee_sign (
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_GlobalFeeSet *fees,
struct GNUNET_TIME_Relative purse_timeout,
struct GNUNET_TIME_Relative history_expiration,
uint32_t purse_account_limit,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify global fees signature.
*
* @param start_time when do the fees start to apply
* @param end_time when do the fees start to apply
* @param fees the global fees
* @param purse_timeout how long do unmerged purses stay around
* @param history_expiration how long do we keep the history of an account
* @param purse_account_limit how many concurrent purses are free per account holder
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_global_fee_verify (
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_GlobalFeeSet *fees,
struct GNUNET_TIME_Relative purse_timeout,
struct GNUNET_TIME_Relative history_expiration,
uint32_t purse_account_limit,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create wire account addition signature.
*
* @param payto_uri bank account
* @param conversion_url URL of the conversion service, or NULL if none
* @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec
* @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec
* @param now timestamp to use for the signature (rounded)
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_wire_add_sign (
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp now,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify wire account addition signature.
*
* @param payto_uri bank account
* @param conversion_url URL of the conversion service, or NULL if none
* @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec
* @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec
* @param sign_time timestamp when signature was created
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_wire_add_verify (
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp sign_time,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create wire account removal signature.
*
* @param payto_uri bank account
* @param now timestamp to use for the signature (rounded)
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_wire_del_sign (
const char *payto_uri,
struct GNUNET_TIME_Timestamp now,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify wire account deletion signature.
*
* @param payto_uri bank account
* @param sign_time timestamp when signature was created
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_wire_del_verify (
const char *payto_uri,
struct GNUNET_TIME_Timestamp sign_time,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Check the signature in @a master_sig.
*
* @param payto_uri URI that is signed
* @param conversion_url URL of the conversion service, or NULL if none
* @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec
* @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec
* @param master_pub master public key of the exchange
* @param master_sig signature of the exchange
* @return #GNUNET_OK if signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_wire_signature_check (
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);
/**
* Create a signed wire statement for the given account.
*
* @param payto_uri account specification
* @param conversion_url URL of the conversion service, or NULL if none
* @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec
* @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_wire_signature_make (
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Compute the hash of the given wire details. The resulting
* @a hc is what will be put into the contract between customer
* and merchant for signing by both parties.
*
* @param payto_uri bank account
* @param salt salt used to eliminate brute-force inversion
* @param[out] hc set to the hash
*/
void
TALER_merchant_wire_signature_hash (const char *payto_uri,
const struct TALER_WireSaltP *salt,
struct TALER_MerchantWireHashP *hc);
/**
* Check the signature in @a wire_s.
*
* @param payto_uri URL that is signed
* @param salt the salt used to salt the @a payto_uri when hashing
* @param merch_pub public key of the merchant
* @param merch_sig signature of the merchant
* @return #GNUNET_OK if signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_merchant_wire_signature_check (
const char *payto_uri,
const struct TALER_WireSaltP *salt,
const struct TALER_MerchantPublicKeyP *merch_pub,
const struct TALER_MerchantSignatureP *merch_sig);
/**
* Create a signed wire statement for the given account.
*
* @param payto_uri account specification
* @param salt the salt used to salt the @a payto_uri when hashing
* @param merch_priv private key to sign with
* @param[out] merch_sig where to write the signature
*/
void
TALER_merchant_wire_signature_make (
const char *payto_uri,
const struct TALER_WireSaltP *salt,
const struct TALER_MerchantPrivateKeyP *merch_priv,
struct TALER_MerchantSignatureP *merch_sig);
/**
* Sign a payment confirmation.
*
* @param h_contract_terms hash of the contact of the merchant with the customer
* @param merch_priv private key to sign with
* @param[out] merch_sig where to write the signature
*/
void
TALER_merchant_pay_sign (
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantPrivateKeyP *merch_priv,
struct GNUNET_CRYPTO_EddsaSignature *merch_sig);
/**
* Verify payment confirmation signature.
*
* @param h_contract_terms hash of the contact of the merchant with the customer
* @param merchant_pub public key of the merchant
* @param merchant_sig signature to verify
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_merchant_pay_verify (
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantSignatureP *merchant_sig);
/**
* Sign contract sent by the merchant to the wallet.
*
* @param h_contract_terms hash of the contract terms
* @param merch_priv private key to sign with
* @param[out] merch_sig where to write the signature
*/
void
TALER_merchant_contract_sign (
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantPrivateKeyP *merch_priv,
struct GNUNET_CRYPTO_EddsaSignature *merch_sig);
/* **************** /management/extensions offline signing **************** */
/**
* Create a signature for the hash of the manifests of extensions
*
* @param h_manifests hash of the JSON object representing the manifests
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
void
TALER_exchange_offline_extension_manifests_hash_sign (
const struct TALER_ExtensionManifestsHashP *h_manifests,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
/**
* Verify the signature in @a master_sig of the given hash, taken over the JSON
* blob representing the manifests of extensions
*
* @param h_manifest hash of the JSON blob of manifests of extensions
* @param master_pub master public key of the exchange
* @param master_sig signature of the exchange
* @return #GNUNET_OK if signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_exchange_offline_extension_manifests_hash_verify (
const struct TALER_ExtensionManifestsHashP *h_manifest,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig
);
/**
* @brief Representation of an age commitment: one public key per age group.
*
* The number of keys must be be the same as the number of bits set in the
* corresponding age mask.
*/
struct TALER_AgeCommitment
{
/**
* The age mask defines the age groups that were a parameter during the
* generation of this age commitment
*/
struct TALER_AgeMask mask;
/**
* The number of public keys, which must be the same as the number of
* groups in the mask.
*/
size_t num;
/**
* The list of @e num public keys. In must have same size as the number of
* age groups defined in the mask.
*
* A hash of this list is the hashed commitment that goes into FDC
* calculation during the withdraw and refresh operations for new coins. That
* way, the particular age commitment becomes mandatory and bound to a coin.
*
* The list has been allocated via GNUNET_malloc().
*/
struct TALER_AgeCommitmentPublicKeyP *keys;
};
/**
* @brief Proof for a particular age commitment, used in age attestation
*
* This struct is used in a call to TALER_age_commitment_attest to create an
* attestation for a minimum age (if that minimum age is less or equal to the
* committed age for this proof). It consists of a list private keys, one per
* age group, for which the committed age is either lager or within that
* particular group.
*/
struct TALER_AgeProof
{
/**
* The number of private keys, which must be at most num_pub_keys. One minus
* this number corresponds to the largest age group that is supported with
* this age commitment.
* **Note**, that this and the next field are only relevant on the wallet
* side for attestation and derive operations.
*/
size_t num;
/**
* List of @e num private keys.
*
* Note that the list can be _smaller_ than the corresponding list of public
* keys. In that case, the wallet can sign off only for a subset of the age
* groups.
*
* The list has been allocated via GNUNET_malloc.
*/
struct TALER_AgeCommitmentPrivateKeyP *keys;
};
/**
* @brief Commitment and Proof for a maximum age
*
* Calling TALER_age_restriction_commit on an (maximum) age value returns this
* data structure. It consists of the proof, which is used to create
* attestations for compatible minimum ages, and the commitment, which is used
* to verify the attestations and derived commitments.
*
* The hash value of the commitment is bound to a particular coin with age
* restriction.
*/
struct TALER_AgeCommitmentProof
{
/**
* The commitment is used to verify a particular attestation. Its hash value
* is bound to a particular coin with age restriction. This structure is
* sent to the merchant in order to verify a particular attestation for a
* minimum age.
* In itself, it does not convey any information about the maximum age that
* went into the call to TALER_age_restriction_commit.
*/
struct TALER_AgeCommitment commitment;
/**
* The proof is used to create an attestation for a (compatible) minimum age.
*/
struct TALER_AgeProof proof;
};
/**
* @brief Generates a hash of the public keys in the age commitment.
*
* @param commitment the age commitment - one public key per age group
* @param[out] hash resulting hash
*/
void
TALER_age_commitment_hash (
const struct TALER_AgeCommitment *commitment,
struct TALER_AgeCommitmentHash *hash);
/**
* @brief Generates an age commitent for the given age.
*
* @param mask The age mask the defines the age groups
* @param age The actual age for which an age commitment is generated
* @param seed The seed that goes into the key generation. MUST be chosen uniformly random.
* @param[out] comm_proof The generated age commitment, ->priv and ->pub allocated via GNUNET_malloc() on success
*/
void
TALER_age_restriction_commit (
const struct TALER_AgeMask *mask,
uint8_t age,
const struct GNUNET_HashCode *seed,
struct TALER_AgeCommitmentProof *comm_proof);
/**
* @brief Derives another, equivalent age commitment for a given one.
*
* @param orig Original age commitment
* @param salt Salt to randomly move the points on the elliptic curve in order to generate another, equivalent commitment.
* @param[out] derived The resulting age commitment, ->priv and ->pub allocated via GNUNET_malloc() on success.
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
enum GNUNET_GenericReturnValue
TALER_age_commitment_derive (
const struct TALER_AgeCommitmentProof *orig,
const struct GNUNET_HashCode *salt,
struct TALER_AgeCommitmentProof *derived);
/**
* @brief Provide attestation for a given age, from a given age commitment, if possible.
*
* @param comm_proof The age commitment to be used for attestation. For successful attestation, it must contain the private key for the corresponding age group.
* @param age Age (not age group) for which the an attestation should be done
* @param[out] attest Signature of the age with the appropriate key from the age commitment for the corresponding age group, if applicaple.
* @return #GNUNET_OK on success, #GNUNET_NO when no attestation can be made for that age with the given commitment, #GNUNET_SYSERR otherwise
*/
enum GNUNET_GenericReturnValue
TALER_age_commitment_attest (
const struct TALER_AgeCommitmentProof *comm_proof,
uint8_t age,
struct TALER_AgeAttestation *attest);
/**
* @brief Verify the attestation for an given age and age commitment
*
* @param commitment The age commitment that went into the attestation. Only the public keys are needed.
* @param age Age (not age group) for which the an attestation should be done
* @param attest Signature of the age with the appropriate key from the age commitment for the corresponding age group, if applicaple.
* @return #GNUNET_OK when the attestation was successful, #GNUNET_NO no attestation couldn't be verified, #GNUNET_SYSERR otherwise
*/
enum GNUNET_GenericReturnValue
TALER_age_commitment_verify (
const struct TALER_AgeCommitment *commitment,
uint8_t age,
const struct TALER_AgeAttestation *attest);
/**
* @brief helper function to free memory of a struct TALER_AgeCommitment
*
* @param ac the commitment from which all memory should be freed.
*/
void
TALER_age_commitment_free (
struct TALER_AgeCommitment *ac);
/**
* @brief helper function to free memory of a struct TALER_AgeProof
*
* @param ap the proof of commitment from which all memory should be freed.
*/
void
TALER_age_proof_free (
struct TALER_AgeProof *ap);
/**
* @brief helper function to free memory of a struct TALER_AgeCommitmentProof
*
* @param acp the commitment and its proof from which all memory should be freed.
*/
void
TALER_age_commitment_proof_free (
struct TALER_AgeCommitmentProof *acp);
/**
* @brief helper function to allocate and copy a struct TALER_AgeCommitmentProof
*
* @param[in] acp The original age commitment proof
* @return The deep copy of @e acp, allocated
*/
struct TALER_AgeCommitmentProof *
TALER_age_commitment_proof_duplicate (
const struct TALER_AgeCommitmentProof *acp);
/**
* @brief helper function to copy a struct TALER_AgeCommitmentProof
*
* @param[in] acp The original age commitment proof
* @param[out] nacp The struct to copy the data into, with freshly allocated and copied keys.
*/
void
TALER_age_commitment_proof_deep_copy (
const struct TALER_AgeCommitmentProof *acp,
struct TALER_AgeCommitmentProof *nacp);
/**
* @brief For age-withdraw, clients have to prove that the public keys for all
* age groups larger than the allowed maximum age group are derived by scalar
* multiplication from this Edx25519 public key (in Crockford Base32 encoding):
*
* DZJRF6HXN520505XDAWM8NMH36QV9J3VH77265WQ09EBQ76QSKCG
*
* Its private key was chosen randomly and then deleted.
*/
extern struct
#ifndef AGE_RESTRICTION_WITH_ECDSA
GNUNET_CRYPTO_Edx25519PublicKey
#else
GNUNET_CRYPTO_EcdsaPublicKey
#endif
TALER_age_commitment_base_public_key;
/**
* @brief Similar to TALER_age_restriction_commit, but takes the coin's
* private key as seed input and calculates the public keys in the slots larger
* than the given age as derived from TALER_age_commitment_base_public_key.
*
* See https://docs.taler.net/core/api-exchange.html#withdraw-with-age-restriction
*
* @param secret The master secret of the coin from which we derive the age restriction
* @param mask The age mask, defining the age groups
* @param max_age The maximum age for this coin.
* @param[out] comm_proof The commitment and proof for age restriction for age @a max_age
*/
void
TALER_age_restriction_from_secret (
const struct TALER_PlanchetMasterSecretP *secret,
const struct TALER_AgeMask *mask,
const uint8_t max_age,
struct TALER_AgeCommitmentProof *comm_proof);
/**
* Group of Denominations. These are the common fields of an array of
* denominations.
*
* The corresponding JSON-blob will also contain an array of particular
* denominations with only the timestamps, cipher-specific public key and the
* master signature.
*/
struct TALER_DenominationGroup
{
/**
* Value of coins in this denomination group.
*/
struct TALER_Amount value;
/**
* Fee structure for all coins in the group.
*/
struct TALER_DenomFeeSet fees;
/**
* Cipher used for the denomination.
*/
enum TALER_DenominationCipher cipher;
/**
* Age mask for the denomiation.
*/
struct TALER_AgeMask age_mask;
};
/**
* Compute a unique key for the meta data of a denomination group.
*
* @param dg denomination group to evaluate
* @param[out] key key to set
*/
void
TALER_denomination_group_get_key (
const struct TALER_DenominationGroup *dg,
struct GNUNET_HashCode *key);
#endif
|