summaryrefslogtreecommitdiff
path: root/core/api-common.rst
blob: 987ba6643cc8133566a43558bd3f08c31fe99527 (plain)
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
..
  This file is part of GNU TALER.
  Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
  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 2.1, 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 Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License along with
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>

  @author Christian Grothoff
  @author Marcello Stanisci

.. _http-common:

=================================
Common Taler HTTP API Conventions
=================================


-------------------------
HTTP Request and Response
-------------------------

Certain response formats are common for all requests. They are documented here
instead of with each individual request.  Furthermore, we note that clients may
theoretically fail to receive any response.  In this case, the client should
verify that the Internet connection is working properly, and then proceed to
handle the error as if an internal error (500) had been returned.

.. http:any:: /*


  **Request:**

  Unless specified otherwise, HTTP requests that carry a message body must
  have the content type ``application/json``.

  :reqheader Content-Type: application/json

  **Response:**

  :resheader Content-Type: application/json
  :status 200:
    The request was successful.
  :status 301 Moved Permanently:
    The server responsible for the reserve
    changed, the client MUST follow the link to the new location. If possible,
    the client SHOULD remember the new URL for the reserve for future
    requests.  Only applicable if the request method is GET.
  :status 302 Found:
    The server responsible for the reserve changed, the
    client MUST follow the link to the new location, but MUST NOT retain the
    new URL for future requests.  Only applicable if the request method is GET.
  :status 307 Temporary Redirect:
    The server responsible for the reserve changed, the
    client MUST follow the link to the new location, but MUST NOT retain the
    new URL for future requests.
  :status 308 Permanent Redirect:
    The server responsible for the reserve
    changed, the client MUST follow the link to the new location. If possible,
    the client SHOULD remember the new URL for the reserve for future
    requests.
  :status 500 Internal server error:
    This always indicates some serious internal operational error of the exchange,
    such as a program bug, database problems, etc., and must not be used for
    client-side problems.  When facing an internal server error, clients should
    retry their request after some delay.  We recommended initially trying after
    1s, twice more at randomized times within 1 minute, then the user should be
    informed and another three retries should be scheduled within the next 24h.
    If the error persists, a report should ultimately be made to the auditor,
    although the auditor API for this is not yet specified.  However, as internal
    server errors are always reported to the exchange operator, a good operator
    should naturally be able to address them in a timely fashion, especially
    within 24h.  When generating an internal server error, the exchange responds with
    a JSON object containing the following fields:
  :status 400 Bad Request:
    One of the arguments to the request is missing or malformed.

  Unless specified otherwise, all error status codes (4xx and 5xx) have a message
  body with an `ErrorDetail` JSON object.

  **Details:**

  .. ts:def:: ErrorDetail

    interface ErrorDetail {

      // Numeric `error code <error-codes>` unique to the condition.
      code: number;

      // Human-readable description of the error, i.e. "missing parameter", "commitment violation", ...
      // The other arguments are specific to the error value reported here.
      // Should give a human-readable hint about the error's nature. Optional.
      hint?: string;

      // Name of the parameter that was bogus (if applicable)
      parameter?: string;

      // Path to the argument that was bogus (if applicable)
      path?: string;

      // Offset of the argument that was bogus (if applicable)
      offset?: string;

      // Index of the argument that was bogus (if applicable)
      index?: string;

      // Name of the object that was bogus (if applicable)
      object?: string;

      // Name of the currency thant was problematic (if applicable)
      currency?: string;

      // Expected type (if applicable).
      type_expected?: string;

      // Type that was provided instead (if applicable).
      type_actual?: string;
    }

-----------------------
Protocol Version Ranges
-----------------------

Some of the Taler services (e.g. exchange, merchant, bank integration API)
expose the range of API versions they support.  Clients in turn have an API
version range they support.  These version ranges are written down in the
`libtool version format <https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html>`__.

A protocol version is a positive, non-zero integer.  A protocol version range consists of three components:

1. The ``current`` version.  This is the latest version of the protocol supported by the client or service.
2. The ``revision`` number.  This value should usually not be interpreted by the client/server, but serves
   purely as a comment.  Each time a service/client for a protocol is updated while supporting the same
   set of protocol versions, the revision should be increased.
   In rare cases, the revision number can be used to work around unintended breakage in deployed
   versions of a service.  This is discouraged and should only be used in exceptional situations.
3. The ``age`` number.  This non-zero integer identifies with how many previous protocol versions this
   implementation is compatible.  An ``age`` of 0 implies that the implementation only supports
   the ``current`` protocol version.  The ``age`` must be less or equal than the ``current`` protocol version.

To avoid confusion with semantic versions, the protocol version range is written down in the following format:

.. code:: none

  current[:revision[:age]]

The angle brackets mark optional components. If either ``revision`` or ``age`` are omitted, they default to 0.

Examples:

* "1" and "1" are compatible
* "1" and "2" are **incompatible**
* "2:0:1" and "1:0:0" are compatible
* "2:5:1" and "1:10:0" are compatible
* "4:0:1" and "2:0:0" are **incompatible**
* "4:0:1" and "3:0:0" are compatible

.. note::

  `Semantic versions <https://semver.org/>`__ are not a good tool for this job, as we concisely want to express
  that the client/server supports the last ``n`` versions of the protocol.
  Semantic versions don't support this, and semantic version ranges are too complex for this.

.. warning::

  A client doesn't have one single protocol version range.  Instead, it has
  a protocol version range for each type of service it talks to.

.. warning::

  For privacy reasons, the protocol version range of a client should not be
  sent to the service.  Instead, the client should just use the two version ranges
  to decide whether it will talk to the service.


.. _encodings-ref:

----------------
Common encodings
----------------

This section describes how certain types of values are represented throughout the API.

.. _base32:

Binary Data
^^^^^^^^^^^

.. ts:def:: foobase

  type Base32 = string;

Binary data is generally encoded using Crockford's variant of Base32
(http://www.crockford.com/wrmg/base32.html), except that "U" is not excluded
but also decodes to "V" to make OCR easy.  We will still simply use the JSON
type "base32" and the term "Crockford Base32" in the text to refer to the
resulting encoding.

Hash codes
^^^^^^^^^^
Hash codes are strings representing base32 encoding of the respective hashed
data. See `base32`_.

.. ts:def:: HashCode

  // 64-byte hash code
  type HashCode = string;

.. ts:def:: ShortHashCode

  // 32-byte hash code
  type HashCode = string;

Safe Integers
^^^^^^^^^^^^^

For easier browser-side processing, we restrict some integers to
the range that is safely representable in JavaScript.

.. ts:def:: SafeUint64

  // Subset of numbers:  Integers in the
  // inclusive range 0 .. (2^53 - 1)
  type SafeUint64 = number;

Large numbers
^^^^^^^^^^^^^

Large numbers such as RSA blinding factors and 256 bit  keys, are transmitted
as other binary data in Crockford Base32 encoding.

Timestamps
^^^^^^^^^^

Timestamps are represented by the following structure:

.. ts:def:: Timestamp

  interface Timestamp {
    // Milliseconds since epoch, or the special
    // value "forever" to represent an event that will
    // never happen.
    t_ms: number | "never";
  }

.. ts:def:: RelativeTime

  interface Duration {
    // Duration in milliseconds or "forever"
    // to represent an infinite duration.
    d_ms: number | "forever";
  }


.. _public\ key:


Integers
^^^^^^^^

.. ts:def:: Integer

  // JavaScript numbers restricted to integers
  type Integer = number;

Objects
^^^^^^^

.. ts:def:: Object

  // JavaScript objects, no further restrictions
  type Object = object;

Keys
^^^^

.. ts:def:: EddsaPublicKey

   // EdDSA and ECDHE public keys always point on Curve25519
   // and represented  using the standard 256 bits Ed25519 compact format,
   // converted to Crockford `Base32`.
   type EddsaPublicKey = string;

.. ts:def:: EddsaPrivateKey

   // EdDSA and ECDHE public keys always point on Curve25519
   // and represented  using the standard 256 bits Ed25519 compact format,
   // converted to Crockford `Base32`.
   type EddsaPrivateKey = string;

.. ts:def:: EcdhePublicKey

   // EdDSA and ECDHE public keys always point on Curve25519
   // and represented  using the standard 256 bits Ed25519 compact format,
   // converted to Crockford `Base32`.
   type EcdhePublicKey = string;

.. ts:def:: EcdhePrivateKey

   // EdDSA and ECDHE public keys always point on Curve25519
   // and represented  using the standard 256 bits Ed25519 compact format,
   // converted to Crockford `Base32`.
   type EcdhePrivateKey = string;

.. ts:def:: CoinPublicKey

   type CoinPublicKey = EddsaPublicKey;

.. ts:def:: RsaPublicKey

   // RSA public key converted to Crockford `Base32`.
   type RsaPublicKey = string;

.. _blinded-coin:

Blinded coin
^^^^^^^^^^^^

.. ts:def:: CoinEnvelope

  // Blinded coin's `public EdDSA key <eddsa-coin-pub>`, `base32` encoded
  type CoinEnvelope = string;

.. _signature:

Signatures
^^^^^^^^^^


.. ts:def:: EddsaSignature

  // EdDSA signatures are transmitted as 64-bytes `base32`
  // binary-encoded objects with just the R and S values (base32_ binary-only)
  type EddsaSignature = string;

.. ts:def:: RsaSignature

  // `base32` encoded RSA signature
  type RsaSignature = string;

.. ts:def:: BlindedRsaSignature

  // `base32` encoded RSA blinded signature
  type BlindedRsaSignature = string;

.. ts:def:: RsaBlindingKeySecret

  // `base32` encoded RSA blinding secret
  type RsaBlindingKeySecret = string;

.. _amount:

Amounts
^^^^^^^

.. ts:def:: Amount

  type Amount = string;

Amounts of currency are serialized as a string of the format ``<Currency>:<DecimalAmount>``.
Taler treats monetary amounts as fixed-precision numbers.  Unlike floating point numbers,
this allows accurate representation of monetary amounts.

The following constrains apply for a valid amount:

1. The ``<Currency>`` part must be at most 12 characters long and may not contain a colon (``:``).
2. The integer part of ``<DecimalAmount>`` may be at most 2^52
3. the fractional part of ``<DecimalAmount>`` may contain at most 8 decimal digits.

Internally, amounts are parsed into the following object:

.. note::

  "EUR:1.50" and "EUR:10" are is a valid amounts.  These are all invalid amounts: "A:B:1.5", "EUR:4503599627370501.0", "EUR:1.", "EUR:.1"

.. ts:def:: ParsedAmount

  interface ParsedAmount {
    // Name of the currency using either a three-character ISO 4217 currency
    // code, or a regional currency identifier starting with a "*" followed by
    // at most 10 characters.  ISO 4217 exponents in the name are not supported,
    // although the "fraction" is corresponds to an ISO 4217 exponent of 6.
    currency: string;

    // Non-negative integer value in the currency, can be at most 2^52.
    // Note that "1" here would correspond to 1 EUR or 1 USD,
    // depending on `currency`, not 1 cent.
    value: number;

    // Unsigned 32 bit fractional value to be added to ``value`` representing
    // an additional currency fraction, in units of one hundred millionth (1e-8)
    // of the base currency value.  For example, a fraction
    // of 50,000,000 would correspond to 50 cents.
    fraction: number;
  }


An amount that is prefixed with a ``+`` or ``-`` character is also used in certain contexts.
When no sign is present, the amount is assumed to be positive.

.. ts:def:: SignedAmount

  type SignedAmount = string;

Images
^^^^^^

.. ts:def:: ImageDataUrl

  // The string must be a data URL according to RFC 2397
  // with explicit mediatype and base64 parameters.
  //
  //     ``data:<mediatype>;base64,<data>``
  //
  // Supported mediatypes are ``image/jpeg`` and ``image/png``.
  // Invalid strings will be rejected by the wallet.
  type ImageDataUrl = string;


--------------
Binary Formats
--------------

.. note::

   Due to the way of handling "big" numbers by some platforms (such as
   JavaScript, for example), wherever the following specification mentions
   a 64-bit value, the actual implementations are strongly advised to rely on
   arithmetic up to 53 bits.

.. note::

   Taler uses ``libgnunetutil`` for interfacing itself with the operating system,
   doing crypto work, and other "low level" actions, therefore it is strongly
   connected with the `GNUnet project <https://gnunet.org>`_.

This section specifies the binary representation of messages used in Taler's
protocols. The message formats are given in a C-style pseudocode notation.
Padding is always specified explicitly, and numeric values are in network byte
order (big endian).

Amounts
^^^^^^^

Amounts of currency are always expressed in terms of a base value, a fractional
value and the denomination of the currency:

.. sourcecode:: c

  struct TALER_Amount {
    uint64_t value;
    uint32_t fraction;
    uint8_t currency_code[12]; // i.e. "EUR" or "USD"
  };
  struct TALER_AmountNBO {
    uint64_t value;            // in network byte order
    uint32_t fraction;         // in network byte order
    uint8_t currency_code[12];
  };


Time
^^^^

In signed messages, time is represented using 64-bit big-endian values,
denoting microseconds since the UNIX Epoch.  ``UINT64_MAX`` represents "never".

.. sourcecode:: c

  struct GNUNET_TIME_Absolute {
    uint64_t timestamp_us;
  };
  struct GNUNET_TIME_AbsoluteNBO {
    uint64_t abs_value_us__;       // in network byte order
  };

Cryptographic primitives
^^^^^^^^^^^^^^^^^^^^^^^^

All elliptic curve operations are on Curve25519.  Public and private keys are
thus 32 bytes, and signatures 64 bytes.  For hashing, including HKDFs, Taler
uses 512-bit hash codes (64 bytes).

.. sourcecode:: c

   struct GNUNET_HashCode {
     uint8_t hash[64];      // usually SHA-512
   };

.. _reserve-pub:
.. sourcecode:: c

   struct TALER_ReservePublicKeyP {
     uint8_t eddsa_pub[32];
   };

.. _reserve-priv:
.. sourcecode:: c

   struct TALER_ReservePrivateKeyP {
     uint8_t eddsa_priv[32];
   };

   struct TALER_ReserveSignatureP {
     uint8_t eddsa_signature[64];
   };

.. _merchant-pub:
.. sourcecode:: c

   struct TALER_MerchantPublicKeyP {
     uint8_t eddsa_pub[32];
   };

   struct TALER_MerchantPrivateKeyP {
     uint8_t eddsa_priv[32];
   };

   struct TALER_TransferPublicKeyP {
     uint8_t ecdhe_pub[32];
   };

   struct TALER_TransferPrivateKeyP {
     uint8_t ecdhe_priv[32];
   };

.. _sign-key-pub:
.. sourcecode:: c

   struct TALER_ExchangePublicKeyP {
     uint8_t eddsa_pub[32];
   };

.. _sign-key-priv:
.. sourcecode:: c

   struct TALER_ExchangePrivateKeyP {
     uint8_t eddsa_priv[32];
   };

.. _eddsa-sig:
.. sourcecode:: c

   struct TALER_ExchangeSignatureP {
     uint8_t eddsa_signature[64];
   };

   struct TALER_MasterPublicKeyP {
     uint8_t eddsa_pub[32];
   };

   struct TALER_MasterPrivateKeyP {
     uint8_t eddsa_priv[32];
   };

    struct TALER_MasterSignatureP {
     uint8_t eddsa_signature[64];
   };

.. _WireTransferIdentifierRawP:
.. sourcecode:: c

   struct WireTransferIdentifierRawP {
     uint8_t raw[32];
   };

.. _UUID:
.. sourcecode:: c

   struct UUID {
     uint32_t value[4];
   };

.. _eddsa-coin-pub:
.. sourcecode:: c

   union TALER_CoinSpendPublicKeyP {
     uint8_t eddsa_pub[32];
     uint8_t ecdhe_pub[32];
   };

.. _coin-priv:
.. sourcecode:: c

   union TALER_CoinSpendPrivateKeyP {
     uint8_t eddsa_priv[32];
     uint8_t ecdhe_priv[32];
   };

   struct TALER_CoinSpendSignatureP {
     uint8_t eddsa_signature[64];
   };

   struct TALER_TransferSecretP {
     uint8_t key[sizeof (struct GNUNET_HashCode)];
   };
     uint8_t key[sizeof (struct GNUNET_HashCode)];
   };

   struct TALER_EncryptedLinkSecretP {
     uint8_t enc[sizeof (struct TALER_LinkSecretP)];
   };

.. _Signatures:

Signatures
^^^^^^^^^^
Any piece of signed data, complies to the abstract data structure given below.

.. sourcecode:: c

  struct Data {
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    type1_t payload1;
    type2_t payload2;
    ...
  };

  /*From gnunet_crypto_lib.h*/
  struct GNUNET_CRYPTO_EccSignaturePurpose {
    /**

    The following constrains apply for a valid amount:

    * asd
     * This field is used to express the context in
     * which the signature is made, ensuring that a
     * signature cannot be lifted from one part of the protocol
     * to another. See `src/include/taler_signatures.h` within the
     * exchange's codebase (git://taler.net/exchange)
     */
    uint32_t purpose;
    /**
     * This field equals the number of bytes being signed,
     * namely 'sizeof (struct Data)'
     */
    uint32_t size;
  };


