summaryrefslogtreecommitdiff
path: root/design-documents/024-age-restriction.rst
blob: 7109a679ace4958f85a1aa4d9dcb815602711da0 (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
DD 024: Anonymous Age Restriction Extension for GNU Taler
#########################################################

Summary
=======

This document presents and discusses an extension to GNU Taler that provides
anonymous age-restriction.

Motivation
==========

Merchants are legally obliged to perform age verification of customers when
they buy certain goods and services.  Current mechanisms for age verification
are either ID-based or require the usage of credit/debit cards.  In all cases
sensitive private information is disclosed.

We want to offer a better mechanism for age-restriction with GNU Taler that

* ensures anonymity and unlinkability of purchases
* can be set to particular age groups by parents/wardens at withdrawal 
* is bound to particular coins/tokens
* can be verified by the merchant at purchase time
* persists even after refresh

The mechanism is presented as an 'extension' to GNU Taler, that is, as an
optional feature that can be switched on by the exchange operator.

Requirements
============

TODO

* legal requirements for merchants must allow for this kind of mechanism


Proposed Solution
=================

We propose an extension to GNU Taler for age-restriction that can be enabled by
an Exchange¹).

Once enabled, coins with age restrictions can be withdrawn by parents/warden
who can choose to **commit** the coins to a certain maximum age out of a
predefined list of age groups.

The minors/wards receive those coins and can now **attest** a required minimum
age (provided that age is less or equal to the committed age of the coins) to
merchants, who can **verify** the minimum age.

For the rest values (change) after an transaction, the minor/ward can
**derive** new age-restricted coins.  The exchange can **compare** the equality
of the age-restriction of the old coin with the new coin (in a zero-knowledge
protocol, that gives the minor/ward a 1/κ chance to raise the minimum age for
the new coin).

The proposed solution maintains the guarantees of GNU Taler with respect to
anonymity and unlinkability. (TODO: refer to the paper, once published)

¹) Once the feature is enabled and the age groups are defined, the exchange has
to stick to that decision until the support for age restriction is disabled.
We might reconsider this design decision at some point.


Main ideas and building blocks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The main ideas are simple:

#. The exchange defines and publishes M+1 different *age groups* of increasing
   order: :math:`0 < a_1 < \ldots < a_M` with :math:`a_i \in \mathbb{N}`.  The
   zeroth age group is :math:`\{0,\ldots,a_1-1\}`.

#. An **unrestricted** *age commitment* is defined as a vector of length M of
   pairs of EdDSA public and private keys on Curve25519. In other words: one
   key pair for each age group after the zeroth:
   :math:`\bigl\langle (p_1, s_1), \ldots, (p_M, s_M) \bigr\rangle`

#. A **restricted** *age commitment* **to age group m** (or m-th age group) is
   derived from an unrestricted age commitment by removing all private keys for
   indices larger than m: :math:`\bigl\langle (p_1, s_1), \ldots, (p_m, s_m),
   \, (p_{m+1}, \perp), \ldots, (p_M, \perp )\bigr\rangle`.
   F.e. if *none* of the private keys is provided, the age commitment would be
   restricted to the zeroth age group.

#. The act of restricting an unrestricted age commitment is performed by the
   parent/ward.

#. An *age commitment* (without prefix) is just the vector of public keys:
   :math:`\vec{Q} := \langle p_1, \ldots, p_M \rangle`.  Note that from
   just the age commitment one can not deduce if it was originated from an
   unrestricted or restricted age commitment (and what age).

#. An *attestation of age group k* is essentially the signature to any message
   with the private key for slot k, if the corresponding private key is
   available in a restricted age commitment.  (Unrestricted age commitments can
   attest for any age group).

#. An age commitment is *bound to a particular coin* by incorporating the
   SHA256 hash value of the age commitment (i.e. the M public keys) into the
   signature of the coin.  So instead of signing :math:`\text{FDH}_N(C_p)` with
   the RSA private key of a denomination with support for age restriction, we
   sign :math:`\text{FDH}_N(C_p, h_a)`.  Here, :math:`C_p` is the EdDSA public
   key of a coin and :math:`h_a` is the hash of the age commitment.

TODO: Summarize the design based on the five functions ``Commit()``,
``Attest()``, ``Verify()``, ``Derive()``, ``Compare()``, once the paper from
Özgür and Christian is published.


Changes in the Exchange API
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The necessary changes in the exchange involve

* indication of support for age restriction as an extension
* modification of the refresh protocol (both, commit and reveal phase)
* modification of the deposit protocol


Extension for age restriction
-----------------------------

.. note::

  Registering an extension is defined in
  :doc:`design document 006 ― Extensions <006-extensions>`.


