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):
- Build an unsigned
VaccineCertificate
. The image goes through the following pre-processing steps:- Resize (maintaining aspect ratio) to 100x100px.
- Remove the alpha channel (if any).
- Convert to greyscale and black/white colourspace.
- Save to
Buffer
in WebP format with quality = 30.
- Sign the
VaccineCertificate
, producing aSignedVaccineCertificate
. - Pack
SignedVaccineCertificate
into aBuffer
using Protobuf. - Compress the
Buffer
using brotli. - Encode the
Buffer
into a QR code.
The decoding process is the exact reverse of steps 2-4.
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 . |
See demo.ts for a complete usage example.
See LICENSE