The following list contains all the data structure that can be signed in
Taler. Their definition is typically found in ``src/include/taler_signatures.h``,
within the
`exchange's codebase <https://docs.taler.net/global-licensing.html#exchange-repo>`_.

.. _TALER_WithdrawRequestPS:
.. sourcecode:: c

  struct TALER_WithdrawRequestPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct TALER_ReservePublicKeyP reserve_pub;
    struct TALER_AmountNBO amount_with_fee;
    struct TALER_AmountNBO withdraw_fee;
    struct GNUNET_HashCode h_denomination_pub;
    struct GNUNET_HashCode h_coin_envelope;
  };

.. _TALER_DepositRequestPS:
.. sourcecode:: c

  struct TALER_DepositRequestPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_WALLET_COIN_DEPOSIT
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_contract_terms;
    struct GNUNET_HashCode h_wire;
    struct GNUNET_HashCode h_denom_pub;
    struct GNUNET_TIME_AbsoluteNBO timestamp;
    struct GNUNET_TIME_AbsoluteNBO refund_deadline;
    struct TALER_AmountNBO amount_with_fee;
    struct TALER_AmountNBO deposit_fee;
    struct TALER_MerchantPublicKeyP merchant;
    union TALER_CoinSpendPublicKeyP coin_pub;
  };