The exchange indicates support for age-restriction in response to ``/keys`` by
registering the extension ``age_restriction`` with a value type
``ExtensionAgeRestriction``:

.. ts:def:: ExtensionAgeRestriction

   interface ExtensionAgeRestriction {
      // The field ``critical`` is mandatory for an extension.
      // Age restriction is not required to be understood by an client, so
      // ``critical`` will be set to ``false``.
      critical: false;

      // The field ``version`` is mandatory for an extension.  It is of type
      // `LibtoolVersion`.
      version: "1";

      // Age restriction specific fields
     
      // The age groups.  This field is mandatory and binding in the sense
      // that its value is taken into consideration when signing the
      // denominations in `ExchangeKeysResponse`.``age_restricted_denoms``.
      age_groups: AgeGroups;
   }

Age Groups
~~~~~~~~~~

Age groups are represented as a finite list of positive, increasing integers
that mark the beginning of the *next* age group.  The value 0 is ommited but
implicitly marks the beginning of the *zeroth* age group and the first number
in the list marks the beginning of the *first* age group.  Age groups are
encoded as a colon separated string of integer values.  They are refered to by
their *slot*, i.e.  "age group 3" is the age group that starts with the 3.
integer in the list.

For example: the string "8:10:12:14:16:18:21" represents the age groups

0. {0,1,2,3,4,5,6,7}
#. {8,9}
#. {10,11}
#. {12,13}
#. {14,15}
#. {16,17}
#. {18,19,20}
#. {21, ⋯ }

The field ``age_groups`` of type `AgeGroups` is mandatory and binding in the
sense that its value is taken into consideration when signing the denominations
in ``ExchangeKeysResponse.age_restricted_denoms``.

.. ts:def:: AgeGroups

   // Representation of the age groups as colon separated edges: Increasing
   // from left to right, the values mark the begining of an age group up
   // to, but not including the next value.  The initial age group starts at
   // 0 and is not listed.  Example: "8:10:12:14:16:18:21".
   type AgeGroups = string;


Age restricted denominations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If age-restriction is registered as an extension under the name
``age_restriction``, as described above, the root-object
``ExchangeKeysResponse`` in response to ``/keys`` MUST be extended by an
additional field ``age_restricted_denoms``.  This is an *additional* list of
denominations that must be used during the modified ``refresh`` and ``deposit``
operations (see below).

The data structure for those denominations is the same as for the regular ones
in ``ExchangeKeysResponse.denoms``.  **However**, the following differences
apply for each denomination in the list:

1. The value of ``TALER_DenominationKeyValidityPS.denom_hash``
   is taken over the public key of the denomination **and** the string in
   ``ExtensionAgeRestriction.age_groups`` from the corresponding extension
   object (see above).

2. The value of ``TALER_DenominationKeyValidityPS.purpose`` is set to
   ``TALER_SIGNATURE_MASTER_AGE_RESTRICTED_DENOMINATION_KEY_VALIDITY``.

And similar to ``.denoms``, if the query parameter ``last_issue_date`` was
provided by the client, the exchange will only return the keys that have
changed since the given timestamp.


.. ts:def:: ExchangeKeysResponse

   interface ExchangeKeysResponse {
   //...

   // List of denominations that support age-restriction with the age groups
   // given in age_groups.  This is only set **iff** the extension
   // ``age_restriction`` is registered under ``entensions`` with type
   // ``ExtensionAgeRestriction``.
   //
   // The data structure for each denomination is the same as for the
   // denominations in ExchangeKeysResponse.denoms.  **However**, the
   // following differences apply for each denomination in the list:
   //
   //  1. The value of ``TALER_DenominationKeyValidityPS.denom_hash``
   //     is taken over the public key of the denomination __and__ the
   //     string in ``ExtensionAgeRestriction.age_groups`` from the
   //     corresponding extension object.
   //
   //  2. The value of ``TALER_DenominationKeyValidityPS.purpose`` is set to
   //     ``TALER_SIGNATURE_MASTER_AGE_RESTRICTED_DENOMINATION_KEY_VALIDITY``
   //
   // Similar as for ``.denoms``, if the query parameter ``last_issue_date``
   // was provided by the client, the exchange will only return the keys that
   // have changed since the given timestamp.
   age_restricted_denoms: Denom[];

   //...
   }


SQL changes
-----------

The exchange has to mark denominations with support for age restriction as such
in the database.  Also, during the melting phase of the refresh operation, the
exchange will have to persist the SHA256 hash of the age commitment of the
original coin.

The schema for the exchange is changed as follows:

.. sourcecode:: sql

   -- Everything in one big transaction
   BEGIN;
   -- Check patch versioning is in place.
   SELECT _v.register_patch('exchange-TBD', NULL, NULL);
   
   -- Support for age restriction is marked per denomination.
   ALTER TABLE denominations
     ADD COLUMN age_restricted BOOLEAN NOT NULL DEFAULT (false);
   COMMENT ON COLUMN denominations.age_restriced
     IS 'true if this denomination can be used for age restriction';

   -- During the melting phase of the refresh, the wallet has to present the 
   -- hash value of the age commitment (only for denominations with support 
   -- for age restriction).
   ALTER TABLE refresh_commitments
     ADD COLUMN age_commitment_h BYTEA CHECK (LENGTH(age_commitment_h)=64);
   COMMENT ON COLUMN refresh_commitments.age_commitment_h
     IS 'SHA256 hash of the age commitment of the old coin, iff the corresponding
         denomimination has support for age restriction, NULL otherwise.';
   COMMIT;

Note the constraint on ``refresh_commitments.age_commitment_h``:  It can be
NULL, but only iff the corresponding denomination (indirectly referenced via
table ``known_coins``) has ``.age_restricted`` set to true.  This constraint
can not be expressed reliably with SQL.

Protocol changes
----------------

Refresh - melting phase
~~~~~~~~~~~~~~~~~~~~~~~

During the melting phase of the refresh, the wallet has to present the hash
value of the age commitment (for denominations with support for age
restriction).  Therefore, in the ``/coins/$COIN_PUB/melt`` POST request, the
``MeltRequest`` object is extended with an optional field
``age_commitment_hash``:

.. ts:def:: MeltRequest

   interface MeltRequest {
      ...

      // SHA256 hash of the age commitment of the coin, IFF the denomination
      // has age restriction support.  MUST be omitted otherwise.
      age_commitment_hash?: AgeCommitmentHash;
      
      ...
   }

.. ts:def:: AgeCommitmentHash

   type AgeCommitmentHash = SHA256HashCode;

The responses to the POST request remain the same.

For normal denominations *without* support for age restriction, the calculation
for the signature check is as before (borrowing notation from 
`Florian's thesis <https://taler.net/papers/thesis-dold-phd-2019.pdf>`_):

.. math::
   \text{FDH}_N(C_p)\; \stackrel{?}{=}\; \left(\sigma_C\right)^{e} \;\;\text{mod}\,N

Here, :math:`C_p` is the EdDSA public key of a coin, :math:`\sigma_C` is its
signature and :math:`\langle e, N \rangle` is the RSA public key of the
denomination.

For denominations *with* support for age restriction, the exchange takes the
hash value ``age_commitment_hash`` (abbreviated as :math:`h_a`) into account
when verifying the coin's signature:

.. math::
   \text{FDH}_N(C_p, h_a)\; \stackrel{?}{=}\; \left(\sigma_C\right)^{e} \;\;\text{mod}N




Refresh - reveal phase
~~~~~~~~~~~~~~~~~~~~~~

During the reveal phase -- that is upon POST to ``/refreshes/$RCH/reveal`` --
the client has to provide the original age commitment of the old coin (i.e. the
vector of public keys), iff the corresponding denomination had support for age
restriction.  The size of the vector ist defined by the Exchange implicetly as
the amount of age groups defined in the field ``.age_groups`` of the
``ExtensionAgeRestriction``.

.. ts:def:: RevealRequest
   
   interface RevealRequest {
      ...

      // Iff the corresponding denomination has support for age restriction,
      // the client MUST provide the original age commitment, i.e. the vector
      // of public keys.
      // The size of the vector ist defined by the Exchange implicetly as the
      // amount of age groups defined in the field ``.age_groups`` of the
      // ``ExtensionAgeRestriction``.
      old_age_commitment?: EddsaPublicKey[];

      
      ...
   }

TODO: describe how the exchange derives the κ-1 other age-restriction vectors
and compares them to the one in ``.old_age_commitment``.


Deposit
~~~~~~~

As always, the merchant has to provide the public key of a coin during a POST
to ``/coins/$COIN_PUB/deposit``.  However, for coins with age restriction, the
signature check requires the hash of the age commitment.  Therefore the request
object ``DepositRequest`` is extended by an optional field
``age_commitment_hash`` which MUST be set (with the SHA256 hash of the age
commitment), iff the corresponding denomination had support for age restriction
enabled.  The merchant has received this value prior from the customer during
purchase.

.. ts:def:: DepositRequest

   interface DepositRequest {
   ...

   // Iff the corresponding denomination had support for age restriction
   // enabled, this field MUST contain the SHA256 value of the age commitment that
   // was provided during the purchase.
   age_commitment_hash?: AgeCommitmentHash;

   ...
   }

Again, the exchange can now check the validity of the coin with age restriction
by evaluating

.. math::
   \text{FDH}_N(C_p, h_a)\; \stackrel{?}{=}\; \left(\sigma_C\right)^{e} \;\;\text{mod}N

