Covid-19 | Integration of Contact Shield with GAEN using DP-3T Protocol

Adriano Pires
7 min readNov 30, 2020

Hello, today we will talk about the integration of Contact Shield with GAEN, using DP-3T Protocol. Do you know Contact Shield can properly interwork with Google and Apple devices? That's right! Wouldn’t you want to quickly access the information of Contact Shield and understand how can you integrate this in in your application? If your answer is yes, come aboard and check this out!

What is the Contact Shield? What is GAEN? What is DP-3T Protocol?

There is a lot of doubts and many concerns about the security of user data in Covid-19 apps. But you don’t have to be afraid! Fortunately, all Covid-19 tracing apps have their open-source application available on public repositories. Take a look and search for you local app in GitHub.

Examples:

Google and Apple jointly created the Exposure Notifications System (Google Apple Exposure Notification) out of a shared sense of responsibility to help governments and our global community fight this pandemic through contact tracing. But, this technology don’t “recognize” the Huawei Devices without Google Mobile Services.

To help confront the global pandemic of coronavirus disease, Huawei provided HMS Core Contact Shield for developers to develop epidemic prevention and control apps. Contact Shield is dedicated to helping users accurately and comprehensively prevent and control COVID-19 through contact tracing. Contact Shield is a derivative solution based on the mainstream epidemic prevention solution DP-3T in the industry. It can interwork with some mainstream DP-3T derivative solutions in the industry.

The Bluetooth technical specifications of Contact Shield are consistent with those of the GAEN. Therefore, Contact Shield can properly interwork with Google and Apple devices.

Huawei also provided some code snippets of Contact Shield inside Huawei Mobile Services (HMS), available to download here. The code mainly focuses on: cryptography, BLE operation, key file analysis, and data storage. The project also provides sample code demonstrating how to make the Contact Shield SDK work with Google Exposure Notification

Finally, Decentralized Privacy-Preserving Proximity Tracing (DP-3T, stylized as dp3t) is an open protocol developed in response to the COVID-19 pandemic to facilitate digital contact tracing of infected participants. The public repository is available here. The Apple/Google Exposure Notification (GAEN) project is based on similar principles as the DP-3T protocol. The DP-3T protocol works off the basis of Ephemeral IDs (EphID), semi-random rotating strings that uniquely identify clients. When two clients encounter each other, they exchange EphIDs and store them locally in a contact log. Then, once a user tests positive for infection, a report is sent to a central server. Each client on the network then collects the reports from the server and independently checks their local contact logs for an EphID contained in the report. If a matching EphID is found, then the user has come in close contact with an infected patient, and is warned by the client. Since each device locally verifies contact logs, and thus contact logs are never transmitted to third parties, the central reporting server cannot by itself ascertain the identity or contact log of any client in the network. DP-3T is listed as one of several privacy-preserving decentralized approaches to contact tracing in a joint statement from over 300 scientists from over 25 countries.

All the documentation and details about DP-3T it’s available here.

How can we use Contact Shield?

You should have an document from the local Government giving authorization to the Company to have access with Contact Shield. This letter should include the APP ID and Package name and signed.

After this submission approved, you will receive an email with the Feedback of this submission.

If any user try to use Contact Shield without Authorization from Huawei, will get every request denied:

Error: EN failed: ApiException: -1: User does not allow this APP to call startContactShield.

Enabling Contact Shield

HMS API Services > My APIs > Add API from library > Contact Shield

And Enable:

As usual, the developer need to do the initial setup of HMS Core (Create app, fingerprint config, agconnect-services.json, etc), please check this post.

Please follow the Integrating the HMS Core SDK for Contact Shield dependencies and repository.

How is the Contact Shield built?

Contact Shield System Architecture

More information: Link

Integration with Contact Shield & GAEN using DP-3T

Huawei developed and included Contact Shield into DP-3T project, using GAEN and Contact Shield in same project. This integration was published at DP-3T Official repository, and available for any country integrate as well. Note: This solution it’s not compatible with the latest version of DP-3T (v2.0.0 using GAEN 1.7.1). Huawei it’s working and developing to support this new version, expecting to be available soon.

The repository of this integration is available here (colocar novo link).

In the ContactShieldWrapper Class, we will find the most important methods:

  • startContactShield: to start broadcast and scanning. When a user exits the app, Contact Shield is still running in the background
  • getPeriodicKey: to obtain the periodic key list. If a user is tested positive for COVID-19, you can upload the list to the diagnosis server. You shall provide technical means to prevent users who are not confirmed with COVID-19 from uploading any shared keys. In addition, ensure that users’ valid and revocable consent is obtained before the collection and use of periodic keys. You shall not associate the personal data collected from other apps with periodic keys, or share, import, or transfer the data collected from other apps to apps developed using Contact Shield
  • putSharedKeyFiles: to send the shared key to Contact Shield for processing. The file used when you call putSharedKeyFiles() is a ZIP package containing shared keys. Contact Shield only reads file content and does not modify or save the file content. In addition, you need to delete the file in time after obtaining the diagnosis result.
  • getContactDetail: to obtain the overall diagnosis result based on the input token type.

More information and source code about this methods: here.

DP3T (main) class:

Init:

Checking what appID will be used, depending if it’s GMS or HMS

Start:

Start() method of the DP-3T Protocol

The logic besides this usage of Contact Shield or GAEN is under the methods “isGMS” and “isHMS”.

Depending of the Device, if is using GMS or HMS, the DP-3T will use GAEN or Contact Shield.

Take a look into the GitHub solution. Push the code to your Android Studio, and explore! Any suggestion or issues, please report on GitHub. If you want to contribute, you’re welcome!

Conclusion

Contact Shield is a basic Bluetooth low energy (BLE) based contact tracing service provided by HMS Core. By calling Contact Shield application programming interfaces (APIs), developers can access Contact Shield capabilities. Governments can authorize developers to develop COVID-19 contact tracing apps using Contact Shield APIs.

Using Contact Shield, we can build and connect all the smart devices, and help the world to fight against the Covid-19 situation, helping each country to prevent and report potential exposures to the virus.

We can use Contact Shield in same project with an existent GAEN implementation, we just need to insert some additional logic to use GAEN in Android Devices with Google Mobiles Services & iOS or Contact Shield for Huawei Mobile Services Devices.

Thank You ! ..

For more details, please check these useful links :

--

--