.. _TALER_DepositConfirmationPS:
.. sourcecode:: c

  struct TALER_DepositConfirmationPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_WALLET_CONFIRM_DEPOSIT
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_contract_terms;
    struct GNUNET_HashCode h_wire;
    struct GNUNET_TIME_AbsoluteNBO timestamp;
    struct GNUNET_TIME_AbsoluteNBO refund_deadline;
    struct TALER_AmountNBO amount_without_fee;
    union TALER_CoinSpendPublicKeyP coin_pub;
    struct TALER_MerchantPublicKeyP merchant;
  };

.. _TALER_RefreshCommitmentP:
.. sourcecode:: c

  // FIXME: put definition here

.. _TALER_RefreshMeltCoinAffirmationPS:
.. sourcecode:: c

  struct TALER_RefreshMeltCoinAffirmationPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_WALLET_COIN_MELT
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode session_hash;
    struct GNUNET_HashCode h_denom_pub;
    struct TALER_AmountNBO amount_with_fee;
    struct TALER_AmountNBO melt_fee;
    union TALER_CoinSpendPublicKeyP coin_pub;
  };

.. _TALER_RefreshMeltConfirmationPS:
.. sourcecode:: c

  struct TALER_RefreshMeltConfirmationPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode session_hash;
    uint16_t noreveal_index;
  };

