rascafr / eu-covid-qr-parser-demo

Quick Node.js PoC to parse and generate european vaccination certificate QR codes
20 stars 5 forks source link
base45 cbor covid-19 cwt hcert qr qr-code

EU Covid QR extractor & generator

Quick Node.js PoC to parse and generate european vaccination certificate QR codes

🛑 DISCLAIMER PLEASE READ 🛑

I'm receiving a lot of messages from people asking if it's possible to create a valid EU Covid Vaccination QRcode so I'll make it clear for you here: NO YOU CAN'T.

The QRcode is signed with a private key to certify its authenticity, so except if you found a way to get it (which is nearly impossible), yes, your QRcode will be decoded with your personal details BUT marked as invalid. This project allows you to play with the QRcodes, not to do forgery, or counterfeiting.

If it's your main goal, please: educate yourself, and get vaccinated.

How it works

1) Read image
2) Find & decode QRcode
3) Remove HC1 (health certificate) prefix
4) Base45 decode
5) zlib inflate (decompress)
6) CBOR decode required fields

Same thing for the QRcode creation... reverse order.

Prerequisites

Requires Node.js 12 at least, otherwise you'll get the ReferenceError: TextDecoder is not defined error.

nvm use 12

Install

git clone https://github.com/rascafr/eu-covid-qr-parser-demo.git
cd eu-covid-qr-parser-demo
npm i

Usage

npm start <your_certif_qr_image>

# example return
Opening eu_digital_att.png ...
Decoded in 499 ms: {
  v: [
    {
      ci: 'urn:uvci:01:FR:AZERTY123456#7',
      co: 'FR',
      dn: 2,
      dt: '2021-06-17',
      is: 'CNAM',
      ma: 'ORG-PFIZER',
      mp: 'EU/BIONTECH',
      sd: 2,
      tg: '1234567',
      vp: 'XXAA000'
    }
  ],
  dob: '1993-12-12',
  nam: { fn: 'LEPAROUX', gn: 'FRANCOIS', fnt: 'LEPAROUX', gnt: 'FRANCOIS' },
  ver: '1.3.0'
}

Helpful sources

Used libraries