tfinlay / vaccine_passport

A basic TypeScript+NodeJS implementation of a vaccine passport system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vaccine Passport

This is a basic vaccine passport creation and validation system using QR codes and an RSA signature to verify legitimacy.

Each QR Code contains an encoding of a 'Vaccine Certificate'. Each certificate contains the following data:

  • Name
  • Image (e.g. a passport photo)
    • Heavily compressed and greyscale to fit inside a scannable QR code.
  • Vaccination Status (one of 'Unvaccinated', 'Partially Vaccinated' and 'Fully Vaccinated')
  • Signature (RSA signature of the other fields)

The process to create a certificate QR code is as follows (assuming an RSA keypair already exists):

  1. Build an unsigned VaccineCertificate. The image goes through the following pre-processing steps:
    1. Resize (maintaining aspect ratio) to 100x100px.
    2. Remove the alpha channel (if any).
    3. Convert to greyscale and black/white colourspace.
    4. Save to Buffer in WebP format with quality = 30.
  2. Sign the VaccineCertificate, producing a SignedVaccineCertificate.
  3. Pack SignedVaccineCertificate into a Buffer using Protobuf.
  4. Compress the Buffer using brotli.
  5. Encode the Buffer into a QR code.

The decoding process is the exact reverse of steps 2-4.

Build & Run Demo

This is a yarn project, so to get set up simply run yarn install.

Command Description
yarn build Build the TypeScript files in src/ into JavaScript.
yarn start Build and then run demo.ts.

Usage

See demo.ts for a complete usage example.

License

See LICENSE

About

A basic TypeScript+NodeJS implementation of a vaccine passport system.

License:MIT License


Languages

Language:TypeScript 100.0%