.. _TALER_ExchangeSigningKeyValidityPS:
.. sourcecode:: c

  struct TALER_ExchangeSigningKeyValidityPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct TALER_MasterPublicKeyP master_public_key;
    struct GNUNET_TIME_AbsoluteNBO start;
    struct GNUNET_TIME_AbsoluteNBO expire;
    struct GNUNET_TIME_AbsoluteNBO end;
    struct TALER_ExchangePublicKeyP signkey_pub;
  };

  struct TALER_ExchangeKeySetPS {
      /**
       * purpose.purpose = TALER_SIGNATURE_EXCHANGE_KEY_SET
       */
      struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
      struct GNUNET_TIME_AbsoluteNBO list_issue_date;
      struct GNUNET_HashCode hc;
  };

.. _TALER_DenominationKeyValidityPS:
.. sourcecode:: c

  struct TALER_DenominationKeyValidityPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct TALER_MasterPublicKeyP master;
    struct GNUNET_TIME_AbsoluteNBO start;
    struct GNUNET_TIME_AbsoluteNBO expire_withdraw;
    struct GNUNET_TIME_AbsoluteNBO expire_spend;
    struct GNUNET_TIME_AbsoluteNBO expire_legal;
    struct TALER_AmountNBO value;
    struct TALER_AmountNBO fee_withdraw;
    struct TALER_AmountNBO fee_deposit;
    struct TALER_AmountNBO fee_refresh;
    struct GNUNET_HashCode denom_hash;
  };

