Skip to content

Commit 71ae0b8

Browse files
* added documentation * Fixed code view Co-authored-by: Alexandr Chernyy <[email protected]>
1 parent 8f07a22 commit 71ae0b8

File tree

8 files changed

+635
-4
lines changed

8 files changed

+635
-4
lines changed

Diff for: README.md

+50-4
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,73 @@
2222
<a href="#how-to-contribute">Contribute</a> •
2323
<a href="#contributors">Contributors</a> •
2424
<a href="#licensing">Licensing</a>
25+
<a href="#assumptions">Assumptions</a>
26+
<a href="#testing & status">Testing & Status</a>
2527
</p>
2628

2729
## About
2830

2931
This repository contains the source code of the EU Digital COVID Certificate Certlogic for iOS.
3032

33+
The [Digital COVID Certificate (DCC)](https://ec.europa.eu/info/live-work-travel-eu/coronavirus-response/safe-covid-19-vaccines-europeans/eu-digital-covid-certificate_en) allows to determine whether a person is deemed fit-for-travel into a country-of-arrival (CoA) based on their vaccination, test, and recovery status.
34+
To make such determinations, business (or validation, or verification) rules have to be implemented in verifier and wallet apps.
35+
3136
This module allows integrating the certlogic in iOS apps.
3237

38+
This repository contains a framework to implement in verifier apps (and backends) using a _CertLogicEngine_.
39+
It [explains how to do that](./documentation/how-to.md) in a way that makes these rules interchangeable across implementors.
40+
The advantage of this approach is that it ultimately allows citizens to check their fit-for-travel status into an intended CoA _ahead_ of travel, against the actual rules.
41+
42+
This can be achieved by adhering to a common, and testable and verifiable way of defining, and executing rules.
43+
The interchangeable rules are uploaded to, and can be downloaded from the EU Digital COVID Certificate Gateway (DGCG) - more info can be found [here](./documentation/gateway.md).
44+
45+
An example of a rule can be found [here](./documentation/example.adoc).
46+
47+
This work is a result of work done by the EU Taskforce Business Rules, and described in [this document](https://ec.europa.eu/health/sites/default/files/ehealth/docs/eu-dcc_validation-rules_en.pdf).
48+
The (JSON Schema) technical specification for the EU DCC can be found [here](https://ec.europa.eu/health/sites/default/files/ehealth/docs/covid-certificate_json_specification_en.pdf).
49+
3350
## Development
3451

3552
### Prerequisites
3653

37-
- [ ] TODO: Prerequisites
54+
This library automaticaly added in dependencies and downloading by XCode Swift Package Manager
55+
56+
* [JsonLogic](https://github.com/eu-digital-green-certificates/json-logic-swift)
57+
* [SwiftyJSON](https://github.com/SwiftyJSON/SwiftyJSON)
58+
59+
#### Using Swift Package Manager
60+
61+
if you use Swift Package Manager add the following in dependencies:
62+
63+
dependencies: [
64+
.package(
65+
url: "https://github.com/eu-digital-green-certificates/dgc-certlogic-ios", from: "1.0.0"
66+
)
67+
]
68+
69+
if you want to use CertLogic as XCode project please use script for generate certlogic.xcodeproj and add this project directly
70+
71+
generate-xcodeproj.sh
72+
73+
74+
## Assumptions
75+
76+
Various code in this repo assumes that you've cloned the following two repos right next to where this repo's cloned:
77+
78+
* [ehn-dcc-schema](https://github.com/ehn-dcc-development/ehn-dcc-schema)
79+
* [ehn-dcc-valuesets](https://github.com/ehn-dcc-development/ehn-dcc-valuesets)
80+
* ([dgc-testdata](https://github.com/ehn-dcc-development/dgc-testdata))
3881

39-
### Build
82+
## Testing & Status
4083

41-
- [ ] TODO: Build Instructions
84+
- If you found any problems, please create an [Issue](/../../issues).
85+
- Current status: Work-In-Progress.
4286

4387
## Documentation
4488

45-
- [ ] TODO: Add docs or link to docs
89+
* [Documentation](./documentation/README.md).
90+
* [JsonLogic](https://github.com/eu-digital-green-certificates/json-logic-swift): documentation and code relating to JsonLogic.
91+
* [SwiftyJSON](https://github.com/SwiftyJSON/SwiftyJSON): documentation and code relating to SwiftyJSON library.
4692

4793
## Support and feedback
4894

Diff for: documentation/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Documentation
2+
3+
* [How-To](./how-to.md) implement business rules.
4+
* [Design choices](./design-choices.md) made for how-to implement business rules.
5+
* [Links to relevant documents](./documents-links.md).
6+
* A list of existing [CertLogic/JsonLogic implementations](./implementations.md).
7+

Diff for: documentation/design-choices.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# CertLogic: design choices
2+
3+
The following requirements are in scope for the business rules:
4+
5+
1. They must be executable on a number of platforms/programming languages.
6+
2. The verifier apps must be updatable with new (versions of) business rules without needing to update the entire app.
7+
3. They must be freely exchangable between participating nations, so that travelers can determine _beforehand_ whether they're going to be deemed fit-for-travel.
8+
9+
A good way to respect these requirements is to express these business rules in a plain JSON format:
10+
11+
1. Their formulation is effectively platform/programming language-aspecific.
12+
2. They can be downloaded to verifier apps “just as data”, decreasing the danger of being seen to violate e.g. Apple's “no code injection”-policies, and of slow app updates.
13+
14+
It was initially proposed to use [JsonLogic](https://jsonlogic.com/) to formulate business rules.
15+
JsonLogic has implementations of its engine for a variety of platforms/programming languages.
16+
However, the following problems were found with (using) JsonLogic:
17+
18+
* The implementations had differing behaviour/semantics.
19+
In theory, this could be mitigated by patching implementations to align their behaviour/semantics.
20+
* No support for date(-times) was provided out-of-the-box.
21+
In theory, this could be mitigated by adding custom operations, but unfortunately, not every implementation allows that.
22+
* JsonLogic provides more than is required for the purpose here, which would mean that much testing is required to ensure that behaviour is consistent across implementations.
23+
24+
To mitigate these problems, a subset of JsonLogic, called **CertLogic**, has been specified, and adorned with a test suite, validator tooling, and own implementations for a number of platforms/programming languages.
25+
A set of validation rules (or _rule set_) is then executed, or “run” by a CertLogic engine against JSON data consisting of a DCC payload, and an external parameters object with value sets, validation clock, etc.
26+
27+
For the moment, [this Confluence page](https://webgate.ec.europa.eu/fpfis/wikis/display/eHN/EU+DGC+Validation+Rules) is the authoritative source of information.
28+
29+
30+
## Regarding CertLogic
31+
32+
* CertLogic is a standalone specification, intrinsically not coupled to the DCC (or its schema), to be able to test engine implementations in isolation.
33+
34+
* The use of “truthy”/“falsy” values that are not already JSON Booleans is discouraged, and limited.
35+
In particular, DCC-validation rules should evaluate to a JSON Boolean, not to any “truthy”/“falsy”.
36+
37+
* This specification can be expanded when the needs arises, but never shrunken.
38+
39+
* The intention is that CertLogic remains compatible with JsonLogic (with JsonLogic restricted to the constructs allowed from CertLogic), but may _expand_ on JsonLogic when and where necessary.
40+
If that happens, that would probably require patching of a JsonLogic engine.
41+
42+
* In the interest of testability and risk mitigation, CertLogic is kept as small and simple as possible, without any “programmers' convenience”.
43+
44+
45+
## Regarding implementing DCC validation rules with CertLogic
46+
47+
Regarding the relation of CertLogic with JsonLogic, and the DCC validation rules:
48+
49+
* Any DCC validation rule must be expressed according to CertLogic, and **may not** use JsonLogic in a way that's inconsistent with CertLogic, or not provided for by CertLogic.
50+
In particular, only JsonLogic constructs present in this CertLogic specification may be used.
51+
52+
* Rule implementors may use any of the CertLogic reference implementations, or any of the existing JsonLogic engines, but *must* ensure that these produce the same results on test suites for both the core evaluation, as for the rules themselves.
53+
54+
* The semantics of the validation rules may be _expressed_ in CertLogic, but are **not** (strictly) _defined_ by it: all implementations should pass the unit tests assertions defined for the validation rules, and should pass additional tests that ascertain the intent of the validation rule.
55+
56+
* Rule implementations should not lean on the JSON Schema for the DCC too much.
57+
In particular, [Postel's law](https://en.wikipedia.org/wiki/Robustness_principle) should be followed.
58+
While the JSON Schema might imply the existence/presence of a certain value, rule implementations should not blindly assume that.
59+
Instead, they should check for a value's existence/presence, and produce a sensible result when it's not present.
60+
61+
Phrased alternatively, every value should in principle have [DICOM Attribute Requirement Type](http://dicomlookup.com/type.asp) 2.
62+
63+
64+
## Design choices specifics
65+
66+
## Operation: extract from UVCI
67+
68+
An example use case for being able to extract information is the need to invalidate DCCs that have been issued by fraudulent pharmacies which can be identified by a certain part of the UVCI.
69+
The UVCI technical format is clearly defined in Annex 2 in the [UVCI specification](https://ec.europa.eu/health/sites/default/files/ehealth/docs/vaccination-proof_interoperability-guidelines_en.pdf).
70+
It has a limited degree of freedom within the format -in particular, the precise format of individual fragments is not pre-defined (outside of the characters allowed).
71+
Also: the `URN:ICVI:` prefix is optional - e.g. UVCIs in DCCs issued by Luxembourg do not have the prefix.
72+
73+
There are several reasons to support extracting information from the UVCI with a specific operation, instead of using a more generic regex-based operation:
74+
75+
1. Regexes live in Pandora's box: they are extremely flexible but are not easy to use well, while it's easy to misuse them, either intentionally, or unintentionally.
76+
2. The CertLogic domain-specific language should be kept small in terms of the ground it can cover, to keep its usage simple, and ensure the language is easy to test.
77+
3. It's more difficult to assess whether a rule implemented using a generic but complex operation is GDPR-compliant than when it uses a simple, functionally-limited/restricted domain-specific operation.
78+
79+
Note that this operation does *not* assume that the given string conforms to the UVCI format.
80+
In particular, it will not check conformance, and will not error on a malformed UVCI.
81+
The rationale for this is a combination of Postel's Law, and the fact that this operation could be used to check for/detect malformed UVCIs.
82+
83+
Point in case: some DCCs have invalid prefixes like `urn:uvci:` (lowercase instead of uppercase-only), and `URN:UCI:` (missing `V`).
84+
To detect such UVCIs, one can use the `extractFromUVCI` operation with indices 0 and 1, because the invalid prefixes will *not* be ignored, but become fragments.
85+

Diff for: documentation/documents-links.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Documents/links
2+
3+
The following is a list of (links to) official documents (or links) pertaining to the DCC:
4+
5+
* Press releases from the EC:
6+
* https://ec.europa.eu/commission/presscorner/detail/en/IP_21_2593
7+
* https://ec.europa.eu/commission/presscorner/detail/en/qanda_21_1187
8+
* https://ec.europa.eu/commission/presscorner/detail/en/qanda_21_2984 - containing actual rules
9+
10+
* [“Legalese” version of the last press release mentioned in the previous bullet](https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=uriserv%3AOJ.LI.2021.213.01.0001.01.ENG&toc=OJ%3AL%3A2021%3A213I%3ATOC)
11+
12+
* [eHN working groups for DCC](https://webgate.ec.europa.eu/fpfis/wikis/display/eHN/eHN+WORKING+GROUPS) - within that Wiki:
13+
* [Taskforce Business Rules](https://webgate.ec.europa.eu/fpfis/wikis/display/eHN/Taskforce+Business+Rules)
14+
* [EU DCC Validation Rules](https://ec.europa.eu/health/sites/default/files/ehealth/docs/eu-dcc_validation-rules_en.pdf) - PDF version of official proposal
15+
* [Semantics sub-group](https://webgate.ec.europa.eu/fpfis/wikis/display/eHN/eHN+sg+Semantics)
16+
17+
* [The technical specification for the EU DCC (JSON Schema)](https://ec.europa.eu/health/sites/default/files/ehealth/docs/covid-certificate_json_specification_en.pdf)
18+
19+
* [WHO-status of vaccines (June 16th, 2021)](https://extranet.who.int/pqweb/sites/default/files/documents/Status_of_COVID-19_Vaccines_within_WHO_EUL-PQ_evaluation_process-16June2021_Final.pdf)
20+

0 commit comments

Comments
 (0)