Also again, :math:`C_p` is the EdDSA public key of a coin, :math:`\sigma_C` is
its signature, :math:`\langle e, N \rangle` is the RSA public key of the
denomination and :math:`h_a` is the value from ``age_commitment_hash``.



Changes in the Merchant API
^^^^^^^^^^^^^^^^^^^^^^^^^^^


Claiming the order
------------------

If an order requires a minimum age, the merchant MUST express that required
minimum age in response to order claim by the wallet, that is, a POST to
``[/instances/$INSTANCE]/orders/$ORDER_ID/claim``.

The object ``ContractTerms`` is extended by an optional field
``required_minimum_age`` that can be any integer greater than 0.  In reality
this value will not be smaller than, say, 8, and not larger than, say, 21.

.. ts:def:: ContractTerms

   interface ContractTerms {
   ...
   
   // If the order requires a minimum age greater than 0, this field is set
   // to the integer value of that age.  In reality this value will not be
   // smaller than, say, 8, and not larger than, say, 21.
   required_minimum_age?: Integer;

   ...
   }

By sending the contract term with the field ``required_minimum_age`` set to an
non-zero integer value, the merchant implicetly signals that it understands the
extension ``age_restriction`` for age restriction from the exchange.


Making the payment
------------------

If the ``ContractTerms`` had a non-zero value in field
``required_minimum_age``, the wallet has to provide evidence of that minimum
age by

#. *either* using coins which are of denominations that had *no* age support
   enabled,

#. *or* using coins which are of denominations that have support for age
   restriction enabled

   * and then  ―for each such coin― it has the right private key of the
     restricted age commitment to the age group into which the required minimum
     age falls (i.e.  a non-empty entry at the right index in vector of EdDSA
     keys, see above).

   * and signs the required minimum age with each coin's private key
     corresponding to the age group,

   * and sends ―for each coin― the complete age commitment and the signature to
     the merchant.

The object ``CoinPaySig`` used within a ``PayRequest`` during a POST to
``[/instances/$INSTANCE]/orders/$ORDER_ID/pay`` is extended as follows:

.. ts:def:: CoinPaySig

   export interface CoinPaySig {
   ...

   // If a minimum age was required by the order and the wallet had coins that
   // are at least commited to the corresponding age group, this is the
   // signature of the minimum age as a string, using the private key to the
   // corresponding age group.
   minimum_age_sig?: EddsaSignature;

   // If a minium age was required by the order, this is age commitment bound
   // to the coin, i.e. the complete vector of EdDSA public keys, one for each
   // age group (as defined by the exchange).
   age_commitment?: EddsaPublicKey[];

   }


The merchant can now verify

#. the validity of each (age restricted) coin by evaluating

   .. math:: \text{FDH}_N(C_p, h_a)\; \stackrel{?}{=}\; \left(\sigma_C\right)^{e} \;\;\text{mod}N

   Again, :math:`C_p` is the EdDSA public key of a coin, :math:`\sigma_C` is
   its signature, :math:`\langle e, N \rangle` is the RSA public key of the
   denomination and :math:`h_a` is the SHA256 hash value of the vector in
   ``age_commitment``.

#. the minimum age requirement by checking the signature in ``minimum_age_sig``
   against the public key ``age_commitment[k]`` of the corresponding age group,
   say, ``k``.  (The minimum age must fall into the age group at index ``k`` as
   defined by the exchange).
   
**Note**: This applies only to coins for denominations that have support for
age restriction.  Denominations *without* support for age restriction *always*
fullfill any minimum age requirement.
   


Changes in the Wallet
^^^^^^^^^^^^^^^^^^^^^

TODO.

* choosing age-restriction during withdrawal coins from denominations with
  support for age restriction.
* Define protocol to pass denominations to child/ward.



Alternatives
============

TODO.

* ID-based systems
* credit/debit card based systems


Drawbacks
=========

TODO.

* age groups, once defined, are set permanently
* age restricted coins are basically shared between ward and warden.

Also discuss:

* storage overhead
* computational overhead
* bandwidth overhead
* legal issues?

Discussion / Q&A
================

We had some very engaged discussions on the GNU Taler `mailing list <taler@gnu.org>`__:

* `Money with capabilities <https://lists.gnu.org/archive/html/taler/2021-08/msg00005.html>`_
  

* `On age-restriction (was: online games in China) <https://lists.gnu.org/archive/html/taler/2021-09/msg00006.html>`__

* `Age-restriction is about coins, not currencies <https://lists.gnu.org/archive/html/taler/2021-09/msg00021.html>`__


The upcoming paper on anonymous age-restriction for GNU Taler from Özgür Kesim
and Christian Grothoff will be cited here, once it is published.