All Projects → MaZderMind → cwa-qr

MaZderMind / cwa-qr

Licence: MIT license
Python Implementation of the CoronaWarnApp (CWA) Event Registration

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to cwa-qr

covid-br
COVID dashboard status from Brazil.
Stars: ✭ 28 (+64.71%)
Mutual labels:  corona, coronavirus, covid-19, covid19
coronainfobd
Real-time corona-virus tracker of Bangladesh 🇧🇩 which includes latest updates, data visualization, public awareness from WHO and some advice to aware people. 🥰❤
Stars: ✭ 46 (+170.59%)
Mutual labels:  corona, coronavirus, covid-19, covid19
covid-19
A web application to display Coronavirus Diseases (COVID19) statistics from different countries.
Stars: ✭ 28 (+64.71%)
Mutual labels:  corona, coronavirus, covid-19, covid19
covid19-timeseries
Covid19 timeseries data store
Stars: ✭ 38 (+123.53%)
Mutual labels:  corona, coronavirus, covid-19, covid19
covid-19-image-repository
Anonymized dataset of COVID-19 cases with a focus on radiological imaging. This includes images (x-ray / ct) with extensive metadata, such as admission-, ICU-, laboratory-, and patient master-data.
Stars: ✭ 42 (+147.06%)
Mutual labels:  corona, coronavirus, covid-19, covid19
Cwa Server
Backend implementation for the Apple/Google exposure notification API.
Stars: ✭ 1,776 (+10347.06%)
Mutual labels:  corona, coronavirus, covid-19, covid19
COVID19
A web app to display the live graphical state-wise reported corona cases in India so far. It also shows the latest news for COVID-19. Stay Home, Stay Safe!
Stars: ✭ 122 (+617.65%)
Mutual labels:  corona, coronavirus, covid-19, covid19
cli-corona
📈 Track COVID-19 (2019 novel Coronavirus) statistics via the command line.
Stars: ✭ 14 (-17.65%)
Mutual labels:  corona, coronavirus, covid-19, covid19
COVID-19-DETECTION
Detect Covid-19 with Chest X-Ray Data
Stars: ✭ 43 (+152.94%)
Mutual labels:  corona, coronavirus, covid-19, covid19
COVID-19-AI
Collection of AI resources to fight against Coronavirus (COVID-19)
Stars: ✭ 25 (+47.06%)
Mutual labels:  corona, coronavirus, covid-19, covid19
CoronaVirusOutbreakAPI
A tiny and small program to crawler and analyze outbreak of COVID-19 in world and every country using PHP.
Stars: ✭ 20 (+17.65%)
Mutual labels:  corona, coronavirus, covid-19, covid19
Api
API for Current cases and more stuff about COVID-19 and Influenza
Stars: ✭ 2,323 (+13564.71%)
Mutual labels:  corona, coronavirus, covid-19, covid19
rcvr-app
recover provides localities a privacy-compliant, safe, and easy way for their guests to check in. See https://www.recoverapp.de/ for more details.
Stars: ✭ 43 (+152.94%)
Mutual labels:  corona, covid-19, covid19
Coronavirus Tracker Api
🦠 A simple and fast (< 200ms) API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. It's written in python using the 🔥 FastAPI framework. Supports multiple sources!
Stars: ✭ 1,577 (+9176.47%)
Mutual labels:  coronavirus, covid-19, covid19
coronavirus-dresden
Collects official SARS-CoV-2 infection statistics published by the city of Dresden.
Stars: ✭ 19 (+11.76%)
Mutual labels:  corona, coronavirus, covid-19
Corona Cli
🦠 Track the Coronavirus disease (COVID-19) in the command line. Worldwide for all countries, for one country, and the US States. Fast response time (< 100ms). To chat: https://twitter.com/MrAhmadAwais/
Stars: ✭ 1,812 (+10558.82%)
Mutual labels:  corona, coronavirus, covid-19
COVID-19-CaseStudy-and-Predictions
This repository is a case study, analysis and visualization of COVID-19 Pandemic spread along with prediction models.
Stars: ✭ 90 (+429.41%)
Mutual labels:  coronavirus, covid-19, covid19
Covid19india React
Tracking the impact of COVID-19 in India
Stars: ✭ 6,847 (+40176.47%)
Mutual labels:  coronavirus, covid-19, covid19
COVID-19-STAT
A web application to keep track of COVID-19 numbers & growth across the world
Stars: ✭ 19 (+11.76%)
Mutual labels:  corona, coronavirus, covid-19
covid-19-usa-by-state
CSV files of COVID-19 total daily confirmed cases and deaths in the USA by state and county. All data from Johns Hopkins & NYT..
Stars: ✭ 35 (+105.88%)
Mutual labels:  coronavirus, covid-19, covid19

Python implementation of the Corona-Warn-App (CWA) Event Registration

GitHub PyPI

This is an implementation of the Protocol used to generate event and location QR codes for the Corona-Warn-App (CWA) as described in Corona-Warn-App: Documentation – Event Registration - Summary.