.. _TALER_MasterWireDetailsPS:
.. sourcecode:: c

  struct TALER_MasterWireDetailsPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_MASTER_WIRE_DETAILS
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_wire_details;
  };


.. _TALER_MasterWireFeePS:
.. sourcecode:: c

  struct TALER_MasterWireFeePS {
    /**
     * purpose.purpose = TALER_SIGNATURE_MASTER_WIRE_FEES
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_wire_method;
    struct GNUNET_TIME_AbsoluteNBO start_date;
    struct GNUNET_TIME_AbsoluteNBO end_date;
    struct TALER_AmountNBO wire_fee;
    struct TALER_AmountNBO closing_fee;
  };

.. _TALER_DepositTrackPS:
.. sourcecode:: c

  struct TALER_DepositTrackPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_MASTER_SEPA_DETAILS || TALER_SIGNATURE_MASTER_TEST_DETAILS
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_contract_terms;
    struct GNUNET_HashCode h_wire;
    struct TALER_MerchantPublicKeyP merchant;
    struct TALER_CoinSpendPublicKeyP coin_pub;
  };

.. _TALER_WireDepositDetailP:
.. sourcecode:: c

  struct TALER_WireDepositDetailP {
    struct GNUNET_HashCode h_contract_terms;
    struct GNUNET_TIME_AbsoluteNBO execution_time;
    struct TALER_CoinSpendPublicKeyP coin_pub;
    struct TALER_AmountNBO deposit_value;
    struct TALER_AmountNBO deposit_fee;
  };


.. _TALER_WireDepositDataPS:
.. _TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT:
.. sourcecode:: c

  struct TALER_WireDepositDataPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct TALER_AmountNBO total;
    struct TALER_AmountNBO wire_fee;
    struct TALER_MerchantPublicKeyP merchant_pub;
    struct GNUNET_HashCode h_wire;
    struct GNUNET_HashCode h_details;
  };

.. _TALER_ExchangeKeyValidityPS:
.. sourcecode:: c

  struct TALER_ExchangeKeyValidityPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode auditor_url_hash;
    struct TALER_MasterPublicKeyP master;
    struct GNUNET_TIME_AbsoluteNBO start;
    struct GNUNET_TIME_AbsoluteNBO expire_withdraw;
    struct GNUNET_TIME_AbsoluteNBO expire_spend;
    struct GNUNET_TIME_AbsoluteNBO expire_legal;
    struct TALER_AmountNBO value;
    struct TALER_AmountNBO fee_withdraw;
    struct TALER_AmountNBO fee_deposit;
    struct TALER_AmountNBO fee_refresh;
    struct GNUNET_HashCode denom_hash;
  };

.. _TALER_PaymentResponsePS:
.. sourcecode:: c

  struct PaymentResponsePS {
    /**
     * purpose.purpose = TALER_SIGNATURE_MERCHANT_PAYMENT_OK
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_contract_terms;
  };

.. _TALER_ContractPS:
.. sourcecode:: c

  struct TALER_ContractPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_MERCHANT_CONTRACT
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct TALER_AmountNBO total_amount;
    struct TALER_AmountNBO max_fee;
    struct GNUNET_HashCode h_contract_terms;
    struct TALER_MerchantPublicKeyP merchant_pub;
  };

.. _TALER_ConfirmWirePS:
.. _TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE:
.. sourcecode:: c

  struct TALER_ConfirmWirePS {
    /**
     * purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_wire;
    struct GNUNET_HashCode h_contract_terms;
    struct TALER_WireTransferIdentifierRawP wtid;
    struct TALER_CoinSpendPublicKeyP coin_pub;
    struct GNUNET_TIME_AbsoluteNBO execution_time;
    struct TALER_AmountNBO coin_contribution;
  };

.. _TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND:
.. sourcecode:: c

  // FIXME: put definition here

.. _TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION:
.. sourcecode:: c

  // FIXME: put definition here

.. _TALER_RefundRequestPS:
.. sourcecode:: c

  struct TALER_RefundRequestPS {
    /**
     *  purpose.purpose = TALER_SIGNATURE_MERCHANT_REFUND
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_contract_terms;
    struct TALER_CoinSpendPublicKeyP coin_pub;
    struct TALER_MerchantPublicKeyP merchant;
    uint64_t rtransaction_id;
    struct TALER_AmountNBO refund_amount;
    struct TALER_AmountNBO refund_fee;
  };

  struct TALER_MerchantRefundConfirmationPS {
    /**
     *  purpose.purpose = TALER_SIGNATURE_MERCHANT_REFUND_OK
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    /**
     * Hash of the order ID (a string), hashed without the 0-termination.
     */
    struct GNUNET_HashCode h_order_id;
  };


.. _TALER_RecoupRequestPS:
.. sourcecode:: c

  struct TALER_RecoupRequestPS {
    /**
     *  purpose.purpose = TALER_SIGNATURE_WALLET_COIN_RECOUP
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct TALER_CoinSpendPublicKeyP coin_pub;
    struct GNUNET_HashCode h_denom_pub;
    struct TALER_DenominationBlindingKeyP coin_blind;
  };

.. _TALER_RecoupRefreshConfirmationPS:
.. sourcecode:: c

  struct TALER_RecoupRefreshConfirmationPS {

    /**
     * purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_TIME_AbsoluteNBO timestamp;
    struct TALER_AmountNBO recoup_amount;
    struct TALER_CoinSpendPublicKeyP coin_pub;
    struct TALER_CoinSpendPublicKeyP old_coin_pub;
  };

.. _TALER_RecoupConfirmationPS:
.. sourcecode:: c

  struct TALER_RecoupConfirmationPS {
    /**
     *  purpose.purpose = TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_TIME_AbsoluteNBO timestamp;
    struct TALER_AmountNBO recoup_amount;
    struct TALER_CoinSpendPublicKeyP coin_pub;
    struct TALER_ReservePublicKeyP reserve_pub;
  };


.. _TALER_ReserveCloseConfirmationPS:
.. sourcecode:: c

  struct TALER_ReserveCloseConfirmationPS {
    /**
     * purpose.purpose = TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_TIME_AbsoluteNBO timestamp;
    struct TALER_AmountNBO closing_amount;
    struct TALER_ReservePublicKeyP reserve_pub;
    struct GNUNET_HashCode h_wire;
  };

.. _TALER_CoinLinkSignaturePS:
.. sourcecode:: c

  struct TALER_CoinLinkSignaturePS {
    /**
     * purpose.purpose = TALER_SIGNATURE_WALLET_COIN_LINK
     */
    struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    struct GNUNET_HashCode h_denom_pub;
    struct TALER_CoinSpendPublicKeyP old_coin_pub;
    struct TALER_TransferPublicKeyP transfer_pub;
    struct GNUNET_HashCode coin_envelope_hash;
  };