This is not an official implementation – use it at your own risk (as far as that's possible, these days…).

State

The Interface described in the Document is implemented, the undocumented pieces (Public Key Value, Seed Length, Versions etc.) have been taken from the Open Source iOS Client Application. As far as I know the interface has been fully implemented, but without an actual positive Corona Test there is no way to do an End-to-End verification.

Usage

Use as follows:

#!/usr/bin/env python3

from datetime import datetime, time, timezone

import cwa_qr

# Construct Event-Descriptor
event_description = cwa_qr.CwaEventDescription()
event_description.location_description = 'Zuhause'
event_description.location_address = 'Gau-Odernheim'
event_description.start_date_time = datetime(2021, 4, 25, 8, 0).astimezone(timezone.utc)
event_description.end_date_time = datetime(2021, 4, 25, 18, 0).astimezone(timezone.utc)
event_description.location_type = cwa_qr.CwaLocation.permanent_workplace
event_description.default_check_in_length_in_minutes = 4 * 60

# Renew QR-Code every night at 4:00
seed_date = event_description.seed = cwa_qr.rollover_date(datetime.now(), time(4, 0))
print("seedDate", seed_date)
event_description.seed = "Some Secret" + str(seed_date)

# Generate QR-Code
qr = cwa_qr.generate_qr_code(event_description)

# Save as PNG
img = qr.make_image(fill_color="black", back_color="white")
img.save('example.png')
print("generated example.png")

See example_full.py for an example using all features.

CwaEventDescription

  • location_description: Description of the Location, Optional, String, max 100 Characters
  • location_address: Address of the Location, Optional, String, max 100 Characters
  • start_date_time: Start of the Event, Optional, datetime in UTC
  • end_date_time: End of the Event, Optional, datetime in UTC Caution, QR-Codes generated with different start/end times will have different Event-IDs and not warn users that have checked in with the other Code. Do not use datetime.now() for start/end-date. For repeating Events use cwa_qr.rollover_date to get a defined rollover.
  • location_type: Type of the Location, Optional, one of
    • cwa.CwaLocation.unspecified
    • cwa.CwaLocation.permanent_other
    • cwa.CwaLocation.temporary_other
    • cwa.CwaLocation.permanent_retail
    • cwa.CwaLocation.permanent_food_service
    • cwa.CwaLocation.permanent_craft
    • cwa.CwaLocation.permanent_workplace
    • cwa.CwaLocation.permanent_educational_institution
    • cwa.CwaLocation.permanent_public_building
    • cwa.CwaLocation.temporary_cultural_event
    • cwa.CwaLocation.temporary_club_activity
    • cwa.CwaLocation.temporary_private_event
    • cwa.CwaLocation.temporary_worship_service
  • default_check_in_length_in_minutes: Default Check-out time in minutes, Optional
  • seed: Seed to rotate the QR-Code, Optional, [str, bytes, int, float, date, datetime] or None (Default). Use with caution & read below! If unsure, leave blank.

Rotating QR-Codes

From the Documentation:

Profiling of Venues

An adversary can collect this information for a single venue by scanning the QR code and extracting and storing the data. To mitigate the risk, CWA encourages owners to regularly generate new QR codes for their venues. The more frequent QR codes are updated, the more difficult it is to keep a central database with venue data up-to-date. However, a new QR code should only be generated when no visitor is at the event or location, because visitors can only warn each other with the same QR code.

From an Application-Developers point of view, special care must be taken to decide if and when QR codes should be changed. A naive approach, i.e. changing the QR-Code on every call, would render the complete Warning-Chain totally useless without anyone noticing. Therefore, the Default of this Library as of 2021/04/26 is to not seed the QR-Codes with random values. This results in every QR-Code being generated without an explicit Seed to be identical, which minimizes the Risk of having QR-Codes that do not warn users as expected at the increased risk of profiling of Venues.

As an Application-Developer you are encouraged to ask you user if and when they want their QR-Codes to change and explain to them that they should only rotate their Codes when they are sure that nobody is at the location or in the venue for at least 30 Minutes, to allow airborne particles to settle or get filtered out. Do not make assumptions regarding a good time to rotate QR-Codes (i.e. always at 4:00 am) because they will fail so warn people in some important Situations (nightclubs, hotels, night-shift working) without anyone noticing.

To disable rotation of QR-Codes, specify None as the Seed (Default behaviour).

The Library also gives you a utility to allow rotating QR-Codes at a given time of the day. Please make sure to also integrate some kind of Secret into the seed, to prevent an adversary from calculating future QR-Codes. The Secret must stay constant over time, or the resulting QR-Codes will not correctly trigger warnings.

import io
from datetime import datetime, time

import cwa_qr

# Construct Event-Descriptor
event_description = cwa_qr.CwaEventDescription()
# …
seed_date = cwa_qr.rollover_date(datetime.now(), time(4, 0))
event_description.seed = "Some Secret" + str(seed_date)

this will keep the date-based seed until 4:00 am on the next day and only then roll over to the next day. See test_rollover.py for an in-depth look at the rollover code.

Posters

This Library has Support for compositing the QR-Code with a Poster, explaining its usage: "Checken Sie ein, stoppen Sie das Virus". The Poster-Functionality works by composing the QR-Code SVG with the Poster-SVG and thus only supports SVG-Output. Both Landscape and Portrait-Posters are supported.

You can use pyrsvg if you need to convert the poster to a PNG or svglib to convert it to a PDF.

See example_full.py for an Example on how to use the Poster-Functionality.

Python 2/3

This library supports Python 3.7+, however there is a backport to Python 2 available at https://github.com/MaZderMind/cwa-qr/tree/py2

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].